annotate src/graphics.cc @ 7865:b74039822fd2

Add support for hggroup
author Michael Goffioul <michael.goffioul@gmail.com>
date Fri, 25 Apr 2008 16:44:59 +0200
parents 56f781f38f0b
children 1b85fcb94c6a
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
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3 Copyright (C) 2007 John W. Eaton
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>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
36
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
37 #include "file-ops.h"
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
38 #include "file-stat.h"
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
39
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
40 #include "defun.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
41 #include "error.h"
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
42 #include "graphics.h"
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
43 #include "input.h"
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
44 #include "ov.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
45 #include "oct-obj.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
46 #include "oct-map.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
47 #include "ov-fcn-handle.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
48 #include "parse.h"
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
49 #include "toplev.h"
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
50 #include "unwind-prot.h"
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
51
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
52 static void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
53 gripe_set_invalid (const std::string& pname)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
54 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
55 error ("set: invalid value for %s property", pname.c_str ());
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
56 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
57
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
58 static Matrix
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
59 jet_colormap (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
60 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
61 Matrix cmap (64, 3, 0.0);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
62
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
63 for (octave_idx_type i = 0; i < 64; i++)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
64 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
65 // 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
66 // 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
67 // property object that includes a colormap_property
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
68 // 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
69 // called, so calling an interpreted function is not
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
70 // possible.
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
71
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
72 double x = i / 63.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
73
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
74 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
75 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
76 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
77 cmap(i,0) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
78 else if (x >= 7.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
79 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
80
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
81 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
82 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
83 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
84 cmap(i,1) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
85 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
86 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
87
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
88 if (x < 1.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
89 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
90 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
91 cmap(i,2) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
92 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
93 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
94 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
95
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
96 return cmap;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
97 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
98
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
99 static Matrix
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
100 default_colororder (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
101 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
102 Matrix retval (7, 3, 0.0);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
103
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
104 retval(0,2) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
105
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
106 retval(1,1) = 0.5;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
107
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
108 retval(2,0) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
109
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
110 retval(3,1) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
111 retval(3,2) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
112
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
113 retval(4,0) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
114 retval(4,2) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
115
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
116 retval(5,0) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
117 retval(5,1) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
118
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
119 retval(6,0) = 0.25;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
120 retval(6,1) = 0.25;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
121 retval(6,2) = 0.25;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
122
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
123 return retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
124 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
125
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
126 static Matrix
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
127 default_lim (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
128 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
129 Matrix m (1, 2, 0);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
130 m(1) = 1;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
131 return m;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
132 }
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 static Matrix
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
135 default_data (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
136 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
137 Matrix retval (1, 2);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
138
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
139 retval(0) = 0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
140 retval(1) = 1;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
141
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
142 return retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
143 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
144
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
145 static Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
146 default_axes_position (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
147 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
148 Matrix m (1, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
149 m(0) = 0.13;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
150 m(1) = 0.11;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
151 m(2) = 0.775;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
152 m(3) = 0.815;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
153 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
154 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
155
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
156 static Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
157 default_axes_outerposition (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
158 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
159 Matrix m (1, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
160 m(2) = m(3) = 1.0;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
161 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
162 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
163
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
164 static Matrix
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
165 default_figure_position (void)
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
166 {
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
167 Matrix m (1, 4, 0.0);
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
168 m(0) = 300;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
169 m(1) = 200;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
170 m(2) = 560;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
171 m(3) = 420;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
172 return m;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
173 }
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
174
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
175
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
176
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
177 static void
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
178 xset_gcbo (const graphics_handle& h)
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
179 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
180 graphics_object go = gh_manager::get_object (0);
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
181 root_figure::properties& props =
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
182 dynamic_cast<root_figure::properties&> (go.get_properties ());
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
183
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
184 props.set_callbackobject (h.as_octave_value ());
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
185 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
186
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
187 static void
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
188 xreset_gcbo (void *)
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
189 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
190 xset_gcbo (graphics_handle ());
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
191 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
192
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
193 // NOTE: "cb" is passed by value, because "function_value" method
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
194 // is non-const; passing "cb" by const-reference is not
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
195 // possible
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
196
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
197 static void
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
198 execute_callback (octave_value cb, const graphics_handle& h,
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
199 const octave_value& data)
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
200 {
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
201 octave_value_list args;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
202 octave_function *fcn = 0;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
203
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
204 args(0) = h.as_octave_value ();
7824
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
205 if (data.is_defined ())
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
206 args(1) = data;
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
207 else
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
208 args(1) = Matrix ();
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
209
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
210 unwind_protect::begin_frame ("execute_callback");
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
211 unwind_protect::add (xreset_gcbo);
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
212
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
213 xset_gcbo (h);
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
214
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
215 BEGIN_INTERRUPT_WITH_EXCEPTIONS;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
216
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
217 if (cb.is_function_handle ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
218 fcn = cb.function_value ();
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
219 else if (cb.is_string ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
220 {
7824
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
221 int status;
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
222 std::string s = cb.string_value ();
7824
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
223
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
224 eval_string (s, false, status);
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
225 }
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
226 else if (cb.is_cell () && cb.length () > 0
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
227 && (cb.rows () == 1 || cb.columns () == 1)
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
228 && cb.cell_value ()(0).is_function_handle ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
229 {
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
230 Cell c = cb.cell_value ();
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
231
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
232 fcn = c(0).function_value ();
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
233 if (! error_state)
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
234 {
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
235 for (int i = 0; i < c.length () ; i++)
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
236 args(2+i) = c(i);
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
237 }
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
238 }
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
239 else
7373
f350da755600 [project @ 2008-01-14 20:12:42 by jwe]
jwe
parents: 7370
diff changeset
240 {
f350da755600 [project @ 2008-01-14 20:12:42 by jwe]
jwe
parents: 7370
diff changeset
241 std::string nm = cb.class_name ();
f350da755600 [project @ 2008-01-14 20:12:42 by jwe]
jwe
parents: 7370
diff changeset
242 error ("trying to execute non-executable object (class = %s)",
f350da755600 [project @ 2008-01-14 20:12:42 by jwe]
jwe
parents: 7370
diff changeset
243 nm.c_str ());
f350da755600 [project @ 2008-01-14 20:12:42 by jwe]
jwe
parents: 7370
diff changeset
244 }
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
245
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
246 if (fcn && ! error_state)
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
247 feval (fcn, args);
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
248
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
249 END_INTERRUPT_WITH_EXCEPTIONS;
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
250
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
251 unwind_protect::run_frame ("execute_callback");
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
252 }
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
253
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
254 static Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
255 convert_position (const Matrix& pos, const caseless_str& from_units,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
256 const caseless_str& to_units,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
257 const Matrix& parent_dim = Matrix (1, 2, 0.0),
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
258 const graphics_backend& backend = graphics_backend ())
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
259 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
260 Matrix retval (1, 4);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
261 double res = 0;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
262
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
263 if (from_units.compare ("pixels"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
264 retval = pos;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
265 else if (from_units.compare ("normalized"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
266 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
267 retval(0) = pos(0) * parent_dim(0) + 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
268 retval(1) = pos(1) * parent_dim(1) + 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
269 retval(2) = pos(2) * parent_dim(0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
270 retval(3) = pos(3) * parent_dim(1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
271 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
272 else if (from_units.compare ("characters"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
273 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
274 // FIXME: implement this
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
275 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
276 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
277 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
278 res = backend.get_screen_resolution ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
279
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
280 double f = 0.0;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
281
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
282 if (from_units.compare ("points"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
283 f = res / 72.0;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
284 else if (from_units.compare ("inches"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
285 f = res;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
286 else if (from_units.compare ("centimeters"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
287 f = res / 2.54;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
288
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
289 if (f > 0)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
290 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
291 retval(0) = pos(0) * f + 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
292 retval(1) = pos(1) * f + 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
293 retval(2) = pos(2) * f;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
294 retval(3) = pos(3) * f;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
295 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
296 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
297
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
298 if (! to_units.compare ("pixels"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
299 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
300 if (to_units.compare ("normalized"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
301 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
302 retval(0) = (retval(0) - 1) / parent_dim(0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
303 retval(1) = (retval(1) - 1) / parent_dim(1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
304 retval(2) /= parent_dim(0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
305 retval(3) /= parent_dim(1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
306 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
307 else if (to_units.compare ("characters"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
308 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
309 // FIXME: implement this
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
310 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
311 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
312 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
313 if (res <= 0)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
314 res = backend.get_screen_resolution ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
315
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
316 double f = 0.0;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
317
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
318 if (to_units.compare ("points"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
319 f = res / 72.0;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
320 else if (to_units.compare ("inches"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
321 f = res;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
322 else if (to_units.compare ("centimeters"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
323 f = res / 2.54;
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 if (f > 0)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
326 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
327 retval(0) = (retval(0) - 1) / f;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
328 retval(1) = (retval(1) - 1) / f;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
329 retval(2) /= f;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
330 retval(3) /= f;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
331 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
332 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
333 }
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 return retval;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
336 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
337
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
338 static graphics_object
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
339 xget_ancestor (graphics_object go, const std::string& type)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
340 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
341 do
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
342 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
343 if (go.valid_object ())
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
344 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
345 if (go.isa (type))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
346 return go;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
347 else
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
348 go = gh_manager::get_object (go.get_parent ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
349 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
350 else
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
351 return graphics_object ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
352 } while (true);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
353 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
354
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
355 static octave_value
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
356 convert_cdata (const base_properties& props, const octave_value& cdata,
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
357 bool is_scaled, int cdim)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
358 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
359 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
360
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
361 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
362 return cdata;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
363
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
364 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
365 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
366
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
367 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
368 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
369
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
370 if (fig.valid_object ())
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
371 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
372 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
373
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
374 if (! error_state)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
375 cmap = _cmap;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
376 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
377
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
378 if (is_scaled)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
379 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
380 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
381
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
382 if (ax.valid_object ())
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
383 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
384 Matrix _clim = ax.get (caseless_str ("clim")).matrix_value ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
385
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
386 if (! error_state)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
387 clim = _clim;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
388 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
389 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
390
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
391 dv.resize (cdim);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
392 dv(cdim-1) = 3;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
393
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
394 NDArray a (dv);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
395
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
396 int lda = static_cast<int> (a.numel () / 3);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
397 int nc = cmap.rows ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
398
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
399 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
400 const double *cmapv = cmap.data ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
401 const double *cv = 0;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
402 const octave_uint8 *icv = 0;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
403
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
404 if (cdata.is_integer_type ())
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
405 icv = cdata.uint8_array_value ().data ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
406 else
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
407 cv = cdata.array_value ().data ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
408
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
409 for (int i = 0; i < lda; i++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
410 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
411 double x = (cv ? cv[i] : double (icv[i]));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
412
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
413 if (is_scaled)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
414 x = xround ((nc - 1) * (x - clim(0)) / (clim(1) - clim(0)));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
415 else
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
416 x = xround (x - 1);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
417
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
418 if (x < 0)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
419 x = 0;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
420 else if (x >= nc)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
421 x = (nc - 1);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
422
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
423 int idx = static_cast<int> (x);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
424
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
425 av[i] = cmapv[idx];
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
426 av[i+lda] = cmapv[idx+nc];
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
427 av[i+2*lda] = cmapv[idx+2*nc];
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
428 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
429
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
430 return octave_value (a);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
431 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
432
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
433 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
434 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
435 get_array_limits (const Array<T>& m, double& emin, double& emax,
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
436 double& eminp)
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
437 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
438 const T *data = m.data ();
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
439 int n = m.numel ();
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
440
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
441 for (int i = 0; i < n; 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
442 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
443 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
444
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
445 if (! (xisinf (e) || xisnan (e)))
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
446 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
447 if (e < emin)
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
448 emin = e;
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
449
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
450 if (e > emax)
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
451 emax = e;
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
452
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
453 if (e >= 0 && e < eminp)
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
454 eminp = e;
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
455 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
456 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
457 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
458
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
459 static bool
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
460 lookup_object_name (const caseless_str& name, caseless_str& go_name,
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
461 caseless_str& rest)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
462 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
463 int len = name.length ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
464 int offset = 0;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
465 bool result = false;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
466
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
467 if (len >= 4)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
468 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
469 caseless_str pfx = name.substr (0, 4);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
470
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
471 if (pfx.compare ("axes") || pfx.compare ("line")
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
472 || pfx.compare ("text"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
473 offset = 4;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
474 else if (len >= 5)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
475 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
476 pfx = name.substr (0, 5);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
477
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
478 if (pfx.compare ("image") || pfx.compare ("patch"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
479 offset = 5;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
480 else if (len >= 6)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
481 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
482 pfx = name.substr (0, 6);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
483
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
484 if (pfx.compare ("figure"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
485 offset = 6;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
486 else if (len >= 7)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
487 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
488 pfx = name.substr (0, 7);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
489
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
490 if (pfx.compare ("surface") || pfx.compare ("hggroup"))
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
491 offset = 7;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
492 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
493 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
494 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
495
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
496 if (offset > 0)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
497 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
498 go_name = pfx;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
499 rest = name.substr (offset);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
500 result = true;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
501 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
502 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
503
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
504 return result;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
505 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
506
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
507 static base_graphics_object*
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
508 make_graphics_object_from_type (const caseless_str& type,
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
509 const graphics_handle& h = graphics_handle (),
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
510 const graphics_handle& p = graphics_handle ())
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
511 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
512 base_graphics_object *go = 0;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
513
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
514 if (type.compare ("figure"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
515 go = new figure (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
516 else if (type.compare ("axes"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
517 go = new axes (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
518 else if (type.compare ("line"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
519 go = new line (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
520 else if (type.compare ("text"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
521 go = new text (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
522 else if (type.compare ("image"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
523 go = new image (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
524 else if (type.compare ("patch"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
525 go = new patch (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
526 else if (type.compare ("surface"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
527 go = new surface (h, p);
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
528 else if (type.compare ("hggroup"))
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
529 go = new hggroup (h, p);
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
530
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
531 return go;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
532 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
533
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
534 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
535
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
536 void
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
537 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
538 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
539 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
540
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
541 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
542 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
543 execute_callback (l(i), parent, octave_value ());
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
544
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
545 if (error_state)
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
546 break;
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
547 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
548 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
549
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
550 radio_values::radio_values (const std::string& opt_string)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
551 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
552 size_t beg = 0;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
553 size_t len = opt_string.length ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
554 bool done = len == 0;
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
555
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
556 while (! done)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
557 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
558 size_t end = opt_string.find ('|', beg);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
559
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
560 if (end == std::string::npos)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
561 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
562 end = len;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
563 done = true;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
564 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
565
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
566 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
567
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
568 // Might want more error checking here...
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
569 if (t[0] == '{')
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
570 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
571 t = t.substr (1, t.length () - 2);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
572 default_val = t;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
573 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
574 else if (beg == 0) // ensure default value
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
575 default_val = t;
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
576
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
577 possible_vals.insert (t);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
578
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
579 beg = end + 1;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
580 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
581 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
582
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
583 bool
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
584 color_values::str2rgb (std::string str)
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
585 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
586 double tmp_rgb[3] = {0, 0, 0};
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
587 bool retval = true;
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
588 unsigned int len = str.length();
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
589
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6898
diff changeset
590 std::transform (str.begin (), str.end (), str.begin (), tolower);
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6898
diff changeset
591
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
592 if (str.compare(0, len, "blue", 0, len) == 0)
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
593 tmp_rgb[2] = 1;
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6898
diff changeset
594 else if (str.compare(0, len, "black", 0, len) == 0 ||
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6898
diff changeset
595 str.compare(0, len, "k", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
596 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
597 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
598 tmp_rgb[0] = 1;
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
599 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
600 tmp_rgb[1] = 1;
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
601 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
602 tmp_rgb[0] = tmp_rgb[1] = 1;
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
603 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
604 tmp_rgb[0] = tmp_rgb[2] = 1;
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
605 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
606 tmp_rgb[1] = tmp_rgb[2] = 1;
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6898
diff changeset
607 else if (str.compare(0, len, "white", 0, len) == 0 ||
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6898
diff changeset
608 str.compare(0, len, "w", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
609 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1;
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
610 else
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
611 retval = false;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
612
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
613 if (retval)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
614 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
615 for (int i = 0; i < 3; i++)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
616 xrgb(i) = tmp_rgb[i];
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
617 }
6563
7a65c1a09ec3 [project @ 2007-04-23 19:26:17 by jwe]
jwe
parents: 6509
diff changeset
618
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
619 return retval;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
620 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
621
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
622 void
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
623 color_property::do_set (const octave_value& val)
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
624 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
625 if (val.is_string ())
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
626 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
627 std::string s = val.string_value ();
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
628
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
629 if (! s.empty ())
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
630 {
6898
f4e1bdb66535 [project @ 2007-09-14 05:20:43 by jwe]
jwe
parents: 6894
diff changeset
631 if (radio_val.contains (s))
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
632 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
633 current_val = s;
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
634 current_type = radio_t;
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
635 }
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
636 else
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
637 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
638 color_values col (s);
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
639 if (! error_state)
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
640 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
641 color_val = col;
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
642 current_type = color_t;
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
643 }
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
644 else
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
645 error ("invalid value for color property \"%s\" (value = %s)",
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
646 get_name ().c_str (), s.c_str ());
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
647 }
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
648 }
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
649 else
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
650 error ("invalid value for color property \"%s\"",
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
651 get_name ().c_str ());
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
652 }
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
653 else if (val.is_real_matrix ())
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
654 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
655 Matrix m = val.matrix_value ();
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
656
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
657 if (m.numel () == 3)
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
658 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
659 color_values col (m (0), m (1), m(2));
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
660 if (! error_state)
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
661 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
662 color_val = col;
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
663 current_type = color_t;
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
664 }
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
665 }
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
666 else
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
667 error ("invalid value for color property \"%s\"",
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
668 get_name ().c_str ());
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
669 }
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
670 else
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
671 error ("invalid value for color property \"%s\"",
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
672 get_name ().c_str ());
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
673 }
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
674
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
675 void
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
676 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
677 {
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
678 if (val.is_string ())
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
679 {
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
680 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
681
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
682 if (! s.empty () && radio_val.contains (s))
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
683 {
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
684 current_val = s;
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
685 current_type = radio_t;
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
686 }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
687 else
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
688 error ("invalid value for double_radio property \"%s\"",
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
689 get_name ().c_str ());
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
690 }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
691 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
692 {
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
693 dval = val.double_value ();
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
694 current_type = double_t;
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
695 }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
696 else
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
697 error ("invalid value for double_radio property \"%s\"",
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
698 get_name ().c_str ());
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
699 }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
700
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
701 bool
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
702 array_property::validate (const octave_value& v)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
703 {
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
704 bool xok = false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
705
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
706 // FIXME: should we always support []?
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
707 if (v.is_empty () && v.is_double_type ())
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
708 return true;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
709
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
710 // check value type
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
711 if (type_constraints.size () > 0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
712 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
713 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
714 ! 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
715 if ((*it) == v.class_name ())
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
716 xok = true;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
717 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
718 else
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
719 xok = v.is_double_type ();
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
720
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
721 if (xok)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
722 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
723 dim_vector vdims = v.dims ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
724 int vlen = vdims.length ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
725
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
726 xok = false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
727
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
728 // check value size
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
729 if (size_constraints.size () > 0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
730 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
731 ! xok && it != size_constraints.end (); ++it)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
732 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
733 dim_vector itdims = (*it);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
734
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
735 if (itdims.length () == vlen)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
736 {
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
737 xok = true;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
738
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
739 for (int i = 0; xok && i < vlen; i++)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
740 if (itdims(i) >= 0 && itdims(i) != vdims(i))
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
741 xok = false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
742 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
743 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
744 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
745 return true;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
746 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
747
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
748 return xok;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
749 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
750
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
751 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
752 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
753 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
754 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
755 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
756
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
757 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
758 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
759 if (data.is_integer_type ())
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
760 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
761 if (data.is_int8_type ())
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
762 get_array_limits (data.int8_array_value (), xmin, xmax, xminp);
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
763 else if (data.is_uint8_type ())
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
764 get_array_limits (data.uint8_array_value (), xmin, xmax, xminp);
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
765 else if (data.is_int16_type ())
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
766 get_array_limits (data.int16_array_value (), xmin, xmax, xminp);
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
767 else if (data.is_uint16_type ())
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
768 get_array_limits (data.uint16_array_value (), xmin, xmax, xminp);
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
769 else if (data.is_int32_type ())
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
770 get_array_limits (data.int32_array_value (), xmin, xmax, xminp);
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
771 else if (data.is_uint32_type ())
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
772 get_array_limits (data.uint32_array_value (), xmin, xmax, xminp);
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
773 else if (data.is_int64_type ())
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
774 get_array_limits (data.int64_array_value (), xmin, xmax, xminp);
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
775 else if (data.is_uint64_type ())
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
776 get_array_limits (data.uint64_array_value (), xmin, xmax, xminp);
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
777 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
778 else
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
779 get_array_limits (data.array_value (), xmin, xmax, xminp);
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
780 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
781 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
782
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
783 void
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
784 handle_property::do_set (const octave_value& v)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
785 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
786 double dv = v.double_value ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
787
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
788 if (! error_state)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
789 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
790 graphics_handle gh = gh_manager::lookup (dv);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
791
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
792 if (xisnan (gh.value ()) || gh.ok ())
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
793 current_val = gh;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
794 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
795 error ("set: invalid graphics handle (= %g) for property \"%s\"",
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
796 dv, get_name ().c_str ());
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
797 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
798 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
799 error ("set: invalid graphics handle for property \"%s\"",
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
800 get_name ().c_str ());
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
801 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
802
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
803 bool
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
804 callback_property::validate (const octave_value& v) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
805 {
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
806 // case 1: function handle
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
807 // 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
808 // case 3: string corresponding to known function name
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
809 // case 4: evaluatable string
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
810 // case 5: empty matrix
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
811
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
812 if (v.is_function_handle ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
813 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
814 else if (v.is_string ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
815 // complete validation will be done at execution-time
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
816 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
817 else if (v.is_cell () && v.length () > 0
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
818 && (v.rows() == 1 || v.columns () == 1)
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
819 && v.cell_value ()(0).is_function_handle ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
820 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
821 else if (v.is_empty ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
822 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
823
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
824 return false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
825 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
826
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
827 void
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
828 callback_property::execute (const octave_value& data) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
829 {
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
830 if (callback.is_defined () && ! callback.is_empty ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
831 execute_callback (callback, get_parent (), data);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
832 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
833
7824
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
834 void
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
835 callback_property::execute (const octave_value& cb, const graphics_handle& h,
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
836 const octave_value& data)
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
837 {
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
838 if (cb.is_defined () && ! cb.is_empty ())
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
839 execute_callback (cb, h, data);
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
840 }
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
841
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
842 // Used to cache dummy graphics objects from which dynamic
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
843 // properties can be cloned.
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
844 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
845
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
846 property
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
847 property::create (const std::string& name, const graphics_handle& h,
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
848 const caseless_str& type, const octave_value_list& args)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
849 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
850 property retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
851
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
852 if (type.compare ("string"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
853 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
854 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
855
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
856 if (! error_state)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
857 retval = property (new string_property (name, h, val));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
858 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
859 else if (type.compare ("any"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
860 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
861 octave_value val =
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
862 (args.length () > 0 ? args(0) : octave_value (Matrix ()));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
863
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
864 retval = property (new any_property (name, h, val));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
865 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
866 else if (type.compare ("radio"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
867 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
868 if (args.length () > 0)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
869 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
870 std::string vals = args(0).string_value ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
871
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
872 if (! error_state)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
873 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
874 retval = property (new radio_property (name, h, vals));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
875
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
876 if (args.length () > 1)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
877 retval.set (args(1));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
878 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
879 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
880 error ("addproperty: invalid argument for radio property, expected a string value");
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
881 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
882 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
883 error ("addproperty: missing possible values for radio property");
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
884 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
885 else if (type.compare ("double"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
886 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
887 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
888
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
889 if (! error_state)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
890 retval = property (new double_property (name, h, d));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
891 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
892 else if (type.compare ("handle"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
893 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
894 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
895
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
896 if (! error_state)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
897 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
898 graphics_handle gh (hh);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
899
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
900 retval = property (new handle_property (name, h, gh));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
901 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
902 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
903 else if (type.compare ("boolean"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
904 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
905 retval = property (new bool_property (name, h, false));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
906
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
907 if (args.length () > 0)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
908 retval.set (args(0));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
909 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
910 else if (type.compare ("data"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
911 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
912 retval = property (new array_property (name, h, Matrix ()));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
913
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
914 if (args.length () > 0)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
915 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
916 retval.set (args(0));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
917
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
918 // FIXME: additional argument could define constraints
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
919 // but is this really useful...?
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
920 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
921 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
922 else if (type.compare ("color"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
923 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
924 color_values cv (0, 0, 0);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
925 radio_values rv;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
926
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
927 if (args.length () > 1)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
928 rv = radio_values (args(1).string_value ());
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
929
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
930 if (! error_state)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
931 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
932 retval = property (new color_property (name, h, cv, rv));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
933
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
934 if (! error_state)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
935 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
936 if (args.length () > 0
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
937 && ! args(0).is_empty ())
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
938 retval.set (args(0));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
939 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
940 retval.set (rv.default_value ());
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
941 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
942 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
943 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
944 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
945 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
946 caseless_str go_name, go_rest;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
947
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
948 if (lookup_object_name (type, go_name, go_rest))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
949 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
950 graphics_object go;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
951
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
952 std::map<caseless_str, graphics_object>::const_iterator it =
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
953 dprop_obj_map.find (go_name);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
954
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
955 if (it == dprop_obj_map.end ())
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
956 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
957 base_graphics_object *bgo =
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
958 make_graphics_object_from_type (go_name);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
959
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
960 if (bgo)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
961 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
962 go = graphics_object (bgo);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
963
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
964 dprop_obj_map[go_name] = go;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
965 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
966 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
967 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
968 go = it->second;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
969
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
970 if (go.valid_object ())
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
971 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
972 property prop = go.get_properties ().get_property (go_rest);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
973
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
974 if (! error_state)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
975 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
976 retval = prop.clone ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
977
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
978 retval.set_parent (h);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
979 retval.set_name (name);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
980
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
981 if (args.length () > 0)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
982 retval.set (args(0));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
983 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
984 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
985 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
986 error ("addproperty: invalid object type (= %s)",
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
987 go_name.c_str ());
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
988 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
989 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
990 error ("addproperty: unsupported type for dynamic property (= %s)",
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
991 type.c_str ());
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
992 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
993
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
994 return retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
995 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
996
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
997 // ---------------------------------------------------------------------
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
998
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
999 void
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1000 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
1001 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1002 size_t offset = 0;
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1003
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1004 size_t len = name.length ();
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1005
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1006 if (len > 4)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1007 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1008 caseless_str pfx = name.substr (0, 4);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1009
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1010 if (pfx.compare ("axes") || pfx.compare ("line")
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1011 || pfx.compare ("text"))
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1012 offset = 4;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1013 else if (len > 5)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1014 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1015 pfx = name.substr (0, 5);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1016
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
1017 if (pfx.compare ("image") || pfx.compare ("patch"))
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1018 offset = 5;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1019 else if (len > 6)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1020 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1021 pfx = name.substr (0, 6);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1022
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1023 if (pfx.compare ("figure"))
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1024 offset = 6;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1025 else if (len > 7)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1026 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1027 pfx = name.substr (0, 7);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1028
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
1029 if (pfx.compare ("surface") || pfx.compare ("hggroup"))
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1030 offset = 7;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1031 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1032 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1033 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1034
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1035 if (offset > 0)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1036 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1037 // FIXME -- should we validate property names and values here?
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1038
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1039 std::string pname = name.substr (offset);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1040
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1041 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1042 std::transform (pname.begin (), pname.end (), pname.begin (), tolower);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1043
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1044 bool remove = false;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1045 if (val.is_string ())
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1046 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1047 caseless_str tval = val.string_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1048
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1049 remove = tval.compare ("remove");
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1050 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1051
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1052 pval_map_type& pval_map = plist_map[pfx];
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1053
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1054 if (remove)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1055 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1056 pval_map_iterator p = pval_map.find (pname);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1057
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1058 if (p != pval_map.end ())
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1059 pval_map.erase (p);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1060 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1061 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1062 pval_map[pname] = val;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1063 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1064 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1065
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1066 if (offset == 0)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1067 error ("invalid default property specification");
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1068 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1069
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1070 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1071 property_list::lookup (const caseless_str& name) const
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1072 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1073 octave_value retval;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1074
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1075 size_t offset = 0;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1076
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1077 size_t len = name.length ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1078
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1079 if (len > 4)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1080 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1081 caseless_str pfx = name.substr (0, 4);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1082
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1083 if (pfx.compare ("axes") || pfx.compare ("line")
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1084 || pfx.compare ("text"))
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1085 offset = 4;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1086 else if (len > 5)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1087 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1088 pfx = name.substr (0, 5);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1089
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
1090 if (pfx.compare ("image") || pfx.compare ("patch"))
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1091 offset = 5;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1092 else if (len > 6)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1093 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1094 pfx = name.substr (0, 6);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1095
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1096 if (pfx.compare ("figure"))
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1097 offset = 6;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1098 else if (len > 7)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1099 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1100 pfx = name.substr (0, 7);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1101
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
1102 if (pfx.compare ("surface") || pfx.compare ("hggroup"))
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1103 offset = 7;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1104 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1105 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1106 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1107
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1108 if (offset > 0)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1109 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1110 std::string pname = name.substr (offset);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1111
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1112 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1113 std::transform (pname.begin (), pname.end (), pname.begin (), tolower);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1114
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1115 plist_map_const_iterator p = find (pfx);
6432
5bec61ae1576 [project @ 2007-03-23 02:19:10 by jwe]
jwe
parents: 6425
diff changeset
1116
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1117 if (p != end ())
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1118 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1119 const pval_map_type& pval_map = p->second;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1120
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1121 pval_map_const_iterator q = pval_map.find (pname);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1122
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1123 if (q != pval_map.end ())
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1124 retval = q->second;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1125 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1126 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1127 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1128
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1129 return retval;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1130 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1131
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1132 Octave_map
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1133 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
1134 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1135 Octave_map m;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1136
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1137 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
1138 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1139 std::string prefix = prefix_arg + p->first;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1140
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1141 const pval_map_type pval_map = p->second;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1142
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1143 for (pval_map_const_iterator q = pval_map.begin ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1144 q != pval_map.end ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1145 q++)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1146 m.assign (prefix + q->first, q->second);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1147 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1148
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1149 return m;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1150 }
6432
5bec61ae1576 [project @ 2007-03-23 02:19:10 by jwe]
jwe
parents: 6425
diff changeset
1151
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1152 graphics_handle::graphics_handle (const octave_value& a)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1153 : val (octave_NaN)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1154 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1155 if (a.is_empty ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1156 /* do nothing */;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1157 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1158 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1159 double tval = a.double_value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1160
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1161 if (! error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1162 val = tval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1163 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1164 error ("invalid graphics handle");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1165 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1166 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1167
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1168 void
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1169 graphics_object::set (const octave_value_list& args)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1170 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1171 int nargin = args.length ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1172
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1173 if (nargin == 0)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1174 rep->defaults ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1175 else if (nargin % 2 == 0)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1176 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1177 for (int i = 0; i < nargin; i += 2)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1178 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1179 caseless_str name = args(i).string_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1180
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1181 if (! error_state)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1182 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1183 octave_value val = args(i+1);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1184
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1185 if (val.is_string ())
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1186 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1187 caseless_str tval = val.string_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1188
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1189 if (tval.compare ("default"))
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1190 val = get_default (name);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1191 else if (tval.compare ("factory"))
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1192 val = get_factory_default (name);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1193 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1194
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1195 if (error_state)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1196 break;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1197
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1198 rep->set (name, val);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1199 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1200 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1201 error ("set: expecting argument %d to be a property name", i);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1202 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1203 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1204 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1205 error ("set: invalid number of arguments");
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1206 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1207
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1208
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1209 graphics_handle
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1210 gh_manager::get_handle (const std::string& go_name)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1211 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1212 graphics_handle retval;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1213
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1214 if (go_name == "figure")
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1215 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1216 // We always want the lowest unused figure number.
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1217
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1218 retval = 1;
6425
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
1219
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1220 while (handle_map.find (retval) != handle_map.end ())
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1221 retval++;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1222 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1223 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1224 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1225 free_list_iterator p = handle_free_list.begin ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1226
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1227 if (p != handle_free_list.end ())
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1228 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1229 retval = *p;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1230 handle_free_list.erase (p);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1231 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1232 else
7286
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
1233 {
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
1234 static double maxrand = RAND_MAX + 2.0;
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
1235
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
1236 retval = graphics_handle (next_handle);
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
1237
7304
ad066356989b [project @ 2007-12-12 16:41:09 by jwe]
jwe
parents: 7296
diff changeset
1238 next_handle = ceil (next_handle) - 1.0 - (rand () + 1.0) / maxrand;
7286
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
1239 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1240 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1241
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1242 return retval;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1243 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1244
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1245 void
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1246 gh_manager::do_free (const graphics_handle& h)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1247 {
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1248 if (h.ok ())
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1249 {
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1250 if (h.value () != 0)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1251 {
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1252 iterator p = handle_map.find (h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1253
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1254 if (p != handle_map.end ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1255 {
7403
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7379
diff changeset
1256 p->second.get_properties ().set_beingdeleted (true);
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7379
diff changeset
1257 p->second.get_properties ().execute_deletefcn ();
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1258
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1259 handle_map.erase (p);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1260
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1261 if (h.value () < 0)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1262 handle_free_list.insert (h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1263 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1264 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1265 error ("graphics_handle::free: invalid object %g", h.value ());
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1266 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1267 else
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1268 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
1269 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1270 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1271
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1272 gh_manager *gh_manager::instance = 0;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1273
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1274 static void
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1275 xset (const graphics_handle& h, const caseless_str& name,
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1276 const octave_value& val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1277 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1278 graphics_object obj = gh_manager::get_object (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1279 obj.set (name, val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1280 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1281
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1282 static void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1283 xset (const graphics_handle& h, const octave_value_list& args)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1284 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1285 if (args.length () > 0)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1286 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1287 graphics_object obj = gh_manager::get_object (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1288 obj.set (args);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1289 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1290 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1291
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1292
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1293 static octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1294 xget (const graphics_handle& h, const caseless_str& name)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1295 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1296 graphics_object obj = gh_manager::get_object (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1297 return obj.get (name);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1298 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1299
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1300 static graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1301 reparent (const octave_value& ov, const std::string& who,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1302 const std::string& property, const graphics_handle& new_parent,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1303 bool adopt = true)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1304 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1305 graphics_handle h = octave_NaN;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1306
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1307 double val = ov.double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1308
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1309 if (! error_state)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1310 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1311 h = gh_manager::lookup (val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1312
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1313 if (h.ok ())
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1314 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1315 graphics_object obj = gh_manager::get_object (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1316
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1317 graphics_handle parent_h = obj.get_parent ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1318
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1319 graphics_object parent_obj = gh_manager::get_object (parent_h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1320
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1321 parent_obj.remove_child (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1322
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1323 if (adopt)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1324 obj.set ("parent", new_parent.value ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1325 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1326 obj.reparent (new_parent);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1327 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1328 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1329 error ("%s: invalid graphics handle (= %g) for %s",
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1330 who.c_str (), val, property.c_str ());
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1331 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1332 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1333 error ("%s: expecting %s to be a graphics handle",
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1334 who.c_str (), property.c_str ());
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1335
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1336 return h;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1337 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1338
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1339 // 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
1340 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1341 gcf (void)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1342 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1343 octave_value val = xget (0, "currentfigure");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1344
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1345 return val.is_empty () ? octave_NaN : val.double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1346 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1347
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1348 // 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
1349 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1350 gca (void)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1351 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1352 octave_value val = xget (gcf (), "currentaxes");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1353
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1354 return val.is_empty () ? octave_NaN : val.double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1355 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1356
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1357 static void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1358 adopt (const graphics_handle& p, const graphics_handle& h)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1359 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1360 graphics_object parent_obj = gh_manager::get_object (p);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1361
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1362 parent_obj.adopt (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1363 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1364
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1365 static bool
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1366 is_handle (const graphics_handle& h)
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1367 {
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1368 return h.ok ();
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1369 }
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1370
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1371 static bool
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1372 is_handle (double val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1373 {
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1374 graphics_handle h = gh_manager::lookup (val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1375
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1376 return h.ok ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1377 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1378
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1379 static bool
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1380 is_handle (const octave_value& val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1381 {
7142
121841c08c25 [project @ 2007-11-09 16:59:43 by jwe]
jwe
parents: 7108
diff changeset
1382 return val.is_real_scalar () && is_handle (val.double_value ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1383 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1384
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1385 static bool
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1386 is_figure (double val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1387 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1388 graphics_object obj = gh_manager::get_object (val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1389
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1390 return obj && obj.isa ("figure");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1391 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1392
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
1393 static void
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
1394 xcreatefcn (const graphics_handle& h)
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
1395 {
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
1396 graphics_object obj = gh_manager::get_object (h);
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
1397 obj.get_properties ().execute_createfcn ();
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
1398 }
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
1399
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1400 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1401
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1402 static int
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1403 compare (const void *a_arg, const void *b_arg)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1404 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1405 double a = *(static_cast<const double *> (a_arg));
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1406 double b = *(static_cast<const double *> (b_arg));
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1407
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1408 return a > b ? 1 : (a < b) ? -1 : 0;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1409 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1410
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1411 static Matrix
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1412 maybe_set_children (const Matrix& kids, const octave_value& val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1413 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1414 const Matrix new_kids = val.matrix_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1415
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1416 bool ok = true;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1417
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1418 if (! error_state)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1419 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1420 if (kids.numel () == new_kids.numel ())
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1421 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1422 Matrix t1 = kids;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1423 Matrix t2 = new_kids;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1424
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1425 t1.qsort (compare);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1426 t2.qsort (compare);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1427
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1428 if (t1 != t2)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1429 ok = false;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1430 } else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1431 ok = false;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1432
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1433 if (! ok)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1434 error ("set: new children must be a permutation of existing children");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1435 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1436 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1437 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1438 ok = false;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1439 error ("set: expecting children to be array of graphics handles");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1440 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1441
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1442 return ok ? new_kids : kids;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1443 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1444
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1445 void
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1446 base_properties::set_from_list (base_graphics_object& obj,
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1447 property_list& defaults)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1448 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1449 std::string go_name = graphics_object_name ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1450
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1451 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
1452
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1453 if (p != defaults.end ())
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1454 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1455 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
1456
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1457 for (property_list::pval_map_const_iterator q = pval_map.begin ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1458 q != pval_map.end ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1459 q++)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1460 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1461 std::string pname = q->first;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1462
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1463 obj.set (pname, q->second);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1464
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1465 if (error_state)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1466 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1467 error ("error setting default property %s", pname.c_str ());
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1468 break;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1469 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1470 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1471 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1472 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1473
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1474 octave_value
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1475 base_properties::get (const caseless_str& name) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1476 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1477 octave_value retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1478
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1479 if (name.compare ("tag"))
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1480 retval = get_tag ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1481 else if (name.compare ("type"))
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1482 retval = get_type ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1483 else if (name.compare ("__modified__"))
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1484 retval = is_modified ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1485 else if (name.compare ("parent"))
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1486 retval = get_parent ().as_octave_value ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1487 else if (name.compare ("children"))
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1488 retval = children;
7366
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1489 else if (name.compare ("busyaction"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1490 retval = get_busyaction ();
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1491 else if (name.compare ("buttondownfcn"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1492 retval = get_buttondownfcn ();
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1493 else if (name.compare ("clipping"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1494 retval = get_clipping ();
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1495 else if (name.compare ("createfcn"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1496 retval = get_createfcn ();
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1497 else if (name.compare ("deletefcn"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1498 retval = get_deletefcn ();
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1499 else if (name.compare ("handlevisibility"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1500 retval = get_handlevisibility ();
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1501 else if (name.compare ("hittest"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1502 retval = get_hittest ();
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1503 else if (name.compare ("interruptible"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1504 retval = get_interruptible ();
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1505 else if (name.compare ("selected"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1506 retval = get_selected ();
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1507 else if (name.compare ("selectionhighlight"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1508 retval = get_selectionhighlight ();
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1509 else if (name.compare ("uicontextmenu"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1510 retval = get_uicontextmenu ();
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1511 else if (name.compare ("userdata"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1512 retval = get_userdata ();
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1513 else if (name.compare ("visible"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1514 retval = get_visible ();
7403
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7379
diff changeset
1515 else if (name.compare ("beingdeleted"))
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7379
diff changeset
1516 retval = get_beingdeleted ();
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1517 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1518 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1519 std::map<caseless_str, property>::const_iterator it = all_props.find (name);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1520
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1521 if (it != all_props.end ())
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1522 retval = it->second.get ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1523 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1524 error ("get: unknown property \"%s\"", name.c_str ());
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1525 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1526
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1527 return retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1528 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1529
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1530 octave_value
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
1531 base_properties::get (bool all) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1532 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1533 Octave_map m;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1534
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1535 for (std::map<caseless_str, property>::const_iterator it = all_props.begin ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1536 it != all_props.end (); ++it)
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
1537 if (all || ! it->second.is_hidden ())
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
1538 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
1539
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1540 m.assign ("tag", get_tag ());
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1541 m.assign ("type", get_type ());
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
1542 if (all)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
1543 m.assign ("__modified__", is_modified ());
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1544 m.assign ("parent", get_parent ().as_octave_value ());
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1545 m.assign ("children", children);
7366
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1546 m.assign ("busyaction", get_busyaction ());
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1547 m.assign ("buttondownfcn", get_buttondownfcn ());
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1548 m.assign ("clipping", get_clipping ());
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1549 m.assign ("createfcn", get_createfcn ());
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1550 m.assign ("deletefcn", get_deletefcn ());
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1551 m.assign ("handlevisibility", get_handlevisibility ());
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1552 m.assign ("hittest", get_hittest ());
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1553 m.assign ("interruptible", get_interruptible ());
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1554 m.assign ("selected", get_selected ());
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1555 m.assign ("selectionhighlight", get_selectionhighlight ());
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1556 m.assign ("uicontextmenu", get_uicontextmenu ());
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1557 m.assign ("userdata", get_userdata ());
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1558 m.assign ("visible", get_visible ());
7403
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7379
diff changeset
1559 m.assign ("beingdeleted", get_beingdeleted ());
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1560
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1561 return m;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1562 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1563
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1564 void
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1565 base_properties::set (const caseless_str& name, const octave_value& val)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1566 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1567 if (name.compare ("tag"))
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1568 set_tag (val);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1569 else if (name.compare ("__modified__"))
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1570 __modified__ = val;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1571 else if (name.compare ("parent"))
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1572 set_parent (val);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1573 else if (name.compare ("children"))
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1574 maybe_set_children (children, val);
7366
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1575 else if (name.compare ("busyaction"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1576 set_busyaction (val);
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1577 else if (name.compare ("buttondownfcn"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1578 set_buttondownfcn (val);
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1579 else if (name.compare ("clipping"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1580 set_clipping (val);
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1581 else if (name.compare ("createfcn"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1582 set_createfcn (val);
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1583 else if (name.compare ("deletefcn"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1584 set_deletefcn (val);
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1585 else if (name.compare ("handlevisibility"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1586 set_handlevisibility (val);
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1587 else if (name.compare ("hittest"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1588 set_hittest (val);
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1589 else if (name.compare ("interruptible"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1590 set_interruptible (val);
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1591 else if (name.compare ("selected"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1592 set_selected (val);
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1593 else if (name.compare ("selectionhighlight"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1594 set_selectionhighlight (val);
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1595 else if (name.compare ("uicontextmenu"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1596 set_uicontextmenu (val);
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1597 else if (name.compare ("userdata"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1598 set_userdata (val);
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1599 else if (name.compare ("visible"))
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7364
diff changeset
1600 set_visible (val);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1601 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1602 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1603 std::map<caseless_str, property>::iterator it = all_props.find (name);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1604
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1605 if (it != all_props.end ())
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1606 it->second.set (val);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1607 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1608 error ("set: unknown property \"%s\"", name.c_str ());
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1609 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1610
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1611 if (! error_state && ! name.compare ("__modified__"))
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1612 mark_modified ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1613 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1614
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1615 property
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1616 base_properties::get_property (const caseless_str& name)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1617 {
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1618 if (name.compare ("beingdeleted"))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1619 return property (&beingdeleted, true);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1620 else if (name.compare ("busyaction"))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1621 return property (&busyaction, true);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1622 else if (name.compare ("buttondownfcn"))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1623 return property (&buttondownfcn, true);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1624 else if (name.compare ("clipping"))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1625 return property (&clipping, true);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1626 else if (name.compare ("createfcn"))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1627 return property (&createfcn, true);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1628 else if (name.compare ("deletefcn"))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1629 return property (&deletefcn, true);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1630 else if (name.compare ("handlevisibility"))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1631 return property (&handlevisibility, true);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1632 else if (name.compare ("hittest"))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1633 return property (&hittest, true);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1634 else if (name.compare ("interruptible"))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1635 return property (&interruptible, true);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1636 else if (name.compare ("parent"))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1637 return property (&parent, true);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1638 else if (name.compare ("selected"))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1639 return property (&selected, true);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1640 else if (name.compare ("selectionhighlight"))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1641 return property (&selectionhighlight, true);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1642 else if (name.compare ("tag"))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1643 return property (&tag, true);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1644 else if (name.compare ("type"))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1645 return property (&userdata, true);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1646 else if (name.compare ("userdata"))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1647 return property (&visible, true);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1648 else if (name.compare ("visible"))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1649 return property (&visible, true);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1650 else if (name.compare ("__modified__"))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1651 return property (&__modified__, true);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1652 else
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1653 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1654 std::map<caseless_str, property>::const_iterator it = all_props.find (name);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1655
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1656 if (it == all_props.end ())
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1657 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1658 error ("get_property: unknown property \"%s\"", name.c_str ());
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1659 return property ();
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1660 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1661 else
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1662 return it->second;
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1663 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1664 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1665
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1666 bool
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1667 base_properties::has_property (const caseless_str& name)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1668 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1669 property p;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1670
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1671 unwind_protect::begin_frame("base_properties::has_property");
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1672
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1673 unwind_protect_bool (discard_error_messages);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1674 unwind_protect_int (error_state);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1675
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1676 discard_error_messages = true;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1677
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1678 p = get_property (name);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1679
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1680 unwind_protect::run_frame ("base_properties::has_property");
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1681
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1682 return (p.ok ());
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1683 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1684
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1685 void
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1686 base_properties::remove_child (const graphics_handle& h)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1687 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1688 octave_idx_type k = -1;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1689 octave_idx_type n = children.numel ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1690 for (octave_idx_type i = 0; i < n; i++)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1691 {
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1692 if (h.value () == children(i))
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1693 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1694 k = i;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1695 break;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1696 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1697 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1698
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1699 if (k >= 0)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1700 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1701 Matrix new_kids (1, n-1);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1702 octave_idx_type j = 0;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1703 for (octave_idx_type i = 0; i < n; i++)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1704 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1705 if (i != k)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1706 new_kids(j++) = children(i);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1707 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1708 children = new_kids;
7378
3771971e8891 [project @ 2008-01-15 07:40:23 by jwe]
jwe
parents: 7373
diff changeset
1709 mark_modified ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1710 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1711 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1712
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1713 void
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1714 base_properties::set_parent (const octave_value& val)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1715 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1716 double tmp = val.double_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1717
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1718 graphics_handle new_parent = octave_NaN;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1719
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1720 if (! error_state)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1721 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1722 new_parent = gh_manager::lookup (tmp);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1723
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1724 if (new_parent.ok ())
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1725 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1726 graphics_object parent_obj = gh_manager::get_object (get_parent ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1727
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1728 parent_obj.remove_child (__myhandle__);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1729
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1730 parent = new_parent.as_octave_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1731
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1732 ::adopt (parent.handle_value (), __myhandle__);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1733 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1734 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1735 error ("set: invalid graphics handle (= %g) for parent", tmp);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1736 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1737 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1738 error ("set: expecting parent to be a graphics handle");
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1739 }
6432
5bec61ae1576 [project @ 2007-03-23 02:19:10 by jwe]
jwe
parents: 6425
diff changeset
1740
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1741 void
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1742 base_properties::mark_modified (void)
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1743 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1744 __modified__ = "on";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1745 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
1746 if (parent_obj)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
1747 parent_obj.mark_modified ();
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1748 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1749
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1750 void
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1751 base_properties::override_defaults (base_graphics_object& obj)
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1752 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1753 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
1754
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1755 if (parent_obj)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1756 parent_obj.override_defaults (obj);
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1757 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1758
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1759 void
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
1760 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
1761 {
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1762 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
1763
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1764 if (obj)
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
1765 obj.update_axis_limits (axis_type);
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
1766 }
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
1767
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
1768 void
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1769 base_properties::delete_children (void)
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1770 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1771 octave_idx_type n = children.numel ();
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1772
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1773 for (octave_idx_type i = 0; i < n; i++)
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1774 gh_manager::free (children(i));
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1775 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1776
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
1777 graphics_backend
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
1778 base_properties::get_backend (void) const
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
1779 {
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
1780 graphics_object go = gh_manager::get_object (get_parent ());
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
1781
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
1782 if (go)
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
1783 return go.get_backend ();
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
1784 else
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
1785 return graphics_backend ();
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
1786 }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
1787
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
1788 void
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
1789 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
1790 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
1791 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
1792
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
1793 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
1794 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
1795 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
1796
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
1797 if (go.valid_object ())
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
1798 go.get_properties ().update_boundingbox ();
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
1799 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
1800 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
1801
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1802 void
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1803 base_properties::add_listener (const caseless_str& nm, const octave_value& v,
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1804 listener_mode mode)
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1805 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1806 property p = get_property (nm);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1807
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1808 if (! error_state && p.ok ())
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1809 p.add_listener (v, mode);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1810 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1811
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1812 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1813
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1814 class gnuplot_backend : public base_graphics_backend
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1815 {
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1816 public:
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1817 gnuplot_backend (void)
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1818 : base_graphics_backend ("gnuplot") { }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1819
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1820 ~gnuplot_backend (void) { }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1821
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1822 bool is_valid (void) const { return true; }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1823
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1824 void close_figure (const octave_value& pstream) const
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1825 {
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1826 if (! pstream.is_empty())
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1827 {
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1828 octave_value_list args;
7680
a0ec02774303 Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents: 7527
diff changeset
1829 Matrix fids = pstream.matrix_value ();
a0ec02774303 Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents: 7527
diff changeset
1830
a0ec02774303 Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents: 7527
diff changeset
1831 if (! error_state)
a0ec02774303 Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents: 7527
diff changeset
1832 {
a0ec02774303 Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents: 7527
diff changeset
1833 args(1) = "\nquit;\n";
a0ec02774303 Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents: 7527
diff changeset
1834 args(0) = octave_value (fids (0));
a0ec02774303 Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents: 7527
diff changeset
1835 feval ("fputs", args);
a0ec02774303 Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents: 7527
diff changeset
1836 args.resize (1);
a0ec02774303 Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents: 7527
diff changeset
1837 feval ("fflush", args);
a0ec02774303 Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents: 7527
diff changeset
1838 feval ("pclose", args);
a0ec02774303 Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents: 7527
diff changeset
1839 if (fids.numel () > 1)
a0ec02774303 Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents: 7527
diff changeset
1840 {
a0ec02774303 Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents: 7527
diff changeset
1841 args(0) = octave_value (fids (1));
a0ec02774303 Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents: 7527
diff changeset
1842 feval ("pclose", args);
a0ec02774303 Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents: 7527
diff changeset
1843 }
a0ec02774303 Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents: 7527
diff changeset
1844 }
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1845 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1846 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1847
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1848 void redraw_figure (const graphics_handle& fh) const
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1849 {
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1850 octave_value_list args;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1851 args(0) = fh.as_octave_value ();
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1852 feval ("gnuplot_drawnow", args);
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1853 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1854
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1855 void print_figure (const graphics_handle& fh, const std::string& term,
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1856 const std::string& file, bool mono,
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1857 const std::string& debug_file) const
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1858 {
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1859 octave_value_list args;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1860 if (! debug_file.empty ())
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1861 args(4) = debug_file;
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
1862 args(3) = mono;
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
1863 args(2) = file;
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
1864 args(1) = term;
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
1865 args(0) = fh.as_octave_value ();
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1866 feval ("gnuplot_drawnow", args);
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1867 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1868
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
1869 Matrix get_canvas_size (const graphics_handle&) const
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
1870 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
1871 Matrix sz (1, 2, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
1872 return sz;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
1873 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
1874
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
1875 double get_screen_resolution (void) const
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
1876 { return 72.0; }
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
1877
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
1878 Matrix get_screen_size (void) const
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
1879 { return Matrix (1, 2, 0.0); }
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1880 };
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1881
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1882 graphics_backend
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1883 graphics_backend::default_backend (void)
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1884 {
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1885 if (available_backends.size () == 0)
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1886 register_backend (new gnuplot_backend ());
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1887
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1888 return available_backends["gnuplot"];
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1889 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1890
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1891 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
1892
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1893 // ---------------------------------------------------------------------
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1894
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1895 void
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1896 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
1897 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1898 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
1899 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1900 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
1901
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1902 if (parent_obj)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1903 parent_obj.update_axis_limits (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
1904 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1905 else
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1906 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
1907 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1908
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1909 // ---------------------------------------------------------------------
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1910
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1911 #include "graphics-props.cc"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1912
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1913 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1914
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
1915 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1916 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
1917 {
7378
3771971e8891 [project @ 2008-01-15 07:40:23 by jwe]
jwe
parents: 7373
diff changeset
1918 graphics_handle val (v);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1919
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1920 if (error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1921 return;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1922
7059
8d57f66e35b8 [project @ 2007-10-24 17:16:23 by jwe]
jwe
parents: 7056
diff changeset
1923 if (xisnan (val.value ()) || is_handle (val))
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1924 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1925 currentfigure = val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1926
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1927 gh_manager::push_figure (val);
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1928 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1929 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1930 gripe_set_invalid ("currentfigure");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1931 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1932
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1933 void
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1934 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
1935 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1936 graphics_handle val (v);
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1937
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1938 if (error_state)
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1939 return;
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1940
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1941 if (xisnan (val.value ()))
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1942 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1943 if (! cbo_stack.empty ())
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1944 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1945 val = cbo_stack.front ();
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1946
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1947 cbo_stack.pop_front ();
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1948 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1949
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1950 callbackobject = val;
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1951 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1952 else if (is_handle (val))
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1953 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1954 if (get_callbackobject ().ok ())
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1955 cbo_stack.push_front (get_callbackobject ());
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1956
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1957 callbackobject = val;
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1958 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1959 else
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1960 gripe_set_invalid ("callbackobject");
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1961 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
1962
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1963 property_list
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1964 root_figure::factory_properties = root_figure::init_factory_properties ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1965
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1966 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1967
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1968 void
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1969 figure::properties::set_currentaxes (const octave_value& v)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1970 {
7378
3771971e8891 [project @ 2008-01-15 07:40:23 by jwe]
jwe
parents: 7373
diff changeset
1971 graphics_handle val (v);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1972
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1973 if (error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1974 return;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1975
7070
7593f8e83a2e [project @ 2007-10-25 20:41:16 by jwe]
jwe
parents: 7059
diff changeset
1976 if (xisnan (val.value ()) || is_handle (val))
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1977 currentaxes = val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1978 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1979 gripe_set_invalid ("currentaxes");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1980 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1981
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1982 void
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1983 figure::properties::set_visible (const octave_value& val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1984 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1985 std::string s = val.string_value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1986
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1987 if (! error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1988 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1989 if (s == "on")
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1990 xset (0, "currentfigure", __myhandle__.value ());
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1991
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1992 visible = val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1993 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1994 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1995
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1996 void
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1997 figure::properties::close (bool pop)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1998 {
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
1999 if (backend)
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2000 backend.close_figure (get___plot_stream__ ());
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2001
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2002 if (pop)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2003 {
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2004 gh_manager::pop_figure (__myhandle__);
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2005
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2006 graphics_handle cf = gh_manager::current_figure ();
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2007
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2008 xset (0, "currentfigure", cf.value ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2009 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2010 }
6432
5bec61ae1576 [project @ 2007-03-23 02:19:10 by jwe]
jwe
parents: 6425
diff changeset
2011
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2012 Matrix
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2013 figure::properties::get_boundingbox (bool) const
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2014 {
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2015 graphics_backend b = get_backend ();
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2016 // FIXME: screen size should be obtained from root object
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2017 Matrix screen_size = b.get_screen_size ();
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2018 Matrix pos;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2019
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2020 pos = convert_position (get_position ().matrix_value (), get_units (),
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2021 "pixels", screen_size, b);
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2022
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2023 pos(0)--;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2024 pos(1)--;
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2025 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
2026
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2027 return pos;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2028 }
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2029
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2030 void
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2031 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
2032 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2033 graphics_backend b = get_backend ();
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2034 // FIXME: screen size should be obtained from root object
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2035 Matrix screen_size = b.get_screen_size ();
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2036 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
2037
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2038 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
2039 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
2040 pos(0)++;
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2041 pos = convert_position (pos, "pixels", get_units (), screen_size, b);
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2042
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2043 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
2044 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2045
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2046 void
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2047 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
2048 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2049 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
2050 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2051 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
2052
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2053 old_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
2054 position = v;
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2055 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
2056
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2057 if (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
2058 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2059 // FIXME: maybe this should be converted into a more generic
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2060 // call like "update_gui (this)"
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2061 get_backend ().set_figure_position (__myhandle__, 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
2062 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2063 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2064 execute_resizefcn ();
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2065 update_boundingbox ();
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2066 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2067 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2068
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2069 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
2070 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2071 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2072
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2073 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2074 figure::get_default (const caseless_str& name) const
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2075 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2076 octave_value retval = default_properties.lookup (name);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2077
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2078 if (retval.is_undefined ())
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2079 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2080 graphics_handle parent = get_parent ();
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2081 graphics_object parent_obj = gh_manager::get_object (parent);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2082
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2083 retval = parent_obj.get_default (name);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2084 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2085
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2086 return retval;
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2087 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2088
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2089 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2090
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
2091 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
2092 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
2093 {
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
2094 // FIXME -- this should take font metrics into consideration,
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
2095 // for now we'll just make it position 90% of 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
2096 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
2097 {
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
2098 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
2099 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
2100 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
2101 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
2102 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
2103 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
2104 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
2105 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
2106 }
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
2107 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
2108 {
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
2109 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
2110 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
2111 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
2112 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
2113 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
2114 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
2115 }
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
2116
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
2117 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
2118 }
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
2119
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2120 void
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2121 axes::properties::set_title (const octave_value& v)
6962
9ac23c7f1c37 [project @ 2007-10-05 20:52:19 by jwe]
jwe
parents: 6945
diff changeset
2122 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2123 graphics_handle val = ::reparent (v, "set", "title", __myhandle__, false);
6962
9ac23c7f1c37 [project @ 2007-10-05 20:52:19 by jwe]
jwe
parents: 6945
diff changeset
2124
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2125 if (! error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2126 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2127 gh_manager::free (title.handle_value ());
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2128 title = val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2129 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2130 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2131
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2132 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2133 axes::properties::set_xlabel (const octave_value& v)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2134 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2135 graphics_handle val = ::reparent (v, "set", "xlabel", __myhandle__, false);
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2136
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2137 if (! error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2138 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2139 gh_manager::free (xlabel.handle_value ());
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2140 xlabel = val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2141 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2142 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2143
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2144 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2145 axes::properties::set_ylabel (const octave_value& v)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2146 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2147 graphics_handle val = ::reparent (v, "set", "ylabel", __myhandle__, false);
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2148
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2149 if (! error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2150 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2151 gh_manager::free (ylabel.handle_value ());
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2152 ylabel = val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2153 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2154 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2155
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2156 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2157 axes::properties::set_zlabel (const octave_value& v)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2158 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2159 graphics_handle val = ::reparent (v, "set", "zlabel", __myhandle__, false);
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2160
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2161 if (! error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2162 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2163 gh_manager::free (zlabel.handle_value ());
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2164 zlabel = val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2165 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2166 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2167
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2168 void
6844
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
2169 axes::properties::set_defaults (base_graphics_object& obj,
6890
b2b7526a5772 [project @ 2007-09-12 20:14:35 by jwe]
jwe
parents: 6874
diff changeset
2170 const std::string& mode)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2171 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2172 title = graphics_handle ();
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2173 box = "on";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2174 key = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2175 keybox = "off";
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2176 keypos = 1.0;
6962
9ac23c7f1c37 [project @ 2007-10-05 20:52:19 by jwe]
jwe
parents: 6945
diff changeset
2177 colororder = default_colororder ();
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2178 dataaspectratio = Matrix (1, 3, 1.0);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2179 dataaspectratiomode = "auto";
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2180 layer = "bottom";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2181
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2182 Matrix tlim (1, 2, 0.0);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2183 tlim(1) = 1;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2184 xlim = tlim;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2185 ylim = tlim;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2186 zlim = tlim;
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
2187
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
2188 Matrix cl (1, 2, 0);
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
2189 cl(1) = 1;
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
2190 clim = cl;
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
2191
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2192 xlimmode = "auto";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2193 ylimmode = "auto";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2194 zlimmode = "auto";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2195 climmode = "auto";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2196 xlabel = graphics_handle ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2197 ylabel = graphics_handle ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2198 zlabel = graphics_handle ();
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2199 xgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2200 ygrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2201 zgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2202 xminorgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2203 yminorgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2204 zminorgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2205 xtick = Matrix ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2206 ytick = Matrix ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2207 ztick = Matrix ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2208 xtickmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2209 ytickmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2210 ztickmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2211 xticklabel = "";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2212 yticklabel = "";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2213 zticklabel = "";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2214 xticklabelmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2215 yticklabelmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2216 zticklabelmode = "auto";
7453
b1cfd33a364b [project @ 2008-02-06 10:46:10 by jwe]
jwe
parents: 7447
diff changeset
2217 color = color_values (1, 1, 1);
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
2218 xcolor = color_values ("black");
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
2219 ycolor = color_values ("black");
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
2220 zcolor = color_values ("black");
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2221 xscale = "linear";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2222 yscale = "linear";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2223 zscale = "linear";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2224 xdir = "normal";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2225 ydir = "normal";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2226 zdir = "normal";
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2227 yaxislocation = "left";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2228 xaxislocation = "bottom";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2229
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2230 // Note: camera properties will be set through update_transform
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2231 camerapositionmode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2232 cameratargetmode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2233 cameraupvectormode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2234 cameraviewanglemode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2235 plotboxaspectratio = Matrix (1, 3, 1.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2236 drawmode = "normal";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2237 fontangle = "normal";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2238 fontname = "Helvetica";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2239 fontsize = 12;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2240 fontunits = "points";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2241 fontweight = "normal";
7820
cb4838d70ab2 Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7680
diff changeset
2242 gridlinestyle = ":";
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2243 linestyleorder = "-";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2244 linewidth = 0.5;
7820
cb4838d70ab2 Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7680
diff changeset
2245 minorgridlinestyle = ":";
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2246 // Note: plotboxaspectratio will be set through update_aspectratiors
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2247 plotboxaspectratiomode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2248 projection = "orthographic";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2249 tickdir = "in";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2250 tickdirmode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2251 ticklength = Matrix (1, 2, 0.1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2252 tightinset = Matrix (1, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2253
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2254 sx = "linear";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2255 sy = "linear";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2256 sz = "linear";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2257
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2258 Matrix tview (1, 2, 0.0);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2259 tview(1) = 90;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2260 view = tview;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2261
6765
e6b528a3a2a9 [project @ 2007-06-28 15:25:43 by jwe]
jwe
parents: 6761
diff changeset
2262 visible = "on";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2263 nextplot = "replace";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2264
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2265 // FIXME -- this is not quite right; we should preserve
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2266 // "position" and "units".
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2267
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2268 if (mode != "replace")
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2269 {
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2270 Matrix touterposition (1, 4, 0.0);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2271 touterposition(2) = 1;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2272 touterposition(3) = 1;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2273 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
2274
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
2275 position = default_axes_position ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2276 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2277
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2278 activepositionproperty = "outerposition";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2279 __colorbar__ = "none";
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2280
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2281 delete_children ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2282
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2283 children = Matrix ();
6432
5bec61ae1576 [project @ 2007-03-23 02:19:10 by jwe]
jwe
parents: 6425
diff changeset
2284
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2285 update_transform ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2286
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2287 override_defaults (obj);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2288 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2289
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2290 graphics_handle
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2291 axes::properties::get_title (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2292 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2293 if (! title.handle_value ().ok ())
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2294 title = gh_manager::make_graphics_handle ("text", __myhandle__);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2295
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2296 return title.handle_value ();
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2297 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2298
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2299 graphics_handle
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2300 axes::properties::get_xlabel (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2301 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2302 if (! xlabel.handle_value ().ok ())
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2303 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2304
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2305 return xlabel.handle_value ();
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2306 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2307
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2308 graphics_handle
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2309 axes::properties::get_ylabel (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2310 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2311 if (! ylabel.handle_value ().ok ())
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2312 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2313
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2314 return ylabel.handle_value ();
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2315 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2316
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2317 graphics_handle
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2318 axes::properties::get_zlabel (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2319 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2320 if (! zlabel.handle_value ().ok ())
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2321 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2322
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2323 return zlabel.handle_value ();
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2324 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2325
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2326 void
6844
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
2327 axes::properties::remove_child (const graphics_handle& h)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2328 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2329 if (title.handle_value ().ok () && h == title.handle_value ())
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2330 title = gh_manager::make_graphics_handle ("text", __myhandle__);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2331 else if (xlabel.handle_value ().ok () && h == xlabel.handle_value ())
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2332 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2333 else if (ylabel.handle_value ().ok () && h == ylabel.handle_value ())
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2334 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2335 else if (zlabel.handle_value ().ok () && h == zlabel.handle_value ())
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2336 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2337 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2338 base_properties::remove_child (h);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2339 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2340
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2341 void
6844
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
2342 axes::properties::delete_children (void)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2343 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2344 base_properties::delete_children ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2345
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2346 gh_manager::free (title.handle_value ());
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2347 gh_manager::free (xlabel.handle_value ());
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2348 gh_manager::free (ylabel.handle_value ());
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2349 gh_manager::free (zlabel.handle_value ());
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2350 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2351
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2352 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2353 xform_matrix (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2354 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2355 Matrix m (4, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2356 for (int i = 0; i < 4; i++)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2357 m(i,i) = 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2358 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2359 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2360
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2361 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2362 xform_vector (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2363 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2364 ColumnVector v (4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2365 v(3) = 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2366 return v;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2367 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2368
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2369 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2370 xform_vector (double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2371 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2372 ColumnVector v (4, 1.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2373 v(0) = x; v(1) = y; v(2) = z;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2374 return v;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2375 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2376
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2377 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2378 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
2379 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2380 return (m * xform_vector (x, y, z));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2381 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2382
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2383 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2384 xform_scale (double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2385 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2386 Matrix m (4, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2387 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
2388 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2389 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2390
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2391 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2392 xform_translate (double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2393 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2394 Matrix m = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2395 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
2396 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2397 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2398
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2399 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2400 scale (Matrix& m, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2401 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2402 m = m * xform_scale (x, y, z);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2403 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2404
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2405 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2406 translate (Matrix& m, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2407 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2408 m = m * xform_translate (x, y, z);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2409 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2410
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2411 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2412 xform (ColumnVector& v, const Matrix& m)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2413 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2414 v = m*v;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2415 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2416
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2417 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2418 scale (ColumnVector& v, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2419 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2420 v(0) *= x;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2421 v(1) *= y;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2422 v(2) *= z;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2423 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2424
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2425 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2426 translate (ColumnVector& v, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2427 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2428 v(0) += x;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2429 v(1) += y;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2430 v(2) += z;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2431 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2432
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2433 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2434 normalize (ColumnVector& v)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2435 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2436 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
2437 scale (v, fact, fact, fact);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2438 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2439
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2440 inline double
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2441 dot (const ColumnVector& v1, const ColumnVector& v2)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2442 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2443 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
2444 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2445
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2446 inline double
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2447 norm (const ColumnVector& v)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2448 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2449 return sqrt (dot (v, v));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2450 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2451
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2452 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2453 cross (const ColumnVector& v1, const ColumnVector& v2)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2454 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2455 ColumnVector r = xform_vector ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2456 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
2457 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
2458 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
2459 return r;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2460 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2461
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2462 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2463 unit_cube (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2464 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2465 static double data[32] = {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2466 0,0,0,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2467 1,0,0,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2468 0,1,0,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2469 0,0,1,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2470 1,1,0,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2471 1,0,1,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2472 0,1,1,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2473 1,1,1,1};
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2474 Matrix m (4, 8);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2475 memcpy (m.fortran_vec (), data, sizeof(double)*32);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2476 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2477 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2478
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2479 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2480 cam2xform (const Array<double>& m)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2481 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2482 ColumnVector retval (4, 1.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2483 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
2484 return retval;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2485 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2486
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2487 inline RowVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2488 xform2cam (const ColumnVector& v)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2489 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2490 return v.extract_n (0, 3).transpose ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2491 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2492
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2493 void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2494 axes::properties::update_camera (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2495 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2496 double xd = (xdir_is ("normal") ? 1 : -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2497 double yd = (ydir_is ("normal") ? 1 : -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2498 double zd = (zdir_is ("normal") ? 1 : -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2499
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
2500 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
2501 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
2502 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
2503
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
2504 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
2505 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
2506 double zo = zlimits(zd > 0 ? 0 : 1);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2507
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2508 Matrix pb = get_plotboxaspectratio ().matrix_value ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2509
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2510 bool autocam = (camerapositionmode_is ("auto")
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2511 && cameratargetmode_is ("auto")
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2512 && cameraupvectormode_is ("auto")
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2513 && cameraviewanglemode_is ("auto"));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2514 bool dowarp = (autocam && dataaspectratiomode_is("auto")
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2515 && plotboxaspectratiomode_is ("auto"));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2516
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2517 ColumnVector c_eye (xform_vector ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2518 ColumnVector c_center (xform_vector ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2519 ColumnVector c_upv (xform_vector ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2520
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2521 if (cameratargetmode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2522 {
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
2523 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
2524 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
2525 c_center(2) = (zlimits(0)+zlimits(1))/2;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2526
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2527 cameratarget = xform2cam (c_center);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2528 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2529 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2530 c_center = cam2xform (get_cameratarget ().matrix_value ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2531
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2532 if (camerapositionmode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2533 {
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
2534 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
2535 double az = tview(0), el = tview(1);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2536 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
2537
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2538 if (el == 90 || el == -90)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2539 c_eye(2) = d*signum(el);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2540 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2541 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2542 az *= M_PI/180.0;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2543 el *= M_PI/180.0;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2544 c_eye(0) = d*cos(el)*sin(az);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2545 c_eye(1) = -d*cos(el)*cos(az);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2546 c_eye(2) = d*sin(el);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2547 }
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
2548 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
2549 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
2550 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
2551
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2552 cameraposition = xform2cam (c_eye);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2553 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2554 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2555 c_eye = cam2xform (get_cameraposition ().matrix_value ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2556
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2557 if (cameraupvectormode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2558 {
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
2559 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
2560 double az = tview(0), el = tview(1);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2561
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2562 if (el == 90 || el == -90)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2563 {
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
2564 c_upv(0) = -sin(az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0);
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
2565 c_upv(1) = cos(az*M_PI/180.0)*(ylimits(1)-ylimits(0))/pb(1);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2566 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2567 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2568 c_upv(2) = 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2569
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2570 cameraupvector = xform2cam (c_upv);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2571 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2572 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2573 c_upv = cam2xform (get_cameraupvector ().matrix_value ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2574
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2575 Matrix x_view = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2576 Matrix x_projection = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2577 Matrix x_viewport = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2578 Matrix x_normrender = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2579 Matrix x_pre = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2580
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2581 x_render = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2582 x_render_inv = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2583
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2584 scale (x_pre, pb(0), pb(1), pb(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2585 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
2586 scale (x_pre, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
2587 zd/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2588 translate (x_pre, -xo, -yo, -zo);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2589
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2590 xform (c_eye, x_pre);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2591 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
2592 scale (c_upv, pb(0)/(xlimits(1)-xlimits(0)), pb(1)/(ylimits(1)-ylimits(0)),
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
2593 pb(2)/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2594 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
2595
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2596 ColumnVector F (c_center), f (F), UP (c_upv);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2597 normalize (f);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2598 normalize (UP);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2599
7440
4e3b073e910e [project @ 2008-02-02 18:23:50 by jwe]
jwe
parents: 7435
diff changeset
2600 if (std::abs (dot (f, UP)) > 1e-15)
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2601 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2602 double fa = 1/sqrt(1-f(2)*f(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2603 scale (UP, fa, fa, fa);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2604 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2605
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2606 ColumnVector s = cross (f, UP);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2607 ColumnVector u = cross (s, f);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2608
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2609 scale (x_view, 1, 1, -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2610 Matrix l = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2611 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
2612 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
2613 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
2614 x_view = x_view * l;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2615 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
2616 scale (x_view, pb(0), pb(1), pb(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2617 translate (x_view, -0.5, -0.5, -0.5);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2618
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2619 Matrix x_cube = x_view * unit_cube ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2620 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
2621 double xM = cmax(0)-cmin(0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2622 double yM = cmax(1)-cmin(1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2623
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2624 Matrix bb = get_boundingbox (true);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2625
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2626 double v_angle;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2627
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2628 if (cameraviewanglemode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2629 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2630 double af;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2631
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2632 // FIXME: Was this really needed? When compared to Matlab, it
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2633 // 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
2634 // backend to see results visually.
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2635 if (false && dowarp)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2636 af = 1.0 / (xM > yM ? xM : yM);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2637 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2638 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2639 if ((bb(2)/bb(3)) > (xM/yM))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2640 af = 1.0 / yM;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2641 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2642 af = 1.0 / xM;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2643 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2644 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
2645
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2646 cameraviewangle = v_angle;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2647 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2648 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2649 v_angle = get_cameraviewangle ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2650
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2651 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
2652 scale (x_projection, pf, pf, 1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2653
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2654 if (dowarp)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2655 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2656 xM *= pf;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2657 yM *= pf;
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2658 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
2659 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
2660 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2661 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2662 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2663 double pix = 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2664 if (autocam)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2665 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2666 if ((bb(2)/bb(3)) > (xM/yM))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2667 pix = bb(3);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2668 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2669 pix = bb(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2670 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2671 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2672 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
2673 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
2674 scale (x_viewport, pix, -pix, 1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2675 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2676
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2677 x_normrender = x_viewport * x_projection * x_view;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2678
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2679 x_cube = x_normrender * unit_cube ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2680 cmin = x_cube.row_min ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2681 cmax = x_cube.row_max ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2682 x_zlim.resize (1, 2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2683 x_zlim(0) = cmin(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2684 x_zlim(1) = cmax(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2685
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2686 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
2687 scale (x_render, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
2688 zd/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2689 translate (x_render, -xo, -yo, -zo);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2690
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2691 x_viewtransform = x_view;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2692 x_projectiontransform = x_projection;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2693 x_viewporttransform = x_viewport;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2694 x_normrendertransform = x_normrender;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2695 x_rendertransform = x_render;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2696
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2697 x_render_inv = x_render.inverse ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2698
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2699 // 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
2700 // 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
2701 // => x_gl_mat2)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2702 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
2703 scale (x_gl_mat1, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
2704 zd/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2705 translate (x_gl_mat1, -xo, -yo, -zo);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2706 x_gl_mat2 = x_viewport * x_projection;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2707 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2708
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2709 void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2710 axes::properties::update_aspectratios (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2711 {
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
2712 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
2713 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
2714 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
2715
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
2716 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
2717 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
2718 double dz = (zlimits(1)-zlimits(0));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2719
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2720 if (dataaspectratiomode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2721 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2722 double dmin = xmin (xmin (dx, dy), dz);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2723 Matrix da (1, 3, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2724
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2725 da(0) = dx/dmin;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2726 da(1) = dy/dmin;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2727 da(2) = dz/dmin;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2728
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2729 dataaspectratio = da;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2730 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2731
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2732 if (plotboxaspectratiomode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2733 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2734 if (dataaspectratiomode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2735 plotboxaspectratio = Matrix (1, 3, 1.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2736 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2737 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2738 Matrix da = get_dataaspectratio ().matrix_value ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2739 Matrix pba (1, 3, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2740
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2741 pba(0) = dx/da(0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2742 pba(1) = dy/da(1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2743 pba(2) = dz/da(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2744 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2745 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2746
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2747 // FIXME: if plotboxaspectratiomode is "manual", limits
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2748 // and/or dataaspectratio might be adapted
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2749 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2750
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2751 // 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
2752
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2753 Matrix
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2754 axes::properties::get_boundingbox (bool internal) const
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2755 {
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2756 graphics_object obj = gh_manager::get_object (get_parent ());
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2757 Matrix parent_bb = obj.get_properties ().get_boundingbox (true);
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2758 Matrix pos = (internal ?
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2759 get_position ().matrix_value ()
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2760 : get_outerposition ().matrix_value ());
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2761
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2762
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2763 pos = convert_position (pos, get_units (), "pixels",
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2764 parent_bb.extract_n (0, 2, 1, 2), get_backend ());
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2765 pos(0)--;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2766 pos(1)--;
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2767 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
2768
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2769 return pos;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2770 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2771
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2772 ColumnVector
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2773 graphics_xform::xform_vector (double x, double y, double z)
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2774 { return ::xform_vector (x, y, z); }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2775
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2776 Matrix
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2777 graphics_xform::xform_eye (void)
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2778 { return ::xform_matrix (); }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2779
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2780 ColumnVector
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2781 graphics_xform::transform (double x, double y, double z,
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2782 bool use_scale) const
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2783 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2784 if (use_scale)
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2785 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2786 x = sx.scale (x);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2787 y = sy.scale (y);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2788 z = sz.scale (z);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2789 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2790
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2791 return ::transform (xform, x, y, z);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2792 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2793
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2794 ColumnVector
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2795 graphics_xform::untransform (double x, double y, double z,
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2796 bool use_scale) const
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2797 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2798 ColumnVector v = ::transform (xform_inv, x, y, z);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2799
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2800 if (use_scale)
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2801 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2802 v(0) = sx.unscale (v(0));
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2803 v(1) = sy.unscale (v(1));
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2804 v(2) = sz.unscale (v(2));
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2805 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2806
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2807 return v;
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2808 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2809
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2810 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2811 axes::get_default (const caseless_str& name) const
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2812 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2813 octave_value retval = default_properties.lookup (name);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2814
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2815 if (retval.is_undefined ())
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2816 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2817 graphics_handle parent = get_parent ();
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2818 graphics_object parent_obj = gh_manager::get_object (parent);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2819
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2820 retval = parent_obj.get_default (name);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2821 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2822
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2823 return retval;
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2824 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2825
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2826 // FIXME: Remove
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
2827 // 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
2828 /*
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
2829 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
2830 check_limit_vals (double& min_val, double& max_val, double& 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
2831 const array_property& data)
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
2832 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
2833 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
2834 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
2835 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
2836 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
2837 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
2838 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
2839 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
2840 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
2841 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
2842 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2843 */
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2844
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2845 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
2846 check_limit_vals (double& min_val, double& max_val, double& min_pos,
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2847 const octave_value& data)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2848 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2849 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
2850 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2851 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
2852
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2853 if (! error_state && m.numel () == 3)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2854 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2855 double val;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2856
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2857 val = m(0);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2858 if (! (xisinf (val) || xisnan (val)) && val < min_val)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2859 min_val = val;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2860
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2861 val = m(1);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2862 if (! (xisinf (val) || xisnan (val)) && val > max_val)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2863 max_val = val;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2864
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2865 val = m(2);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2866 if (! (xisinf (val) || xisnan (val)) && val > 0 && val < min_pos)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2867 min_pos = val;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2868 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2869 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2870 }
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
2871
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2872 // 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
2873 // integral.
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2874
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2875 static void magform (double x, double& a, int& b)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2876 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2877 if (x == 0)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2878 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2879 a = 0;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2880 b = 0;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2881 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2882 else
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2883 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2884 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
2885 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
2886 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
2887 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
2888 if (a < 1)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2889 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2890 a *= 10;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2891 b -= 1;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2892 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2893
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2894 if (x < 0)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2895 a = -a;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2896 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2897 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2898
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2899 // 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
2900 // 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
2901 // FIXME -- add log ticks
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2902
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2903 double
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2904 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
2905 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2906 int ticint = 5;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2907
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2908 // 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
2909 // 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
2910 // 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
2911 // 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
2912
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2913 double a;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2914 int b, x;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2915
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2916 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
2917
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2918 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
2919 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
2920 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
2921
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2922 if (a < sqrt_2)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2923 x = 1;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2924 else if (a < sqrt_10)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2925 x = 2;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2926 else if (a < sqrt_50)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2927 x = 5;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2928 else
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2929 x = 10;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2930
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2931 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
2932
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2933 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2934
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2935 // 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
2936 // 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
2937 // value.
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2938
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2939 Matrix
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2940 axes::properties::get_axis_limits (double xmin, double xmax, double min_pos, bool logscale)
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2941 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2942 Matrix retval;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2943
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2944 double min_val = xmin;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2945 double max_val = xmax;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2946
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2947 if (! (xisinf (min_val) || xisinf (max_val)))
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2948 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2949 if (logscale)
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2950 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2951 if (xisinf (min_pos))
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2952 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2953 // warning ("axis: logscale with no positive values to plot");
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2954 return retval;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2955 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2956
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2957 if (min_val <= 0)
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2958 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2959 warning ("axis: omitting nonpositive data in log plot");
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2960 min_val = min_pos;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2961 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2962 // FIXME -- maybe this test should also be relative?
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2963 if (std::abs (min_val - max_val) < sqrt (DBL_EPSILON))
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2964 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2965 min_val *= 0.9;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2966 max_val *= 1.1;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2967 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2968 min_val = pow (10, floor (log10 (min_val)));
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2969 max_val = pow (10, ceil (log10 (max_val)));
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2970 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2971 else
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2972 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2973 if (min_val == 0 && max_val == 0)
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2974 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2975 min_val = -1;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2976 max_val = 1;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2977 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2978 // FIXME -- maybe this test should also be relative?
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2979 else if (std::abs (min_val - max_val) < sqrt (DBL_EPSILON))
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2980 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2981 min_val -= 0.1 * std::abs (min_val);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2982 max_val += 0.1 * std::abs (max_val);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2983 }
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2984
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2985 double tick_sep = calc_tick_sep (min_val , max_val);
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2986 min_val = tick_sep * std::floor (min_val / tick_sep);
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
2987 max_val = tick_sep * ceil (max_val / tick_sep);
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2988 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2989 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2990
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2991 retval.resize (1, 2);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2992
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2993 retval(0) = min_val;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2994 retval(1) = max_val;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2995
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2996 return retval;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2997 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2998
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
2999 void
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3000 axes::properties::calc_ticks_and_lims (array_property& lims, array_property& ticks, bool limmode_is_auto, bool is_logscale)
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
3001 {
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3002
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3003 // FIXME -- add log ticks and lims
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
3004
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
3005 if (lims.get ().is_empty ())
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
3006 return;
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
3007
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
3008 double lo = (lims.get ().matrix_value ()) (0);
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
3009 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
3010 // 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
3011 if (hi < lo)
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
3012 {
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
3013 double tmp = hi;
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
3014 hi = lo;
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
3015 lo = tmp;
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
3016 }
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3017
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3018 if (is_logscale)
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3019 {
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3020 // 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
3021 hi = std::log10 (hi);
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3022 lo = std::log10 (lo);
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3023 }
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3024
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3025 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
3026
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3027 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
3028 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
3029
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3030 if (limmode_is_auto)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3031 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3032 // 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
3033 Matrix tmp_lims (1,2);
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3034 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
3035 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
3036
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3037 if (is_logscale)
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3038 {
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3039 tmp_lims(0) = std::pow (10.,tmp_lims(0));
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3040 tmp_lims(1) = std::pow (10.,tmp_lims(1));
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3041 }
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3042 lims = tmp_lims;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3043 }
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
3044 else
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3045 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3046 // 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
3047 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
3048 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
3049 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3050
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3051 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
3052 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
3053 {
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3054 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
3055 if (is_logscale)
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3056 tmp_ticks (i) = std::pow (10., tmp_ticks (i));
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3057 }
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3058
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
3059
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3060
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3061 ticks = tmp_ticks;
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
3062 }
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
3063
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3064 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
3065 get_children_limits (double& min_val, double& max_val, double& min_pos,
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3066 const Matrix& kids, char 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
3067 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3068 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
3069
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3070 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
3071 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3072 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
3073 for (octave_idx_type i = 0; i < n; i++)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3074 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3075 graphics_object obj = gh_manager::get_object (kids(i));
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3076
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3077 if (obj.is_xliminclude ())
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3078 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3079 octave_value lim = obj.get_xlim ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3080
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3081 check_limit_vals (min_val, max_val, min_pos, lim);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3082 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3083 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3084 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3085
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3086 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
3087 for (octave_idx_type i = 0; i < n; i++)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3088 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3089 graphics_object obj = gh_manager::get_object (kids(i));
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3090
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3091 if (obj.is_yliminclude ())
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3092 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3093 octave_value lim = obj.get_ylim ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3094
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3095 check_limit_vals (min_val, max_val, min_pos, lim);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3096 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3097 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3098 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3099
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3100 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
3101 for (octave_idx_type i = 0; i < n; i++)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3102 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3103 graphics_object obj = gh_manager::get_object (kids(i));
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3104
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3105 if (obj.is_zliminclude ())
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3106 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3107 octave_value lim = obj.get_zlim ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3108
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3109 check_limit_vals (min_val, max_val, min_pos, lim);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3110 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3111 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3112 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3113
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3114 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
3115 for (octave_idx_type i = 0; i < n; i++)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3116 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3117 graphics_object obj = gh_manager::get_object (kids(i));
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3118
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3119 if (obj.is_climinclude ())
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3120 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3121 octave_value lim = obj.get_clim ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3122
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3123 check_limit_vals (min_val, max_val, min_pos, lim);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3124 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3125 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3126 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3127
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3128 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
3129 for (octave_idx_type i = 0; i < n; i++)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3130 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3131 graphics_object obj = gh_manager::get_object (kids(i));
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3132
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3133 if (obj.is_aliminclude ())
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3134 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3135 octave_value lim = obj.get_alim ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3136
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3137 check_limit_vals (min_val, max_val, min_pos, lim);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3138 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3139 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3140 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3141
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3142 default:
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3143 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3144 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3145 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3146
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3147 static bool updating_axis_limits = false;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3148
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
3149 void
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3150 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
3151 {
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3152 if (updating_axis_limits)
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3153 return;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3154
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3155 Matrix kids = xproperties.get_children ();
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3156
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3157 octave_idx_type n = kids.numel ();
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3158
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3159 double min_val = octave_Inf;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3160 double max_val = -octave_Inf;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3161 double min_pos = octave_Inf;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3162
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3163 char update_type = 0;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3164
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3165 Matrix limits;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3166
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3167 if (axis_type == "xdata" || axis_type == "xscale"
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3168 || axis_type == "xldata" || axis_type == "xudata"
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3169 || 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
3170 || axis_type == "xlim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3171 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3172 if (xproperties.xlimmode_is ("auto"))
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3173 {
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3174 get_children_limits (min_val, max_val, min_pos, kids, 'x');
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3175
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3176 limits = xproperties.get_axis_limits (min_val, max_val, min_pos,
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3177 xproperties.xscale_is ("log"));
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3178
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3179 update_type = 'x';
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3180 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3181 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3182 else if (axis_type == "ydata" || axis_type == "yscale"
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3183 || axis_type == "ldata" || axis_type == "udata"
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3184 || axis_type == "ylimmode" || axis_type == "yliminclude"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3185 || axis_type == "ylim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3186 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3187 if (xproperties.ylimmode_is ("auto"))
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3188 {
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3189 get_children_limits (min_val, max_val, min_pos, kids, 'y');
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3190
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3191 limits = xproperties.get_axis_limits (min_val, max_val, min_pos,
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3192 xproperties.yscale_is ("log"));
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3193
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3194 update_type = 'y';
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3195 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3196 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3197 else if (axis_type == "zdata" || axis_type == "zscale"
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3198 || axis_type == "zlimmode" || axis_type == "zliminclude"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3199 || axis_type == "zlim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3200 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3201 if (xproperties.zlimmode_is ("auto"))
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3202 {
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3203 get_children_limits (min_val, max_val, min_pos, kids, 'z');
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3204
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3205 limits = xproperties.get_axis_limits (min_val, max_val, min_pos,
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
3206 xproperties.zscale_is ("log"));
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3207
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3208 update_type = 'z';
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3209 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3210 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3211 else if (axis_type == "cdata" || axis_type == "climmode"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3212 || axis_type == "cdatamapping" || axis_type == "climinclude"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3213 || axis_type == "clim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3214 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3215 if (xproperties.climmode_is ("auto"))
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3216 {
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3217 get_children_limits (min_val, max_val, min_pos, kids, 'c');
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3218
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3219 if (min_val > max_val)
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3220 {
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3221 min_val = min_pos = 0;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3222 max_val = 1;
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3223 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3224 else if (min_val == max_val)
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3225 max_val = min_val + 1;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3226
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3227 limits.resize (1, 2);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3228
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3229 limits(0) = min_val;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3230 limits(1) = max_val;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3231
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3232 update_type = 'c';
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3233 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3234
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3235 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3236 else if (axis_type == "alphadata" || axis_type == "alimmode"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3237 || axis_type == "alphadatamapping" || axis_type == "aliminclude"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3238 || axis_type == "alim")
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3239 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3240 if (xproperties.alimmode_is ("auto"))
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3241 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3242 get_children_limits (min_val, max_val, min_pos, kids, 'a');
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3243
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3244 if (min_val > max_val)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3245 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3246 min_val = min_pos = 0;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3247 max_val = 1;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3248 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3249 else if (min_val == max_val)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3250 max_val = min_val + 1;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3251
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3252 limits.resize (1, 2);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3253
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3254 limits(0) = min_val;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3255 limits(1) = max_val;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3256
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3257 update_type = 'a';
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3258 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3259
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3260 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3261
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3262 unwind_protect_bool (updating_axis_limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3263 updating_axis_limits = true;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3264
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3265 switch (update_type)
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3266 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3267 case 'x':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3268 xproperties.set_xlim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3269 xproperties.set_xlimmode ("auto");
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
3270 xproperties.update_xlim ();
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3271 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3272
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3273 case 'y':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3274 xproperties.set_ylim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3275 xproperties.set_ylimmode ("auto");
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
3276 xproperties.update_ylim ();
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3277 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3278
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3279 case 'z':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3280 xproperties.set_zlim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3281 xproperties.set_zlimmode ("auto");
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
3282 xproperties.update_zlim ();
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3283 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3284
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3285 case 'c':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3286 xproperties.set_clim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3287 xproperties.set_climmode ("auto");
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3288 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3289
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3290 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
3291 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
3292 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
3293 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3294
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3295 default:
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3296 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3297 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3298
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3299 xproperties.update_transform ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3300
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3301 unwind_protect::run ();
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
3302 }
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
3303
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3304 void
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3305 axes::properties::zoom (const Matrix& xl, const Matrix& yl)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3306 {
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3307 zoom_stack.push_front (xlimmode.get ());
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3308 zoom_stack.push_front (xlim.get ());
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3309 zoom_stack.push_front (ylimmode.get ());
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3310 zoom_stack.push_front (ylim.get ());
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3311
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3312 xlim = xl;
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3313 xlimmode = "manual";
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3314 ylim = yl;
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3315 ylimmode = "manual";
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3316
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3317 update_transform ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3318 update_xlim (false);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3319 update_ylim (false);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3320 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3321
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3322 void
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3323 axes::properties::unzoom (void)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3324 {
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3325 if (zoom_stack.size () >= 4)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3326 {
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3327 ylim = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3328 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3329 ylimmode = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3330 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3331 xlim = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3332 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3333 xlimmode = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3334 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3335
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3336 update_transform ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3337 update_xlim (false);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3338 update_ylim (false);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3339 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3340 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3341
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3342 void
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3343 axes::properties::clear_zoom_stack (void)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3344 {
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3345 while (zoom_stack.size () > 4)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3346 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3347
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3348 unzoom ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3349 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
3350
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3351 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3352
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3353 Matrix
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3354 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
3355 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3356 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
3357
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3358 m(0) = xmin (xdata.min_val (), xmin (xldata.min_val (), xudata.min_val ()));
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3359 m(1) = xmax (xdata.max_val (), xmax (xldata.max_val (), xudata.max_val ()));
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3360 m(2) = xmin (xdata.min_pos (), xmin (xldata.min_pos (), xudata.min_pos ()));
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3361
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3362 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
3363 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3364
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3365 Matrix
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3366 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
3367 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3368 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
3369
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3370 m(0) = xmin (ydata.min_val (), xmin (ldata.min_val (), udata.min_val ()));
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3371 m(1) = xmax (ydata.max_val (), xmax (ldata.max_val (), udata.max_val ()));
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3372 m(2) = xmin (ydata.min_pos (), xmin (ldata.min_pos (), udata.min_pos ()));
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3373
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3374 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
3375 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3376
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3377 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3378
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3379 // Note: "text" code is entirely auto-generated
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3380
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3381 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3382
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3383 // Note: "image" code is entirely auto-generated
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3384
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3385 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3386
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
3387 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
3388 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
3389 {
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
3390 return convert_cdata (*this, get_facevertexcdata (),
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
3391 cdatamapping_is ("scaled"), 2);
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
3392 }
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
3393
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
3394 // ---------------------------------------------------------------------
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
3395
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3396 octave_value
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3397 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
3398 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3399 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
3400 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3401
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3402 inline void
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3403 cross_product (double x1, double y1, double z1,
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3404 double x2, double y2, double z2,
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3405 double& x, double& y, double& z)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3406 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3407 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
3408 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
3409 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
3410 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3411
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3412 void
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3413 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
3414 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3415 if (normalmode_is ("auto"))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3416 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3417 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
3418 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
3419 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
3420
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3421 int p = z.columns (), q = z.rows ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3422 int i1, i2, i3;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3423 int j1, j2, j3;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3424
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3425 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
3426 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
3427
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3428 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
3429
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3430 i1 = i2 = i3 = 0;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3431 j1 = j2 = j3 = 0;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3432
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3433 // FIXME: normal computation at boundaries
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3434 for (int i = 1; i < (p-1); i++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3435 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3436 if (y_mat)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3437 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3438 i1 = i-1;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3439 i2 = i;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3440 i3 = i+1;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3441 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3442
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3443 for (int j = 1; j < (q-1); j++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3444 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3445 if (x_mat)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3446 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3447 j1 = j-1;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3448 j2 = j;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3449 j3 = j+1;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3450 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3451
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3452 double& nx = n(j, i, 0);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3453 double& ny = n(j, i, 1);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3454 double& nz = n(j, i, 2);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3455
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3456 cross_product (x(j3,i)-x(j2,i), y(j+1,i2)-y(j,i2), z(j+1,i)-z(j,i),
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3457 x(j2,i+1)-x(j2,i), y(j,i3)-y(j,i2), z(j,i+1)-z(i,j),
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3458 nx, ny, nz);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3459 cross_product (x(j2,i-1)-x(j2,i), y(j,i1)-y(j,i2), z(j,i-1)-z(j,i),
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3460 x(j3,i)-x(j2,i), y(j+1,i2)-y(j,i2), z(j+1,i)-z(i,j),
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3461 nx, ny, nz);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3462 cross_product (x(j1,i)-x(j2,i), y(j-1,i2)-y(j,i2), z(j-1,i)-z(j,i),
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3463 x(j2,i-1)-x(j2,i), y(j,i1)-y(j,i2), z(j,i-1)-z(i,j),
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3464 nx, ny, nz);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3465 cross_product (x(j2,i+1)-x(j2,i), y(j,i3)-y(j,i2), z(j,i+1)-z(j,i),
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3466 x(j1,i)-x(j2,i), y(j-1,i2)-y(j,i2), z(j-1,i)-z(i,j),
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3467 nx, ny, nz);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3468
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3469 double d = - sqrt (nx*nx + ny*ny + nz*nz);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3470
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3471 nx /= d;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3472 ny /= d;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3473 nz /= d;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3474 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3475 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3476
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3477 vertexnormals = n;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3478 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3479 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3480
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3481 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3482
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3483 void
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3484 hggroup::update_axis_limits (const std::string& axis_type)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3485 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3486 Matrix kids = xproperties.get_children ();
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3487
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3488 octave_idx_type n = kids.numel ();
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3489
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3490 double min_val = octave_Inf;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3491 double max_val = -octave_Inf;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3492 double min_pos = octave_Inf;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3493
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3494 char update_type = 0;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3495
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3496 if (axis_type == "xlim")
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3497 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3498 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
3499
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3500 update_type = 'x';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3501 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3502 else if (axis_type == "ylim")
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3503 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3504 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
3505
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3506 update_type = 'y';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3507 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3508 else if (axis_type == "zlim")
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3509 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3510 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
3511
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3512 update_type = 'z';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3513 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3514 else if (axis_type == "clim")
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3515 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3516 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
3517
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3518 update_type = 'c';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3519
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3520 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3521 else if (axis_type == "alim")
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3522 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3523 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
3524
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3525 update_type = 'a';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3526 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3527
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3528 Matrix limits (1, 3, 0.0);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3529
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3530 limits(0) = min_val;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3531 limits(1) = max_val;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3532 limits(2) = min_pos;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3533
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3534 switch (update_type)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3535 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3536 case 'x':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3537 xproperties.set_xlim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3538 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3539
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3540 case 'y':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3541 xproperties.set_ylim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3542 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3543
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3544 case 'z':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3545 xproperties.set_zlim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3546 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3547
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3548 case 'c':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3549 xproperties.set_clim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3550 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3551
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3552 case 'a':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3553 xproperties.set_alim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3554 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3555
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3556 default:
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3557 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3558 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3559
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3560 base_graphics_object::update_axis_limits (axis_type);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3561 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3562
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3563 // ---------------------------------------------------------------------
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3564
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3565 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
3566 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
3567 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3568 graphics_handle parent = get_parent ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3569 graphics_object parent_obj = gh_manager::get_object (parent);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3570
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3571 return parent_obj.get_default (type () + name);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3572 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3573
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3574 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
3575 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
3576 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3577 graphics_object parent_obj = gh_manager::get_object (0);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3578
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3579 return parent_obj.get_factory_default (type () + name);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3580 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3581
7286
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
3582 // 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
3583 // scalar values for the first argument.
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3584 gh_manager::gh_manager (void)
7286
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
3585 : handle_map (), handle_free_list (),
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
3586 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
3587 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3588 handle_map[0] = graphics_object (new root_figure ());
7847
40b16e04172a Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7844
diff changeset
3589
40b16e04172a Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7844
diff changeset
3590 // Make sure the default backend is registered.
40b16e04172a Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7844
diff changeset
3591 graphics_backend::default_backend ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3592 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3593
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3594 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3595 gh_manager::do_make_graphics_handle (const std::string& go_name,
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
3596 const graphics_handle& p, bool do_createfcn)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3597 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3598 graphics_handle h = get_handle (go_name);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3599
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3600 base_graphics_object *go = 0;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3601
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
3602 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
3603
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3604 if (go)
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
3605 {
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
3606 handle_map[h] = graphics_object (go);
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
3607 if (do_createfcn)
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
3608 go->get_properties ().execute_createfcn ();
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
3609 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3610 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3611 error ("gh_manager::do_make_graphics_handle: invalid object type `%s'",
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3612 go_name.c_str ());
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3613
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3614 return h;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3615 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3616
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3617 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3618 gh_manager::do_make_figure_handle (double val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3619 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3620 graphics_handle h = val;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3621
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3622 handle_map[h] = graphics_object (new figure (h, 0));
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3623
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3624 return h;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3625 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3626
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3627 void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3628 gh_manager::do_push_figure (const graphics_handle& h)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3629 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3630 do_pop_figure (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3631
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3632 figure_list.push_front (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3633 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3634
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3635 void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3636 gh_manager::do_pop_figure (const graphics_handle& h)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3637 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3638 for (figure_list_iterator p = figure_list.begin ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3639 p != figure_list.end ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3640 p++)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3641 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3642 if (*p == h)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3643 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3644 figure_list.erase (p);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3645 break;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3646 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3647 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3648 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3649
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3650 property_list::plist_map_type
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3651 root_figure::init_factory_properties (void)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3652 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3653 property_list::plist_map_type plist_map;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3654
6844
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
3655 plist_map["figure"] = figure::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
3656 plist_map["axes"] = axes::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
3657 plist_map["line"] = line::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
3658 plist_map["text"] = text::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
3659 plist_map["image"] = image::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
3660 plist_map["patch"] = patch::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
3661 plist_map["surface"] = surface::properties::factory_defaults ();
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3662 plist_map["hggroup"] = hggroup::properties::factory_defaults ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3663
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3664 return plist_map;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3665 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3666
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3667 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3668
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3669 DEFUN (ishandle, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3670 "-*- texinfo -*-\n\
6678
49724abe1236 [project @ 2007-05-31 19:44:45 by jwe]
jwe
parents: 6595
diff changeset
3671 @deftypefn {Built-in Function} {} ishandle (@var{h})\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3672 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
3673 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3674 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3675 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3676
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3677 if (args.length () == 1)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3678 retval = is_handle (args(0));
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3679 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3680 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3681
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3682 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3683 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3684
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3685 DEFUN (set, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3686 "-*- texinfo -*-\n\
6678
49724abe1236 [project @ 2007-05-31 19:44:45 by jwe]
jwe
parents: 6595
diff changeset
3687 @deftypefn {Built-in Function} {} set (@var{h}, @var{p}, @var{v}, @dots{})\n\
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3688 Set the named property value or vector @var{p} to the value @var{v}\n\
6894
0a71f51ae624 [project @ 2007-09-13 16:36:18 by jwe]
jwe
parents: 6890
diff changeset
3689 for the graphics handle @var{h}.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3690 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3691 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3692 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3693
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3694 int nargin = args.length ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3695
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3696 if (nargin > 0)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3697 {
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3698 ColumnVector hcv (args(0).vector_value ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3699
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3700 if (! error_state)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3701 {
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3702 bool request_drawnow = false;
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3703
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3704 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
3705 {
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3706 graphics_object obj = gh_manager::get_object (hcv(n));
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3707
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3708 if (obj)
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3709 {
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3710 obj.set (args.splice (0, 1));
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3711
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3712 request_drawnow = true;
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3713 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3714 else
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3715 {
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3716 error ("set: invalid handle (= %g)", hcv(n));
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3717 break;
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3718 }
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3719 }
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3720
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3721 if (! error_state && request_drawnow)
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
3722 Vdrawnow_requested = true;
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3723 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3724 else
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3725 error ("set: expecting graphics handle as first argument");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3726 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3727 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3728 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3729
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3730 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3731 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3732
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3733 DEFUN (get, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3734 "-*- texinfo -*-\n\
6678
49724abe1236 [project @ 2007-05-31 19:44:45 by jwe]
jwe
parents: 6595
diff changeset
3735 @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
3736 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
3737 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
3738 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
3739 values or lists respectively.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3740 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3741 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3742 octave_value retval;
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3743 octave_value_list vlist;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3744
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3745 int nargin = args.length ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3746
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3747 if (nargin == 1 || nargin == 2)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3748 {
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3749 ColumnVector hcv (args(0).vector_value ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3750
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3751 if (! error_state)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3752 {
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3753 octave_idx_type len = hcv.length ();
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3754
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3755 vlist.resize (len);
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3756
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3757 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
3758 {
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3759 graphics_object obj = gh_manager::get_object (hcv(n));
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3760
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3761 if (obj)
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3762 {
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3763 if (nargin == 1)
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3764 vlist(n) = obj.get ();
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3765 else
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3766 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
3767 caseless_str property = args(1).string_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3768
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3769 if (! error_state)
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3770 vlist(n) = obj.get (property);
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3771 else
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3772 {
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3773 error ("get: expecting property name as second argument");
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3774 break;
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3775 }
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3776 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3777 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3778 else
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3779 {
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3780 error ("get: invalid handle (= %g)", hcv(n));
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3781 break;
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3782 }
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3783 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3784 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3785 else
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3786 error ("get: expecting graphics handle as first argument");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3787 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3788 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3789 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3790
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3791 if (! error_state)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3792 {
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3793 octave_idx_type len = vlist.length ();
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3794
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3795 if (len > 1)
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3796 retval = Cell (vlist);
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3797 else if (len == 1)
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
3798 retval = vlist(0);
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3799 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
3800
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3801 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3802 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3803
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3804 DEFUN (__get__, args, ,
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3805 "-*- texinfo -*-\n\
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3806 @deftypefn {Built-in Function} {} __get__ (@var{h})\n\
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3807 Return all properties from the graphics handle @var{h}.\n\
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3808 If @var{h} is a vector, return a cell array including the property\n\
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3809 values or lists respectively.\n\
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3810 @end deftypefn")
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3811 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3812 octave_value retval;
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3813 octave_value_list vlist;
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3814
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3815 int nargin = args.length ();
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3816
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3817 if (nargin == 1)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3818 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3819 ColumnVector hcv (args(0).vector_value ());
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3820
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3821 if (! error_state)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3822 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3823 octave_idx_type len = hcv.length ();
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3824
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3825 vlist.resize (len);
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3826
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3827 for (octave_idx_type n = 0; n < len; n++)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3828 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3829 graphics_object obj = gh_manager::get_object (hcv(n));
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3830
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3831 if (obj)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3832 vlist(n) = obj.get (true);
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3833 else
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3834 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3835 error ("get: invalid handle (= %g)", hcv(n));
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3836 break;
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3837 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3838 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3839 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3840 else
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3841 error ("get: expecting graphics handle as first argument");
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3842 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3843 else
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3844 print_usage ();
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3845
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3846 if (! error_state)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3847 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3848 octave_idx_type len = vlist.length ();
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3849
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3850 if (len > 1)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3851 retval = Cell (vlist);
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3852 else if (len == 1)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3853 retval = vlist(0);
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3854 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3855
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3856 return retval;
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3857 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
3858
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3859 static octave_value
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3860 make_graphics_object (const std::string& go_name,
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3861 const octave_value_list& args)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3862 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3863 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3864
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3865 double val = octave_NaN;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3866
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3867 octave_value_list xargs = args.splice (0, 1);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3868
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3869 caseless_str p ("parent");
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3870
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3871 for (int i = 0; i < xargs.length (); i++)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3872 if (xargs(i).is_string ()
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3873 && p.compare (xargs(i).string_value ()))
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3874 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3875 if (i < (xargs.length () - 1))
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3876 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3877 val = xargs(i+1).double_value ();
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3878
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3879 if (! error_state)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3880 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3881 xargs = xargs.splice (i, 2);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3882 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3883 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3884 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3885 else
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3886 error ("__go_%s__: missing value for parent property",
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3887 go_name.c_str ());
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3888 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3889
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3890 if (! error_state && xisnan (val))
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3891 val = args(0).double_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3892
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3893 if (! error_state)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3894 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3895 graphics_handle parent = gh_manager::lookup (val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3896
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
3897 if (parent.ok ())
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3898 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3899 graphics_handle h
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
3900 = gh_manager::make_graphics_handle (go_name, parent, false);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3901
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3902 if (! error_state)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3903 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3904 adopt (parent, h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3905
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3906 xset (h, xargs);
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
3907 xcreatefcn (h);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3908
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3909 retval = h.value ();
7296
c06476bb301d [project @ 2007-12-11 21:21:32 by jwe]
jwe
parents: 7286
diff changeset
3910
c06476bb301d [project @ 2007-12-11 21:21:32 by jwe]
jwe
parents: 7286
diff changeset
3911 if (! error_state)
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
3912 Vdrawnow_requested = true;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3913 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3914 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3915 error ("__go%s__: unable to create graphics handle",
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3916 go_name.c_str ());
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3917 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3918 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3919 error ("__go_%s__: invalid parent", go_name.c_str ());
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3920 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3921 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3922 error ("__go_%s__: invalid parent", go_name.c_str ());
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3923
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3924 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3925 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3926
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3927 DEFUN (__go_figure__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3928 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3929 @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
3930 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3931 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3932 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3933 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3934
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3935 if (args.length () > 0)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3936 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3937 double val = args(0).double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3938
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3939 if (! error_state)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3940 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3941 if (is_figure (val))
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3942 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3943 graphics_handle h = gh_manager::lookup (val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3944
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3945 xset (h, args.splice (0, 1));
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3946
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3947 retval = h.value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3948 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3949 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3950 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3951 graphics_handle h = octave_NaN;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3952
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3953 if (xisnan (val))
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
3954 h = gh_manager::make_graphics_handle ("figure", 0, false);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3955 else if (val > 0 && D_NINT (val) == val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3956 h = gh_manager::make_figure_handle (val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3957 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3958 error ("__go_figure__: invalid figure number");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3959
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
3960 if (! error_state && h.ok ())
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3961 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3962 adopt (0, h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3963
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3964 xset (h, args.splice (0, 1));
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
3965 xcreatefcn (h);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3966
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3967 retval = h.value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3968 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3969 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3970 error ("__go_figure__: failed to create figure handle");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3971 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3972 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3973 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3974 error ("__go_figure__: expecting figure number to be double value");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3975 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3976 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3977 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3978
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3979 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3980 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3981
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3982 #define GO_BODY(TYPE) \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3983 octave_value retval; \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3984 \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3985 if (args.length () > 0) \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3986 retval = make_graphics_object (#TYPE, args); \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3987 else \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3988 print_usage (); \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3989 \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3990 return retval
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3991
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3992 DEFUN (__go_axes__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3993 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3994 @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
3995 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3996 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3997 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3998 GO_BODY (axes);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3999 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4000
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4001 DEFUN (__go_line__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4002 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4003 @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
4004 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4005 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4006 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4007 GO_BODY (line);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4008 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4009
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4010 DEFUN (__go_text__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4011 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4012 @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
4013 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4014 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4015 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4016 GO_BODY (text);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4017 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4018
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4019 DEFUN (__go_image__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4020 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4021 @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
4022 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4023 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4024 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4025 GO_BODY (image);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4026 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4027
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4028 DEFUN (__go_surface__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4029 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4030 @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
4031 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4032 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4033 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4034 GO_BODY (surface);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4035 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4036
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
4037 DEFUN (__go_patch__, args, ,
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
4038 "-*- texinfo -*-\n\
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
4039 @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
4040 Undocumented internal function.\n\
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
4041 @end deftypefn")
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
4042 {
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
4043 GO_BODY (patch);
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
4044 }
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
4045
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4046 DEFUN (__go_hggroup__, args, ,
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4047 "-*- texinfo -*-\n\
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4048 @deftypefn {Built-in Function} {} __go_hggroup__ (@var{parent})\n\
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4049 Undocumented internal function.\n\
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4050 @end deftypefn")
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4051 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4052 GO_BODY (hggroup);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4053 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4054
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4055 DEFUN (__go_delete__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4056 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4057 @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
4058 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4059 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4060 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4061 octave_value_list retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4062
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4063 if (args.length () == 1)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4064 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4065 graphics_handle h = octave_NaN;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4066
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4067 double val = args(0).double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4068
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4069 if (! error_state)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4070 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4071 h = gh_manager::lookup (val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4072
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
4073 if (h.ok ())
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4074 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4075 graphics_object obj = gh_manager::get_object (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4076
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4077 graphics_handle parent_h = obj.get_parent ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4078
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4079 graphics_object parent_obj = gh_manager::get_object (parent_h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4080
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
4081 // NOTE: free the handle before removing it from its parent's
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
4082 // children, such that the object's state is correct when
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
4083 // the deletefcn callback is executed
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4084
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4085 gh_manager::free (h);
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
4086
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
4087 parent_obj.remove_child (h);
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4088
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
4089 Vdrawnow_requested = true;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4090 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4091 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4092 error ("delete: invalid graphics object (= %g)", val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4093 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4094 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4095 error ("delete: invalid graphics object");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4096 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4097 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4098 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4099
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4100 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4101 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4102
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4103 DEFUN (__go_axes_init__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4104 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4105 @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
4106 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4107 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4108 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4109 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4110
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4111 int nargin = args.length ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4112
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4113 std::string mode = "";
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4114
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4115 if (nargin == 2)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4116 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4117 mode = args(1).string_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4118
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4119 if (error_state)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4120 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4121 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4122
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4123 if (nargin == 1 || nargin == 2)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4124 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4125 graphics_handle h = octave_NaN;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4126
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4127 double val = args(0).double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4128
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4129 if (! error_state)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4130 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4131 h = gh_manager::lookup (val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4132
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
4133 if (h.ok ())
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4134 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4135 graphics_object obj = gh_manager::get_object (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4136
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4137 obj.set_defaults (mode);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4138 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4139 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4140 error ("__go_axes_init__: invalid graphics object (= %g)", val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4141 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4142 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4143 error ("__go_axes_init__: invalid graphics object");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4144 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4145 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4146 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4147
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4148 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4149 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4150
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4151 DEFUN (__go_handles__, , ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4152 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4153 @deftypefn {Built-in Function} {} __go_handles__ ()\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
4154 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4155 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4156 {
6425
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
4157 return octave_value (gh_manager::handle_list ());
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
4158 }
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
4159
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
4160 DEFUN (__go_figure_handles__, , ,
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
4161 "-*- texinfo -*-\n\
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
4162 @deftypefn {Built-in Function} {} __go_figure_handles__ ()\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
4163 Undocumented internal function.\n\
6425
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
4164 @end deftypefn")
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
4165 {
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
4166 return octave_value (gh_manager::figure_handle_list ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4167 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4168
7835
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
4169 DEFUN (available_backends, args, ,
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
4170 "-*- texinfo -*-\n\
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
4171 @deftypefn {Built-in Function} {} available_backends ()\n\
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
4172 Returns resgistered graphics backends.\n\
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
4173 @end deftypefn")
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
4174 {
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
4175 return octave_value (graphics_backend::available_backends_list ());
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
4176 }
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
4177
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4178 static void
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4179 clear_drawnow_request (void *)
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4180 {
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4181 Vdrawnow_requested = false;
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4182 }
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4183
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4184 DEFUN (drawnow, args, ,
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4185 "-*- texinfo -*-\n\
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4186 @deftypefn {Built-in Function} {} __go_drawnow__ ()\n\
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4187 @deftypefnx {Built-in Function} {} __go_drawnow__ (@var{term}, @var{file}, @var{mono}, @var{debug_file})\n\
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4188 Undocumented internal function.\n\
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4189 @end deftypefn")
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4190 {
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4191 static int drawnow_executing = 0;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4192 static bool __go_close_all_registered__ = false;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4193
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4194 octave_value retval;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4195
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4196 unwind_protect::begin_frame ("Fdrawnow");
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4197 unwind_protect::add (clear_drawnow_request);
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4198
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4199 unwind_protect_int (drawnow_executing);
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4200
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4201 if (++drawnow_executing <= 1)
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4202 {
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4203 if (! __go_close_all_registered__)
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4204 {
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4205 octave_add_atexit_function ("__go_close_all__");
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4206
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4207 __go_close_all_registered__ = true;
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4208 }
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4209
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4210 if (args.length () == 0)
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4211 {
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4212 Matrix hlist = gh_manager::figure_handle_list ();
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4213
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4214 for (int i = 0; ! error_state && i < hlist.length (); i++)
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4215 {
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4216 graphics_handle h = gh_manager::lookup (hlist(i));
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4217
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4218 if (h.ok () && h != 0)
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4219 {
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4220 graphics_object go = gh_manager::get_object (h);
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4221 figure::properties& fprops = dynamic_cast <figure::properties&> (go.get_properties ());
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4222
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4223 if (fprops.is_modified ())
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4224 {
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4225 if (fprops.is_visible ())
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4226 fprops.get_backend ().redraw_figure (h);
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4227 else if (! fprops.get___plot_stream__ ().is_empty ())
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4228 {
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4229 fprops.close (false);
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4230 fprops.set___plot_stream__ (Matrix ());
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4231 fprops.set___enhanced__ (false);
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4232 }
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4233 fprops.set_modified (false);
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4234 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4235 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4236 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4237 }
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4238 else if (args.length () >= 2 && args.length () <= 4)
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4239 {
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4240 std::string term, file, debug_file;
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4241 bool mono;
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4242
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4243 term = args(0).string_value ();
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4244
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4245 if (! error_state)
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4246 {
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4247 file = args(1).string_value ();
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4248
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4249 if (! error_state)
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4250 {
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4251 size_t pos = file.find_last_of (file_ops::dir_sep_chars);
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4252
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4253 if (pos != NPOS)
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4254 {
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4255 file_stat fs (file.substr (0, pos));
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4256
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4257 if (! (fs && fs.is_dir ()))
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4258 error ("drawnow: nonexistent directory `%s'",
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4259 file.substr (0, pos).c_str ());
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4260 }
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4261
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4262 mono = (args.length () >= 3 ? args(2).bool_value () : false);
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4263
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4264 if (! error_state)
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4265 {
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4266 debug_file = (args.length () > 3 ? args(3).string_value ()
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4267 : "");
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4268
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4269 if (! error_state)
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4270 {
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4271 graphics_handle h = gcf ();
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4272
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4273 if (h.ok ())
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4274 {
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4275 graphics_object go = gh_manager::get_object (h);
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4276
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
4277 go.get_backend ()
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4278 .print_figure (h, term, file, mono, debug_file);
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4279 }
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4280 else
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4281 error ("drawnow: nothing to draw");
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4282 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4283 else
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4284 error ("drawnow: invalid debug_file, expected a string value");
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4285 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4286 else
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4287 error ("drawnow: invalid colormode, expected a boolean value");
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4288 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4289 else
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4290 error ("drawnow: invalid file, expected a string value");
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4291 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4292 else
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4293 error ("drawnow: invalid terminal, expected a string value");
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4294 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4295 else
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4296 print_usage ();
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4297 }
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4298
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
4299 unwind_protect::run_frame ("Fdrawnow");
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4300
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4301 return retval;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4302 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
4303
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
4304 DEFUN (addlistener, args, ,
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4305 "-*- texinfo -*-\n\
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
4306 @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
4307 Register @var{fcn} as listener for the property @var{prop} of the graphics\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4308 object @var{h}. Property listeners are executed (in order of registration)\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4309 when the property is set. The new value is already available when the\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4310 listeners are executed.\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4311 \n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4312 @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
4313 \n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4314 @var{fcn} can be a function handle, a string or a cell array whose first\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4315 element is a function handle. If @var{fcn} is a function handle, the\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4316 corresponding function should accept at least 2 arguments, that will be\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4317 set to the object handle and the empty matrix respectively. If @var{fcn}\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4318 is a string, it must be any valid octave expression. If @var{fcn} is a cell\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4319 array, the first element must be a function handle with the same signature\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4320 as described above. The next elements of the cell array are passed\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4321 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
4322 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4323 Example:\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4324 \n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4325 @example\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4326 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
4327 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
4328 endfunction\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4329 \n\
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
4330 addlistener (gcf, \"position\", @{@@my_listener, \"my string\"@})\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4331 @end example\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4332 \n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4333 @end deftypefn")
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4334 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4335 octave_value retval;
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4336
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4337 if (args.length () == 3)
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4338 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4339 double h = args(0).double_value ();
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4340
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4341 if (! error_state)
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4342 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4343 std::string pname = args(1).string_value ();
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4344
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4345 if (! error_state)
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4346 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4347 graphics_handle gh = gh_manager::lookup (h);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4348
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4349 if (gh.ok ())
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4350 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4351 graphics_object go = gh_manager::get_object (gh);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4352
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4353 go.add_property_listener (pname, args(2), POSTSET);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4354 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4355 else
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
4356 error ("addlistener: invalid graphics object (= %g)",
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4357 h);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4358 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4359 else
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
4360 error ("addlistener: invalid property name, expected a string value");
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4361 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4362 else
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
4363 error ("addlistener: invalid handle");
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4364 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4365 else
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4366 print_usage ();
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4367
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4368 return retval;
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4369 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
4370
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4371 DEFUN (addproperty, args, ,
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4372 "-*- texinfo -*-\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4373 @deftypefn {Built-in Function} {} addproperty (@var{name}, @var{h}, @var{type}, [@var{arg}, ...])\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4374 Create a new property named @var{name} in graphics object @var{h}.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4375 @var{type} determines the type of the property to create. @var{args}\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4376 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
4377 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
4378 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4379 The supported property types are:\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4380 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4381 @table @code\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4382 @item string\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4383 A string property. @var{arg} contains the default string value.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4384 @item any\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4385 An un-typed property. This kind of property can hold any octave\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4386 value. @var{args} contains the default value.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4387 @item radio\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4388 A string property with a limited set of accepted values. The first\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4389 argument must be a string with all accepted values separated by\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4390 a vertical bar ('|'). The default value can be marked by enclosing\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4391 it with a '@{' '@}' pair. The default value may also be given as\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4392 an optional second string argument.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4393 @item boolean\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4394 A boolean property. This property type is equivalent to a radio\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4395 property with \"on|off\" as accepted values. @var{arg} contains\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4396 the default property value.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4397 @item double\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4398 A scalar double property. @var{arg} contains the default value.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4399 @item handle\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4400 A handle property. This kind of property holds the handle of a\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4401 graphics object. @var{arg} contains the default handle value.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4402 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
4403 the empty matrix.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4404 @item data\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4405 A data (matrix) property. @var{arg} contains the default data\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4406 value. When no default value is given, the data is initialized to\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4407 the empty matrix.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4408 @item color\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4409 A color property. @var{arg} contains the default color value.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4410 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
4411 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
4412 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
4413 @end table\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4414 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4415 @var{type} may also be the concatenation of a core object type and\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4416 a valid property name for that object type. The property created\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4417 then has the same characteristics as the referenced property (type,\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4418 possible values, hidden state...). This allows to clone an existing\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4419 property into the graphics object @var{h}.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4420 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4421 Examples:\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4422 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4423 @example\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4424 addproperty (\"my_property\", gcf, \"string\", \"a string value\");\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4425 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
4426 addproperty (\"my_style\", gcf, \"linelinestyle\", \"--\");\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4427 @end example\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4428 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4429 @end deftypefn")
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4430 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4431 octave_value retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4432
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4433 if (args.length () >= 3)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4434 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4435 std::string name = args(0).string_value ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4436
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4437 if (! error_state)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4438 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4439 double h = args(1).double_value ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4440
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4441 if (! error_state)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4442 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4443 graphics_handle gh = gh_manager::lookup (h);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4444
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4445 if (gh.ok ())
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4446 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4447 graphics_object go = gh_manager::get_object (gh);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4448
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4449 std::string type = args(2).string_value ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4450
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4451 if (! error_state)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4452 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4453 if (! go.get_properties ().has_property (name))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4454 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4455 property p = property::create (name, gh, type,
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4456 args.splice (0, 3));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4457
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4458 if (! error_state)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4459 go.get_properties ().insert_property (name, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4460 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4461 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4462 error ("addproperty: a `%s' property already exists in the graphics object",
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4463 name.c_str ());
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4464 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4465 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4466 error ("addproperty: invalid property type, expected a string value");
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4467 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4468 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4469 error ("addproperty: invalid graphics object (= %g)", h);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4470 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4471 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4472 error ("addproperty: invalid handle value");
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4473 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4474 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4475 error ("addproperty: invalid property name, expected a string value");
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4476 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4477 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4478 print_usage ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4479
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4480 return retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4481 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
4482
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4483 octave_value
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
4484 get_property_from_handle (double handle, const std::string& property,
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
4485 const std::string& func)
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4486 {
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4487 graphics_object obj = gh_manager::get_object (handle);
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4488 octave_value retval;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4489
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4490 if (obj)
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4491 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
4492 caseless_str p = std::string (property);
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4493 retval = obj.get (p);
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4494 }
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4495 else
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4496 error ("%s: invalid handle (= %g)", func.c_str(), handle);
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4497
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4498 return retval;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4499 }
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4500
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4501 bool
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
4502 set_property_in_handle (double handle, const std::string& property,
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
4503 const octave_value& arg, const std::string& func)
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4504 {
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4505 graphics_object obj = gh_manager::get_object (handle);
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4506 int ret = false;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4507
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4508 if (obj)
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4509 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
4510 caseless_str p = std::string (property);
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4511 obj.set (p, arg);
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4512 if (!error_state)
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4513 ret = true;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4514 }
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4515 else
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4516 error ("%s: invalid handle (= %g)", func.c_str(), handle);
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4517
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4518 return ret;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4519 }
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
4520
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4521 /*
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4522 ;;; Local Variables: ***
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4523 ;;; mode: C++ ***
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4524 ;;; End: ***
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4525 */