annotate src/graphics.cc @ 11076:b748b86cb8c1

fix images with width or height of 1
author Shai Ayal <shaiay@users.sourceforge.net>
date Mon, 04 Oct 2010 21:35:02 +0200
parents 8a3b7e8fcbbc
children f0e9befd6a1c
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
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8896
diff changeset
3 Copyright (C) 2007, 2008, 2009 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>
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
30
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
31 #include <algorithm>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
32 #include <list>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
33 #include <map>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
34 #include <set>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
35 #include <string>
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
36 #include <sstream>
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
37
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
38 #include "file-ops.h"
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
39 #include "file-stat.h"
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
40
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
41 #include "cmd-edit.h"
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
42 #include "defun.h"
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
43 #include "display.h"
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
44 #include "error.h"
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
45 #include "graphics.h"
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
46 #include "input.h"
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
47 #include "ov.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
48 #include "oct-obj.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
49 #include "oct-map.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
50 #include "ov-fcn-handle.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
51 #include "parse.h"
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
52 #include "toplev.h"
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
53 #include "txt-eng-ft.h"
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
54 #include "unwind-prot.h"
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
55
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
56 // 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
57 static octave_value xget (const graphics_handle& h, const caseless_str& name);
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
58 static graphics_object xget_ancestor (const graphics_object& go_arg,
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
59 const std::string& type);
9238
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
60
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
61 static void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
62 gripe_set_invalid (const std::string& pname)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
63 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
64 error ("set: invalid value for %s property", pname.c_str ());
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
65 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
66
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
67 // 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
68 // 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
69 // 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
70
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
71 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
72 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
73 const std::set<std::string>& pnames,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
74 const caseless_str& pname)
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
75 {
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
76 size_t len = pname.length ();
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
77 std::set<std::string> matches;
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
78
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
79 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
80 p != pnames.end (); p++)
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
81 {
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
82 if (pname.compare (*p, len))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
83 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
84 if (len == p->length ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
85 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
86 // Exact match.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
87 return pname;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
88 }
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 matches.insert (*p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
91 }
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
92 }
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
93
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
94 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
95
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
96 if (num_matches == 0)
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
97 {
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
98 error ("%s: unknown %s property %s",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
99 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
100 }
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
101 else if (num_matches > 1)
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
102 {
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
103 string_vector sv (matches);
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 std::ostringstream os;
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 sv.list_in_columns (os);
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::string match_list = os.str ();
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
110
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
111 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
112 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
113 }
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
114 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
115 {
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
116 // 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
117
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
118 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
119
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
120 warning_with_id ("Octave:abbreviated-property-match",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
121 "%s: allowing %s to match %s property %s",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
122 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
123 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
124
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
125 return possible_match;
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
126 }
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
127
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
128 return caseless_str ();
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
129 }
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
130
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
131 static Matrix
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
132 jet_colormap (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
133 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
134 Matrix cmap (64, 3, 0.0);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
135
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
136 for (octave_idx_type i = 0; i < 64; i++)
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 // 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
139 // 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
140 // property object that includes a colormap_property
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
141 // 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
142 // called, so calling an interpreted function is not
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
143 // possible.
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
144
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
145 double x = i / 63.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
146
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
147 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
148 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
149 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
150 cmap(i,0) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
151 else if (x >= 7.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
152 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
153
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
154 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
155 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
156 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
157 cmap(i,1) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
158 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
159 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
160
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
161 if (x < 1.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
162 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
163 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
164 cmap(i,2) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
165 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
166 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
167 }
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 return cmap;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
170 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
171
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
172 static double
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
173 default_screendepth (void)
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
174 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
175 return display_info::depth ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
176 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
177
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
178 static Matrix
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
179 default_screensize (void)
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
180 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
181 Matrix retval (1, 4, 1.0);
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 retval(2) = display_info::width ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
184 retval(3) = display_info::height ();
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 return retval;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
187 }
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 static double
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
190 default_screenpixelsperinch (void)
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
191 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
192 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
193 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
194
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
195 static Matrix
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
196 default_colororder (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
197 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
198 Matrix retval (7, 3, 0.0);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
199
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
200 retval(0,2) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
201
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
202 retval(1,1) = 0.5;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
203
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
204 retval(2,0) = 1.0;
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 retval(3,1) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
207 retval(3,2) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
208
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
209 retval(4,0) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
210 retval(4,2) = 0.75;
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(5,0) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
213 retval(5,1) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
214
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
215 retval(6,0) = 0.25;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
216 retval(6,1) = 0.25;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
217 retval(6,2) = 0.25;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
218
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
219 return retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
220 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
221
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
222 static Matrix
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
223 default_lim (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
224 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
225 Matrix m (1, 2, 0);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
226 m(1) = 1;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
227 return m;
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
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
231 default_data (void)
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 retval (1, 2);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
234
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
235 retval(0) = 0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
236 retval(1) = 1;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
237
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
238 return retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
239 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
240
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
241 static Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
242 default_axes_position (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
243 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
244 Matrix m (1, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
245 m(0) = 0.13;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
246 m(1) = 0.11;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
247 m(2) = 0.775;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
248 m(3) = 0.815;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
249 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
250 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
251
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
252 static Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
253 default_axes_outerposition (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
254 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
255 Matrix m (1, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
256 m(2) = m(3) = 1.0;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
257 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
258 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
259
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
260 static Matrix
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
261 default_axes_tick (void)
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
262 {
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
263 Matrix m (1, 6, 0.0);
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
264 m(0) = 0.0;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
265 m(1) = 0.2;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
266 m(2) = 0.4;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
267 m(3) = 0.6;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
268 m(4) = 0.8;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
269 m(5) = 1.0;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
270 return m;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
271 }
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
272
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
273 static Matrix
8740
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
274 default_axes_ticklength (void)
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
275 {
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
276 Matrix m (1, 2, 0.01);
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
277 m(1) = 0.025;
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
278 return m;
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
279 }
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
280
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
281 static Matrix
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
282 default_figure_position (void)
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
283 {
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
284 Matrix m (1, 4, 0.0);
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
285 m(0) = 300;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
286 m(1) = 200;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
287 m(2) = 560;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
288 m(3) = 420;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
289 return m;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
290 }
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
291
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
292 static Matrix
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
293 default_figure_papersize (void)
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
294 {
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
295 Matrix m (1, 2, 0.0);
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
296 m(0) = 8.5;
8961
6b87f2f34fdd graphics.cc: Fix default "papersize" property value.
Ben Abbott <bpabbott@mac.com>
parents: 8944
diff changeset
297 m(1) = 11.0;
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
298 return m;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
299 }
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
300
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
301 static Matrix
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
302 default_figure_paperposition (void)
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
303 {
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
304 Matrix m (1, 4, 0.0);
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
305 m(0) = 0.25;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
306 m(1) = 2.50;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
307 m(2) = 8.00;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
308 m(3) = 6.00;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
309 return m;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
310 }
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 static Matrix
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
313 convert_position (const Matrix& pos, const caseless_str& from_units,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
314 const caseless_str& to_units,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
315 const Matrix& parent_dim = Matrix (1, 2, 0.0))
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
316 {
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
317 Matrix retval (1, pos.numel ());
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
318 double res = 0;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
319 bool is_rectangle = (pos.numel () == 4);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
320
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
321 if (from_units.compare ("pixels"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
322 retval = pos;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
323 else if (from_units.compare ("normalized"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
324 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
325 retval(0) = pos(0) * parent_dim(0) + 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
326 retval(1) = pos(1) * parent_dim(1) + 1;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
327 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
328 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
329 retval(2) = pos(2) * parent_dim(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
330 retval(3) = pos(3) * parent_dim(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
331 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
332 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
333 retval(2) = 0;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
334 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
335 else if (from_units.compare ("characters"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
336 {
9238
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
337 if (res <= 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
338 res = xget (0, "screenpixelsperinch").double_value ();
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
339
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
340 double f = 0.0;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
341
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
342 // FIXME -- this assumes the system font is Helvetica 10pt
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
343 // (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
344 f = 12.0 * res / 74.951;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
345
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
346 if (f > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
347 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
348 retval(0) = 0.5 * pos(0) * f;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
349 retval(1) = pos(1) * f;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
350 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
351 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
352 retval(2) = 0.5 * pos(2) * f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
353 retval(3) = pos(3) * f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
354 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
355 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
356 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
357 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
358 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
359 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
360 {
9238
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
361 if (res <= 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
362 res = xget (0, "screenpixelsperinch").double_value ();
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
363
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
364 double f = 0.0;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
365
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
366 if (from_units.compare ("points"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
367 f = res / 72.0;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
368 else if (from_units.compare ("inches"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
369 f = res;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
370 else if (from_units.compare ("centimeters"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
371 f = res / 2.54;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
372
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
373 if (f > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
374 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
375 retval(0) = pos(0) * f + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
376 retval(1) = pos(1) * f + 1;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
377 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
378 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
379 retval(2) = pos(2) * f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
380 retval(3) = pos(3) * f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
381 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
382 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
383 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
384 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
385 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
386
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
387 if (! to_units.compare ("pixels"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
388 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
389 if (to_units.compare ("normalized"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
390 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
391 retval(0) = (retval(0) - 1) / parent_dim(0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
392 retval(1) = (retval(1) - 1) / parent_dim(1);
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
393 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
394 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
395 retval(2) /= parent_dim(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
396 retval(3) /= parent_dim(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
397 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
398 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
399 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
400 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
401 else if (to_units.compare ("characters"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
402 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
403 if (res <= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
404 res = xget (0, "screenpixelsperinch").double_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
405
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
406 double f = 0.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
407
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
408 f = 12.0 * res / 74.951;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
409
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
410 if (f > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
411 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
412 retval(0) = 2 * retval(0) / f;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
413 retval(1) = retval(1) / f;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
414 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
415 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
416 retval(2) = 2 * retval(2) / f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
417 retval(3) = retval(3) / f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
418 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
419 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
420 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
421 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
422 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
423 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
424 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
425 if (res <= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
426 res = xget (0, "screenpixelsperinch").double_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
427
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
428 double f = 0.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
429
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
430 if (to_units.compare ("points"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
431 f = res / 72.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
432 else if (to_units.compare ("inches"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
433 f = res;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
434 else if (to_units.compare ("centimeters"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
435 f = res / 2.54;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
436
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
437 if (f > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
438 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
439 retval(0) = (retval(0) - 1) / f;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
440 retval(1) = (retval(1) - 1) / f;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
441 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
442 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
443 retval(2) /= f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
444 retval(3) /= f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
445 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
446 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
447 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
448 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
449 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
450 }
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
451 else if (! is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
452 retval(2) = 0;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
453
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
454 return retval;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
455 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
456
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
457 static Matrix
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
458 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
459 const caseless_str& from_units,
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
460 const caseless_str& to_units)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
461 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
462 graphics_object go = gh_manager::get_object (props.get___myhandle__ ());
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
463 graphics_object ax = xget_ancestor (go, "axes");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
464
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
465 Matrix retval (1, pos.numel (), 0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
466
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
467 if (ax.valid_object ())
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
468 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
469 const axes::properties& ax_props =
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
470 dynamic_cast<const axes::properties&> (ax.get_properties ());
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
471 graphics_xform ax_xform = ax_props.get_transform ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
472 bool is_rectangle = (pos.numel () == 4);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
473 Matrix ax_bbox = ax_props.get_boundingbox (true),
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
474 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
475
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
476 if (from_units.compare ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
477 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
478 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
479 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
480 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
481 v2 = ax_xform.transform (pos(0) + pos(2),
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
482 pos(1) + pos(3), 0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
483
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
484 retval(0) = v1(0) - ax_bbox(0) + 1;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
485 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
486 retval(2) = v2(0) - v1(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
487 retval(3) = v1(1) - v2(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
488 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
489 else
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 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
492
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
493 retval(0) = v(0) - ax_bbox(0) + 1;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
494 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
495 retval(2) = 0;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
496 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
497 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
498 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
499 retval = convert_position (pos, from_units, "pixels", ax_size);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
500
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
501 if (! to_units.compare ("pixels"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
502 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
503 if (to_units.compare ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
504 {
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 ColumnVector v1 = ax_xform.untransform (retval(0) + ax_bbox(0) - 1,
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
508 ax_bbox(1) + ax_bbox(3) - retval(1) + 1),
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
509 v2 = ax_xform.untransform (retval(0) + retval(2) + ax_bbox(0) - 1,
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
510 ax_bbox(1) + ax_bbox(3) - (retval(1) + retval(3)) + 1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
511
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
512 retval(0) = v1(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
513 retval(1) = v1(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
514 retval(2) = v2(0) - v1(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
515 retval(3) = v2(1) - v1(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
516 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
517 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
518 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
519 ColumnVector v = ax_xform.untransform (retval(0) + ax_bbox(0) - 1,
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
520 ax_bbox(1) + ax_bbox(3) - retval(1) + 1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
521
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
522 retval(0) = v(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
523 retval(1) = v(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
524 retval(2) = v(2);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
525 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
526 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
527 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
528 retval = convert_position (retval, "pixels", to_units, ax_size);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
529 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
530 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
531
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
532 return retval;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
533 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
534
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
535 // This function always returns the screensize in pixels
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
536 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
537 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
538 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
539 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
540 Matrix sz = obj.get ("screensize").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
541 return convert_position (sz, obj.get ("units").string_value (), "pixels", sz.extract_n (0, 2, 1, 2)).extract_n (0, 2, 1, 2);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
542 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
543
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
544 static graphics_object
7878
b4ac6bb4114b graphics.cc (execute_callback, xget_ancestor): pass args by const reference and make explicit copies
John W. Eaton <jwe@octave.org>
parents: 7871
diff changeset
545 xget_ancestor (const graphics_object& go_arg, const std::string& type)
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
546 {
7878
b4ac6bb4114b graphics.cc (execute_callback, xget_ancestor): pass args by const reference and make explicit copies
John W. Eaton <jwe@octave.org>
parents: 7871
diff changeset
547 graphics_object go = go_arg;
b4ac6bb4114b graphics.cc (execute_callback, xget_ancestor): pass args by const reference and make explicit copies
John W. Eaton <jwe@octave.org>
parents: 7871
diff changeset
548
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
549 do
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
550 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
551 if (go.valid_object ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
552 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
553 if (go.isa (type))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
554 return go;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
555 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
556 go = gh_manager::get_object (go.get_parent ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
557 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
558 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
559 return graphics_object ();
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
560 }
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
561 while (true);
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
562 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
563
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
564 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
565 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
566 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
567 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
568 {
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
569 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
570 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
571 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
572 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
573
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
574 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
575 {
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
576 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
577 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
578 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
579 }
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
580 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
581 {
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
582 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
583 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
584 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
585 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
586
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
587 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
588
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
589 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
590 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
591 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
592 }
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
593 }
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
594
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
595 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
596 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
597 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
598 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
599 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
600 {
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
601 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
602 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
603 }
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
604
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
605 static octave_value
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
606 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
607 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
608 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
609 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
610
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
611 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
612 return cdata;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
613
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
614 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
615 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
616
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
617 graphics_object go = gh_manager::get_object (props.get___myhandle__ ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
618 graphics_object fig = xget_ancestor (go, "figure");
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
619
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
620 if (fig.valid_object ())
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
621 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
622 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
623
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
624 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
625 cmap = _cmap;
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
626 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
627
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
628 if (is_scaled)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
629 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
630 graphics_object ax = xget_ancestor (go, "axes");
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
631
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
632 if (ax.valid_object ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
633 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
634 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
635
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
636 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
637 clim = _clim;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
638 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
639 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
640
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
641 dv.resize (cdim);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
642 dv(cdim-1) = 3;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
643
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
644 NDArray a (dv);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
645
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
646 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
647 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
648
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
649 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
650 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
651
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
652 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
653 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
654
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
655 #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
656 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
657 { \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
658 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
659 \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
660 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
661 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
662 } \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
663 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
664
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
665 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
666 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
667 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
668 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
669 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
670 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
671 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
672 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
673
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 #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
675
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
676 return octave_value (a);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
677 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
678
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
679 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
680 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
681 get_array_limits (const Array<T>& m, double& emin, double& emax,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
682 double& eminp)
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
683 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
684 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
685 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
686
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
687 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
688 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
689 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
690
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
691 if (! (xisinf (e) || xisnan (e)))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
692 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
693 if (e < emin)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
694 emin = e;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
695
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
696 if (e > emax)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
697 emax = e;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
698
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
699 if (e > 0 && e < eminp)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
700 eminp = e;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
701 }
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
702 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
703 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
704
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
705 static bool
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
706 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
707 caseless_str& rest)
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
708 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
709 int len = name.length ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
710 int offset = 0;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
711 bool result = false;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
712
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
713 if (len >= 4)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
714 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
715 caseless_str pfx = name.substr (0, 4);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
716
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
717 if (pfx.compare ("axes") || pfx.compare ("line")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
718 || pfx.compare ("text"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
719 offset = 4;
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
720 else if (len >= 5)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
721 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
722 pfx = name.substr (0, 5);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
723
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
724 if (pfx.compare ("image") || pfx.compare ("patch"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
725 offset = 5;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
726 else if (len >= 6)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
727 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
728 pfx = name.substr (0, 6);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
729
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
730 if (pfx.compare ("figure"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
731 offset = 6;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
732 else if (len >= 7)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
733 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
734 pfx = name.substr (0, 7);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
735
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
736 if (pfx.compare ("surface") || pfx.compare ("hggroup"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
737 offset = 7;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
738 }
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 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
741
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
742 if (offset > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
743 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
744 go_name = pfx;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
745 rest = name.substr (offset);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
746 result = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
747 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
748 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
749
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
750 return result;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
751 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
752
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
753 static base_graphics_object*
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
754 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
755 const graphics_handle& h = graphics_handle (),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
756 const graphics_handle& p = graphics_handle ())
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
757 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
758 base_graphics_object *go = 0;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
759
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
760 if (type.compare ("figure"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
761 go = new figure (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
762 else if (type.compare ("axes"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
763 go = new axes (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
764 else if (type.compare ("line"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
765 go = new line (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
766 else if (type.compare ("text"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
767 go = new text (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
768 else if (type.compare ("image"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
769 go = new image (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
770 else if (type.compare ("patch"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
771 go = new patch (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
772 else if (type.compare ("surface"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
773 go = new surface (h, p);
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
774 else if (type.compare ("hggroup"))
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
775 go = new hggroup (h, p);
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
776
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
777 return go;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
778 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
779
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
780 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
781
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
782 bool
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
783 base_property::set (const octave_value& v, bool do_run )
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
784 {
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
785 if (do_set (v))
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
786 {
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
787
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
788 // notify backend
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
789 if (id >= 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
790 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
791 graphics_object go = gh_manager::get_object (parent);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
792 if (go)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
793 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
794 graphics_backend backend = go.get_backend();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
795 if (backend)
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
796 backend.update (go, id);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
797 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
798 }
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
799
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
800 // run listeners
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
801 if (do_run && ! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
802 run_listeners (POSTSET);
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
803
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
804 return true;
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
805 }
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
806
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
807 return false;
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
808 }
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
809
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
810
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
811 void
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
812 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
813 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
814 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
815
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
816 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
817 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
818 gh_manager::execute_callback (parent, l(i), octave_value ());
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
819
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
820 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
821 break;
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
822 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
823 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
824
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
825 radio_values::radio_values (const std::string& opt_string)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
826 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
827 size_t beg = 0;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
828 size_t len = opt_string.length ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
829 bool done = len == 0;
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
830
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
831 while (! done)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
832 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
833 size_t end = opt_string.find ('|', beg);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
834
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
835 if (end == std::string::npos)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
836 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
837 end = len;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
838 done = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
839 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
840
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
841 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
842
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
843 // Might want more error checking here...
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
844 if (t[0] == '{')
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
845 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
846 t = t.substr (1, t.length () - 2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
847 default_val = t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
848 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
849 else if (beg == 0) // ensure default value
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
850 default_val = t;
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
851
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
852 possible_vals.insert (t);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
853
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
854 beg = end + 1;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
855 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
856 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
857
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
858 std::string
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
859 radio_values::values_as_string (void) const
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
860 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
861 std::string retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
862 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
863 it != possible_vals.end (); it++)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
864 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
865 if (retval == "")
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
866 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
867 if (*it == default_value ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
868 retval = "{" + *it + "}";
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
869 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
870 retval = *it;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
871 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
872 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
873 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
874 if (*it == default_value ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
875 retval += " | {" + *it + "}";
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
876 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
877 retval += " | " + *it;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
878 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
879 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
880 if (retval != "")
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
881 retval = "[ " + retval + " ]";
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
882 return retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
883 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
884
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
885 Cell
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
886 radio_values::values_as_cell (void) const
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
887 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
888 octave_idx_type i = 0;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
889 Cell retval (nelem (), 1);
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
890 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
891 it != possible_vals.end (); it++)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
892 retval(i++) = std::string (*it);
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
893 return retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
894 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
895
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
896 bool
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
897 color_values::str2rgb (std::string str)
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
898 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
899 double tmp_rgb[3] = {0, 0, 0};
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
900 bool retval = true;
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
901 unsigned int len = str.length();
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
902
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6898
diff changeset
903 std::transform (str.begin (), str.end (), str.begin (), tolower);
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6898
diff changeset
904
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
905 if (str.compare(0, len, "blue", 0, len) == 0)
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
906 tmp_rgb[2] = 1;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
907 else if (str.compare(0, len, "black", 0, len) == 0
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
908 || str.compare(0, len, "k", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
909 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0;
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
910 else if (str.compare(0, len, "red", 0, len) == 0)
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
911 tmp_rgb[0] = 1;
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
912 else if (str.compare(0, len, "green", 0, len) == 0)
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
913 tmp_rgb[1] = 1;
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
914 else if (str.compare(0, len, "yellow", 0, len) == 0)
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
915 tmp_rgb[0] = tmp_rgb[1] = 1;
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
916 else if (str.compare(0, len, "magenta", 0, len) == 0)
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
917 tmp_rgb[0] = tmp_rgb[2] = 1;
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
918 else if (str.compare(0, len, "cyan", 0, len) == 0)
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
919 tmp_rgb[1] = tmp_rgb[2] = 1;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
920 else if (str.compare(0, len, "white", 0, len) == 0
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
921 || str.compare(0, len, "w", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
922 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
923 else
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
924 retval = false;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
925
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
926 if (retval)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
927 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
928 for (int i = 0; i < 3; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
929 xrgb(i) = tmp_rgb[i];
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
930 }
6563
7a65c1a09ec3 [project @ 2007-04-23 19:26:17 by jwe]
jwe
parents: 6509
diff changeset
931
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
932 return retval;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
933 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
934
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
935 bool
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
936 color_property::do_set (const octave_value& val)
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
937 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
938 if (val.is_string ())
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
939 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
940 std::string s = val.string_value ();
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
941
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
942 if (! s.empty ())
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 if (radio_val.contains (s))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
945 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
946 if (current_type != radio_t || current_val != s)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
947 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
948 current_val = s;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
949 current_type = radio_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
950 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
951 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
952 }
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
953 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
954 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
955 color_values col (s);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
956 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
957 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
958 if (current_type != color_t || col != color_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
959 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
960 color_val = col;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
961 current_type = color_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
962 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
963 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
964 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
965 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
966 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
967 get_name ().c_str (), s.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
968 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
969 }
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
970 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
971 error ("invalid value for color property \"%s\"",
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
972 get_name ().c_str ());
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
973 }
9311
868fbeb2e365 allow ranges and other matrices in set
Jaroslav Hajek <highegg@gmail.com>
parents: 9238
diff changeset
974 else if (val.is_numeric_type ())
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
975 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
976 Matrix m = val.matrix_value ();
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
977
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
978 if (m.numel () == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
979 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
980 color_values col (m (0), m (1), m(2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
981 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
982 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
983 if (current_type != color_t || col != color_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
984 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
985 color_val = col;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
986 current_type = color_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
987 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
988 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
989 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
990 }
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
991 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
992 error ("invalid value for color property \"%s\"",
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
993 get_name ().c_str ());
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
994 }
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
995 else
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
996 error ("invalid value for color property \"%s\"",
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
997 get_name ().c_str ());
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
998
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
999 return false;
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1000 }
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1001
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1002 bool
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1003 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
1004 {
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1005 if (val.is_string ())
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1006 {
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1007 std::string s = val.string_value ();
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1008
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1009 if (! s.empty () && radio_val.contains (s))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1010 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1011 if (current_type != radio_t || s != current_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1012 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1013 current_val = s;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1014 current_type = radio_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1015 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1016 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1017 }
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1018 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1019 error ("invalid value for double_radio property \"%s\"",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1020 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
1021 }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1022 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
1023 {
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1024 double new_dval = val.double_value ();
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1025
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1026 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
1027 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1028 dval = new_dval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1029 current_type = double_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1030 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1031 }
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1032 }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1033 else
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1034 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
1035 get_name ().c_str ());
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1036
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1037 return false;
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1038 }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1039
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1040 bool
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1041 array_property::validate (const octave_value& v)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1042 {
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1043 bool xok = false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1044
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8299
diff changeset
1045 // FIXME -- should we always support []?
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
1046 if (v.is_empty () && v.is_numeric_type ())
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1047 return true;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1048
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1049 // check value type
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1050 if (type_constraints.size () > 0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1051 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1052 for (std::list<std::string>::const_iterator it = type_constraints.begin ();
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1053 ! xok && it != type_constraints.end (); ++it)
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
1054 if ((*it) == v.class_name ())
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1055 xok = true;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1056 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1057 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
1058 xok = v.is_numeric_type ();
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1059
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1060 if (xok)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1061 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1062 dim_vector vdims = v.dims ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1063 int vlen = vdims.length ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1064
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1065 xok = false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1066
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1067 // check value size
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1068 if (size_constraints.size () > 0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1069 for (std::list<dim_vector>::const_iterator it = size_constraints.begin ();
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1070 ! xok && it != size_constraints.end (); ++it)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1071 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1072 dim_vector itdims = (*it);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1073
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1074 if (itdims.length () == vlen)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1075 {
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1076 xok = true;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1077
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1078 for (int i = 0; xok && i < vlen; i++)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1079 if (itdims(i) >= 0 && itdims(i) != vdims(i))
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1080 xok = false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1081 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1082 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1083 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1084 return true;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1085 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1086
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1087 return xok;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1088 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1089
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1090 bool
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1091 array_property::is_equal (const octave_value& v) const
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1092 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1093 if (data.type_name () == v.type_name ())
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1094 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1095 if (data.dims () == v.dims ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1096 {
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
1097
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
1098 #define CHECK_ARRAY_EQUAL(T,F,A) \
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1099 { \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1100 if (data.numel () == 1) \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1101 return data.F ## scalar_value () == \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1102 v.F ## scalar_value (); \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1103 else \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1104 { \
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
1105 /* 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
1106 /* that are converted, to not be deallocated early */ \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1107 const A m1 = data.F ## array_value (); \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1108 const T* d1 = m1.data (); \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1109 const A m2 = v.F ## array_value (); \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1110 const T* d2 = m2.data ();\
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 bool flag = true; \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1113 \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1114 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
1115 if (d1[i] != d2[i]) \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1116 flag = false; \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1117 \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1118 return flag; \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1119 } \
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 if (data.is_double_type() || data.is_bool_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1123 CHECK_ARRAY_EQUAL (double, , NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1124 else if (data.is_single_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1125 CHECK_ARRAY_EQUAL (float, float_, FloatNDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1126 else if (data.is_int8_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1127 CHECK_ARRAY_EQUAL (octave_int8, int8_, int8NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1128 else if (data.is_int16_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1129 CHECK_ARRAY_EQUAL (octave_int16, int16_, int16NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1130 else if (data.is_int32_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1131 CHECK_ARRAY_EQUAL (octave_int32, int32_, int32NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1132 else if (data.is_int64_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1133 CHECK_ARRAY_EQUAL (octave_int64, int64_, int64NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1134 else if (data.is_uint8_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1135 CHECK_ARRAY_EQUAL (octave_uint8, uint8_, uint8NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1136 else if (data.is_uint16_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1137 CHECK_ARRAY_EQUAL (octave_uint16, uint16_, uint16NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1138 else if (data.is_uint32_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1139 CHECK_ARRAY_EQUAL (octave_uint32, uint32_, uint32NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1140 else if (data.is_uint64_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1141 CHECK_ARRAY_EQUAL (octave_uint64, uint64_, uint64NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1142 }
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1143 }
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1144
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1145 return false;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1146 }
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1147
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1148 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
1149 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
1150 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1151 xmin = xminp = octave_Inf;
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1152 xmax = -octave_Inf;
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1153
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1154 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
1155 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1156 if (data.is_integer_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1157 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1158 if (data.is_int8_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1159 get_array_limits (data.int8_array_value (), xmin, xmax, xminp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1160 else if (data.is_uint8_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1161 get_array_limits (data.uint8_array_value (), xmin, xmax, xminp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1162 else if (data.is_int16_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1163 get_array_limits (data.int16_array_value (), xmin, xmax, xminp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1164 else if (data.is_uint16_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1165 get_array_limits (data.uint16_array_value (), xmin, xmax, xminp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1166 else if (data.is_int32_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1167 get_array_limits (data.int32_array_value (), xmin, xmax, xminp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1168 else if (data.is_uint32_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1169 get_array_limits (data.uint32_array_value (), xmin, xmax, xminp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1170 else if (data.is_int64_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1171 get_array_limits (data.int64_array_value (), xmin, xmax, xminp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1172 else if (data.is_uint64_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1173 get_array_limits (data.uint64_array_value (), xmin, xmax, xminp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1174 }
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
1175 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1176 get_array_limits (data.array_value (), xmin, xmax, xminp);
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
1177 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1178 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1179
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1180 bool
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1181 handle_property::do_set (const octave_value& v)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1182 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1183 double dv = v.double_value ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1184
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1185 if (! error_state)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1186 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1187 graphics_handle gh = gh_manager::lookup (dv);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1188
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1189 if (xisnan (gh.value ()) || gh.ok ())
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 if (current_val != gh)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1192 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1193 current_val = gh;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1194 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1195 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1196 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1197 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1198 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
1199 dv, get_name ().c_str ());
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1200 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1201 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1202 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
1203 get_name ().c_str ());
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1204
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1205 return false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1206 }
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 bool
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1209 callback_property::validate (const octave_value& v) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1210 {
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1211 // case 1: function handle
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1212 // 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
1213 // case 3: string corresponding to known function name
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1214 // case 4: evaluatable string
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1215 // case 5: empty matrix
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1216
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1217 if (v.is_function_handle ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1218 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1219 else if (v.is_string ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1220 // complete validation will be done at execution-time
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1221 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1222 else if (v.is_cell () && v.length () > 0
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1223 && (v.rows() == 1 || v.columns () == 1)
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1224 && v.cell_value ()(0).is_function_handle ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1225 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1226 else if (v.is_empty ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1227 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1228
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1229 return false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1230 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1231
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1232 void
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1233 callback_property::execute (const octave_value& data) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1234 {
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1235 if (callback.is_defined () && ! callback.is_empty ())
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
1236 gh_manager::execute_callback (get_parent (), callback, data);
7824
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
1237 }
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
1238
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1239 // Used to cache dummy graphics objects from which dynamic
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1240 // properties can be cloned.
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1241 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
1242
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1243 property
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1244 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
1245 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
1246 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1247 property retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1248
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1249 if (type.compare ("string"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1250 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1251 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
1252
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1253 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1254 retval = property (new string_property (name, h, val));
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1255 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1256 else if (type.compare ("any"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1257 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1258 octave_value val =
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1259 (args.length () > 0 ? args(0) : octave_value (Matrix ()));
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1260
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1261 retval = property (new any_property (name, h, val));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1262 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1263 else if (type.compare ("radio"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1264 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1265 if (args.length () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1266 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1267 std::string vals = args(0).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1268
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1269 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1270 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1271 retval = property (new radio_property (name, h, vals));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1272
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1273 if (args.length () > 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1274 retval.set (args(1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1275 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1276 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1277 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
1278 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1279 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1280 error ("addproperty: missing possible values for radio property");
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1281 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1282 else if (type.compare ("double"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1283 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1284 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
1285
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1286 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1287 retval = property (new double_property (name, h, d));
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1288 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1289 else if (type.compare ("handle"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1290 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1291 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
1292
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1293 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1294 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1295 graphics_handle gh (hh);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1296
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1297 retval = property (new handle_property (name, h, gh));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1298 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1299 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1300 else if (type.compare ("boolean"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1301 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1302 retval = property (new bool_property (name, h, false));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1303
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1304 if (args.length () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1305 retval.set (args(0));
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1306 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1307 else if (type.compare ("data"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1308 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1309 retval = property (new array_property (name, h, Matrix ()));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1310
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1311 if (args.length () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1312 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1313 retval.set (args(0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1314
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1315 // FIXME -- additional argument could define constraints,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1316 // but is this really useful?
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1317 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1318 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1319 else if (type.compare ("color"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1320 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1321 color_values cv (0, 0, 0);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1322 radio_values rv;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1323
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1324 if (args.length () > 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1325 rv = radio_values (args(1).string_value ());
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1326
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1327 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1328 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1329 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
1330
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1331 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1332 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1333 if (args.length () > 0 && ! args(0).is_empty ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1334 retval.set (args(0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1335 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1336 retval.set (rv.default_value ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1337 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1338 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1339 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1340 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1341 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1342 caseless_str go_name, go_rest;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1343
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1344 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
1345 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1346 graphics_object go;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1347
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1348 std::map<caseless_str, graphics_object>::const_iterator it =
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1349 dprop_obj_map.find (go_name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1350
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1351 if (it == dprop_obj_map.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1352 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1353 base_graphics_object *bgo =
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1354 make_graphics_object_from_type (go_name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1355
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1356 if (bgo)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1357 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1358 go = graphics_object (bgo);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1359
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1360 dprop_obj_map[go_name] = go;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1361 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1362 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1363 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1364 go = it->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1365
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1366 if (go.valid_object ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1367 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1368 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
1369
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1370 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1371 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1372 retval = prop.clone ();
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 retval.set_parent (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1375 retval.set_name (name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1376
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1377 if (args.length () > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1378 retval.set (args(0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1379 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1380 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1381 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1382 error ("addproperty: invalid object type (= %s)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1383 go_name.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1384 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1385 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1386 error ("addproperty: unsupported type for dynamic property (= %s)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1387 type.c_str ());
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1388 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1389
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1390 return retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1391 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1392
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1393 // ---------------------------------------------------------------------
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1394
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1395 void
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1396 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
1397 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1398 size_t offset = 0;
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1399
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1400 size_t len = name.length ();
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1401
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1402 if (len > 4)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1403 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1404 caseless_str pfx = name.substr (0, 4);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1405
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1406 if (pfx.compare ("axes") || pfx.compare ("line")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1407 || pfx.compare ("text"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1408 offset = 4;
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1409 else if (len > 5)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1410 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1411 pfx = name.substr (0, 5);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1412
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1413 if (pfx.compare ("image") || pfx.compare ("patch"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1414 offset = 5;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1415 else if (len > 6)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1416 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1417 pfx = name.substr (0, 6);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1418
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1419 if (pfx.compare ("figure"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1420 offset = 6;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1421 else if (len > 7)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1422 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1423 pfx = name.substr (0, 7);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1424
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1425 if (pfx.compare ("surface") || pfx.compare ("hggroup"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1426 offset = 7;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1427 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1428 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1429 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1430
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1431 if (offset > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1432 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1433 // FIXME -- should we validate property names and values here?
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1434
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1435 std::string pname = name.substr (offset);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1436
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1437 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1438 std::transform (pname.begin (), pname.end (), pname.begin (), tolower);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1439
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1440 bool has_property = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1441 if (pfx == "axes")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1442 has_property = axes::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1443 else if (pfx == "line")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1444 has_property = line::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1445 else if (pfx == "text")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1446 has_property = text::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1447 else if (pfx == "image")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1448 has_property = image::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1449 else if (pfx == "patch")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1450 has_property = patch::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1451 else if (pfx == "figure")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1452 has_property = figure::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1453 else if (pfx == "surface")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1454 has_property = surface::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1455 else if (pfx == "hggroup")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1456 has_property = hggroup::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1457
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1458 if (has_property)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1459 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1460 bool remove = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1461 if (val.is_string ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1462 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1463 caseless_str tval = val.string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1464
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1465 remove = tval.compare ("remove");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1466 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1467
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1468 pval_map_type& pval_map = plist_map[pfx];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1469
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1470 if (remove)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1471 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1472 pval_map_iterator p = pval_map.find (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1473
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1474 if (p != pval_map.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1475 pval_map.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1476 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1477 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1478 pval_map[pname] = val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1479 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1480 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1481 error ("invalid %s property `%s'", pfx.c_str (), pname.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1482 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1483 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1484
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
1485 if (! error_state && offset == 0)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1486 error ("invalid default property specification");
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1487 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1488
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1489 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1490 property_list::lookup (const caseless_str& name) const
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1491 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1492 octave_value retval;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1493
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1494 size_t offset = 0;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1495
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1496 size_t len = name.length ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1497
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1498 if (len > 4)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1499 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1500 caseless_str pfx = name.substr (0, 4);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1501
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1502 if (pfx.compare ("axes") || pfx.compare ("line")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1503 || pfx.compare ("text"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1504 offset = 4;
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1505 else if (len > 5)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1506 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1507 pfx = name.substr (0, 5);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1508
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1509 if (pfx.compare ("image") || pfx.compare ("patch"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1510 offset = 5;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1511 else if (len > 6)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1512 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1513 pfx = name.substr (0, 6);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1514
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1515 if (pfx.compare ("figure"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1516 offset = 6;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1517 else if (len > 7)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1518 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1519 pfx = name.substr (0, 7);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1520
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1521 if (pfx.compare ("surface") || pfx.compare ("hggroup"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1522 offset = 7;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1523 }
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 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1526
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1527 if (offset > 0)
10315
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 std::string pname = name.substr (offset);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1530
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1531 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1532 std::transform (pname.begin (), pname.end (), pname.begin (), tolower);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1533
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1534 plist_map_const_iterator p = find (pfx);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1535
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1536 if (p != end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1537 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1538 const pval_map_type& pval_map = p->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1539
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1540 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
1541
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1542 if (q != pval_map.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1543 retval = q->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1544 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1545 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1546 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1547
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1548 return retval;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1549 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1550
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
1551 octave_scalar_map
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1552 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
1553 {
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
1554 octave_scalar_map m;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1555
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1556 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
1557 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1558 std::string prefix = prefix_arg + p->first;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1559
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1560 const pval_map_type pval_map = p->second;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1561
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1562 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
1563 q != pval_map.end ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1564 q++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1565 m.assign (prefix + q->first, q->second);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1566 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1567
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1568 return m;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1569 }
6432
5bec61ae1576 [project @ 2007-03-23 02:19:10 by jwe]
jwe
parents: 6425
diff changeset
1570
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1571 graphics_handle::graphics_handle (const octave_value& a)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1572 : val (octave_NaN)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1573 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1574 if (a.is_empty ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1575 /* do nothing */;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1576 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1577 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1578 double tval = a.double_value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1579
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1580 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1581 val = tval;
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1582 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1583 error ("invalid graphics handle");
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1584 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1585 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1586
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1587 // 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
1588
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1589 void
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1590 graphics_object::set (const octave_value_list& args)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1591 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1592 int nargin = args.length ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1593
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1594 if (nargin == 0)
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1595 error ("graphics_object::set: Nothing to set");
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1596 else if (nargin % 2 == 0)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1597 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1598 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
1599 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1600 caseless_str name = args(i).string_value ();
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 if (! error_state)
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 octave_value val = args(i+1);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1605
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1606 set_value_or_default (name, val);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1607
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1608 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1609 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1610 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1611 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1612 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
1613 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1614 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1615 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1616 error ("set: invalid number of arguments");
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1617 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1618
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1619 /*
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1620 %!# test set with name, value pairs
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1621 %!test
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1622 %! set(gcf, "visible", "off");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1623 %! h = plot (1:10, 10:-1:1);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1624 %! set (h, "linewidth", 10, "marker", "x");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1625 %! assert (get (h, "linewidth"), 10);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1626 %! assert (get (h, "marker"), "x");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1627 */
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1628
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1629 // 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
1630 void
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1631 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
1632 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
1633 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1634 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
1635 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1636 error("set: number of names must match number of value columns (%d != %d)",
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1637 names.numel (), values.columns ());
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1638 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1639
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1640 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
1641
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1642 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
1643 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1644 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
1645 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
1646
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1647 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
1648
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1649 if (error_state)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1650 break;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1651 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1652 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1653
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1654 /*
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1655 %!# test set with cell array arguments
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1656 %!test
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1657 %! set (gcf, "visible", "off");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1658 %! h = plot (1:10, 10:-1:1);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1659 %! set (h, {"linewidth", "marker"}, {10, "x"});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1660 %! assert (get(h, "linewidth"), 10);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1661 %! assert (get(h, "marker"), "x");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1662
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1663 %!# test set with multiple handles and cell array arguments
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1664 %!test
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1665 %! set (gcf, "visible", "off");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1666 %! h = plot (1:10, 10:-1:1, 1:10, 1:10);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1667 %! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1668 %! assert (get (h, "linewidth"), {10; 5});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1669 %! assert (get (h, "marker"), {"x"; "o"});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1670 %! set (h, {"linewidth", "marker"}, {10, "x"});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1671 %! assert (get (h, "linewidth"), {10; 10});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1672 %! assert (get (h, "marker"), {"x"; "x"});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1673
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1674 %!error <set: number of graphics handles must match number of value rows>
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1675 %! set (gcf, "visible", "off");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1676 %! h = plot (1:10, 10:-1:1, 1:10, 1:10);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1677 %! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"; 7, "."});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1678
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1679 %!error <set: number of names must match number of value columns>
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1680 %! set (gcf, "visible", "off");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1681 %! h = plot (1:10, 10:-1:1, 1:10, 1:10);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1682 %! set (h, {"linewidth"}, {10, "x"; 5, "o"});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1683 */
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1684
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1685 // 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
1686 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
1687 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
1688 {
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
1689 for (octave_map::const_iterator p = m.begin ();
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1690 p != m.end (); p++)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1691 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1692 caseless_str name = m.key (p);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1693
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1694 octave_value val = octave_value (m.contents (p).elem (m.numel () - 1));
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1695
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1696 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
1697
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1698 if (error_state)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1699 break;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1700 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1701 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1702
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1703 /*
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1704 %!# test set with struct arguments
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1705 %!test
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1706 %! set (gcf, "visible", "off");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1707 %! h = plot (1:10, 10:-1:1);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1708 %! set (h, struct ("linewidth", 10, "marker", "x"));
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1709 %! assert (get (h, "linewidth"), 10);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1710 %! assert (get (h, "marker"), "x");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1711 %! h = plot (1:10, 10:-1:1, 1:10, 1:10);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1712 %! set (h, struct ("linewidth", {5, 10}));
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1713 %! assert (get(h, "linewidth"), {10; 10});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1714 */
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1715
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1716 // 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
1717
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1718 void
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1719 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
1720 const octave_value& val)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1721 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1722 if (val.is_string ())
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1723 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1724 caseless_str tval = val.string_value ();
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1725
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1726 octave_value default_val;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1727
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1728 if (tval.compare ("default"))
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1729 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1730 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
1731
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1732 if (error_state)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1733 return;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1734
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1735 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
1736 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1737 else if (tval.compare ("factory"))
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1738 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1739 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
1740
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1741 if (error_state)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1742 return;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1743
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1744 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
1745 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1746 else
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1747 rep->set (name, val);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1748 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1749 else
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1750 rep->set (name, val);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1751 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1752
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1753 /*
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1754 %!# test setting of default values
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1755 %!test
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1756 %! set (gcf, "visible", "off");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1757 %! h = plot (1:10, 10:-1:1);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1758 %! set (0, "defaultlinelinewidth", 20);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1759 %! set (h, "linewidth", "default");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1760 %! assert (get (h, "linewidth"), 20);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1761 %! set (h, "linewidth", "factory");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1762 %! assert (get (h, "linewidth"), 0.5);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1763 */
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1764
8234
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1765 static double
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1766 make_handle_fraction (void)
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1767 {
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1768 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
1769
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1770 return (rand () + 1.0) / maxrand;
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1771 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1772
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1773 graphics_handle
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1774 gh_manager::get_handle (const std::string& go_name)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1775 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1776 graphics_handle retval;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1777
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1778 if (go_name == "figure")
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1779 {
8234
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1780 // 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
1781 // figure number.
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1782
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1783 // We always want the lowest unused figure number.
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1784
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1785 retval = 1;
6425
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
1786
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1787 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
1788 retval++;
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1789 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1790 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1791 {
8234
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1792 // 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
1793 // 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
1794 // 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
1795 // time.
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1796
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1797 free_list_iterator p = handle_free_list.begin ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1798
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1799 if (p != handle_free_list.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1800 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1801 retval = *p;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1802 handle_free_list.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1803 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1804 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1805 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1806 retval = graphics_handle (next_handle);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1807
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1808 next_handle = ceil (next_handle) - 1.0 - make_handle_fraction ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1809 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1810 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1811
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1812 return retval;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1813 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1814
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1815 void
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1816 gh_manager::do_free (const graphics_handle& h)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1817 {
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1818 if (h.ok ())
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1819 {
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1820 if (h.value () != 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1821 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1822 iterator p = handle_map.find (h);
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 if (p != handle_map.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1825 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1826 base_properties& bp = p->second.get_properties ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1827
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1828 bp.set_beingdeleted (true);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1829
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1830 bp.delete_children ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1831
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1832 octave_value val = bp.get_deletefcn ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1833
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1834 bp.execute_deletefcn ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1835
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1836 // notify backend
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1837 graphics_backend backend = p->second.get_backend ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1838 if (backend)
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
1839 backend.finalize (p->second);
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
1840
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1841 // Note: this will be valid only for first explicitly
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1842 // deleted object. All its children will then have an
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1843 // unknown backend.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1844
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1845 // Graphics handles for non-figure objects are negative
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1846 // integers plus some random fractional part. To avoid
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1847 // 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
1848 // 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
1849
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1850 handle_map.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1851
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1852 if (h.value () < 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1853 handle_free_list.insert (ceil (h.value ()) - make_handle_fraction ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1854 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1855 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1856 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
1857 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1858 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1859 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
1860 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1861 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1862
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1863 gh_manager *gh_manager::instance = 0;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1864
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1865 static void
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1866 xset (const graphics_handle& h, const caseless_str& name,
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1867 const octave_value& val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1868 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1869 graphics_object obj = gh_manager::get_object (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1870 obj.set (name, val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1871 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1872
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1873 static void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1874 xset (const graphics_handle& h, const octave_value_list& args)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1875 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1876 if (args.length () > 0)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1877 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1878 graphics_object obj = gh_manager::get_object (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1879 obj.set (args);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1880 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1881 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1882
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1883
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1884 static octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1885 xget (const graphics_handle& h, const caseless_str& name)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1886 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1887 graphics_object obj = gh_manager::get_object (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1888 return obj.get (name);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1889 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1890
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1891 static graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1892 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
1893 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
1894 bool adopt = true)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1895 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1896 graphics_handle h = octave_NaN;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1897
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1898 double val = ov.double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1899
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1900 if (! error_state)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1901 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1902 h = gh_manager::lookup (val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1903
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1904 if (h.ok ())
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 graphics_object obj = gh_manager::get_object (h);
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 graphics_handle parent_h = obj.get_parent ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1909
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1910 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
1911
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1912 parent_obj.remove_child (h);
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 (adopt)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1915 obj.set ("parent", new_parent.value ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1916 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1917 obj.reparent (new_parent);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1918 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1919 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1920 error ("%s: invalid graphics handle (= %g) for %s",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1921 who.c_str (), val, property.c_str ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1922 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1923 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1924 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
1925 who.c_str (), property.c_str ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1926
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1927 return h;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1928 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1929
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1930 // 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
1931 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1932 gcf (void)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1933 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1934 octave_value val = xget (0, "currentfigure");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1935
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1936 return val.is_empty () ? octave_NaN : val.double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1937 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1938
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1939 // 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
1940 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1941 gca (void)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1942 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1943 octave_value val = xget (gcf (), "currentaxes");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1944
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1945 return val.is_empty () ? octave_NaN : val.double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1946 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1947
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1948 static void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1949 adopt (const graphics_handle& p, const graphics_handle& h)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1950 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1951 graphics_object parent_obj = gh_manager::get_object (p);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1952
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1953 parent_obj.adopt (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1954 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1955
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1956 static bool
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1957 is_handle (const graphics_handle& h)
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1958 {
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1959 return h.ok ();
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1960 }
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1961
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1962 static bool
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1963 is_handle (double val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1964 {
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1965 graphics_handle h = gh_manager::lookup (val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1966
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1967 return h.ok ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1968 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1969
8183
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
1970 static octave_value
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1971 is_handle (const octave_value& val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1972 {
8183
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
1973 octave_value retval = false;
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
1974
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
1975 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
1976 retval = true;
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
1977 else if (val.is_real_matrix ())
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
1978 {
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
1979 if (val.is_string ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1980 retval = boolNDArray (val.dims (), false);
8183
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
1981 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1982 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1983 const NDArray handles = val.array_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1984
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1985 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1986 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1987 boolNDArray result (handles.dims ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1988
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1989 for (octave_idx_type i = 0; i < handles.numel (); i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1990 result.xelem (i) = is_handle (handles (i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1991
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1992 retval = result;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1993 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1994 }
8183
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
1995 }
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
1996
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
1997 return retval;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1998 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1999
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2000 static bool
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2001 is_figure (double val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2002 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2003 graphics_object obj = gh_manager::get_object (val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2004
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2005 return obj && obj.isa ("figure");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2006 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2007
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2008 static void
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2009 xcreatefcn (const graphics_handle& h)
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2010 {
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2011 graphics_object obj = gh_manager::get_object (h);
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2012 obj.get_properties ().execute_createfcn ();
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2013 }
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2014
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2015 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2016
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2017 void
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
2018 base_graphics_backend::update (const graphics_handle& h, int id)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2019 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2020 graphics_object go = gh_manager::get_object (h);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2021
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
2022 update (go, id);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2023 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2024
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2025 void
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
2026 base_graphics_backend::initialize (const graphics_handle& h)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2027 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2028 graphics_object go = gh_manager::get_object (h);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2029
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
2030 initialize (go);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2031 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2032
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2033 void
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
2034 base_graphics_backend::finalize (const graphics_handle& h)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2035 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2036 graphics_object go = gh_manager::get_object (h);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2037
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
2038 finalize (go);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2039 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2040 // ---------------------------------------------------------------------
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2041
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2042 void
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2043 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
2044 property_list& defaults)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2045 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2046 std::string go_name = graphics_object_name ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2047
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2048 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
2049
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2050 if (p != defaults.end ())
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2051 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2052 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
2053
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2054 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
2055 q != pval_map.end ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2056 q++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2057 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2058 std::string pname = q->first;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2059
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2060 obj.set (pname, q->second);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2061
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2062 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2063 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2064 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
2065 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2066 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2067 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2068 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2069 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2070
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2071 octave_value
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2072 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
2073 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2074 octave_value retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2075
8090
3cc1ca1b1576 MSVC compilation fix
Michael Goffioul
parents: 8081
diff changeset
2076 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it = all_props.find (name);
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2077
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2078 if (it != all_props.end ())
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2079 retval = it->second.get ();
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2080 else
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2081 error ("get: unknown property \"%s\"", name.c_str ());
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2082
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2083 return retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2084 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2085
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2086 octave_value
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2087 base_properties::get_dynamic (bool all) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2088 {
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
2089 octave_scalar_map m;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2090
8090
3cc1ca1b1576 MSVC compilation fix
Michael Goffioul
parents: 8081
diff changeset
2091 for (std::map<caseless_str, property, cmp_caseless_str>::const_iterator it = all_props.begin ();
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2092 it != all_props.end (); ++it)
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
2093 if (all || ! it->second.is_hidden ())
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
2094 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
2095
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2096 return m;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2097 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2098
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
2099 std::set<std::string>
9972
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2100 base_properties::dynamic_property_names (void) const
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2101 {
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2102 return dynamic_properties;
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
2103 }
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
2104
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2105 bool
9972
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2106 base_properties::has_dynamic_property (const std::string& pname)
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2107 {
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2108 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
2109
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2110 return dynprops.find (pname) != dynprops.end ();
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2111 }
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2112
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2113 void
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2114 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
2115 const octave_value& val)
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2116 {
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2117 std::map<caseless_str, property, cmp_caseless_str>::iterator it = all_props.find (pname);
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2118
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2119 if (it != all_props.end ())
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2120 it->second.set (val);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2121 else
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2122 error ("set: unknown property \"%s\"", pname.c_str ());
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2123
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2124 if (! error_state)
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2125 {
9972
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2126 dynamic_properties.insert (pname);
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2127
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2128 mark_modified ();
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2129 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2130 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2131
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2132 property
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2133 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
2134 {
8090
3cc1ca1b1576 MSVC compilation fix
Michael Goffioul
parents: 8081
diff changeset
2135 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it = all_props.find (name);
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2136
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2137 if (it == all_props.end ())
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2138 {
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2139 error ("get_property: unknown property \"%s\"", name.c_str ());
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2140 return property ();
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2141 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2142 else
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2143 return it->second;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2144 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2145
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2146 void
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2147 base_properties::remove_child (const graphics_handle& h)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2148 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2149 octave_idx_type k = -1;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2150 octave_idx_type n = children.numel ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2151 for (octave_idx_type i = 0; i < n; i++)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2152 {
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2153 if (h.value () == children(i))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2154 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2155 k = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2156 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2157 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2158 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2159
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2160 if (k >= 0)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2161 {
8233
beaf723a49eb graphics.cc (base_properties::remove_child): handle children as a column vector instead of a row vector
John W. Eaton <jwe@octave.org>
parents: 8228
diff changeset
2162 Matrix new_kids (n-1, 1);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2163 octave_idx_type j = 0;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2164 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
2165 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2166 if (i != k)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2167 new_kids(j++) = children(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2168 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2169 children = new_kids;
7378
3771971e8891 [project @ 2008-01-15 07:40:23 by jwe]
jwe
parents: 7373
diff changeset
2170 mark_modified ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2171 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2172 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2173
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2174 void
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2175 base_properties::set_parent (const octave_value& val)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2176 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2177 double tmp = val.double_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2178
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2179 graphics_handle new_parent = octave_NaN;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2180
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2181 if (! error_state)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2182 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2183 new_parent = gh_manager::lookup (tmp);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2184
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2185 if (new_parent.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2186 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2187 graphics_object parent_obj = gh_manager::get_object (get_parent ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2188
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2189 parent_obj.remove_child (__myhandle__);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2190
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2191 parent = new_parent.as_octave_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2192
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2193 ::adopt (parent.handle_value (), __myhandle__);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2194 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2195 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2196 error ("set: invalid graphics handle (= %g) for parent", tmp);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2197 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2198 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2199 error ("set: expecting parent to be a graphics handle");
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2200 }
6432
5bec61ae1576 [project @ 2007-03-23 02:19:10 by jwe]
jwe
parents: 6425
diff changeset
2201
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2202 void
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2203 base_properties::set_children (const octave_value& val)
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2204 {
10289
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2205 const Matrix new_kids = val.matrix_value ();
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2206
10301
9e0ec19df4bc commit accidentally omitted parts of previous change
John W. Eaton <jwe@octave.org>
parents: 10289
diff changeset
2207 octave_idx_type nel = new_kids.numel ();
9e0ec19df4bc commit accidentally omitted parts of previous change
John W. Eaton <jwe@octave.org>
parents: 10289
diff changeset
2208
9e0ec19df4bc commit accidentally omitted parts of previous change
John W. Eaton <jwe@octave.org>
parents: 10289
diff changeset
2209 const Matrix new_kids_column = new_kids.reshape (dim_vector (nel, 1));
9e0ec19df4bc commit accidentally omitted parts of previous change
John W. Eaton <jwe@octave.org>
parents: 10289
diff changeset
2210
10289
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2211 bool ok = true;
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2212
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2213 if (! error_state)
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2214 {
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2215 const Matrix visible_kids = get_children ();
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2216
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2217 if (visible_kids.numel () == new_kids.numel ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2218 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2219 Matrix t1 = visible_kids.sort ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2220 Matrix t2 = new_kids_column.sort ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2221
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2222 if (t1 != t2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2223 ok = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2224 }
10289
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2225 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2226 ok = false;
10289
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2227
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2228 if (! ok)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2229 error ("set: new children must be a permutation of existing children");
10289
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2230 }
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2231 else
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2232 {
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2233 ok = false;
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2234 error ("set: expecting children to be array of graphics handles");
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2235 }
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2236
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
2237 if (ok)
10301
9e0ec19df4bc commit accidentally omitted parts of previous change
John W. Eaton <jwe@octave.org>
parents: 10289
diff changeset
2238 children = new_kids_column.stack (get_hidden_children ());
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2239 }
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2240
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2241 void
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2242 base_properties::mark_modified (void)
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2243 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2244 __modified__ = "on";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2245 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
2246 if (parent_obj)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
2247 parent_obj.mark_modified ();
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2248 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2249
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2250 void
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2251 base_properties::override_defaults (base_graphics_object& obj)
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2252 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2253 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
2254
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
2255 if (parent_obj)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
2256 parent_obj.override_defaults (obj);
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2257 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2258
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2259 void
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2260 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
2261 {
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2262 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
2263
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2264 if (obj)
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2265 obj.update_axis_limits (axis_type);
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2266 }
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2267
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2268 void
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2269 base_properties::delete_children (void)
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2270 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2271 octave_idx_type n = children.numel ();
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2272
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
2273 // A callback function might have already deleted the child,
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
2274 // so check before deleting
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2275 for (octave_idx_type i = 0; i < n; i++)
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
2276 {
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
2277 graphics_object go = gh_manager::get_object (children(i));
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
2278
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
2279 if (go.valid_object ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2280 gh_manager::free (children(i));
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
2281 }
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2282 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2283
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2284 graphics_backend
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2285 base_properties::get_backend (void) const
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2286 {
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2287 graphics_object go = gh_manager::get_object (get_parent ());
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2288
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2289 if (go)
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2290 return go.get_backend ();
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2291 else
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2292 return graphics_backend ();
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2293 }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2294
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2295 void
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2296 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
2297 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2298 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
2299
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2300 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
2301 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2302 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
2303
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2304 if (go.valid_object ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2305 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
2306 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2307 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2308
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2309 void
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2310 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
2311 listener_mode mode)
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2312 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2313 property p = get_property (nm);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2314
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2315 if (! error_state && p.ok ())
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2316 p.add_listener (v, mode);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2317 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2318
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2319 void
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2320 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
2321 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
2322 {
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2323 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
2324
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2325 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
2326 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
2327 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2328
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2329 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2330
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2331 class gnuplot_backend : public base_graphics_backend
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2332 {
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2333 public:
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2334 gnuplot_backend (void)
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2335 : base_graphics_backend ("gnuplot") { }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2336
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2337 ~gnuplot_backend (void) { }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2338
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2339 bool is_valid (void) const { return true; }
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2340
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
2341 void finalize (const graphics_object& go)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2342 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2343 if (go.isa ("figure"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2344 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2345 const figure::properties& props =
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2346 dynamic_cast<const figure::properties&> (go.get_properties ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2347
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2348 send_quit (props.get___plot_stream__ ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2349 }
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2350 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2351
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
2352 void update (const graphics_object& go, int id)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2353 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2354 if (go.isa ("figure"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2355 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2356 graphics_object obj (go);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2357
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2358 figure::properties& props =
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2359 dynamic_cast<figure::properties&> (obj.get_properties ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2360
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2361 switch (id)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2362 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2363 case base_properties::VISIBLE:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2364 if (! props.is_visible ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2365 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2366 send_quit (props.get___plot_stream__ ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2367 props.set___plot_stream__ (Matrix ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2368 props.set___enhanced__ (false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2369 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2370 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2371 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2372 }
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2373 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2374
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2375 void redraw_figure (const graphics_object& go) const
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2376 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2377 octave_value_list args;
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2378 args(0) = go.get_handle ().as_octave_value ();
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2379 feval ("gnuplot_drawnow", args);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2380 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2381
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2382 void print_figure (const graphics_object& go, const std::string& term,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2383 const std::string& file, bool mono,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2384 const std::string& debug_file) const
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2385 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2386 octave_value_list args;
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2387 if (! debug_file.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2388 args(4) = debug_file;
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2389 args(3) = mono;
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2390 args(2) = file;
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2391 args(1) = term;
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2392 args(0) = go.get_handle ().as_octave_value ();
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2393 feval ("gnuplot_drawnow", args);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2394 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2395
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2396 Matrix get_canvas_size (const graphics_handle&) const
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2397 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2398 Matrix sz (1, 2, 0.0);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2399 return sz;
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2400 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2401
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2402 double get_screen_resolution (void) const
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2403 { return 72.0; }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2404
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2405 Matrix get_screen_size (void) const
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2406 { return Matrix (1, 2, 0.0); }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2407
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2408 private:
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2409 void send_quit (const octave_value& pstream) const
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2410 {
9561
c60a9e1a0372 try to avoid gnuplot zombies
John W. Eaton <jwe@octave.org>
parents: 9455
diff changeset
2411 if (! pstream.is_empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2412 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2413 octave_value_list args;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2414 Matrix fids = pstream.matrix_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2415
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2416 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2417 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2418 args(1) = "\nquit;\n";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2419 args(0) = fids(0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2420 feval ("fputs", args);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2421
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2422 args.resize (1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2423 feval ("fflush", args);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2424 feval ("pclose", args);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2425
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2426 if (fids.numel () > 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2427 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2428 args(0) = fids(1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2429 feval ("pclose", args);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2430
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2431 if (fids.numel () > 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2432 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2433 args(0) = fids(2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2434 feval ("waitpid", args);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2435 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2436 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2437 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2438 }
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2439 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2440 };
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2441
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2442 graphics_backend
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2443 graphics_backend::default_backend (void)
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2444 {
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2445 if (available_backends.size () == 0)
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2446 register_backend (new gnuplot_backend ());
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2447
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2448 return available_backends["gnuplot"];
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2449 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2450
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2451 std::map<std::string, graphics_backend> graphics_backend::available_backends;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2452
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2453 // ---------------------------------------------------------------------
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2454
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2455 void
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2456 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
2457 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2458 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
2459 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2460 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
2461
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2462 if (parent_obj)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2463 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
2464 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2465 else
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2466 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
2467 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2468
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2469 void
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2470 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
2471 {
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
2472 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
2473
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
2474 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
2475 {
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2476 // FIXME -- there has to be a better way. I think we want to
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2477 // 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
2478 // 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
2479
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
2480 unwind_protect frame;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
2481
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
2482 frame.protect_var (discard_error_messages);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
2483 frame.protect_var (error_state);
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2484
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2485 discard_error_messages = true;
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2486
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2487 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
2488
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2489 if (! error_state && p.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2490 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
2491 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2492 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2493
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2494 std::string
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2495 base_graphics_object::values_as_string (void)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2496 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2497 std::string retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2498
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2499 if (valid_object ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2500 {
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
2501 octave_map m = get ().map_value ();
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2502
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
2503 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
2504 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2505 if (pa->first != "children")
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2506 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2507 property p = get_properties ().get_property (pa->first);
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2508
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2509 if (p.ok () && ! p.is_hidden ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2510 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2511 retval += "\n\t" + std::string (pa->first) + ": ";
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2512 if (p.is_radio ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2513 retval += p.values_as_string ();
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2514 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2515 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2516 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2517 if (retval != "")
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2518 retval += "\n";
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2519 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2520 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2521 error ("base_graphics_object::values_as_string: invalid graphics object");
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2522
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2523 return retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2524 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2525
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
2526 octave_scalar_map
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2527 base_graphics_object::values_as_struct (void)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2528 {
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
2529 octave_scalar_map retval;
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2530
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2531 if (valid_object ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2532 {
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
2533 octave_scalar_map m = get ().scalar_map_value ();
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2534
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
2535 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
2536 pa != m.end (); pa++)
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2537 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2538 if (pa->first != "children")
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2539 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2540 property p = get_properties ().get_property (pa->first);
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2541
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2542 if (p.ok () && ! p.is_hidden ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2543 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2544 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
2545 retval.assign (p.get_name (), p.values_as_cell ());
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2546 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
2547 retval.assign (p.get_name (), Cell ());
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2548 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2549 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2550 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2551 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2552 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2553 error ("base_graphics_object::values_as_struct: invalid graphics object");
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2554
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2555 return retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2556 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2557
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2558 // ---------------------------------------------------------------------
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2559
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2560 #include "graphics-props.cc"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2561
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2562 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2563
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2564 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2565 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
2566 {
7378
3771971e8891 [project @ 2008-01-15 07:40:23 by jwe]
jwe
parents: 7373
diff changeset
2567 graphics_handle val (v);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2568
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2569 if (error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2570 return;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2571
7059
8d57f66e35b8 [project @ 2007-10-24 17:16:23 by jwe]
jwe
parents: 7056
diff changeset
2572 if (xisnan (val.value ()) || is_handle (val))
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2573 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2574 currentfigure = val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2575
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2576 gh_manager::push_figure (val);
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2577 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2578 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2579 gripe_set_invalid ("currentfigure");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2580 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2581
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2582 void
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2583 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
2584 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2585 graphics_handle val (v);
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2586
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2587 if (error_state)
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2588 return;
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2589
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2590 if (xisnan (val.value ()))
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2591 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2592 if (! cbo_stack.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2593 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2594 val = cbo_stack.front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2595
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2596 cbo_stack.pop_front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2597 }
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2598
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2599 callbackobject = val;
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2600 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2601 else if (is_handle (val))
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2602 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2603 if (get_callbackobject ().ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2604 cbo_stack.push_front (get_callbackobject ());
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2605
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2606 callbackobject = val;
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2607 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2608 else
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2609 gripe_set_invalid ("callbackobject");
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2610 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2611
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
2612 // FIXME This should update monitorpositions and pointerlocation, but
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2613 // 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
2614 // aren't set yet.
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2615 void
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2616 root_figure::properties::update_units (void)
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2617 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2618 caseless_str xunits = get_units ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2619
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2620 Matrix ss = default_screensize ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2621
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2622 double dpi = get_screenpixelsperinch ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2623
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2624 if (xunits.compare ("inches"))
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2625 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2626 ss(0) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2627 ss(1) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2628 ss(2) /= dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2629 ss(3) /= dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2630 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2631 else if (xunits.compare ("centimeters"))
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2632 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2633 ss(0) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2634 ss(1) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2635 ss(2) *= 2.54 / dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2636 ss(3) *= 2.54 / dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2637 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2638 else if (xunits.compare ("normalized"))
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2639 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2640 ss = Matrix (1, 4, 1.0);
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2641 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2642 else if (xunits.compare ("points"))
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2643 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2644 ss(0) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2645 ss(1) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2646 ss(2) *= 72 / dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2647 ss(3) *= 72 / dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2648 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2649
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2650 set_screensize (ss);
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2651 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2652
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2653 void
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2654 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
2655 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2656 gh_manager::pop_figure (gh);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2657
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2658 graphics_handle cf = gh_manager::current_figure ();
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2659
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2660 xset (0, "currentfigure", cf.value ());
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2661
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2662 base_properties::remove_child (gh);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2663 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2664
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2665 property_list
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2666 root_figure::factory_properties = root_figure::init_factory_properties ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2667
10733
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
2668 static void
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
2669 reset_default_properties (property_list& default_properties)
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2670 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2671 property_list new_defaults;
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2672
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2673 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
2674 p != default_properties.end (); p++)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2675 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2676 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
2677 std::string prefix = p->first;
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2678
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2679 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
2680 q != pval_map.end ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2681 q++)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2682 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2683 std::string s = q->first;
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2684
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2685 if (prefix == "axes" && (s == "position" || s == "units"))
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2686 new_defaults.set (prefix + s, q->second);
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2687 else if (prefix == "figure" && (s == "position" || s == "units"
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2688 || s == "windowstyle"
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2689 || s == "paperunits"))
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2690 new_defaults.set (prefix + s, q->second);
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2691 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2692 }
10733
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
2693
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2694 default_properties = new_defaults;
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2695 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2696
10733
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
2697 void
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
2698 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
2699 {
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
2700 ::reset_default_properties (default_properties);
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
2701 }
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
2702
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2703 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2704
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2705 void
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2706 figure::properties::set_currentaxes (const octave_value& v)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2707 {
7378
3771971e8891 [project @ 2008-01-15 07:40:23 by jwe]
jwe
parents: 7373
diff changeset
2708 graphics_handle val (v);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2709
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2710 if (error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2711 return;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2712
7070
7593f8e83a2e [project @ 2007-10-25 20:41:16 by jwe]
jwe
parents: 7059
diff changeset
2713 if (xisnan (val.value ()) || is_handle (val))
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2714 currentaxes = val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2715 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2716 gripe_set_invalid ("currentaxes");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2717 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2718
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2719 void
8266
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2720 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
2721 {
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2722 base_properties::remove_child (gh);
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2723
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2724 if (gh == currentaxes.handle_value ())
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2725 {
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2726 graphics_handle new_currentaxes;
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2727
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2728 for (octave_idx_type i = 0; i < children.numel (); i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2729 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2730 graphics_handle kid = children(i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2731
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2732 graphics_object go = gh_manager::get_object (kid);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2733
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2734 if (go.isa ("axes"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2735 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2736 new_currentaxes = kid;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2737 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2738 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2739 }
8266
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2740
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2741 currentaxes = new_currentaxes;
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2742 }
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2743 }
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2744
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2745 void
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2746 figure::properties::set_visible (const octave_value& val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2747 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2748 std::string s = val.string_value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2749
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2750 if (! error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2751 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2752 if (s == "on")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2753 xset (0, "currentfigure", __myhandle__.value ());
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2754
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2755 visible = val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2756 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2757 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2758
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2759 Matrix
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2760 figure::properties::get_boundingbox (bool) const
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2761 {
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
2762 Matrix screen_size = screen_size_pixels ();
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2763 Matrix pos;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2764
10949
848f3a13b7cf Backed out changeset 6b50fd2d4ca6
David Bateman <dbateman@free.fr>
parents: 10948
diff changeset
2765 pos = convert_position (get_position ().matrix_value (), get_units (),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2766 "pixels", screen_size);
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2767
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2768 pos(0)--;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2769 pos(1)--;
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2770 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
2771
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2772 return pos;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2773 }
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2774
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2775 void
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2776 figure::properties::set_boundingbox (const Matrix& bb)
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2777 {
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
2778 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
2779 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
2780
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2781 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
2782 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
2783 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
2784 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
2785
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2786 set_position (pos);
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2787 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2788
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2789 void
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2790 figure::properties::set_position (const octave_value& v)
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2791 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2792 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
2793 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2794 Matrix old_bb, new_bb;
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2795
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2796 old_bb = get_boundingbox ();
10949
848f3a13b7cf Backed out changeset 6b50fd2d4ca6
David Bateman <dbateman@free.fr>
parents: 10948
diff changeset
2797 position = v;
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2798 new_bb = get_boundingbox ();
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2799
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2800 if (old_bb != new_bb)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2801 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2802 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
2803 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2804 execute_resizefcn ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2805 update_boundingbox ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2806 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2807 }
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2808
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2809 mark_modified ();
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2810 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2811 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2812
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
2813 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
2814 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
2815 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2816 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
2817 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2818 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
2819 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
2820 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
2821 {
10994
9e1270a84a10 graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents: 10991
diff changeset
2822 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
2823 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
2824 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
2825 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2826 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
2827 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
2828 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2829 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
2830 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
2831 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2832 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2833 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2834 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2835 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2836
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2837 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
2838 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
2839 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2840 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
2841 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2842 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
2843 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
2844 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
2845 {
10994
9e1270a84a10 graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents: 10991
diff changeset
2846 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
2847 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
2848 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
2849 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2850 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
2851 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2852 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
2853 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
2854 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2855 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2856 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2857 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2858 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2859
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2860 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
2861 papersize_from_type (const caseless_str punits, const caseless_str typ)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2862 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2863 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
2864
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2865 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
2866 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2867 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
2868 double 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
2869
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2870 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
2871 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2872 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
2873 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
2874 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2875 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
2876 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2877 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
2878 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
2879 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2880 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
2881 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2882 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
2883 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
2884 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2885
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2886 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
2887 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2888 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
2889 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
2890 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2891 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
2892 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2893 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
2894 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
2895 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2896 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
2897 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2898 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
2899 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
2900 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2901 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
2902 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2903 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
2904 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
2905 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2906 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
2907 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2908 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
2909 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
2910 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2911 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
2912 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2913 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
2914 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
2915 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2916 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
2917 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2918 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
2919 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
2920 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2921 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
2922 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2923 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
2924 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
2925 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2926 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
2927 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2928 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
2929 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
2930 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2931 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
2932 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2933 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
2934 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
2935 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2936 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
2937 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2938 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
2939 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
2940 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2941 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
2942 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2943 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
2944 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
2945 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2946 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
2947 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2948 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
2949 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
2950 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2951 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
2952 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2953 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
2954 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
2955 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2956 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
2957 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2958 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
2959 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
2960 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2961 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
2962 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2963 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
2964 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
2965 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2966 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
2967 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2968 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
2969 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
2970 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2971 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
2972 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2973 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
2974 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
2975 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2976 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
2977 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2978 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
2979 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
2980 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2981 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
2982 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2983 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
2984 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
2985 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2986 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
2987 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2988 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
2989 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
2990 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2991 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
2992 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2993 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
2994 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
2995 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2996 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
2997 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2998 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
2999 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
3000 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3001 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
3002 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3003 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
3004 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
3005 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3006 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
3007 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3008 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
3009 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
3010 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3011 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3012
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3013 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
3014 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3015
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3016 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
3017 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
3018 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3019 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
3020 Matrix sz = get_papersize ().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
3021
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3022 pos (0) = pos (0) / sz(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
3023 pos (1) = pos (1) / sz(1);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3024 pos (2) = pos (2) / sz(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
3025 pos (3) = pos (3) / sz(1);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3026
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3027 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
3028 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
3029
10994
9e1270a84a10 graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents: 10991
diff changeset
3030 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
3031 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3032 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
3033 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3034 sz (0) = sz (0) / 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
3035 sz (1) = sz (1) / 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
3036 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3037 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
3038 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3039 sz (0) = sz (0) / 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
3040 sz (1) = sz (1) / 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
3041 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3042
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3043 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
3044 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3045 sz(0) = sz(0) * 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
3046 sz(1) = sz(1) * 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
3047 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3048 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
3049 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3050 sz (0) = sz (0) * 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
3051 sz (1) = sz (1) * 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
3052 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3053 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3054 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
3055 sz = papersize_from_type (punits, typ);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3056
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3057 pos (0) = pos (0) * sz(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
3058 pos (1) = pos (1) * sz(1);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3059 pos (2) = pos (2) * sz(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
3060 pos (3) = pos (3) * sz(1);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3061
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3062 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
3063 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
3064 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3065
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3066 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
3067 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
3068 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3069 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
3070
10994
9e1270a84a10 graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents: 10991
diff changeset
3071 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
3072 // Call papersize.set rather than set_papersize to avoid loops between
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3073 // update_papersize and 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
3074 papersize.set (octave_value (papersize_from_type (get_paperunits (), typ)));
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3075 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3076
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3077 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
3078 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
3079 {
10994
9e1270a84a10 graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents: 10991
diff changeset
3080 papertype.set ("<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
3081 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3082
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3083 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
3084 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
3085 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3086 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
3087 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3088 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
3089 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
3090 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3091 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
3092 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
3093 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3094 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3095 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3096
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3097 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
3098 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
3099 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3100 set_position (convert_position (get_position ().matrix_value (), 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
3101 get_units (), screen_size_pixels ()));
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3102 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3103
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3104 std::string
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3105 figure::properties::get_title (void) const
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3106 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3107 if (is_numbertitle ())
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3108 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3109 std::ostringstream os;
8062
e04a4beeb283 graphics.cc (figure::properties::get_title): avoid gcc warning
John W. Eaton <jwe@octave.org>
parents: 8061
diff changeset
3110 std::string nm = get_name ();
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3111
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3112 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
3113 if (! nm.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3114 os << ": " << get_name ();
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3115
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3116 return os.str ();
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3117 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3118 else
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3119 return get_name ();
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3120 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3121
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3122 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
3123 figure::get_default (const caseless_str& name) const
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3124 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3125 octave_value retval = default_properties.lookup (name);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3126
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3127 if (retval.is_undefined ())
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3128 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3129 graphics_handle parent = get_parent ();
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3130 graphics_object parent_obj = gh_manager::get_object (parent);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3131
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3132 retval = parent_obj.get_default (name);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3133 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3134
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3135 return retval;
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3136 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3137
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3138 void
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3139 figure::reset_default_properties (void)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3140 {
10733
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
3141 ::reset_default_properties (default_properties);
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3142 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3143
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3144 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3145
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3146 void
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3147 axes::properties::init (void)
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3148 {
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3149 position.add_constraint (dim_vector (1, 4));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3150 position.add_constraint (dim_vector (0, 0));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3151 outerposition.add_constraint (dim_vector (1, 4));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3152 colororder.add_constraint (dim_vector (-1, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3153 dataaspectratio.add_constraint (dim_vector (1, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3154 plotboxaspectratio.add_constraint (dim_vector (1, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3155 xlim.add_constraint (2);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3156 ylim.add_constraint (2);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3157 zlim.add_constraint (2);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3158 clim.add_constraint (2);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3159 alim.add_constraint (2);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3160 xtick.add_constraint (dim_vector (1, -1));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3161 ytick.add_constraint (dim_vector (1, -1));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3162 ztick.add_constraint (dim_vector (1, -1));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3163 Matrix vw (1, 2, 0);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3164 vw(1) = 90;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3165 view = vw;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3166 view.add_constraint (dim_vector (1, 2));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3167 cameraposition.add_constraint (dim_vector (1, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3168 Matrix upv (1, 3, 0.0);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3169 upv(2) = 1.0;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3170 cameraupvector = upv;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3171 cameraupvector.add_constraint (dim_vector (1, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3172 currentpoint.add_constraint (dim_vector (2, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3173 ticklength.add_constraint (dim_vector (1, 2));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3174 tightinset.add_constraint (dim_vector (1, 4));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3175
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3176 x_zlim.resize (1, 2);
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3177
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3178 sx = "linear";
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3179 sy = "linear";
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3180 sz = "linear";
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3181
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3182 calc_ticklabels (xtick, xticklabel, xscale.is ("log"));
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3183 calc_ticklabels (ytick, yticklabel, yscale.is ("log"));
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3184 calc_ticklabels (ztick, zticklabel, zscale.is ("log"));
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3185
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3186 xset (xlabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3187 xset (ylabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3188 xset (zlabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3189 xset (title.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3190
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3191 xset (xlabel.handle_value (), "horizontalalignment", "center");
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3192 xset (ylabel.handle_value (), "horizontalalignment", "center");
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3193 xset (zlabel.handle_value (), "horizontalalignment", "right");
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3194 xset (title.handle_value (), "horizontalalignment", "center");
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3195
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3196 xset (xlabel.handle_value (), "verticalalignment", "cap");
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3197 xset (ylabel.handle_value (), "verticalalignment", "bottom");
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3198 xset (title.handle_value (), "verticalalignment", "bottom");
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3199
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3200 xset (ylabel.handle_value (), "rotation", 90.0);
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3201 xset (zlabel.handle_value (), "visible", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3202
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3203 xset (xlabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3204 xset (ylabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3205 xset (zlabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3206 xset (title.handle_value (), "clipping", "off");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3207
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3208 adopt (xlabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3209 adopt (ylabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3210 adopt (zlabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3211 adopt (title.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3212 }
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3213
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
3214 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
3215 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
3216 {
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3217 #if 0
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
3218 // FIXME -- this should take font metrics into consideration,
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3219 // and also the fact that the colorbox leaves the outerposition
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3220 // alone but alters the position. For now just don't adjust the
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3221 // positions relative to each other.
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3222
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
3223 if (activepositionproperty.is ("outerposition"))
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3224 {
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3225 Matrix outpos = outerposition.get ().matrix_value ();
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3226 Matrix defpos = default_axes_position ();
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3227 Matrix pos(outpos);
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3228 pos(0) = outpos(0) + defpos(0) * outpos(2);
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3229 pos(1) = outpos(1) + defpos(1) * outpos(3);
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3230 pos(2) = outpos(2) * defpos(2);
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3231 pos(3) = outpos(3) * defpos(3);
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3232 position = pos;
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3233 }
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3234 else
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3235 {
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3236 Matrix pos = position.get ().matrix_value ();
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3237 pos(0) -= pos(2)*0.05;
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3238 pos(1) -= pos(3)*0.05;
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3239 pos(2) *= 1.1;
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3240 pos(3) *= 1.1;
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3241 outerposition = pos;
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3242 }
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3243 #endif
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
3244
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3245 update_transform ();
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3246 }
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3247
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3248 void
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3249 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
3250 const std::string& who,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3251 const octave_value& v)
6962
9ac23c7f1c37 [project @ 2007-10-05 20:52:19 by jwe]
jwe
parents: 6945
diff changeset
3252 {
10265
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3253 graphics_handle val;
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3254
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3255 if (v.is_string ())
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3256 {
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3257 val = gh_manager::make_graphics_handle ("text", __myhandle__, false);
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3258
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3259 xset (val, "string", v);
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3260 }
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3261 else
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3262 {
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3263 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
3264
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3265 if (go.isa ("text"))
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3266 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
3267 else
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3268 {
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3269 std::string cname = v.class_name ();
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3270
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3271 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
3272 who.c_str (), cname.c_str ());
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3273 }
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3274 }
6962
9ac23c7f1c37 [project @ 2007-10-05 20:52:19 by jwe]
jwe
parents: 6945
diff changeset
3275
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3276 if (! error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3277 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3278 xset (val, "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3279
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3280 gh_manager::free (hp.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3281
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3282 base_properties::remove_child (hp.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3283
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3284 hp = val;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3285
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3286 adopt (hp.handle_value ());
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3287 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3288 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3289
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3290 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3291 axes::properties::set_xlabel (const octave_value& v)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3292 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3293 set_text_child (xlabel, "xlabel", v);
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3294 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3295
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3296 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3297 axes::properties::set_ylabel (const octave_value& v)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3298 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3299 set_text_child (ylabel, "ylabel", v);
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3300 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3301
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3302 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3303 axes::properties::set_zlabel (const octave_value& v)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3304 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3305 set_text_child (zlabel, "zlabel", v);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3306 }
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3307
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3308 void
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3309 axes::properties::set_title (const octave_value& v)
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3310 {
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3311 set_text_child (title, "title", v);
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3312 }
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 void
6844
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
3315 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
3316 const std::string& mode)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3317 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3318 box = "on";
6962
9ac23c7f1c37 [project @ 2007-10-05 20:52:19 by jwe]
jwe
parents: 6945
diff changeset
3319 colororder = default_colororder ();
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3320 dataaspectratio = Matrix (1, 3, 1.0);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3321 dataaspectratiomode = "auto";
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3322 layer = "bottom";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3323
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3324 Matrix tlim (1, 2, 0.0);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3325 tlim(1) = 1;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3326 xlim = tlim;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3327 ylim = tlim;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3328 zlim = tlim;
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
3329
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
3330 Matrix cl (1, 2, 0);
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
3331 cl(1) = 1;
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
3332 clim = cl;
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
3333
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3334 xlimmode = "auto";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3335 ylimmode = "auto";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3336 zlimmode = "auto";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3337 climmode = "auto";
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3338
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3339 xgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3340 ygrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3341 zgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3342 xminorgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3343 yminorgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3344 zminorgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3345 xtick = Matrix ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3346 ytick = Matrix ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3347 ztick = Matrix ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3348 xtickmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3349 ytickmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3350 ztickmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3351 xticklabel = "";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3352 yticklabel = "";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3353 zticklabel = "";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3354 xticklabelmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3355 yticklabelmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3356 zticklabelmode = "auto";
10565
2880a862b1a8 Make the default axes color none (bug #29060)
David Bateman <dbateman@free.fr>
parents: 10553
diff changeset
3357 color = "none";
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
3358 xcolor = color_values ("black");
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
3359 ycolor = color_values ("black");
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
3360 zcolor = color_values ("black");
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3361 xscale = "linear";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3362 yscale = "linear";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3363 zscale = "linear";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3364 xdir = "normal";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3365 ydir = "normal";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3366 zdir = "normal";
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3367 yaxislocation = "left";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3368 xaxislocation = "bottom";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3369
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3370 // Note: camera properties will be set through update_transform
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3371 camerapositionmode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3372 cameratargetmode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3373 cameraupvectormode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3374 cameraviewanglemode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3375 plotboxaspectratio = Matrix (1, 3, 1.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3376 drawmode = "normal";
7820
cb4838d70ab2 Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7680
diff changeset
3377 gridlinestyle = ":";
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3378 linestyleorder = "-";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3379 linewidth = 0.5;
7820
cb4838d70ab2 Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7680
diff changeset
3380 minorgridlinestyle = ":";
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3381 // Note: plotboxaspectratio will be set through update_aspectratiors
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3382 plotboxaspectratiomode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3383 projection = "orthographic";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3384 tickdir = "in";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3385 tickdirmode = "auto";
8740
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
3386 ticklength = default_axes_ticklength ();
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3387 tightinset = Matrix (1, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3388
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3389 sx = "linear";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3390 sy = "linear";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3391 sz = "linear";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3392
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3393 Matrix tview (1, 2, 0.0);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3394 tview(1) = 90;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3395 view = tview;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3396
6765
e6b528a3a2a9 [project @ 2007-06-28 15:25:43 by jwe]
jwe
parents: 6761
diff changeset
3397 visible = "on";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3398 nextplot = "replace";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3399
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3400 if (mode != "replace")
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3401 {
8228
53dbbd331498 Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents: 8209
diff changeset
3402 fontangle = "normal";
8944
cb0e9facc342 make default fontname * instead of Helvetica
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
3403 fontname = OCTAVE_DEFAULT_FONTNAME;
8228
53dbbd331498 Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents: 8209
diff changeset
3404 fontsize = 12;
53dbbd331498 Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents: 8209
diff changeset
3405 fontunits = "points";
53dbbd331498 Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents: 8209
diff changeset
3406 fontweight = "normal";
53dbbd331498 Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents: 8209
diff changeset
3407
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3408 Matrix touterposition (1, 4, 0.0);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3409 touterposition(2) = 1;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3410 touterposition(3) = 1;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3411 outerposition = touterposition;
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
3412
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3413 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
3414
53dbbd331498 Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents: 8209
diff changeset
3415 activepositionproperty = "outerposition";
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3416 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3417
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3418 delete_children ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3419
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3420 children = Matrix ();
6432
5bec61ae1576 [project @ 2007-03-23 02:19:10 by jwe]
jwe
parents: 6425
diff changeset
3421
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3422 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__, false);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3423 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__, false);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3424 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__, false);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3425 title = gh_manager::make_graphics_handle ("text", __myhandle__, false);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3426
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3427 xset (xlabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3428 xset (ylabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3429 xset (zlabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3430 xset (title.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3431
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3432 xset (xlabel.handle_value (), "horizontalalignment", "center");
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3433 xset (ylabel.handle_value (), "horizontalalignment", "center");
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3434 xset (zlabel.handle_value (), "horizontalalignment", "right");
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3435 xset (title.handle_value (), "horizontalalignment", "center");
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3436
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3437 xset (xlabel.handle_value (), "verticalalignment", "cap");
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3438 xset (ylabel.handle_value (), "verticalalignment", "bottom");
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3439 xset (title.handle_value (), "verticalalignment", "bottom");
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3440
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3441 xset (ylabel.handle_value (), "rotation", 90.0);
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3442 xset (zlabel.handle_value (), "visible", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3443
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3444 xset (xlabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3445 xset (ylabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3446 xset (zlabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3447 xset (title.handle_value (), "clipping", "off");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3448
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3449 adopt (xlabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3450 adopt (ylabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3451 adopt (zlabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3452 adopt (title.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3453
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3454 update_transform ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3455
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3456 override_defaults (obj);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3457 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3458
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3459 void
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3460 axes::properties::delete_text_child (handle_property& hp)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3461 {
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3462 graphics_handle h = hp.handle_value ();
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3463
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3464 if (h.ok ())
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3465 {
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3466 graphics_object go = gh_manager::get_object (h);
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3467
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3468 if (go.valid_object ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3469 gh_manager::free (h);
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3470
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3471 base_properties::remove_child (h);
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3472 }
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3473
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3474 // FIXME -- is it necessary to check whether the axes object is
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3475 // 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
3476 // 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
3477 // object is deleted.
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3478
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3479 if (! is_beingdeleted ())
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3480 {
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3481 hp = gh_manager::make_graphics_handle ("text", __myhandle__, false);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3482
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3483 xset (hp.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3484
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3485 adopt (hp.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3486 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3487 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3488
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3489 void
6844
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
3490 axes::properties::remove_child (const graphics_handle& h)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3491 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3492 if (xlabel.handle_value ().ok () && h == xlabel.handle_value ())
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3493 delete_text_child (xlabel);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3494 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
3495 delete_text_child (ylabel);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3496 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
3497 delete_text_child (zlabel);
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3498 else if (title.handle_value ().ok () && h == title.handle_value ())
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3499 delete_text_child (title);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3500 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3501 base_properties::remove_child (h);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3502 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3503
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3504 Matrix
10289
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3505 base_properties::get_children_internal (bool return_hidden) const
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3506 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3507 Matrix retval = children;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3508
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3509 graphics_object go = gh_manager::get_object (0);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3510
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3511 root_figure::properties& props =
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3512 dynamic_cast<root_figure::properties&> (go.get_properties ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3513
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3514 if (! props.is_showhiddenhandles ())
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3515 {
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3516 octave_idx_type k = 0;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3517
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3518 for (octave_idx_type i = 0; i < children.numel (); i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3519 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3520 graphics_handle kid = children (i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3521
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3522 if (gh_manager::is_handle_visible (kid))
10289
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3523 {
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3524 if (! return_hidden)
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3525 retval(k++) = children(i);
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3526 }
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3527 else
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3528 {
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3529 if (return_hidden)
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3530 retval(k++) = children(i);
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3531 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3532 }
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3533
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3534 retval.resize (k, 1);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3535 }
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3536
10289
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3537 return retval;
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3538 }
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3539
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3540 Matrix
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3541 base_properties::get_children (void) const
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3542 {
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3543 return get_children_internal (false);
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3544 }
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3545
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3546 Matrix
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3547 base_properties::get_hidden_children (void) const
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3548 {
4b124317dc38 base_properties::set_children: account for hidden children
John W. Eaton <jwe@octave.org>
parents: 10265
diff changeset
3549 return get_children_internal (true);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3550 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3551
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3552 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3553 xform_matrix (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3554 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3555 Matrix m (4, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3556 for (int i = 0; i < 4; i++)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3557 m(i,i) = 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3558 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3559 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3560
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3561 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3562 xform_vector (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3563 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3564 ColumnVector v (4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3565 v(3) = 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3566 return v;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3567 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3568
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3569 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3570 xform_vector (double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3571 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3572 ColumnVector v (4, 1.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3573 v(0) = x; v(1) = y; v(2) = z;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3574 return v;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3575 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3576
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3577 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3578 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
3579 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3580 return (m * xform_vector (x, y, z));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3581 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3582
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3583 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3584 xform_scale (double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3585 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3586 Matrix m (4, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3587 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
3588 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3589 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3590
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3591 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3592 xform_translate (double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3593 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3594 Matrix m = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3595 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
3596 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3597 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3598
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3599 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3600 scale (Matrix& m, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3601 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3602 m = m * xform_scale (x, y, z);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3603 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3604
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3605 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3606 translate (Matrix& m, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3607 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3608 m = m * xform_translate (x, y, z);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3609 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3610
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3611 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3612 xform (ColumnVector& v, const Matrix& m)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3613 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3614 v = m*v;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3615 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3616
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3617 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3618 scale (ColumnVector& v, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3619 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3620 v(0) *= x;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3621 v(1) *= y;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3622 v(2) *= z;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3623 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3624
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3625 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3626 translate (ColumnVector& v, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3627 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3628 v(0) += x;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3629 v(1) += y;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3630 v(2) += z;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3631 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3632
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3633 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3634 normalize (ColumnVector& v)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3635 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3636 double fact = 1.0/sqrt(v(0)*v(0)+v(1)*v(1)+v(2)*v(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3637 scale (v, fact, fact, fact);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3638 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3639
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3640 inline double
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3641 dot (const ColumnVector& v1, const ColumnVector& v2)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3642 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3643 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
3644 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3645
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3646 inline double
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3647 norm (const ColumnVector& v)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3648 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3649 return sqrt (dot (v, v));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3650 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3651
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3652 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3653 cross (const ColumnVector& v1, const ColumnVector& v2)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3654 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3655 ColumnVector r = xform_vector ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3656 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
3657 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
3658 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
3659 return r;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3660 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3661
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3662 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3663 unit_cube (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3664 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3665 static double data[32] = {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3666 0,0,0,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3667 1,0,0,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3668 0,1,0,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3669 0,0,1,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3670 1,1,0,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3671 1,0,1,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3672 0,1,1,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3673 1,1,1,1};
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3674 Matrix m (4, 8);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3675 memcpy (m.fortran_vec (), data, sizeof(double)*32);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3676 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3677 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3678
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3679 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3680 cam2xform (const Array<double>& m)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3681 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3682 ColumnVector retval (4, 1.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3683 memcpy (retval.fortran_vec (), m.fortran_vec (), sizeof(double)*3);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3684 return retval;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3685 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3686
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3687 inline RowVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3688 xform2cam (const ColumnVector& v)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3689 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3690 return v.extract_n (0, 3).transpose ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3691 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3692
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3693 void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3694 axes::properties::update_camera (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3695 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3696 double xd = (xdir_is ("normal") ? 1 : -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3697 double yd = (ydir_is ("normal") ? 1 : -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3698 double zd = (zdir_is ("normal") ? 1 : -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3699
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
3700 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
3701 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
3702 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
3703
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
3704 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
3705 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
3706 double zo = zlimits(zd > 0 ? 0 : 1);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3707
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3708 Matrix pb = get_plotboxaspectratio ().matrix_value ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3709
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3710 bool autocam = (camerapositionmode_is ("auto")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3711 && cameratargetmode_is ("auto")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3712 && cameraupvectormode_is ("auto")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3713 && cameraviewanglemode_is ("auto"));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3714 bool dowarp = (autocam && dataaspectratiomode_is("auto")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3715 && plotboxaspectratiomode_is ("auto"));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3716
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3717 ColumnVector c_eye (xform_vector ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3718 ColumnVector c_center (xform_vector ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3719 ColumnVector c_upv (xform_vector ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3720
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3721 if (cameratargetmode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3722 {
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
3723 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
3724 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
3725 c_center(2) = (zlimits(0)+zlimits(1))/2;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3726
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3727 cameratarget = xform2cam (c_center);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3728 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3729 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3730 c_center = cam2xform (get_cameratarget ().matrix_value ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3731
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3732 if (camerapositionmode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3733 {
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
3734 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
3735 double az = tview(0), el = tview(1);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3736 double d = 5*sqrt(pb(0)*pb(0)+pb(1)*pb(1)+pb(2)*pb(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3737
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3738 if (el == 90 || el == -90)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3739 c_eye(2) = d*signum(el);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3740 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3741 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3742 az *= M_PI/180.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3743 el *= M_PI/180.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3744 c_eye(0) = d*cos(el)*sin(az);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3745 c_eye(1) = -d*cos(el)*cos(az);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3746 c_eye(2) = d*sin(el);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3747 }
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
3748 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
3749 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
3750 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
3751
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3752 cameraposition = xform2cam (c_eye);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3753 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3754 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3755 c_eye = cam2xform (get_cameraposition ().matrix_value ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3756
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3757 if (cameraupvectormode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3758 {
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
3759 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
3760 double az = tview(0), el = tview(1);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3761
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3762 if (el == 90 || el == -90)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3763 {
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
3764 c_upv(0) =
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
3765 -signum(el)*sin(az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0);
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
3766 c_upv(1) =
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
3767 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
3768 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3769 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3770 c_upv(2) = 1;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3771
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3772 cameraupvector = xform2cam (c_upv);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3773 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3774 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3775 c_upv = cam2xform (get_cameraupvector ().matrix_value ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3776
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3777 Matrix x_view = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3778 Matrix x_projection = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3779 Matrix x_viewport = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3780 Matrix x_normrender = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3781 Matrix x_pre = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3782
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3783 x_render = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3784 x_render_inv = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3785
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3786 scale (x_pre, pb(0), pb(1), pb(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3787 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
3788 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
3789 zd/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3790 translate (x_pre, -xo, -yo, -zo);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3791
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3792 xform (c_eye, x_pre);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3793 xform (c_center, x_pre);
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
3794 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
3795 pb(2)/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3796 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
3797
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3798 ColumnVector F (c_center), f (F), UP (c_upv);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3799 normalize (f);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3800 normalize (UP);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3801
7440
4e3b073e910e [project @ 2008-02-02 18:23:50 by jwe]
jwe
parents: 7435
diff changeset
3802 if (std::abs (dot (f, UP)) > 1e-15)
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3803 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3804 double fa = 1/sqrt(1-f(2)*f(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3805 scale (UP, fa, fa, fa);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3806 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3807
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3808 ColumnVector s = cross (f, UP);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3809 ColumnVector u = cross (s, f);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3810
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3811 scale (x_view, 1, 1, -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3812 Matrix l = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3813 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
3814 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
3815 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
3816 x_view = x_view * l;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3817 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
3818 scale (x_view, pb(0), pb(1), pb(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3819 translate (x_view, -0.5, -0.5, -0.5);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3820
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3821 Matrix x_cube = x_view * unit_cube ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3822 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
3823 double xM = cmax(0)-cmin(0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3824 double yM = cmax(1)-cmin(1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3825
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
3826 Matrix bb = get_boundingbox (true);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3827
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3828 double v_angle;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3829
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3830 if (cameraviewanglemode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3831 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3832 double af;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3833
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8299
diff changeset
3834 // 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
3835 // does not seem to be required. Need investigation with concrete
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3836 // backend to see results visually.
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3837 if (false && dowarp)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3838 af = 1.0 / (xM > yM ? xM : yM);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3839 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3840 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3841 if ((bb(2)/bb(3)) > (xM/yM))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3842 af = 1.0 / yM;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3843 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3844 af = 1.0 / xM;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3845 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3846 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
3847
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3848 cameraviewangle = v_angle;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3849 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3850 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3851 v_angle = get_cameraviewangle ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3852
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3853 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
3854 scale (x_projection, pf, pf, 1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3855
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3856 if (dowarp)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3857 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3858 xM *= pf;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3859 yM *= pf;
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
3860 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
3861 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
3862 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3863 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3864 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3865 double pix = 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3866 if (autocam)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3867 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3868 if ((bb(2)/bb(3)) > (xM/yM))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3869 pix = bb(3);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3870 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3871 pix = bb(2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3872 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3873 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3874 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
3875 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
3876 scale (x_viewport, pix, -pix, 1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3877 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3878
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3879 x_normrender = x_viewport * x_projection * x_view;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3880
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3881 x_cube = x_normrender * unit_cube ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3882 cmin = x_cube.row_min ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3883 cmax = x_cube.row_max ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3884 x_zlim.resize (1, 2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3885 x_zlim(0) = cmin(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3886 x_zlim(1) = cmax(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3887
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3888 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
3889 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
3890 zd/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3891 translate (x_render, -xo, -yo, -zo);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3892
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3893 x_viewtransform = x_view;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3894 x_projectiontransform = x_projection;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3895 x_viewporttransform = x_viewport;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3896 x_normrendertransform = x_normrender;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3897 x_rendertransform = x_render;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3898
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3899 x_render_inv = x_render.inverse ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3900
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3901 // 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
3902 // 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
3903 // => x_gl_mat2)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3904 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
3905 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
3906 zd/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3907 translate (x_gl_mat1, -xo, -yo, -zo);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3908 x_gl_mat2 = x_viewport * x_projection;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3909 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3910
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3911 void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3912 axes::properties::update_aspectratios (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3913 {
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
3914 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
3915 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
3916 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
3917
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
3918 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
3919 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
3920 double dz = (zlimits(1)-zlimits(0));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3921
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3922 if (dataaspectratiomode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3923 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3924 double dmin = xmin (xmin (dx, dy), dz);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3925 Matrix da (1, 3, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3926
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3927 da(0) = dx/dmin;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3928 da(1) = dy/dmin;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3929 da(2) = dz/dmin;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3930
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3931 dataaspectratio = da;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3932 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3933
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3934 if (plotboxaspectratiomode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3935 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3936 if (dataaspectratiomode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3937 plotboxaspectratio = Matrix (1, 3, 1.0);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3938 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3939 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3940 Matrix da = get_dataaspectratio ().matrix_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3941 Matrix pba (1, 3, 0.0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3942
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3943 pba(0) = dx/da(0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3944 pba(1) = dy/da(1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3945 pba(2) = dz/da(2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3946 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3947 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3948
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8299
diff changeset
3949 // FIXME -- if plotboxaspectratiomode is "manual", limits
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8299
diff changeset
3950 // and/or dataaspectratio might be adapted.
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3951 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3952
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
3953 // 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
3954
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3955 Matrix
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
3956 axes::properties::get_boundingbox (bool internal) const
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3957 {
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
3958 graphics_object obj = gh_manager::get_object (get_parent ());
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
3959 Matrix parent_bb = obj.get_properties ().get_boundingbox (true);
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
3960 Matrix pos = (internal ?
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3961 get_position ().matrix_value ()
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3962 : get_outerposition ().matrix_value ());
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
3963
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
3964
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
3965 pos = convert_position (pos, get_units (), "pixels",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3966 parent_bb.extract_n (0, 2, 1, 2));
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
3967
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3968 pos(0)--;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3969 pos(1)--;
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
3970 pos(1) = parent_bb(3) - pos(1) - pos(3);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3971
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3972 return pos;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3973 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3974
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
3975 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
3976 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
3977 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3978 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
3979 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3980 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
3981 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
3982 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3983 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
3984 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
3985 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3986 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3987 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3988
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3989 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
3990 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
3991 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3992 graphics_object obj = gh_manager::get_object (get_parent ());
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3993 Matrix parent_bb = obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3994 caseless_str new_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
3995 set_position (octave_value (convert_position (get_position().matrix_value(), old_units, new_units, parent_bb)));
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3996 set_outerposition (octave_value (convert_position (get_outerposition().matrix_value(), old_units, new_units, parent_bb)));
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3997 set_tightinset (octave_value (convert_position (get_tightinset().matrix_value(), old_units, new_units, parent_bb)));
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3998 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3999
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4000 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
4001 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
4002 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4003 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
4004 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4005 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
4006 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
4007 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4008 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
4009 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
4010 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4011 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4012 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4013
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4014 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
4015 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
4016 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4017 caseless_str new_units = 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
4018 double fsz = get_fontsize ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4019 double pixelsperinch = xget (0, "screenpixelsperinch").double_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
4020 double parent_height = get_boundingbox (true).elem (3);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4021
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4022 if (old_units.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
4023 fsz = fsz * parent_height * 72 / pixelsperinch;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4024 else if (old_units.compare ("pixels"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4025 fsz = fsz * 72 / pixelsperinch;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4026 else if (old_units.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
4027 fsz = fsz * 72;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4028 else if (old_units.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
4029 fsz = fsz * 72 / 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
4030
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4031 if (new_units.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
4032 fsz = fsz * pixelsperinch / parent_height / 72;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4033 else if (new_units.compare ("pixels"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4034 fsz = fsz * pixelsperinch / 72;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4035 else if (new_units.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
4036 fsz = fsz / 72;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4037 else if (new_units.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
4038 fsz = fsz * 2.54 / 72;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4039
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4040 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
4041 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4042
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4043 ColumnVector
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4044 graphics_xform::xform_vector (double x, double y, double z)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
4045 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
4046 return ::xform_vector (x, y, z);
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
4047 }
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4048
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4049 Matrix
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4050 graphics_xform::xform_eye (void)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
4051 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
4052 return ::xform_matrix ();
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
4053 }
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4054
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4055 ColumnVector
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4056 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
4057 bool use_scale) const
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4058 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4059 if (use_scale)
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4060 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4061 x = sx.scale (x);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4062 y = sy.scale (y);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4063 z = sz.scale (z);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4064 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4065
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4066 return ::transform (xform, x, y, z);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4067 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4068
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4069 ColumnVector
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4070 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
4071 bool use_scale) const
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4072 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4073 ColumnVector v = ::transform (xform_inv, x, y, z);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4074
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4075 if (use_scale)
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4076 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4077 v(0) = sx.unscale (v(0));
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4078 v(1) = sy.unscale (v(1));
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4079 v(2) = sz.unscale (v(2));
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4080 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4081
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4082 return v;
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4083 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
4084
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4085 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
4086 axes::get_default (const caseless_str& name) const
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4087 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4088 octave_value retval = default_properties.lookup (name);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4089
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4090 if (retval.is_undefined ())
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4091 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4092 graphics_handle parent = get_parent ();
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4093 graphics_object parent_obj = gh_manager::get_object (parent);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4094
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4095 retval = parent_obj.get_default (name);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4096 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4097
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4098 return retval;
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4099 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4100
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8299
diff changeset
4101 // FIXME -- remove.
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8299
diff changeset
4102 // 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
4103 /*
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
4104 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
4105 check_limit_vals (double& min_val, double& max_val, double& min_pos,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4106 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
4107 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
4108 double val = data.min_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
4109 if (! (xisinf (val) || xisnan (val)) && val < min_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
4110 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
4111 val = data.max_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
4112 if (! (xisinf (val) || xisnan (val)) && val > max_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
4113 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
4114 val = data.min_pos ();
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
4115 if (! (xisinf (val) || xisnan (val)) && val > 0 && val < min_pos)
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
4116 min_pos = 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
4117 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4118 */
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4119
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4120 static void
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4121 check_limit_vals (double& min_val, double& max_val, double& min_pos,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4122 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
4123 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4124 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
4125 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4126 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
4127
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4128 if (! error_state && m.numel () == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4129 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4130 double val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4131
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4132 val = m(0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4133 if (! (xisinf (val) || xisnan (val)) && val < min_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4134 min_val = val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4135
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4136 val = m(1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4137 if (! (xisinf (val) || xisnan (val)) && val > max_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4138 max_val = val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4139
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4140 val = m(2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4141 if (! (xisinf (val) || xisnan (val)) && val > 0 && val < min_pos)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4142 min_pos = val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4143 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4144 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4145 }
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
4146
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4147 // magform(x) Returns (a, b), where x = a * 10^b, a >= 1., and b is
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4148 // integral.
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4149
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
4150 static void
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
4151 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
4152 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4153 if (x == 0)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4154 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4155 a = 0;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4156 b = 0;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4157 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4158 else
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4159 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4160 double l = std::log10 (std::abs (x));
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4161 double r = std::fmod (l, 1.);
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4162 a = std::pow (10.0, r);
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4163 b = static_cast<int> (l-r);
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4164 if (a < 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4165 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4166 a *= 10;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4167 b -= 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4168 }
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4169
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4170 if (x < 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4171 a = -a;
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4172 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4173 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4174
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4175 // 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
4176 // http://kurage.nimh.nih.gov/tomh/tics.py
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4177 // FIXME -- add log ticks
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4178
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4179 double
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4180 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
4181 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4182 int ticint = 5;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4183
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4184 // 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
4185 // 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
4186 // 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
4187 // 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
4188
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4189 double a;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4190 int b, x;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4191
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4192 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
4193
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4194 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
4195 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
4196 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
4197
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4198 if (a < sqrt_2)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4199 x = 1;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4200 else if (a < sqrt_10)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4201 x = 2;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4202 else if (a < sqrt_50)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4203 x = 5;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4204 else
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4205 x = 10;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4206
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4207 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
4208
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4209 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4210
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4211 // 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
4212 // 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
4213 // value.
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4214
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4215 Matrix
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
4216 axes::properties::get_axis_limits (double xmin, double xmax,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4217 double min_pos, bool logscale)
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4218 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4219 Matrix retval;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4220
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4221 double min_val = xmin;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4222 double max_val = xmax;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4223
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4224 if (! (xisinf (min_val) || xisinf (max_val)))
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4225 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4226 if (logscale)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4227 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4228 if (xisinf (min_pos))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4229 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4230 // warning ("axis: logscale with no positive values to plot");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4231 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4232 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4233
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4234 if (min_val <= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4235 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4236 warning ("axis: omitting nonpositive data in log plot");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4237 min_val = min_pos;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4238 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4239 // FIXME -- maybe this test should also be relative?
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4240 if (std::abs (min_val - max_val) < sqrt (DBL_EPSILON))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4241 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4242 min_val *= 0.9;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4243 max_val *= 1.1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4244 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4245 min_val = pow (10, floor (log10 (min_val)));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4246 max_val = pow (10, ceil (log10 (max_val)));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4247 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4248 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4249 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4250 if (min_val == 0 && max_val == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4251 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4252 min_val = -1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4253 max_val = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4254 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4255 // FIXME -- maybe this test should also be relative?
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4256 else if (std::abs (min_val - max_val) < sqrt (DBL_EPSILON))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4257 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4258 min_val -= 0.1 * std::abs (min_val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4259 max_val += 0.1 * std::abs (max_val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4260 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4261
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4262 double tick_sep = calc_tick_sep (min_val , max_val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4263 min_val = tick_sep * std::floor (min_val / tick_sep);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4264 max_val = tick_sep * ceil (max_val / tick_sep);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4265 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4266 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4267
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4268 retval.resize (1, 2);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4269
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4270 retval(0) = min_val;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4271 retval(1) = max_val;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4272
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4273 return retval;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4274 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4275
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
4276 void
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
4277 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
4278 array_property& ticks,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4279 bool limmode_is_auto, bool is_logscale)
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
4280 {
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4281 // FIXME -- add log ticks and lims
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
4282
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
4283 if (lims.get ().is_empty ())
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
4284 return;
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
4285
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
4286 double lo = (lims.get ().matrix_value ()) (0);
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
4287 double hi = (lims.get ().matrix_value ()) (1);
7843
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
4288 // FIXME should this be checked for somewhere else? (i.e. set{x,y,z}lim)
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
4289 if (hi < lo)
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
4290 {
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
4291 double tmp = hi;
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
4292 hi = lo;
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
4293 lo = tmp;
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
4294 }
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
4295
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
4296 if (is_logscale)
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
4297 {
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
4298 // FIXME we should check for negtives here
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
4299 hi = std::log10 (hi);
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
4300 lo = std::log10 (lo);
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
4301 }
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
4302
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4303 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
4304
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4305 int i1 = static_cast<int> (std::floor (lo / tick_sep));
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4306 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
4307
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4308 if (limmode_is_auto)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4309 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4310 // 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
4311 Matrix tmp_lims (1,2);
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4312 tmp_lims(0) = tick_sep * i1;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4313 tmp_lims(1) = tick_sep * i2;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4314
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
4315 if (is_logscale)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4316 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4317 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
4318 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
4319 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
4320 tmp_lims(0) = std::pow (10., lo);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4321 }
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4322 lims = tmp_lims;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4323 }
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
4324 else
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4325 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4326 // adjust min and max tics if they are out of limits
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4327 i1 = static_cast<int> (std::ceil (lo / tick_sep));
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4328 i2 = static_cast<int> (std::floor (hi / tick_sep));
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4329 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4330
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4331 Matrix tmp_ticks (1, i2-i1+1);
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
4332 for (int i = 0; i <= i2-i1; i++)
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
4333 {
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
4334 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
4335 if (is_logscale)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4336 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
4337 }
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4338
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
4339 ticks = tmp_ticks;
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
4340 }
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
4341
9347
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
4342 void
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
4343 axes::properties::calc_ticklabels (const array_property& ticks,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4344 any_property& labels, bool /*logscale*/)
9347
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
4345 {
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
4346 Matrix values = ticks.get ().matrix_value ();
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
4347 Cell c (values.dims ());
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
4348 std::ostringstream os;
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
4349
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
4350 for (int i = 0; i < values.numel (); i++)
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
4351 {
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
4352 os.str (std::string ());
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
4353 os << values(i);
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
4354 c(i) = os.str ();
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
4355 }
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
4356
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
4357 labels = c;
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
4358 }
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
4359
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4360 void
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4361 get_children_limits (double& min_val, double& max_val, double& min_pos,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4362 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
4363 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4364 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
4365
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4366 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
4367 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4368 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
4369 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
4370 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4371 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
4372
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4373 if (obj.is_xliminclude ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4374 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4375 octave_value lim = obj.get_xlim ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4376
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4377 check_limit_vals (min_val, max_val, min_pos, lim);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4378 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4379 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4380 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4381
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4382 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
4383 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
4384 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4385 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
4386
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4387 if (obj.is_yliminclude ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4388 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4389 octave_value lim = obj.get_ylim ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4390
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4391 check_limit_vals (min_val, max_val, min_pos, lim);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4392 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4393 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4394 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4395
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4396 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
4397 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
4398 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4399 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
4400
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4401 if (obj.is_zliminclude ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4402 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4403 octave_value lim = obj.get_zlim ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4404
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4405 check_limit_vals (min_val, max_val, min_pos, lim);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4406 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4407 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4408 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4409
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4410 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
4411 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
4412 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4413 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
4414
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4415 if (obj.is_climinclude ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4416 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4417 octave_value lim = obj.get_clim ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4418
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4419 check_limit_vals (min_val, max_val, min_pos, lim);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4420 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4421 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4422 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4423
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4424 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
4425 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
4426 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4427 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
4428
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4429 if (obj.is_aliminclude ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4430 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4431 octave_value lim = obj.get_alim ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4432
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4433 check_limit_vals (min_val, max_val, min_pos, lim);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4434 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4435 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4436 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4437
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4438 default:
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4439 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4440 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4441 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4442
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4443 static bool updating_axis_limits = false;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4444
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
4445 void
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4446 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
4447 {
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4448 if (updating_axis_limits)
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4449 return;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4450
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4451 Matrix kids = xproperties.get_children ();
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4452
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4453 double min_val = octave_Inf;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4454 double max_val = -octave_Inf;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4455 double min_pos = octave_Inf;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4456
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4457 char update_type = 0;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4458
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4459 Matrix limits;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4460
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4461 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
4462 || 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
4463 || axis_type == "xlim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4464 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4465 if (xproperties.xlimmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4466 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4467 get_children_limits (min_val, max_val, min_pos, kids, 'x');
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4468
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4469 limits = xproperties.get_axis_limits (min_val, max_val, min_pos,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4470 xproperties.xscale_is ("log"));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4471
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4472 update_type = 'x';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4473 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4474 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4475 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
4476 || axis_type == "ylimmode" || axis_type == "yliminclude"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4477 || axis_type == "ylim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4478 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4479 if (xproperties.ylimmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4480 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4481 get_children_limits (min_val, max_val, min_pos, kids, 'y');
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4482
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4483 limits = xproperties.get_axis_limits (min_val, max_val, min_pos,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4484 xproperties.yscale_is ("log"));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4485
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4486 update_type = 'y';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4487 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4488 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4489 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
4490 || axis_type == "zlimmode" || axis_type == "zliminclude"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4491 || axis_type == "zlim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4492 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4493 if (xproperties.zlimmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4494 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4495 get_children_limits (min_val, max_val, min_pos, kids, 'z');
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4496
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4497 limits = xproperties.get_axis_limits (min_val, max_val, min_pos,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4498 xproperties.zscale_is ("log"));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4499
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4500 update_type = 'z';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4501 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4502 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4503 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
4504 || axis_type == "cdatamapping" || axis_type == "climinclude"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4505 || axis_type == "clim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4506 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4507 if (xproperties.climmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4508 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4509 get_children_limits (min_val, max_val, min_pos, kids, 'c');
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4510
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4511 if (min_val > max_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4512 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4513 min_val = min_pos = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4514 max_val = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4515 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4516 else if (min_val == max_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4517 max_val = min_val + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4518
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4519 limits.resize (1, 2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4520
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4521 limits(0) = min_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4522 limits(1) = max_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4523
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4524 update_type = 'c';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4525 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4526
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4527 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4528 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
4529 || axis_type == "alphadatamapping" || axis_type == "aliminclude"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4530 || 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
4531 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4532 if (xproperties.alimmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4533 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4534 get_children_limits (min_val, max_val, min_pos, kids, 'a');
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4535
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4536 if (min_val > max_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4537 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4538 min_val = min_pos = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4539 max_val = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4540 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4541 else if (min_val == max_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4542 max_val = min_val + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4543
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4544 limits.resize (1, 2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4545
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4546 limits(0) = min_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4547 limits(1) = max_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4548
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4549 update_type = 'a';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4550 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4551
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4552 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4553
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
4554 unwind_protect frame;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
4555 frame.protect_var (updating_axis_limits);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
4556
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4557 updating_axis_limits = true;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4558
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4559 switch (update_type)
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4560 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4561 case 'x':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4562 xproperties.set_xlim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4563 xproperties.set_xlimmode ("auto");
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
4564 xproperties.update_xlim ();
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4565 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4566
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4567 case 'y':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4568 xproperties.set_ylim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4569 xproperties.set_ylimmode ("auto");
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
4570 xproperties.update_ylim ();
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4571 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4572
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4573 case 'z':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4574 xproperties.set_zlim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4575 xproperties.set_zlimmode ("auto");
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
4576 xproperties.update_zlim ();
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4577 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4578
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4579 case 'c':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4580 xproperties.set_clim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4581 xproperties.set_climmode ("auto");
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4582 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4583
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4584 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
4585 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
4586 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
4587 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4588
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4589 default:
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4590 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4591 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
4592
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4593 xproperties.update_transform ();
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
4594 }
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
4595
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4596 inline
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4597 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
4598 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4599 if (x < lower)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4600 { return lower; }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4601 else if (x > upper)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4602 { return upper; }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4603 else
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4604 { return x; }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4605 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4606
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4607 void
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4608 axes::properties::zoom_about_point (double x, double y, double factor,
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4609 bool push_to_zoom_stack)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4610 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4611 // FIXME: Do we need error checking here?
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4612 Matrix xlims = get_xlim ().matrix_value ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4613 Matrix ylims = get_ylim ().matrix_value ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4614
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4615 // Get children axes limits
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4616 Matrix kids = get_children ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4617 double minx = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4618 double maxx = -octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4619 double min_pos_x = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4620 get_children_limits (minx, maxx, min_pos_x, kids, 'x');
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4621
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4622 double miny = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4623 double maxy = -octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4624 double min_pos_y = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4625 get_children_limits (miny, maxy, min_pos_y, kids, 'y');
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4626
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4627 // Perform the zooming
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4628 xlims (0) = x + factor * (xlims (0) - x);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4629 xlims (1) = x + factor * (xlims (1) - x);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4630 ylims (0) = y + factor * (ylims (0) - y);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4631 ylims (1) = y + factor * (ylims (1) - y);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4632
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4633 zoom (xlims, ylims, push_to_zoom_stack);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4634 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4635
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4636 void
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4637 axes::properties::zoom (const Matrix& xl, const Matrix& yl, bool push_to_zoom_stack)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4638 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4639 if (push_to_zoom_stack)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4640 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4641 zoom_stack.push_front (xlimmode.get ());
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4642 zoom_stack.push_front (xlim.get ());
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4643 zoom_stack.push_front (ylimmode.get ());
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4644 zoom_stack.push_front (ylim.get ());
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4645 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4646
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4647 xlim = xl;
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4648 xlimmode = "manual";
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4649 ylim = yl;
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4650 ylimmode = "manual";
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4651
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4652 update_transform ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4653 update_xlim (false);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4654 update_ylim (false);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4655 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4656
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4657 void
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4658 axes::properties::translate_view (double delta_x, double delta_y)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4659 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4660 // FIXME: Do we need error checking here?
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4661 Matrix xlims = get_xlim ().matrix_value ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4662 Matrix ylims = get_ylim ().matrix_value ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4663
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4664 // Get children axes limits
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4665 Matrix kids = get_children ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4666 double minx = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4667 double maxx = -octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4668 double min_pos_x = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4669 get_children_limits (minx, maxx, min_pos_x, kids, 'x');
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4670
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4671 double miny = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4672 double maxy = -octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4673 double min_pos_y = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4674 get_children_limits (miny, maxy, min_pos_y, kids, 'y');
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4675
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
4676 xlims (0) += delta_x;
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
4677 xlims (1) += delta_x;
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
4678 ylims (0) += delta_y;
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
4679 ylims (1) += delta_y;
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
4680
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4681 zoom (xlims, ylims, false);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4682 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4683
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
4684 void
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
4685 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
4686 {
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
4687 Matrix v = get_view ().matrix_value ();
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
4688
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
4689 v (1) += delta_el;
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
4690
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
4691 if(v(1) > 90)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
4692 v(1) = 90;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
4693 if(v(1) < -90)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
4694 v(1) = -90;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
4695
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
4696 v (0) = fmod(v(0) - delta_az + 720,360);
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
4697
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
4698 set_view(v);
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
4699 update_transform();
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
4700 }
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
4701
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
4702 void
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4703 axes::properties::unzoom (void)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4704 {
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4705 if (zoom_stack.size () >= 4)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4706 {
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4707 ylim = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4708 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4709 ylimmode = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4710 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4711 xlim = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4712 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4713 xlimmode = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4714 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4715
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4716 update_transform ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4717 update_xlim (false);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4718 update_ylim (false);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4719 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4720 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4721
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4722 void
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4723 axes::properties::clear_zoom_stack (void)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4724 {
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4725 while (zoom_stack.size () > 4)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4726 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4727
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4728 unzoom ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4729 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
4730
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
4731 void
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
4732 axes::reset_default_properties (void)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
4733 {
10733
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
4734 ::reset_default_properties (default_properties);
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
4735 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
4736
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4737 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4738
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4739 Matrix
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4740 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
4741 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4742 Matrix m (1, 3);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4743
10596
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
4744 m(0) = xdata.min_val ();
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
4745 m(1) = xdata.max_val ();
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
4746 m(2) = xdata.min_pos ();
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4747
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4748 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
4749 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4750
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4751 Matrix
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4752 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
4753 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4754 Matrix m (1, 3);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4755
10596
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
4756 m(0) = ydata.min_val ();
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
4757 m(1) = ydata.max_val ();
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
4758 m(2) = ydata.min_pos ();
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4759
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
4760 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
4761 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4762
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4763 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4764
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4765 Matrix
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4766 text::properties::get_data_position (void) const
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4767 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4768 Matrix pos = get_position ().matrix_value ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4769
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4770 if (! units_is ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4771 pos = convert_text_position (pos, *this, get_units (), "data");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4772
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4773 return pos;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4774 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4775
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4776 octave_value
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4777 text::properties::get_extent (void) const
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4778 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4779 Matrix m = extent.get ().matrix_value ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4780
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4781 return convert_text_position (m, *this, "pixels", get_units ());
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4782 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4783
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4784 void
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4785 text::properties::update_text_extent (void)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4786 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4787 #ifdef HAVE_FREETYPE
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4788
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4789 text_element *elt;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4790 ft_render text_renderer;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4791 Matrix box;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4792
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4793 // FIXME: parsed content should be cached for efficiency
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4794
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4795 elt = text_parser_none ().parse (get_string ());
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
4796 #ifdef HAVE_FONTCONFIG
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4797 text_renderer.set_font (*this);
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
4798 #endif
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4799 box = text_renderer.get_extent (elt, get_rotation ());
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4800
10553
f88e3d5d88e2 avoid GCC warnings
John W. Eaton <jwe@octave.org>
parents: 10526
diff changeset
4801 Matrix ext (1, 4, 0.0);
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4802
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4803 // FIXME: also handle left and bottom components
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4804
10553
f88e3d5d88e2 avoid GCC warnings
John W. Eaton <jwe@octave.org>
parents: 10526
diff changeset
4805 ext(0) = ext(1) = 1;
f88e3d5d88e2 avoid GCC warnings
John W. Eaton <jwe@octave.org>
parents: 10526
diff changeset
4806 ext(2) = box(0);
f88e3d5d88e2 avoid GCC warnings
John W. Eaton <jwe@octave.org>
parents: 10526
diff changeset
4807 ext(3) = box(1);
f88e3d5d88e2 avoid GCC warnings
John W. Eaton <jwe@octave.org>
parents: 10526
diff changeset
4808
f88e3d5d88e2 avoid GCC warnings
John W. Eaton <jwe@octave.org>
parents: 10526
diff changeset
4809 set_extent (ext);
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4810
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4811 #endif
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4812 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4813
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4814 void
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4815 text::properties::update_units (void)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4816 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4817 if (! units_is ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4818 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4819 set_xliminclude ("off");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4820 set_yliminclude ("off");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4821 set_zliminclude ("off");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4822 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4823
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4824 Matrix pos = get_position ().matrix_value ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4825
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4826 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
4827 // 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
4828 // 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
4829 // to "off".
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4830 set_position (pos);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4831
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4832 if (units_is ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4833 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4834 set_xliminclude ("on");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4835 set_yliminclude ("on");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4836 // FIXME: see above
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4837 set_zliminclude ("off");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4838 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4839
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4840 cached_units = get_units ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4841 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4842
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4843 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4844
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
4845 octave_value
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
4846 image::properties::get_color_data (void) const
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
4847 {
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
4848 return convert_cdata (*this, get_cdata (),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4849 cdatamapping_is ("scaled"), 3);
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
4850 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4851
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4852 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4853
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
4854 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
4855 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
4856 {
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
4857 return convert_cdata (*this, get_facevertexcdata (),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4858 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
4859 }
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
4860
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
4861 // ---------------------------------------------------------------------
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
4862
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4863 octave_value
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4864 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
4865 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4866 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
4867 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4868
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4869 inline void
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4870 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
4871 double x2, double y2, double z2,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4872 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
4873 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4874 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
4875 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
4876 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
4877 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4878
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4879 void
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4880 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
4881 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4882 if (normalmode_is ("auto"))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4883 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4884 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
4885 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
4886 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
4887
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4888
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4889 int p = z.columns (), q = z.rows ();
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4890 int i1 = 0, i2 = 0, i3 = 0;
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4891 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
4892
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4893 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
4894 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
4895
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4896 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
4897
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4898 for (int i = 0; i < p; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4899 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4900 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4901 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4902 i1 = i - 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4903 i2 = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4904 i3 = i + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4905 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4906
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4907 for (int j = 0; j < q; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4908 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4909 if (x_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4910 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4911 j1 = j - 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4912 j2 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4913 j3 = j + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4914 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4915
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4916 double& nx = n(j, i, 0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4917 double& ny = n(j, i, 1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4918 double& nz = n(j, i, 2);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4919
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4920 if ((j > 0) && (i > 0))
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4921 // upper left quadrangle
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4922 cross_product (x(j1,i-1)-x(j2,i), y(j-1,i1)-y(j,i2), z(j-1,i-1)-z(j,i),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4923 x(j2,i-1)-x(j1,i), y(j,i1)-y(j-1,i2), z(j,i-1)-z(j-1,i),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4924 nx, ny, nz);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4925
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4926 if ((j > 0) && (i < (p -1)))
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4927 // upper right quadrangle
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4928 cross_product (x(j1,i+1)-x(j2,i), y(j-1,i3)-y(j,i2), z(j-1,i+1)-z(j,i),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4929 x(j1,i)-x(j2,i+1), y(j-1,i2)-y(j,i3), z(j-1,i)-z(j,i+1),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4930 nx, ny, nz);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4931
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4932 if ((j < (q - 1)) && (i > 0))
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4933 // lower left quadrangle
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4934 cross_product (x(j2,i-1)-x(j3,i), y(j,i1)-y(j+1,i2), z(j,i-1)-z(j+1,i),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4935 x(j3,i-1)-x(j2,i), y(j+1,i1)-y(j,i2), z(j+1,i-1)-z(j,i),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4936 nx, ny, nz);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4937
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4938 if ((j < (q - 1)) && (i < (p -1)))
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4939 // lower right quadrangle
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4940 cross_product (x(j3,i)-x(j2,i+1), y(j+1,i2)-y(j,i3), z(j+1,i)-z(j,i+1),
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4941 x(j3,i+1)-x(j2,i), y(j+1,i3)-y(j,i2), z(j+1,i+1)-z(j,i),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4942 nx, ny, nz);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4943
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
4944 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
4945
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4946 nx /= d;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4947 ny /= d;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4948 nz /= d;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4949 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4950 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4951 vertexnormals = n;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4952 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
4953 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4954
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4955 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4956
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4957 void
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4958 hggroup::update_axis_limits (const std::string& axis_type)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4959 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4960 Matrix kids = xproperties.get_children ();
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4961
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4962 double min_val = octave_Inf;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4963 double max_val = -octave_Inf;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4964 double min_pos = octave_Inf;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4965
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4966 char update_type = 0;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4967
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
4968 if (axis_type == "xlim" || axis_type == "xliminclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4969 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4970 get_children_limits (min_val, max_val, min_pos, kids, 'x');
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4971
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4972 update_type = 'x';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4973 }
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
4974 else if (axis_type == "ylim" || axis_type == "yliminclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4975 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4976 get_children_limits (min_val, max_val, min_pos, kids, 'y');
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4977
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4978 update_type = 'y';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4979 }
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
4980 else if (axis_type == "zlim" || axis_type == "zliminclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4981 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4982 get_children_limits (min_val, max_val, min_pos, kids, 'z');
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4983
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4984 update_type = 'z';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4985 }
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
4986 else if (axis_type == "clim" || axis_type == "climinclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4987 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4988 get_children_limits (min_val, max_val, min_pos, kids, 'c');
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4989
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4990 update_type = 'c';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4991
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4992 }
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
4993 else if (axis_type == "alim" || axis_type == "aliminclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4994 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4995 get_children_limits (min_val, max_val, min_pos, kids, 'a');
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4996
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4997 update_type = 'a';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4998 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4999
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5000 Matrix limits (1, 3, 0.0);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5001
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5002 limits(0) = min_val;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5003 limits(1) = max_val;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5004 limits(2) = min_pos;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5005
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5006 switch (update_type)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5007 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5008 case 'x':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5009 xproperties.set_xlim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5010 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5011
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5012 case 'y':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5013 xproperties.set_ylim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5014 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5015
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5016 case 'z':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5017 xproperties.set_zlim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5018 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5019
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5020 case 'c':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5021 xproperties.set_clim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5022 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5023
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5024 case 'a':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5025 xproperties.set_alim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5026 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5027
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5028 default:
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5029 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5030 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5031
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5032 base_graphics_object::update_axis_limits (axis_type);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5033 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5034
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5035 // ---------------------------------------------------------------------
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5036
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5037 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
5038 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
5039 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5040 graphics_handle parent = get_parent ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5041 graphics_object parent_obj = gh_manager::get_object (parent);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5042
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5043 return parent_obj.get_default (type () + name);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5044 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5045
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5046 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
5047 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
5048 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5049 graphics_object parent_obj = gh_manager::get_object (0);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5050
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5051 return parent_obj.get_factory_default (type () + name);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5052 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5053
7286
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
5054 // 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
5055 // scalar values for the first argument.
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5056 gh_manager::gh_manager (void)
7286
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
5057 : handle_map (), handle_free_list (),
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
5058 next_handle (-1.0 - (rand () + 1.0) / (RAND_MAX + 2.0))
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5059 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5060 handle_map[0] = graphics_object (new root_figure ());
7847
40b16e04172a Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7844
diff changeset
5061
40b16e04172a Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7844
diff changeset
5062 // Make sure the default backend is registered.
40b16e04172a Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7844
diff changeset
5063 graphics_backend::default_backend ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5064 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5065
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5066 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5067 gh_manager::do_make_graphics_handle (const std::string& go_name,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5068 const graphics_handle& p, bool do_createfcn)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5069 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5070 graphics_handle h = get_handle (go_name);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5071
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5072 base_graphics_object *go = 0;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5073
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
5074 go = make_graphics_object_from_type (go_name, h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
5075
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5076 if (go)
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
5077 {
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
5078 graphics_object obj (go);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
5079
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
5080 handle_map[h] = obj;
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
5081 if (do_createfcn)
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
5082 go->get_properties ().execute_createfcn ();
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
5083
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
5084 // notify backend
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
5085 graphics_backend backend = go->get_backend ();
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
5086 if (backend)
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
5087 backend.initialize (obj);
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
5088 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5089 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5090 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
5091 go_name.c_str ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5092
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5093 return h;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5094 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5095
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5096 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5097 gh_manager::do_make_figure_handle (double val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5098 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5099 graphics_handle h = val;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5100
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
5101 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
5102 graphics_object obj (go);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
5103
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
5104 handle_map[h] = obj;
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
5105
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
5106 // notify backend
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
5107 graphics_backend backend = go->get_backend ();
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
5108 if (backend)
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
5109 backend.initialize (obj);
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
5110
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5111 return h;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5112 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5113
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5114 void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5115 gh_manager::do_push_figure (const graphics_handle& h)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5116 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5117 do_pop_figure (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5118
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5119 figure_list.push_front (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5120 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5121
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5122 void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5123 gh_manager::do_pop_figure (const graphics_handle& h)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5124 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5125 for (figure_list_iterator p = figure_list.begin ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5126 p != figure_list.end ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5127 p++)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5128 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5129 if (*p == h)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5130 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5131 figure_list.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5132 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5133 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5134 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5135 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5136
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5137 class
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5138 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
5139 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5140 public:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5141 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
5142 const octave_value& data = Matrix ())
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5143 : base_graphics_event (), handle (h), callback_name (name),
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5144 callback_data (data) { }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5145
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5146 void execute (void)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5147 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5148 gh_manager::execute_callback (handle, callback_name, callback_data);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5149 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5150
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5151 private:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5152 callback_event (void)
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5153 : base_graphics_event () { }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5154
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5155 private:
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5156 graphics_handle handle;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5157 std::string callback_name;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5158 octave_value callback_data;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5159 };
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5160
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5161 class
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5162 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
5163 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5164 public:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5165 function_event (graphics_event::event_fcn fcn, void* data = 0)
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5166 : base_graphics_event (), function (fcn),
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5167 function_data (data) { }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5168
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5169 void execute (void)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5170 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5171 function (function_data);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5172 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5173
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5174 private:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5175 function_event (void)
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5176 : base_graphics_event () { }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5177
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5178 private:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5179 graphics_event::event_fcn function;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5180 void* function_data;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5181 };
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5182
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5183 class
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5184 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
5185 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5186 public:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5187 set_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
5188 const octave_value& value)
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5189 : base_graphics_event (), handle (h), property_name (name),
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5190 property_value (value) { }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5191
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5192 void execute (void)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5193 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5194 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5195
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5196 xset (handle, property_name, property_value);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5197 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5198
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5199 private:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5200 set_event (void)
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5201 : base_graphics_event () { }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5202
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5203 private:
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5204 graphics_handle handle;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5205 std::string property_name;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5206 octave_value property_value;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5207 };
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5208
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5209 graphics_event
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5210 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
5211 const std::string& name,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5212 const octave_value& data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5213 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5214 graphics_event e;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5215
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5216 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
5217
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5218 return e;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5219 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5220
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5221 graphics_event
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5222 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
5223 void *data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5224 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5225 graphics_event e;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5226
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5227 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
5228
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5229 return e;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5230 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5231
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5232 graphics_event
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5233 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
5234 const std::string& name,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5235 const octave_value& data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5236 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5237 graphics_event e;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5238
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5239 e.rep = new set_event (h, name, data);
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5240
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5241 return e;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5242 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5243
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5244 static void
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5245 xset_gcbo (const graphics_handle& h)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5246 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5247 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
5248 root_figure::properties& props =
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5249 dynamic_cast<root_figure::properties&> (go.get_properties ());
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5250
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5251 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
5252 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5253
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5254 void
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5255 gh_manager::do_restore_gcbo (void)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5256 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5257 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5258
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5259 callback_objects.pop_front ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5260
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5261 xset_gcbo (callback_objects.empty ()
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5262 ? graphics_handle ()
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5263 : callback_objects.front ().get_handle ());
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5264 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5265
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5266 void
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5267 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
5268 const octave_value& cb_arg,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5269 const octave_value& data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5270 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5271 octave_value_list args;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5272 octave_function *fcn = 0;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5273
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5274 args(0) = h.as_octave_value ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5275 if (data.is_defined ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5276 args(1) = data;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5277 else
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5278 args(1) = Matrix ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5279
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
5280 unwind_protect_safe frame;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
5281 frame.add_fcn (gh_manager::restore_gcbo);
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5282
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5283 if (true)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5284 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5285 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5286
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5287 callback_objects.push_front (get_object (h));
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5288 xset_gcbo (h);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5289 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5290
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5291 BEGIN_INTERRUPT_WITH_EXCEPTIONS;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5292
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5293 // Copy CB because "function_value" method is non-const.
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5294
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5295 octave_value cb = cb_arg;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5296
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5297 if (cb.is_function_handle ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5298 fcn = cb.function_value ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5299 else if (cb.is_string ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5300 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5301 int status;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5302 std::string s = cb.string_value ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5303
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5304 eval_string (s, false, status);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5305 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5306 else if (cb.is_cell () && cb.length () > 0
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5307 && (cb.rows () == 1 || cb.columns () == 1)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5308 && cb.cell_value ()(0).is_function_handle ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5309 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5310 Cell c = cb.cell_value ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5311
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5312 fcn = c(0).function_value ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5313 if (! error_state)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5314 {
8052
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8021
diff changeset
5315 for (int i = 1; i < c.length () ; i++)
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8021
diff changeset
5316 args(1+i) = c(i);
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5317 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5318 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5319 else
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5320 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5321 std::string nm = cb.class_name ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5322 error ("trying to execute non-executable object (class = %s)",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5323 nm.c_str ());
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5324 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5325
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5326 if (fcn && ! error_state)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5327 feval (fcn, args);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5328
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5329 END_INTERRUPT_WITH_EXCEPTIONS;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5330 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5331
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5332 void
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5333 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
5334 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5335 event_queue.push_back (e);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5336
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5337 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
5338 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5339
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5340 void
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5341 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
5342 const octave_value& data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5343 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5344 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5345
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5346 graphics_object go = get_object (h);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5347
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5348 if (go.valid_object ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5349 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5350 if (callback_objects.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5351 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
5352 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5353 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5354 const graphics_object& current = callback_objects.front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5355
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5356 if (current.get_properties ().is_interruptible ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5357 do_post_event (graphics_event::create_callback_event (h, name, data));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5358 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5359 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5360 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
5361
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5362 if (busy_action.compare ("queue"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5363 do_post_event (graphics_event::create_callback_event (h, name, data));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5364 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5365 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5366 caseless_str cname (name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5367
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5368 if (cname.compare ("deletefcn")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5369 || cname.compare ("createfcn")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5370 || (go.isa ("figure")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5371 && (cname.compare ("closerequestfcn")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5372 || cname.compare ("resizefcn"))))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5373 do_post_event (graphics_event::create_callback_event (h, name, data));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5374 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5375 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5376 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5377 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5378 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5379
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5380 void
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5381 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
5382 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5383 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5384
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5385 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
5386 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5387
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5388 void
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5389 gh_manager::do_post_set (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
5390 const octave_value& value)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5391 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5392 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5393
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5394 do_post_event (graphics_event::create_set_event (h, name, value));
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5395 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5396
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5397 int
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5398 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
5399 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5400 graphics_event e;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5401
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5402 do
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5403 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
5404 e = graphics_event ();
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5405
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5406 gh_manager::lock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5407
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5408 if (! event_queue.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5409 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5410 if (callback_objects.empty () || force)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5411 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5412 e = event_queue.front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5413
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5414 event_queue.pop_front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5415 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5416 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5417 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5418 const graphics_object& go = callback_objects.front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5419
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5420 if (go.get_properties ().is_interruptible ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5421 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5422 e = event_queue.front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5423
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5424 event_queue.pop_front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5425 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5426 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5427 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5428
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5429 gh_manager::unlock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5430
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5431 if (e.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5432 e.execute ();
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5433 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5434 while (e.ok ());
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5435
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5436 gh_manager::lock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5437
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5438 if (event_queue.empty ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5439 command_editor::remove_event_hook (gh_manager::process_events);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5440
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5441 gh_manager::unlock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5442
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5443 return 0;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5444 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5445
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5446 property_list::plist_map_type
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5447 root_figure::init_factory_properties (void)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5448 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5449 property_list::plist_map_type plist_map;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5450
6844
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
5451 plist_map["figure"] = figure::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
5452 plist_map["axes"] = axes::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
5453 plist_map["line"] = line::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
5454 plist_map["text"] = text::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
5455 plist_map["image"] = image::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
5456 plist_map["patch"] = patch::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
5457 plist_map["surface"] = surface::properties::factory_defaults ();
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5458 plist_map["hggroup"] = hggroup::properties::factory_defaults ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5459
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5460 return plist_map;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5461 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5462
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5463 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5464
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5465 DEFUN (ishandle, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5466 "-*- texinfo -*-\n\
6678
49724abe1236 [project @ 2007-05-31 19:44:45 by jwe]
jwe
parents: 6595
diff changeset
5467 @deftypefn {Built-in Function} {} ishandle (@var{h})\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5468 Return true if @var{h} is a graphics handle and false otherwise.\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5469 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5470 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5471 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5472
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5473 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5474
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5475 if (args.length () == 1)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5476 retval = is_handle (args(0));
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5477 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5478 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5479
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5480 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5481 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5482
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5483 DEFUN (reset, args, ,
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5484 "-*- texinfo -*-\n\
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5485 @deftypefn {Built-in Function} {} reset (@var{h}, @var{property})\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
5486 Removes any defaults set for the handle @var{h}. The default figure\n\
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5487 properties \"position\", \"units\", \"windowstyle\" and\n\
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5488 \"paperunits\" and the default axes properties \"position\" and \"units\"\n\
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5489 are not reset.\n\
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5490 @end deftypefn")
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5491 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5492 int nargin = args.length ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5493
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5494 if (nargin != 1)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5495 print_usage ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5496 else
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5497 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5498 // get vector of graphics handles
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5499 ColumnVector hcv (args(0).vector_value ());
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5500
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5501 if (! error_state)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5502 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5503 // loop over graphics objects
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5504 for (octave_idx_type n = 0; n < hcv.length (); n++)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5505 gh_manager::get_object (hcv(n)).reset_default_properties ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5506 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5507 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5508
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5509 return octave_value ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5510 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
5511
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
5512 DEFUN (set, args, nargout,
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5513 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
5514 @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
5515 @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
5516 @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
5517 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
5518 handles) @var{h}.\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5519 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
5520 \n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5521 @itemize\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5522 @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
5523 \n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5524 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
5525 @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
5526 \n\
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5527 @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
5528 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
5529 \n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5530 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
5531 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
5532 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
5533 @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
5534 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
5535 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
5536 the first row of @var{values} and so on.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
5537 \n\
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5538 @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
5539 \n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5540 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
5541 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
5542 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
5543 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
5544 @end itemize\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5545 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5546 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5547 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5548
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5549 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5550
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5551 int nargin = args.length ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5552
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5553 if (nargin > 0)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5554 {
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5555 // get vector of graphics handles
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5556 ColumnVector hcv (args(0).vector_value ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5557
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5558 if (! error_state)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5559 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5560 bool request_drawnow = false;
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
5561
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5562 // loop over graphics objects
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5563 for (octave_idx_type n = 0; n < hcv.length (); n++)
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5564 {
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5565 graphics_object obj = gh_manager::get_object (hcv(n));
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5566
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5567 if (obj)
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5568 {
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5569 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
5570 && args(2).is_cell ())
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5571 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5572 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
5573 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5574 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
5575 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
5576 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5577 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
5578 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5579 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
5580 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
5581 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5582 else
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5583 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5584 error("set: number of graphics handles must match number of value rows (%d != %d)",
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5585 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
5586 break;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5587
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5588 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5589 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5590 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
5591 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5592 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
5593 }
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
5594 else if (nargin == 1)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
5595 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
5596 if (nargout != 0)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
5597 retval = obj.values_as_struct ();
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
5598 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
5599 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
5600 std::string s = obj.values_as_string ();
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
5601 if (! error_state)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
5602 octave_stdout << s;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
5603 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
5604 }
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5605 else
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5606 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5607 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
5608 request_drawnow = true;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5609 }
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5610 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5611 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5612 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5613 error ("set: invalid handle (= %g)", hcv(n));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5614 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5615 }
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5616
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5617 if (error_state)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5618 break;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5619
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5620 request_drawnow = true;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
5621 }
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
5622
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5623 if (! error_state && request_drawnow)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5624 Vdrawnow_requested = true;
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5625 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5626 else
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5627 error ("set: expecting graphics handle as first argument");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5628 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5629 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5630 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5631
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5632 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5633 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5634
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5635 DEFUN (get, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5636 "-*- texinfo -*-\n\
6678
49724abe1236 [project @ 2007-05-31 19:44:45 by jwe]
jwe
parents: 6595
diff changeset
5637 @deftypefn {Built-in Function} {} get (@var{h}, @var{p})\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5638 Return the named property @var{p} from the graphics handle @var{h}.\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5639 If @var{p} is omitted, return the complete property list for @var{h}.\n\
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5640 If @var{h} is a vector, return a cell array including the property\n\
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5641 values or lists respectively.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5642 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5643 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5644 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5645
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5646 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
5647
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
5648 Cell vals;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5649
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5650 int nargin = args.length ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5651
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5652 if (nargin == 1 || nargin == 2)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5653 {
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5654 ColumnVector hcv (args(0).vector_value ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5655
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5656 if (! error_state)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5657 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5658 octave_idx_type len = hcv.length ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5659
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5660 vals.resize (dim_vector (len, 1));
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
5661
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
5662 for (octave_idx_type n = 0; n < len; n++)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5663 {
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5664 graphics_object obj = gh_manager::get_object (hcv(n));
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5665
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5666 if (obj)
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5667 {
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5668 if (nargin == 1)
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
5669 vals(n) = obj.get ();
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5670 else
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5671 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
5672 caseless_str property = args(1).string_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5673
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5674 if (! error_state)
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
5675 vals(n) = obj.get (property);
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5676 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5677 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5678 error ("get: expecting property name as second argument");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5679 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5680 }
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5681 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5682 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5683 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5684 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5685 error ("get: invalid handle (= %g)", hcv(n));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5686 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5687 }
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5688 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5689 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5690 else
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5691 error ("get: expecting graphics handle as first argument");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5692 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5693 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5694 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5695
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
5696 if (! error_state)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5697 {
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
5698 octave_idx_type len = vals.numel ();
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
5699
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
5700 if (len > 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5701 retval = vals;
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
5702 else if (len == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5703 retval = vals(0);
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5704 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
5705
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5706 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5707 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5708
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8740
diff changeset
5709 // 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
5710 // 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
5711 // 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
5712
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5713 DEFUN (__get__, args, ,
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5714 "-*- texinfo -*-\n\
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5715 @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
5716 Undocumented internal function.\n\
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5717 @end deftypefn")
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5718 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5719 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5720
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5721 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
5722
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
5723 Cell vals;
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5724
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5725 int nargin = args.length ();
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5726
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5727 if (nargin == 1)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5728 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5729 ColumnVector hcv (args(0).vector_value ());
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5730
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5731 if (! error_state)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5732 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5733 octave_idx_type len = hcv.length ();
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5734
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
5735 vals.resize (dim_vector (len, 1));
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5736
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5737 for (octave_idx_type n = 0; n < len; n++)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5738 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5739 graphics_object obj = gh_manager::get_object (hcv(n));
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5740
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5741 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
5742 vals(n) = obj.get (true);
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5743 else
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5744 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5745 error ("get: invalid handle (= %g)", hcv(n));
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5746 break;
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5747 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5748 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5749 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5750 else
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5751 error ("get: expecting graphics handle as first argument");
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5752 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5753 else
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5754 print_usage ();
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5755
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5756 if (! error_state)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5757 {
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
5758 octave_idx_type len = vals.numel ();
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5759
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5760 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
5761 retval = vals;
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5762 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
5763 retval = vals(0);
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5764 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5765
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5766 return retval;
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5767 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
5768
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5769 static octave_value
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5770 make_graphics_object (const std::string& go_name,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5771 const octave_value_list& args)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5772 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5773 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5774
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5775 double val = octave_NaN;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5776
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5777 octave_value_list xargs = args.splice (0, 1);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5778
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5779 caseless_str p ("parent");
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5780
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5781 for (int i = 0; i < xargs.length (); i++)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5782 if (xargs(i).is_string ()
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5783 && p.compare (xargs(i).string_value ()))
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5784 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5785 if (i < (xargs.length () - 1))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5786 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5787 val = xargs(i+1).double_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5788
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5789 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5790 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5791 xargs = xargs.splice (i, 2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5792 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5793 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5794 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5795 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5796 error ("__go_%s__: missing value for parent property",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5797 go_name.c_str ());
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5798 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5799
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5800 if (! error_state && xisnan (val))
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
5801 val = args(0).double_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5802
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5803 if (! error_state)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5804 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5805 graphics_handle parent = gh_manager::lookup (val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5806
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
5807 if (parent.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5808 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5809 graphics_handle h
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5810 = gh_manager::make_graphics_handle (go_name, parent, false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5811
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5812 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5813 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5814 adopt (parent, h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5815
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5816 xset (h, xargs);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5817 xcreatefcn (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5818
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5819 retval = h.value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5820
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5821 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5822 Vdrawnow_requested = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5823 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5824 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5825 error ("__go%s__: unable to create graphics handle",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5826 go_name.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5827 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5828 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5829 error ("__go_%s__: invalid parent", go_name.c_str ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5830 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5831 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5832 error ("__go_%s__: invalid parent", go_name.c_str ());
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5833
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5834 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5835 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5836
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5837 DEFUN (__go_figure__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5838 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5839 @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
5840 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5841 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5842 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5843 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5844
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5845 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5846
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5847 if (args.length () > 0)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5848 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5849 double val = args(0).double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5850
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5851 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5852 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5853 if (is_figure (val))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5854 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5855 graphics_handle h = gh_manager::lookup (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5856
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5857 xset (h, args.splice (0, 1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5858
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5859 retval = h.value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5860 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5861 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5862 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5863 graphics_handle h = octave_NaN;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5864
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5865 if (xisnan (val))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5866 h = gh_manager::make_graphics_handle ("figure", 0, false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5867 else if (val > 0 && D_NINT (val) == val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5868 h = gh_manager::make_figure_handle (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5869 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5870 error ("__go_figure__: invalid figure number");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5871
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5872 if (! error_state && h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5873 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5874 adopt (0, h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5875
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5876 xset (h, args.splice (0, 1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5877 xcreatefcn (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5878
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5879 retval = h.value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5880 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5881 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5882 error ("__go_figure__: failed to create figure handle");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5883 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5884 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5885 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5886 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
5887 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5888 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5889 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5890
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5891 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5892 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5893
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5894 #define GO_BODY(TYPE) \
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5895 gh_manager::autolock guard; \
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
5896 \
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5897 octave_value retval; \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5898 \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5899 if (args.length () > 0) \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5900 retval = make_graphics_object (#TYPE, args); \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5901 else \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5902 print_usage (); \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5903 \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5904 return retval
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5905
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5906 int
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5907 calc_dimensions (const graphics_object& go)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5908 {
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5909
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5910 int nd = 2;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5911
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5912 if (go.isa ("surface"))
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5913 nd = 3;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5914
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5915 if ((go.isa ("line") || go.isa ("patch")) && ! go.get("zdata").is_empty ())
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5916 nd = 3;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5918 Matrix kids = go.get_properties().get_children ();
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5919
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5920 for (octave_idx_type i = 0; i < kids.length (); i++)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5921 {
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5922 graphics_handle hnd = gh_manager::lookup (kids(i));
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5923
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5924 if (hnd.ok ())
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5925 {
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5926 const graphics_object& kid = gh_manager::get_object(hnd);
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5927
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5928 if (kid.valid_object())
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5929 nd = calc_dimensions (kid);
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5930
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5931 if (nd == 3)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5932 break;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5933 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5934 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5935
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5936 return nd;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5937 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5938
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5939 DEFUN (__calc_dimensions__, args, ,
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5940 "-*- texinfo -*-\n\
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5941 @deftypefn {Built-in Function} {} __calc_dimensions__ (@var{axes})\n\
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5942 Internal function. Determine the number of dimensions in a graphics\n\
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5943 object, whether 2 or 3.\n\
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5944 @end deftypefn")
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5945 {
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5946 gh_manager::autolock guard;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5947
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5948 octave_value retval;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5949
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5950 int nargin = args.length ();
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5951
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5952 if (nargin == 1)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5953 {
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5954 double h = args(0).double_value ();
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5955
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5956 if (! error_state)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5957 retval = calc_dimensions (gh_manager::get_object (h));
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5958 else
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5959 error ("__calc_dimensions__: expecting graphics handle as only argument");
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5960 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5961 else
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5962 print_usage ();
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5963
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5964 return retval;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5965 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5966
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5967 DEFUN (__go_axes__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5968 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5969 @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
5970 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5971 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5972 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5973 GO_BODY (axes);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5974 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5975
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5976 DEFUN (__go_line__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5977 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5978 @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
5979 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5980 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5981 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5982 GO_BODY (line);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5983 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5984
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5985 DEFUN (__go_text__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5986 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5987 @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
5988 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5989 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5990 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5991 GO_BODY (text);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5992 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5993
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5994 DEFUN (__go_image__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5995 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5996 @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
5997 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5998 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5999 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6000 GO_BODY (image);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6001 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6002
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6003 DEFUN (__go_surface__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6004 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6005 @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
6006 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6007 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6008 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6009 GO_BODY (surface);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6010 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6011
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
6012 DEFUN (__go_patch__, args, ,
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
6013 "-*- texinfo -*-\n\
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
6014 @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
6015 Undocumented internal function.\n\
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
6016 @end deftypefn")
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
6017 {
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
6018 GO_BODY (patch);
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
6019 }
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
6020
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6021 DEFUN (__go_hggroup__, args, ,
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6022 "-*- texinfo -*-\n\
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6023 @deftypefn {Built-in Function} {} __go_hggroup__ (@var{parent})\n\
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6024 Undocumented internal function.\n\
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6025 @end deftypefn")
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6026 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6027 GO_BODY (hggroup);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6028 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6029
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6030 DEFUN (__go_delete__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6031 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6032 @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
6033 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6034 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6035 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6036 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6037
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6038 octave_value_list retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6039
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6040 if (args.length () == 1)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6041 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6042 graphics_handle h = octave_NaN;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6043
8196
32e9e8103390 Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents: 8183
diff changeset
6044 const NDArray vals = args (0).array_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6045
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6046 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6047 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6048 // 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
6049 // 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
6050 // later want to delete
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6051 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
6052 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6053 h = gh_manager::lookup (vals.elem (i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6054
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6055 if (! h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6056 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6057 error ("delete: invalid graphics object (= %g)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6058 vals.elem (i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6059 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6060 }
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
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6063 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6064 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6065 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
6066 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6067 h = gh_manager::lookup (vals.elem (i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6068
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6069 if (h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6070 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6071 graphics_object obj = gh_manager::get_object (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6072
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6073 // Don't do recursive deleting, due to callbacks
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6074 if (! obj.get_properties ().is_beingdeleted ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6075 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6076 graphics_handle parent_h = obj.get_parent ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6077
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6078 graphics_object parent_obj =
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6079 gh_manager::get_object (parent_h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6080
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6081 // NOTE: free the handle before removing it from its
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6082 // parent's children, such that the object's
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6083 // state is correct when the deletefcn callback
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6084 // is executed
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6085
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6086 gh_manager::free (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6087
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6088 // A callback function might have already deleted
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6089 // the parent
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6090 if (parent_obj.valid_object ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6091 parent_obj.remove_child (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6092
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6093 Vdrawnow_requested = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6094 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6095 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6096 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6097 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6098 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6099 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6100 error ("delete: invalid graphics object");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6101 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6102 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6103 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6104
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6105 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6106 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6107
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6108 DEFUN (__go_axes_init__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6109 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6110 @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
6111 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6112 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6113 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6114 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6115
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6116 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6117
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6118 int nargin = args.length ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6119
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6120 std::string mode = "";
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6121
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6122 if (nargin == 2)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6123 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6124 mode = args(1).string_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6125
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6126 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6127 return retval;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6128 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6129
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6130 if (nargin == 1 || nargin == 2)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6131 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6132 graphics_handle h = octave_NaN;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6133
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6134 double val = args(0).double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6135
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6136 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6137 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6138 h = gh_manager::lookup (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6139
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6140 if (h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6141 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6142 graphics_object obj = gh_manager::get_object (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6143
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6144 obj.set_defaults (mode);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6145
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6146 h = gh_manager::lookup (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6147 if (! h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6148 error ("__go_axes_init__: axis deleted during initialization (= %g)", val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6149 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6150 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6151 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
6152 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6153 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6154 error ("__go_axes_init__: invalid graphics object");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6155 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6156 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6157 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6158
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6159 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6160 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6161
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6162 DEFUN (__go_handles__, , ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6163 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6164 @deftypefn {Built-in Function} {} __go_handles__ ()\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
6165 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6166 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6167 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6168 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6169
6425
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
6170 return octave_value (gh_manager::handle_list ());
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
6171 }
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
6172
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
6173 DEFUN (__go_figure_handles__, , ,
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
6174 "-*- texinfo -*-\n\
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
6175 @deftypefn {Built-in Function} {} __go_figure_handles__ ()\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
6176 Undocumented internal function.\n\
6425
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
6177 @end deftypefn")
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
6178 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6179 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6180
6425
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
6181 return octave_value (gh_manager::figure_handle_list ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6182 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6183
7967
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6184 DEFUN (__go_execute_callback__, args, ,
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6185 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
6186 @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
6187 @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
6188 Undocumented internal function.\n\
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6189 @end deftypefn")
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6190 {
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6191 octave_value retval;
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6192
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6193 int nargin = args.length ();
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6194
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6195 if (nargin == 2 || nargin == 3)
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6196 {
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6197 double val = args(0).double_value ();
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6198
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6199 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6200 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6201 graphics_handle h = gh_manager::lookup (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6202
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6203 if (h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6204 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6205 std::string name = args(1).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6206
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6207 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6208 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6209 if (nargin == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6210 gh_manager::execute_callback (h, name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6211 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6212 gh_manager::execute_callback (h, name, args(2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6213 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6214 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6215 error ("__go_execute_callback__: invalid callback name");
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 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6218 error ("__go_execute_callback__: invalid graphics object (= %g)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6219 val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6220 }
7967
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6221 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6222 error ("__go_execute_callback__: invalid graphics object");
7967
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6223 }
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6224 else
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6225 print_usage ();
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6226
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6227 return retval;
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6228 }
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
6229
11076
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6230 DEFUN (__image_pixel_size__, args, ,
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6231 "-*- texinfo -*-\n\
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6232 @deftypefn {Built-in Function} {@var{px},@var{py}} __image_pixel_size__ (@var{h})\n\
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6233 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
6234 @end deftypefn")
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6235 {
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6236 octave_value retval;
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6237
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6238 int nargin = args.length ();
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6239
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6240 if (nargin == 1)
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6241 {
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6242 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
6243
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6244 if (! error_state)
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6245 {
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6246 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
6247 if (fobj && fobj.isa ("image"))
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6248 {
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6249 image::properties& ip =
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6250 dynamic_cast<image::properties&> (fobj.get_properties ());
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6251
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6252 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
6253 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
6254 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
6255 retval = dp;
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6256 }
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6257 else
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6258 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
6259 }
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6260 else
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6261 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
6262 }
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6263 else
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6264 print_usage ();
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6265
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6266 return retval;
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6267 }
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
6268
7924
4976f66d469b miscellaneous cleanup
John W. Eaton <jwe@octave.org>
parents: 7878
diff changeset
6269 DEFUN (available_backends, , ,
7835
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
6270 "-*- texinfo -*-\n\
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
6271 @deftypefn {Built-in Function} {} available_backends ()\n\
9316
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
6272 Return a cell array of registered graphics backends.\n\
7835
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
6273 @end deftypefn")
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
6274 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6275 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6276
7835
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
6277 return octave_value (graphics_backend::available_backends_list ());
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
6278 }
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
6279
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
6280 DEFUN (drawnow, args, ,
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
6281 "-*- texinfo -*-\n\
9316
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
6282 @deftypefn {Built-in Function} {} drawnow ()\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
6283 @deftypefnx {Built-in Function} {} drawnow (\"expose\")\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
6284 @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
6285 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
6286 any callbacks generated are executed. With the optional argument\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
6287 @code{\"expose\"}, only graphic objects are updated and no other events or\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
6288 callbacks are processed.\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
6289 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
6290 undocumented.\n\
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
6291 @end deftypefn")
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
6292 {
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
6293 static int drawnow_executing = 0;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
6294 static bool __go_close_all_registered__ = false;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
6295
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
6296 octave_value retval;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
6297
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6298 gh_manager::lock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6299
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
6300 unwind_protect frame;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
6301 frame.protect_var (Vdrawnow_requested, false);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
6302
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
6303 frame.protect_var (drawnow_executing);
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
6304
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
6305 if (++drawnow_executing <= 1)
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
6306 {
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
6307 if (! __go_close_all_registered__)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6308 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6309 octave_add_atexit_function ("__go_close_all__");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6310
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6311 __go_close_all_registered__ = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6312 }
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
6313
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6314 if (args.length () == 0 || args.length () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6315 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6316 Matrix hlist = gh_manager::figure_handle_list ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6317
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6318 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
6319 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6320 graphics_handle h = gh_manager::lookup (hlist(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6321
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6322 if (h.ok () && h != 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6323 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6324 graphics_object go = gh_manager::get_object (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6325 figure::properties& fprops = dynamic_cast <figure::properties&> (go.get_properties ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6326
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6327 if (fprops.is_modified ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6328 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6329 if (fprops.is_visible ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6330 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6331 gh_manager::unlock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6332
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6333 fprops.get_backend ().redraw_figure (go);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6334
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6335 gh_manager::lock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6336 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6337
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6338 fprops.set_modified (false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6339 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6340 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6341 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6342
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6343 bool do_events = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6344
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6345 if (args.length () == 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6346 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6347 caseless_str val (args(0).string_value ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6348
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6349 if (! error_state && val.compare ("expose"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6350 do_events = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6351 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6352 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6353 error ("drawnow: invalid argument, expected `expose' as argument");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6354 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6355 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6356 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6357
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6358 if (do_events)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6359 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6360 gh_manager::unlock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6361
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6362 gh_manager::process_events ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6363
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6364 gh_manager::lock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6365 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6366 }
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
6367 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
6368 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6369 std::string term, file, debug_file;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6370 bool mono;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6371
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6372 term = args(0).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6373
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6374 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6375 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6376 file = args(1).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6377
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6378 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6379 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6380 size_t pos = file.find_last_of (file_ops::dir_sep_chars ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6381
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6382 if (pos != std::string::npos)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6383 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6384 std::string dirname = file.substr (0, pos+1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6385
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6386 file_stat fs (dirname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6387
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6388 if (! (fs && fs.is_dir ()))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6389 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6390 error ("drawnow: nonexistent directory `%s'",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6391 dirname.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6392
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6393 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6394 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6395 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6396
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6397 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
6398
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6399 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6400 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6401 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
6402 : "");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6403
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6404 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6405 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6406 graphics_handle h = gcf ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6407
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6408 if (h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6409 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6410 graphics_object go = gh_manager::get_object (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6411
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6412 gh_manager::unlock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6413
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6414 go.get_backend ()
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6415 .print_figure (go, term, file, mono, debug_file);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6416
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6417 gh_manager::lock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6418 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6419 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6420 error ("drawnow: nothing to draw");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6421 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6422 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6423 error ("drawnow: invalid debug_file, expected a string value");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6424 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6425 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6426 error ("drawnow: invalid colormode, expected a boolean value");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6427 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6428 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6429 error ("drawnow: invalid file, expected a string value");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6430 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6431 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6432 error ("drawnow: invalid terminal, expected a string value");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6433 }
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
6434 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6435 print_usage ();
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
6436 }
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
6437
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6438 gh_manager::unlock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6439
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
6440 return retval;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
6441 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
6442
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
6443 DEFUN (addlistener, args, ,
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6444 "-*- texinfo -*-\n\
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
6445 @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
6446 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
6447 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
6448 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
6449 listeners are executed.\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6450 \n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6451 @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
6452 \n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6453 @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
6454 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
6455 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
6456 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
6457 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
6458 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
6459 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
6460 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
6461 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6462 Example:\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6463 \n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6464 @example\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
6465 @group\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6466 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
6467 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
6468 endfunction\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6469 \n\
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
6470 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
6471 @end group\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6472 @end example\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6473 \n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6474 @end deftypefn")
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6475 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6476 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6477
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6478 octave_value retval;
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6479
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6480 if (args.length () == 3)
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6481 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6482 double h = args(0).double_value ();
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6483
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6484 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6485 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6486 std::string pname = args(1).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6487
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6488 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6489 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6490 graphics_handle gh = gh_manager::lookup (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6491
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6492 if (gh.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6493 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6494 graphics_object go = gh_manager::get_object (gh);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6495
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6496 go.add_property_listener (pname, args(2), POSTSET);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6497 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6498 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6499 error ("addlistener: invalid graphics object (= %g)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6500 h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6501 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6502 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6503 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
6504 }
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6505 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6506 error ("addlistener: invalid handle");
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6507 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6508 else
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6509 print_usage ();
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6510
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6511 return retval;
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6512 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
6513
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6514 DEFUN (dellistener, args, ,
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6515 "-*- texinfo -*-\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6516 @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
6517 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
6518 @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
6519 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
6520 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
6521 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6522 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
6523 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
6524 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6525 Example:\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6526 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6527 @example\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
6528 @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
6529 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
6530 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
6531 endfunction\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6532 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6533 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
6534 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
6535 dellistener (gcf, \"position\", c);\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
6536 @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
6537 @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
6538 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6539 @end deftypefn")
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6540 {
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6541 gh_manager::autolock guard;
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6542
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6543 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
6544
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6545 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
6546 {
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6547 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
6548
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6549 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6550 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6551 std::string pname = args(1).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6552
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6553 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6554 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6555 graphics_handle gh = gh_manager::lookup (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6556
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6557 if (gh.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6558 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6559 graphics_object go = gh_manager::get_object (gh);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6560
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6561 if (args.length () == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6562 go.delete_property_listener (pname, octave_value (), POSTSET);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6563 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6564 go.delete_property_listener (pname, args(2), POSTSET);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6565 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6566 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6567 error ("dellistener: invalid graphics object (= %g)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6568 h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6569 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6570 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6571 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
6572 }
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6573 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6574 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
6575 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6576 else
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6577 print_usage ();
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6578
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6579 return retval;
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6580 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
6581
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6582 DEFUN (addproperty, args, ,
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
6583 "-*- texinfo -*-\n\
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
6584 @deftypefn {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
6585 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
6586 @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
6587 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
6588 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
6589 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6590 The supported property types are:\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6591 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6592 @table @code\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6593 @item string\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
6594 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
6595 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6596 @item any\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
6597 An un-typed property. This kind of property can hold any octave\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
6598 value. @var{args} contains the default value.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
6599 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6600 @item radio\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
6601 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
6602 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
6603 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
6604 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
6605 an optional second string argument.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
6606 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6607 @item boolean\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
6608 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
6609 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
6610 the default property value.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
6611 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6612 @item double\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
6613 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
6614 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6615 @item handle\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
6616 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
6617 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
6618 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
6619 the empty matrix.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
6620 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6621 @item data\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
6622 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
6623 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
6624 the empty matrix.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
6625 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6626 @item color\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
6627 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
6628 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
6629 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
6630 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
6631 @end table\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6632 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6633 @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
6634 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
6635 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
6636 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
6637 property into the graphics object @var{h}.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6638 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6639 Examples:\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6640 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6641 @example\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
6642 @group\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6643 addproperty (\"my_property\", gcf, \"string\", \"a string value\");\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6644 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
6645 addproperty (\"my_style\", gcf, \"linelinestyle\", \"--\");\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
6646 @end group\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6647 @end example\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6648 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6649 @end deftypefn")
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6650 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6651 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6652
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6653 octave_value retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6654
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6655 if (args.length () >= 3)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6656 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6657 std::string name = args(0).string_value ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6658
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6659 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6660 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6661 double h = args(1).double_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6662
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6663 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6664 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6665 graphics_handle gh = gh_manager::lookup (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6666
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6667 if (gh.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6668 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6669 graphics_object go = gh_manager::get_object (gh);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6670
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6671 std::string type = args(2).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6672
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6673 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6674 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6675 if (! go.get_properties ().has_property (name))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6676 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6677 property p = property::create (name, gh, type,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6678 args.splice (0, 3));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6679
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6680 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6681 go.get_properties ().insert_property (name, p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6682 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6683 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6684 error ("addproperty: a `%s' property already exists in the graphics object",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6685 name.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6686 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6687 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6688 error ("addproperty: invalid property type, expected a string value");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6689 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6690 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6691 error ("addproperty: invalid graphics object (= %g)", h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6692 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6693 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6694 error ("addproperty: invalid handle value");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6695 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6696 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6697 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
6698 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6699 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6700 print_usage ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6701
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6702 return retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6703 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6704
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6705 octave_value
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
6706 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
6707 const std::string& func)
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6708 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6709 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6710
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6711 graphics_object obj = gh_manager::get_object (handle);
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6712 octave_value retval;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6713
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6714 if (obj)
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
6715 retval = obj.get (caseless_str (property));
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6716 else
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6717 error ("%s: invalid handle (= %g)", func.c_str(), handle);
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6718
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6719 return retval;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6720 }
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6721
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6722 bool
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
6723 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
6724 const octave_value& arg, const std::string& func)
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6725 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6726 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6727
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6728 graphics_object obj = gh_manager::get_object (handle);
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6729 int ret = false;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6730
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6731 if (obj)
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6732 {
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
6733 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
6734
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
6735 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6736 ret = true;
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6737 }
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6738 else
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6739 error ("%s: invalid handle (= %g)", func.c_str(), handle);
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6740
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6741 return ret;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
6742 }