annotate src/graphics.cc @ 13132:e3e8ca96f923

Support log scale plots with all negative data. Front-end fix for Bug #34232. * src/graphics.h.in: Add "max_neg" to the array_proprerty class. * src/graphics.cc: Determine log-scale axes ticks and limits for negative data.
author Ben Abbott <bpabbott@mac.com>
date Mon, 12 Sep 2011 18:53:05 -0400
parents d7f74a8bdc46
children e81ddf9cacd5
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
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11492
diff changeset
3 Copyright (C) 2007-2011 John W. Eaton
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6962
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6962
diff changeset
10 option) any later version.
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
11
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
15 for more details.
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
16
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6962
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6962
diff changeset
19 <http://www.gnu.org/licenses/>.
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
20
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
21 */
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
22
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
24 #include <config.h>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
25 #endif
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
26
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
27 #include <cctype>
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
28 #include <cfloat>
7286
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
29 #include <cstdlib>
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
30
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
31 #include <algorithm>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
32 #include <list>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
33 #include <map>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
34 #include <set>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
35 #include <string>
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
36 #include <sstream>
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
37
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
38 #include "file-ops.h"
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
39 #include "file-stat.h"
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
40
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
41 #include "cmd-edit.h"
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
42 #include "defun.h"
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
43 #include "display.h"
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
44 #include "error.h"
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
45 #include "graphics.h"
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
46 #include "input.h"
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
47 #include "ov.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
48 #include "oct-obj.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
49 #include "oct-map.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
50 #include "ov-fcn-handle.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
51 #include "parse.h"
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
52 #include "toplev.h"
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
53 #include "txt-eng-ft.h"
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
54 #include "unwind-prot.h"
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
55
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
56 // forward declarations
9238
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
57 static octave_value xget (const graphics_handle& h, const caseless_str& name);
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
58
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
59 static void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
60 gripe_set_invalid (const std::string& pname)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
61 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
62 error ("set: invalid value for %s property", pname.c_str ());
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
63 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
64
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
65 // Check to see that PNAME matches just one of PNAMES uniquely.
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
66 // Return the full name of the match, or an empty caseless_str object
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
67 // if there is no match, or the match is ambiguous.
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
68
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
69 static caseless_str
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
70 validate_property_name (const std::string& who, const std::string& what,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
71 const std::set<std::string>& pnames,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
72 const caseless_str& pname)
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
73 {
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
74 size_t len = pname.length ();
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
75 std::set<std::string> matches;
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
76
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
77 for (std::set<std::string>::const_iterator p = pnames.begin ();
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
78 p != pnames.end (); p++)
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
79 {
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
80 if (pname.compare (*p, len))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
81 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
82 if (len == p->length ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
83 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
84 // Exact match.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
85 return pname;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
86 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
87
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
88 matches.insert (*p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
89 }
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
90 }
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
91
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
92 size_t num_matches = matches.size ();
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
93
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
94 if (num_matches == 0)
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
95 {
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
96 error ("%s: unknown %s property %s",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
97 who.c_str (), what.c_str (), pname.c_str ());
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
98 }
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
99 else if (num_matches > 1)
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
100 {
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
101 string_vector sv (matches);
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
102
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
103 std::ostringstream os;
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
104
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
105 sv.list_in_columns (os);
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
106
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
107 std::string match_list = os.str ();
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
108
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
109 error ("%s: ambiguous %s property name %s; possible matches:\n\n%s",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
110 who.c_str (), what.c_str (), pname.c_str (), match_list.c_str ());
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
111 }
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
112 else if (num_matches == 1)
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
113 {
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
114 // Exact match was handled above.
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
115
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
116 std::string possible_match = *(matches.begin ());
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
117
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
118 warning_with_id ("Octave:abbreviated-property-match",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
119 "%s: allowing %s to match %s property %s",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
120 who.c_str (), pname.c_str (), what.c_str (),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
121 possible_match.c_str ());
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
122
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
123 return possible_match;
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
124 }
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
125
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
126 return caseless_str ();
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
127 }
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
128
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
129 static Matrix
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
130 jet_colormap (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
131 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
132 Matrix cmap (64, 3, 0.0);
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 for (octave_idx_type i = 0; i < 64; i++)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
135 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
136 // 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
137 // 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
138 // property object that includes a colormap_property
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
139 // 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
140 // called, so calling an interpreted function is not
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
141 // possible.
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
142
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
143 double x = i / 63.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
144
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
145 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
146 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
147 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
148 cmap(i,0) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
149 else if (x >= 7.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
150 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
151
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
152 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
153 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
154 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
155 cmap(i,1) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
156 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
157 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
158
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
159 if (x < 1.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
160 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
161 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
162 cmap(i,2) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
163 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
164 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
165 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
166
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
167 return cmap;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
168 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
169
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
170 static double
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
171 default_screendepth (void)
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
172 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
173 return display_info::depth ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
174 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
175
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
176 static Matrix
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
177 default_screensize (void)
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
178 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
179 Matrix retval (1, 4, 1.0);
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
180
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
181 retval(2) = display_info::width ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
182 retval(3) = display_info::height ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
183
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
184 return retval;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
185 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
186
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
187 static double
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
188 default_screenpixelsperinch (void)
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
189 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
190 return (display_info::x_dpi () + display_info::y_dpi ()) / 2;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
191 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
192
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
193 static Matrix
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
194 default_colororder (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
195 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
196 Matrix retval (7, 3, 0.0);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
197
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
198 retval(0,2) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
199
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
200 retval(1,1) = 0.5;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
201
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
202 retval(2,0) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
203
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
204 retval(3,1) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
205 retval(3,2) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
206
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
207 retval(4,0) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
208 retval(4,2) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
209
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
210 retval(5,0) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
211 retval(5,1) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
212
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
213 retval(6,0) = 0.25;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
214 retval(6,1) = 0.25;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
215 retval(6,2) = 0.25;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
216
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
217 return retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
218 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
219
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
220 static Matrix
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
221 default_lim (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
222 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
223 Matrix m (1, 2, 0);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
224 m(1) = 1;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
225 return m;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
226 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
227
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
228 static Matrix
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
229 default_data (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
230 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
231 Matrix retval (1, 2);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
232
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
233 retval(0) = 0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
234 retval(1) = 1;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
235
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
236 return retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
237 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
238
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
239 static Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
240 default_axes_position (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
241 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
242 Matrix m (1, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
243 m(0) = 0.13;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
244 m(1) = 0.11;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
245 m(2) = 0.775;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
246 m(3) = 0.815;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
247 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
248 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
249
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
250 static Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
251 default_axes_outerposition (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
252 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
253 Matrix m (1, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
254 m(2) = m(3) = 1.0;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
255 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
256 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
257
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
258 static Matrix
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
259 default_axes_tick (void)
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
260 {
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
261 Matrix m (1, 6, 0.0);
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
262 m(0) = 0.0;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
263 m(1) = 0.2;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
264 m(2) = 0.4;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
265 m(3) = 0.6;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
266 m(4) = 0.8;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
267 m(5) = 1.0;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
268 return m;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
269 }
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
270
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
271 static Matrix
8740
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
272 default_axes_ticklength (void)
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
273 {
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
274 Matrix m (1, 2, 0.01);
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
275 m(1) = 0.025;
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
276 return m;
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
277 }
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
278
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
279 static Matrix
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
280 default_figure_position (void)
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
281 {
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
282 Matrix m (1, 4, 0.0);
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
283 m(0) = 300;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
284 m(1) = 200;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
285 m(2) = 560;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
286 m(3) = 420;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
287 return m;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
288 }
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
289
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
290 static Matrix
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
291 default_figure_papersize (void)
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
292 {
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
293 Matrix m (1, 2, 0.0);
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
294 m(0) = 8.5;
8961
6b87f2f34fdd graphics.cc: Fix default "papersize" property value.
Ben Abbott <bpabbott@mac.com>
parents: 8944
diff changeset
295 m(1) = 11.0;
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
296 return m;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
297 }
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
298
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
299 static Matrix
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
300 default_figure_paperposition (void)
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
301 {
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
302 Matrix m (1, 4, 0.0);
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
303 m(0) = 0.25;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
304 m(1) = 2.50;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
305 m(2) = 8.00;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
306 m(3) = 6.00;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
307 return m;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
308 }
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
309
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
310 static Matrix
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
311 convert_position (const Matrix& pos, const caseless_str& from_units,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
312 const caseless_str& to_units,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
313 const Matrix& parent_dim = Matrix (1, 2, 0.0))
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
314 {
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
315 Matrix retval (1, pos.numel ());
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
316 double res = 0;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
317 bool is_rectangle = (pos.numel () == 4);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
318
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
319 if (from_units.compare ("pixels"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
320 retval = pos;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
321 else if (from_units.compare ("normalized"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
322 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
323 retval(0) = pos(0) * parent_dim(0) + 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
324 retval(1) = pos(1) * parent_dim(1) + 1;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
325 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
326 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
327 retval(2) = pos(2) * parent_dim(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
328 retval(3) = pos(3) * parent_dim(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
329 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
330 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
331 retval(2) = 0;
7427
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 else if (from_units.compare ("characters"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
334 {
9238
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
335 if (res <= 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
336 res = xget (0, "screenpixelsperinch").double_value ();
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
337
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
338 double f = 0.0;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
339
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
340 // FIXME -- this assumes the system font is Helvetica 10pt
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
341 // (for which "x" requires 6x12 pixels at 74.951 pixels/inch)
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
342 f = 12.0 * res / 74.951;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
343
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
344 if (f > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
345 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
346 retval(0) = 0.5 * pos(0) * f;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
347 retval(1) = pos(1) * f;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
348 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
349 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
350 retval(2) = 0.5 * pos(2) * f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
351 retval(3) = pos(3) * f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
352 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
353 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
354 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
355 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
356 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
357 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
358 {
9238
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
359 if (res <= 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
360 res = xget (0, "screenpixelsperinch").double_value ();
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
361
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
362 double f = 0.0;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
363
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
364 if (from_units.compare ("points"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
365 f = res / 72.0;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
366 else if (from_units.compare ("inches"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
367 f = res;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
368 else if (from_units.compare ("centimeters"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
369 f = res / 2.54;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
370
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
371 if (f > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
372 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
373 retval(0) = pos(0) * f + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
374 retval(1) = pos(1) * f + 1;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
375 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
376 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
377 retval(2) = pos(2) * f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
378 retval(3) = pos(3) * f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
379 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
380 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
381 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
382 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
383 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
384
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
385 if (! to_units.compare ("pixels"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
386 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
387 if (to_units.compare ("normalized"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
388 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
389 retval(0) = (retval(0) - 1) / parent_dim(0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
390 retval(1) = (retval(1) - 1) / parent_dim(1);
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
391 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
392 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
393 retval(2) /= parent_dim(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
394 retval(3) /= parent_dim(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
395 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
396 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
397 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
398 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
399 else if (to_units.compare ("characters"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
400 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
401 if (res <= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
402 res = xget (0, "screenpixelsperinch").double_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
403
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
404 double f = 0.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
405
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
406 f = 12.0 * res / 74.951;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
407
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
408 if (f > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
409 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
410 retval(0) = 2 * retval(0) / f;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
411 retval(1) = retval(1) / f;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
412 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
413 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
414 retval(2) = 2 * retval(2) / f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
415 retval(3) = retval(3) / f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
416 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
417 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
418 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
419 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
420 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
421 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
422 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
423 if (res <= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
424 res = xget (0, "screenpixelsperinch").double_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
425
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
426 double f = 0.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
427
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
428 if (to_units.compare ("points"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
429 f = res / 72.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
430 else if (to_units.compare ("inches"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
431 f = res;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
432 else if (to_units.compare ("centimeters"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
433 f = res / 2.54;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
434
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
435 if (f > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
436 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
437 retval(0) = (retval(0) - 1) / f;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
438 retval(1) = (retval(1) - 1) / f;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
439 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
440 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
441 retval(2) /= f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
442 retval(3) /= f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
443 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
444 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
445 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
446 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
447 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
448 }
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
449 else if (! is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
450 retval(2) = 0;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
451
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
452 return retval;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
453 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
454
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
455 static Matrix
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
456 convert_text_position (const Matrix& pos, const text::properties& props,
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
457 const caseless_str& from_units,
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
458 const caseless_str& to_units)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
459 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
460 graphics_object go = gh_manager::get_object (props.get___myhandle__ ());
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
461 graphics_object ax = go.get_ancestor ("axes");
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
462
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
463 Matrix retval (1, pos.numel (), 0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
464
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
465 if (ax.valid_object ())
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
466 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
467 const axes::properties& ax_props =
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
468 dynamic_cast<const axes::properties&> (ax.get_properties ());
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
469 graphics_xform ax_xform = ax_props.get_transform ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
470 bool is_rectangle = (pos.numel () == 4);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
471 Matrix ax_bbox = ax_props.get_boundingbox (true),
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
472 ax_size = ax_bbox.extract_n (0, 2, 1, 2);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
473
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
474 if (from_units.compare ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
475 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
476 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
477 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
478 ColumnVector v1 = ax_xform.transform (pos(0), pos(1), 0),
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
479 v2 = ax_xform.transform (pos(0) + pos(2),
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
480 pos(1) + pos(3), 0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
481
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
482 retval(0) = v1(0) - ax_bbox(0) + 1;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
483 retval(1) = ax_bbox(1) + ax_bbox(3) - v1(1) + 1;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
484 retval(2) = v2(0) - v1(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
485 retval(3) = v1(1) - v2(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
486 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
487 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
488 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
489 ColumnVector v = ax_xform.transform (pos(0), pos(1), pos(2));
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
490
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
491 retval(0) = v(0) - ax_bbox(0) + 1;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
492 retval(1) = ax_bbox(1) + ax_bbox(3) - v(1) + 1;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
493 retval(2) = 0;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
494 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
495 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
496 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
497 retval = convert_position (pos, from_units, "pixels", ax_size);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
498
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
499 if (! to_units.compare ("pixels"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
500 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
501 if (to_units.compare ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
502 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
503 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
504 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
505 ColumnVector v1 = ax_xform.untransform (retval(0) + ax_bbox(0) - 1,
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
506 ax_bbox(1) + ax_bbox(3) - retval(1) + 1),
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
507 v2 = ax_xform.untransform (retval(0) + retval(2) + ax_bbox(0) - 1,
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
508 ax_bbox(1) + ax_bbox(3) - (retval(1) + retval(3)) + 1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
509
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
510 retval(0) = v1(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
511 retval(1) = v1(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
512 retval(2) = v2(0) - v1(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
513 retval(3) = v2(1) - v1(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
514 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
515 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
516 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
517 ColumnVector v = ax_xform.untransform (retval(0) + ax_bbox(0) - 1,
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
518 ax_bbox(1) + ax_bbox(3) - retval(1) + 1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
519
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
520 retval(0) = v(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
521 retval(1) = v(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
522 retval(2) = v(2);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
523 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
524 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
525 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
526 retval = convert_position (retval, "pixels", to_units, ax_size);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
527 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
528 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
529
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
530 return retval;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
531 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
532
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
533 // This function always returns the screensize in pixels
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
534 static Matrix
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
535 screen_size_pixels (void)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
536 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
537 graphics_object obj = gh_manager::get_object (0);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
538 Matrix sz = obj.get ("screensize").matrix_value ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
539 return convert_position (sz, obj.get ("units").string_value (), "pixels", sz.extract_n (0, 2, 1, 2)).extract_n (0, 2, 1, 2);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
540 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
541
10923
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
542 static void
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
543 convert_cdata_2 (bool is_scaled, double clim_0, double clim_1,
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
544 const double *cmapv, double x, octave_idx_type lda,
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
545 octave_idx_type nc, octave_idx_type i, double *av)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
546 {
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
547 if (is_scaled)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
548 x = xround ((nc - 1) * (x - clim_0) / (clim_1 - clim_0));
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
549 else
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
550 x = xround (x - 1);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
551
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
552 if (xisnan (x))
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
553 {
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
554 av[i] = x;
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
555 av[i+lda] = x;
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
556 av[i+2*lda] = x;
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
557 }
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
558 else
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
559 {
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
560 if (x < 0)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
561 x = 0;
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
562 else if (x >= nc)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
563 x = (nc - 1);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
564
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
565 octave_idx_type idx = static_cast<octave_idx_type> (x);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
566
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
567 av[i] = cmapv[idx];
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
568 av[i+lda] = cmapv[idx+nc];
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
569 av[i+2*lda] = cmapv[idx+2*nc];
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
570 }
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
571 }
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
572
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
573 template <class T>
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
574 void
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
575 convert_cdata_1 (bool is_scaled, double clim_0, double clim_1,
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
576 const double *cmapv, const T *cv, octave_idx_type lda,
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
577 octave_idx_type nc, double *av)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
578 {
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
579 for (octave_idx_type i = 0; i < lda; i++)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
580 convert_cdata_2 (is_scaled, clim_0, clim_1, cmapv, cv[i], lda, nc, i, av);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
581 }
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
582
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
583 static octave_value
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
584 convert_cdata (const base_properties& props, const octave_value& cdata,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
585 bool is_scaled, int cdim)
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
586 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
587 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
588
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
589 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
590 return cdata;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
591
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
592 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
593 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
594
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
595 graphics_object go = gh_manager::get_object (props.get___myhandle__ ());
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
596 graphics_object fig = go.get_ancestor ("figure");
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
597
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
598 if (fig.valid_object ())
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
599 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
600 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
601
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
602 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
603 cmap = _cmap;
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
604 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
605
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
606 if (is_scaled)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
607 {
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
608 graphics_object ax = go.get_ancestor ("axes");
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
609
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
610 if (ax.valid_object ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
611 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
612 Matrix _clim = ax.get (caseless_str ("clim")).matrix_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
613
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
614 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
615 clim = _clim;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
616 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
617 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
618
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
619 dv.resize (cdim);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
620 dv(cdim-1) = 3;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
621
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
622 NDArray a (dv);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
623
8075
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
624 octave_idx_type lda = a.numel () / static_cast<octave_idx_type> (3);
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
625 octave_idx_type nc = cmap.rows ();
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
626
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
627 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
628 const double *cmapv = cmap.data ();
10923
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
629
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
630 double clim_0 = clim(0);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
631 double clim_1 = clim(1);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
632
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
633 #define CONVERT_CDATA_1(ARRAY_T, VAL_FN) \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
634 do \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
635 { \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
636 ARRAY_T tmp = cdata. VAL_FN ## array_value (); \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
637 \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
638 convert_cdata_1 (is_scaled, clim_0, clim_1, cmapv, \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
639 tmp.data (), lda, nc, av); \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
640 } \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
641 while (0)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
642
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
643 if (cdata.is_uint8_type ())
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
644 CONVERT_CDATA_1 (uint8NDArray, uint8_);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
645 else if (cdata.is_single_type ())
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
646 CONVERT_CDATA_1 (FloatNDArray, float_);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
647 else if (cdata.is_double_type ())
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
648 CONVERT_CDATA_1 (NDArray, );
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
649 else
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
650 error ("unsupported type for cdata (= %s)", cdata.type_name ().c_str ());
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
651
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
652 #undef CONVERT_CDATA_1
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
653
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
654 return octave_value (a);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
655 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
656
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
657 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
658 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
659 get_array_limits (const Array<T>& m, double& emin, double& emax,
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
660 double& eminp, double& emaxp)
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
661 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
662 const T *data = m.data ();
8075
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
663 octave_idx_type n = m.numel ();
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
664
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
665 for (octave_idx_type i = 0; i < n; i++)
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
666 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
667 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
668
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
669 // Don't need to test for NaN here as NaN>x and NaN<x is always false
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
670 if (! xisinf (e))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
671 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
672 if (e < emin)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
673 emin = e;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
674
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
675 if (e > emax)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
676 emax = e;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
677
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
678 if (e > 0 && e < eminp)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
679 eminp = e;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
680
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
681 if (e < 0 && e > emaxp)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
682 emaxp = e;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
683 }
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
684 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
685 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
686
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
687 static bool
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
688 lookup_object_name (const caseless_str& name, caseless_str& go_name,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
689 caseless_str& rest)
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
690 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
691 int len = name.length ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
692 int offset = 0;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
693 bool result = false;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
694
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
695 if (len >= 4)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
696 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
697 caseless_str pfx = name.substr (0, 4);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
698
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
699 if (pfx.compare ("axes") || pfx.compare ("line")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
700 || pfx.compare ("text"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
701 offset = 4;
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
702 else if (len >= 5)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
703 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
704 pfx = name.substr (0, 5);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
705
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
706 if (pfx.compare ("image") || pfx.compare ("patch"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
707 offset = 5;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
708 else if (len >= 6)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
709 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
710 pfx = name.substr (0, 6);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
711
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
712 if (pfx.compare ("figure") || pfx.compare ("uimenu"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
713 offset = 6;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
714 else if (len >= 7)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
715 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
716 pfx = name.substr (0, 7);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
717
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
718 if (pfx.compare ("surface") || pfx.compare ("hggroup"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
719 offset = 7;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
720 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
721 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
722 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
723
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
724 if (offset > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
725 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
726 go_name = pfx;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
727 rest = name.substr (offset);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
728 result = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
729 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
730 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
731
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
732 return result;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
733 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
734
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
735 static base_graphics_object*
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
736 make_graphics_object_from_type (const caseless_str& type,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
737 const graphics_handle& h = graphics_handle (),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
738 const graphics_handle& p = graphics_handle ())
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
739 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
740 base_graphics_object *go = 0;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
741
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
742 if (type.compare ("figure"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
743 go = new figure (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
744 else if (type.compare ("axes"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
745 go = new axes (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
746 else if (type.compare ("line"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
747 go = new line (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
748 else if (type.compare ("text"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
749 go = new text (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
750 else if (type.compare ("image"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
751 go = new image (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
752 else if (type.compare ("patch"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
753 go = new patch (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
754 else if (type.compare ("surface"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
755 go = new surface (h, p);
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
756 else if (type.compare ("hggroup"))
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
757 go = new hggroup (h, p);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
758 else if (type.compare ("uimenu"))
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
759 go = new uimenu (h, p);
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
760 return go;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
761 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
762
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
763 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
764
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
765 bool
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
766 base_property::set (const octave_value& v, bool do_run )
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
767 {
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
768 if (do_set (v))
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
769 {
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
770
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
771 // Notify graphics toolkit.
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
772 if (id >= 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
773 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
774 graphics_object go = gh_manager::get_object (parent);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
775 if (go)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
776 {
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
777 graphics_toolkit toolkit = go.get_toolkit ();
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
778 if (toolkit)
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
779 toolkit.update (go, id);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
780 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
781 }
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
782
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
783 // run listeners
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
784 if (do_run && ! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
785 run_listeners (POSTSET);
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
786
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
787 return true;
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
788 }
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
789
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
790 return false;
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
791 }
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
792
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
793
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
794 void
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
795 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
796 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
797 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
798
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
799 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
800 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
801 gh_manager::execute_callback (parent, l(i), octave_value ());
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
802
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
803 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
804 break;
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
805 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
806 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
807
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
808 radio_values::radio_values (const std::string& opt_string)
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
809 : default_val (), possible_vals ()
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
810 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
811 size_t beg = 0;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
812 size_t len = opt_string.length ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
813 bool done = len == 0;
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
814
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
815 while (! done)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
816 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
817 size_t end = opt_string.find ('|', beg);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
818
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
819 if (end == std::string::npos)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
820 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
821 end = len;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
822 done = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
823 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
824
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
825 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
826
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
827 // Might want more error checking here...
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
828 if (t[0] == '{')
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
829 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
830 t = t.substr (1, t.length () - 2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
831 default_val = t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
832 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
833 else if (beg == 0) // ensure default value
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
834 default_val = t;
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
835
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
836 possible_vals.insert (t);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
837
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
838 beg = end + 1;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
839 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
840 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
841
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
842 std::string
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
843 radio_values::values_as_string (void) const
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
844 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
845 std::string retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
846 for (std::set<caseless_str>::const_iterator it = possible_vals.begin ();
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
847 it != possible_vals.end (); it++)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
848 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
849 if (retval == "")
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
850 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
851 if (*it == default_value ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
852 retval = "{" + *it + "}";
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
853 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
854 retval = *it;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
855 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
856 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
857 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
858 if (*it == default_value ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
859 retval += " | {" + *it + "}";
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
860 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
861 retval += " | " + *it;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
862 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
863 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
864 if (retval != "")
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
865 retval = "[ " + retval + " ]";
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
866 return retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
867 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
868
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
869 Cell
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
870 radio_values::values_as_cell (void) const
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
871 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
872 octave_idx_type i = 0;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
873 Cell retval (nelem (), 1);
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
874 for (std::set<caseless_str>::const_iterator it = possible_vals.begin ();
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
875 it != possible_vals.end (); it++)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
876 retval(i++) = std::string (*it);
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
877 return retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
878 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
879
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
880 bool
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
881 color_values::str2rgb (std::string str)
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
882 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
883 double tmp_rgb[3] = {0, 0, 0};
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
884 bool retval = true;
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
885 unsigned int len = str.length();
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
886
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6898
diff changeset
887 std::transform (str.begin (), str.end (), str.begin (), tolower);
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6898
diff changeset
888
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
889 if (str.compare(0, len, "blue", 0, len) == 0)
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
890 tmp_rgb[2] = 1;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
891 else if (str.compare(0, len, "black", 0, len) == 0
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
892 || str.compare(0, len, "k", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
893 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
894 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
895 tmp_rgb[0] = 1;
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
896 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
897 tmp_rgb[1] = 1;
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
898 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
899 tmp_rgb[0] = tmp_rgb[1] = 1;
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
900 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
901 tmp_rgb[0] = tmp_rgb[2] = 1;
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
902 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
903 tmp_rgb[1] = tmp_rgb[2] = 1;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
904 else if (str.compare(0, len, "white", 0, len) == 0
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
905 || str.compare(0, len, "w", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
906 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
907 else
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
908 retval = false;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
909
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
910 if (retval)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
911 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
912 for (int i = 0; i < 3; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
913 xrgb(i) = tmp_rgb[i];
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
914 }
6563
7a65c1a09ec3 [project @ 2007-04-23 19:26:17 by jwe]
jwe
parents: 6509
diff changeset
915
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
916 return retval;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
917 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
918
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
919 bool
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
920 color_property::do_set (const octave_value& val)
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
921 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
922 if (val.is_string ())
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
923 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
924 std::string s = val.string_value ();
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
925
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
926 if (! s.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
927 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
928 if (radio_val.contains (s))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
929 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
930 if (current_type != radio_t || current_val != s)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
931 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
932 current_val = s;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
933 current_type = radio_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
934 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
935 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
936 }
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
937 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
938 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
939 color_values col (s);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
940 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
941 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
942 if (current_type != color_t || col != color_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
943 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
944 color_val = col;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
945 current_type = color_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
946 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
947 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
948 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
949 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
950 error ("invalid value for color property \"%s\" (value = %s)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
951 get_name ().c_str (), s.c_str ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
952 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
953 }
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
954 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
955 error ("invalid value for color property \"%s\"",
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
956 get_name ().c_str ());
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
957 }
9311
868fbeb2e365 allow ranges and other matrices in set
Jaroslav Hajek <highegg@gmail.com>
parents: 9238
diff changeset
958 else if (val.is_numeric_type ())
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
959 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
960 Matrix m = val.matrix_value ();
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
961
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
962 if (m.numel () == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
963 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
964 color_values col (m (0), m (1), m(2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
965 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
966 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
967 if (current_type != color_t || col != color_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
968 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
969 color_val = col;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
970 current_type = color_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
971 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
972 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
973 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
974 }
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
975 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
976 error ("invalid value for color property \"%s\"",
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
977 get_name ().c_str ());
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
978 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
979 else
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
980 error ("invalid value for color property \"%s\"",
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
981 get_name ().c_str ());
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
982
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
983 return false;
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
984 }
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
985
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
986 bool
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
987 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
988 {
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
989 if (val.is_string ())
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
990 {
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
991 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
992
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
993 if (! s.empty () && radio_val.contains (s))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
994 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
995 if (current_type != radio_t || s != current_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
996 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
997 current_val = s;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
998 current_type = radio_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
999 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1000 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1001 }
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1002 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1003 error ("invalid value for double_radio property \"%s\"",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1004 get_name ().c_str ());
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1005 }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1006 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
1007 {
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1008 double new_dval = val.double_value ();
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1009
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1010 if (current_type != double_t || new_dval != dval)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1011 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1012 dval = new_dval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1013 current_type = double_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1014 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1015 }
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1016 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1017 else
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1018 error ("invalid value for double_radio property \"%s\"",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1019 get_name ().c_str ());
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1020
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1021 return false;
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1022 }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1023
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1024 bool
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1025 array_property::validate (const octave_value& v)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1026 {
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1027 bool xok = false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1028
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8299
diff changeset
1029 // FIXME -- should we always support []?
9181
86ae7e50dc5d graphics.cc (array_property::validate): require value to be numeric, not necessarily double
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
1030 if (v.is_empty () && v.is_numeric_type ())
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1031 return true;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1032
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1033 // check value type
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1034 if (type_constraints.size () > 0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1035 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1036 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
1037 ! 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
1038 if ((*it) == v.class_name ())
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1039 xok = true;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1040 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1041 else
9181
86ae7e50dc5d graphics.cc (array_property::validate): require value to be numeric, not necessarily double
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
1042 xok = v.is_numeric_type ();
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1043
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1044 if (xok)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1045 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1046 dim_vector vdims = v.dims ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1047 int vlen = vdims.length ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1048
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1049 xok = false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1050
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1051 // check value size
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1052 if (size_constraints.size () > 0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1053 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
1054 ! xok && it != size_constraints.end (); ++it)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1055 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1056 dim_vector itdims = (*it);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1057
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1058 if (itdims.length () == vlen)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1059 {
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1060 xok = true;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1061
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1062 for (int i = 0; xok && i < vlen; i++)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1063 if (itdims(i) >= 0 && itdims(i) != vdims(i))
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1064 xok = false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1065 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1066 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1067 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1068 return true;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1069 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1070
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1071 return xok;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1072 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1073
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1074 bool
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1075 array_property::is_equal (const octave_value& v) const
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1076 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1077 if (data.type_name () == v.type_name ())
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1078 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1079 if (data.dims () == v.dims ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1080 {
8075
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
1081
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
1082 #define CHECK_ARRAY_EQUAL(T,F,A) \
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1083 { \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1084 if (data.numel () == 1) \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1085 return data.F ## scalar_value () == \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1086 v.F ## scalar_value (); \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1087 else \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1088 { \
8075
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
1089 /* Keep copy of array_value to allow sparse/bool arrays */ \
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1090 /* that are converted, to not be deallocated early */ \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1091 const A m1 = data.F ## array_value (); \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1092 const T* d1 = m1.data (); \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1093 const A m2 = v.F ## array_value (); \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1094 const T* d2 = m2.data ();\
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1095 \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1096 bool flag = true; \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1097 \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1098 for (int i = 0; flag && i < data.numel (); i++) \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1099 if (d1[i] != d2[i]) \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1100 flag = false; \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1101 \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1102 return flag; \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1103 } \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1104 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1105
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1106 if (data.is_double_type() || data.is_bool_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1107 CHECK_ARRAY_EQUAL (double, , NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1108 else if (data.is_single_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1109 CHECK_ARRAY_EQUAL (float, float_, FloatNDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1110 else if (data.is_int8_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1111 CHECK_ARRAY_EQUAL (octave_int8, int8_, int8NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1112 else if (data.is_int16_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1113 CHECK_ARRAY_EQUAL (octave_int16, int16_, int16NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1114 else if (data.is_int32_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1115 CHECK_ARRAY_EQUAL (octave_int32, int32_, int32NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1116 else if (data.is_int64_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1117 CHECK_ARRAY_EQUAL (octave_int64, int64_, int64NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1118 else if (data.is_uint8_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1119 CHECK_ARRAY_EQUAL (octave_uint8, uint8_, uint8NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1120 else if (data.is_uint16_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1121 CHECK_ARRAY_EQUAL (octave_uint16, uint16_, uint16NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1122 else if (data.is_uint32_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1123 CHECK_ARRAY_EQUAL (octave_uint32, uint32_, uint32NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1124 else if (data.is_uint64_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1125 CHECK_ARRAY_EQUAL (octave_uint64, uint64_, uint64NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1126 }
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1127 }
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1128
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1129 return false;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1130 }
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1131
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1132 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
1133 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
1134 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1135 xmin = xminp = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
1136 xmax = xmaxp = -octave_Inf;
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1137
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1138 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
1139 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1140 if (data.is_integer_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1141 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1142 if (data.is_int8_type ())
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
1143 get_array_limits (data.int8_array_value (), xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1144 else if (data.is_uint8_type ())
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
1145 get_array_limits (data.uint8_array_value (), xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1146 else if (data.is_int16_type ())
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
1147 get_array_limits (data.int16_array_value (), xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1148 else if (data.is_uint16_type ())
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
1149 get_array_limits (data.uint16_array_value (), xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1150 else if (data.is_int32_type ())
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
1151 get_array_limits (data.int32_array_value (), xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1152 else if (data.is_uint32_type ())
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
1153 get_array_limits (data.uint32_array_value (), xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1154 else if (data.is_int64_type ())
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
1155 get_array_limits (data.int64_array_value (), xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1156 else if (data.is_uint64_type ())
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
1157 get_array_limits (data.uint64_array_value (), xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1158 }
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
1159 else
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
1160 get_array_limits (data.array_value (), xmin, xmax, xminp, xmaxp);
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1161 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1162 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1163
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1164 bool
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1165 handle_property::do_set (const octave_value& v)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1166 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1167 double dv = v.double_value ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1168
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1169 if (! error_state)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1170 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1171 graphics_handle gh = gh_manager::lookup (dv);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1172
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1173 if (xisnan (gh.value ()) || gh.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1174 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1175 if (current_val != gh)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1176 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1177 current_val = gh;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1178 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1179 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1180 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1181 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1182 error ("set: invalid graphics handle (= %g) for property \"%s\"",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1183 dv, get_name ().c_str ());
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1184 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1185 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1186 error ("set: invalid graphics handle for property \"%s\"",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1187 get_name ().c_str ());
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1188
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1189 return false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1190 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1191
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1192 Matrix
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1193 children_property::do_get_children (bool return_hidden) const
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1194 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1195 Matrix retval (children_list.size (), 1);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1196 octave_idx_type k = 0;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1197
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1198 graphics_object go = gh_manager::get_object (0);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1199
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1200 root_figure::properties& props =
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1201 dynamic_cast<root_figure::properties&> (go.get_properties ());
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1202
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1203 if (! props.is_showhiddenhandles ())
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1204 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1205 for (const_children_list_iterator p = children_list.begin ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1206 p != children_list.end (); p++)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1207 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1208 graphics_handle kid = *p;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1209
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1210 if (gh_manager::is_handle_visible (kid))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1211 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1212 if (! return_hidden)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1213 retval(k++) = *p;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1214 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1215 else if (return_hidden)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1216 retval(k++) = *p;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1217 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1218
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1219 retval.resize (k, 1);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1220 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1221 else
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1222 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1223 for (const_children_list_iterator p = children_list.begin ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1224 p != children_list.end (); p++)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1225 retval(k++) = *p;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1226 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1227
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1228 return retval;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1229 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1230
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1231 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1232 children_property::do_delete_children (bool clear)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1233 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1234 for (children_list_iterator p = children_list.begin ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1235 p != children_list.end (); p++)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1236 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1237 graphics_object go = gh_manager::get_object (*p);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1238
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1239 if (go.valid_object ())
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1240 gh_manager::free (*p);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1241
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1242 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1243
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1244 if (clear)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1245 children_list.clear ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1246 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1247
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1248 bool
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1249 callback_property::validate (const octave_value& v) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1250 {
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1251 // case 1: function handle
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1252 // 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
1253 // case 3: string corresponding to known function name
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1254 // case 4: evaluatable string
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1255 // case 5: empty matrix
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1256
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1257 if (v.is_function_handle ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1258 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1259 else if (v.is_string ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1260 // complete validation will be done at execution-time
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1261 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1262 else if (v.is_cell () && v.length () > 0
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1263 && (v.rows() == 1 || v.columns () == 1)
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1264 && v.cell_value ()(0).is_function_handle ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1265 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1266 else if (v.is_empty ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1267 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1268
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1269 return false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1270 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1271
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1272 void
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1273 callback_property::execute (const octave_value& data) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1274 {
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1275 if (callback.is_defined () && ! callback.is_empty ())
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
1276 gh_manager::execute_callback (get_parent (), callback, data);
7824
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
1277 }
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
1278
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1279 // Used to cache dummy graphics objects from which dynamic
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1280 // properties can be cloned.
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1281 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
1282
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1283 property
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1284 property::create (const std::string& name, const graphics_handle& h,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1285 const caseless_str& type, const octave_value_list& args)
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1286 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1287 property retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1288
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1289 if (type.compare ("string"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1290 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1291 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
1292
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1293 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1294 retval = property (new string_property (name, h, val));
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1295 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1296 else if (type.compare ("any"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1297 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1298 octave_value val =
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1299 (args.length () > 0 ? args(0) : octave_value (Matrix ()));
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1300
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1301 retval = property (new any_property (name, h, val));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1302 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1303 else if (type.compare ("radio"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1304 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1305 if (args.length () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1306 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1307 std::string vals = args(0).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1308
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1309 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1310 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1311 retval = property (new radio_property (name, h, vals));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1312
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1313 if (args.length () > 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1314 retval.set (args(1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1315 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1316 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1317 error ("addproperty: invalid argument for radio property, expected a string value");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1318 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1319 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1320 error ("addproperty: missing possible values for radio property");
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1321 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1322 else if (type.compare ("double"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1323 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1324 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
1325
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1326 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1327 retval = property (new double_property (name, h, d));
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1328 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1329 else if (type.compare ("handle"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1330 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1331 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
1332
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1333 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1334 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1335 graphics_handle gh (hh);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1336
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1337 retval = property (new handle_property (name, h, gh));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1338 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1339 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1340 else if (type.compare ("boolean"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1341 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1342 retval = property (new bool_property (name, h, false));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1343
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1344 if (args.length () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1345 retval.set (args(0));
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1346 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1347 else if (type.compare ("data"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1348 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1349 retval = property (new array_property (name, h, Matrix ()));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1350
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1351 if (args.length () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1352 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1353 retval.set (args(0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1354
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1355 // FIXME -- additional argument could define constraints,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1356 // but is this really useful?
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1357 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1358 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1359 else if (type.compare ("color"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1360 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1361 color_values cv (0, 0, 0);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1362 radio_values rv;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1363
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1364 if (args.length () > 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1365 rv = radio_values (args(1).string_value ());
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1366
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1367 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1368 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1369 retval = property (new color_property (name, h, cv, rv));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1370
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1371 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1372 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1373 if (args.length () > 0 && ! args(0).is_empty ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1374 retval.set (args(0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1375 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1376 retval.set (rv.default_value ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1377 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1378 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1379 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1380 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1381 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1382 caseless_str go_name, go_rest;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1383
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1384 if (lookup_object_name (type, go_name, go_rest))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1385 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1386 graphics_object go;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1387
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1388 std::map<caseless_str, graphics_object>::const_iterator it =
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1389 dprop_obj_map.find (go_name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1390
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1391 if (it == dprop_obj_map.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1392 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1393 base_graphics_object *bgo =
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1394 make_graphics_object_from_type (go_name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1395
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1396 if (bgo)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1397 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1398 go = graphics_object (bgo);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1399
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1400 dprop_obj_map[go_name] = go;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1401 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1402 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1403 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1404 go = it->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1405
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1406 if (go.valid_object ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1407 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1408 property prop = go.get_properties ().get_property (go_rest);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1409
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1410 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1411 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1412 retval = prop.clone ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1413
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1414 retval.set_parent (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1415 retval.set_name (name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1416
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1417 if (args.length () > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1418 retval.set (args(0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1419 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1420 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1421 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1422 error ("addproperty: invalid object type (= %s)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1423 go_name.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1424 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1425 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1426 error ("addproperty: unsupported type for dynamic property (= %s)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1427 type.c_str ());
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1428 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1429
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1430 return retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1431 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1432
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1433 // ---------------------------------------------------------------------
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1434
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1435 void
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1436 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
1437 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1438 size_t offset = 0;
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1439
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1440 size_t len = name.length ();
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1441
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1442 if (len > 4)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1443 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1444 caseless_str pfx = name.substr (0, 4);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1445
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1446 if (pfx.compare ("axes") || pfx.compare ("line")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1447 || pfx.compare ("text"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1448 offset = 4;
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1449 else if (len > 5)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1450 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1451 pfx = name.substr (0, 5);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1452
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1453 if (pfx.compare ("image") || pfx.compare ("patch"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1454 offset = 5;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1455 else if (len > 6)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1456 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1457 pfx = name.substr (0, 6);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1458
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
1459 if (pfx.compare ("figure") || pfx.compare ("uimenu"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1460 offset = 6;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1461 else if (len > 7)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1462 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1463 pfx = name.substr (0, 7);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1464
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1465 if (pfx.compare ("surface") || pfx.compare ("hggroup"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1466 offset = 7;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1467 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1468 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1469 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1470
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1471 if (offset > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1472 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1473 // FIXME -- should we validate property names and values here?
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1474
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1475 std::string pname = name.substr (offset);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1476
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1477 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1478 std::transform (pname.begin (), pname.end (), pname.begin (), tolower);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1479
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1480 bool has_property = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1481 if (pfx == "axes")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1482 has_property = axes::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1483 else if (pfx == "line")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1484 has_property = line::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1485 else if (pfx == "text")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1486 has_property = text::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1487 else if (pfx == "image")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1488 has_property = image::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1489 else if (pfx == "patch")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1490 has_property = patch::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1491 else if (pfx == "figure")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1492 has_property = figure::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1493 else if (pfx == "surface")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1494 has_property = surface::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1495 else if (pfx == "hggroup")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1496 has_property = hggroup::properties::has_core_property (pname);
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents: 11259
diff changeset
1497 else if (pfx == "uimenu")
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
1498 has_property = uimenu::properties::has_core_property (pname);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1499
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1500 if (has_property)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1501 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1502 bool remove = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1503 if (val.is_string ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1504 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1505 caseless_str tval = val.string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1506
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1507 remove = tval.compare ("remove");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1508 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1509
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1510 pval_map_type& pval_map = plist_map[pfx];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1511
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1512 if (remove)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1513 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1514 pval_map_iterator p = pval_map.find (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1515
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1516 if (p != pval_map.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1517 pval_map.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1518 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1519 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1520 pval_map[pname] = val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1521 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1522 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1523 error ("invalid %s property `%s'", pfx.c_str (), pname.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1524 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1525 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1526
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
1527 if (! error_state && offset == 0)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1528 error ("invalid default property specification");
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1529 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1530
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1531 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1532 property_list::lookup (const caseless_str& name) const
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1533 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1534 octave_value retval;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1535
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1536 size_t offset = 0;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1537
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1538 size_t len = name.length ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1539
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1540 if (len > 4)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1541 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1542 caseless_str pfx = name.substr (0, 4);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1543
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1544 if (pfx.compare ("axes") || pfx.compare ("line")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1545 || pfx.compare ("text"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1546 offset = 4;
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1547 else if (len > 5)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1548 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1549 pfx = name.substr (0, 5);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1550
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1551 if (pfx.compare ("image") || pfx.compare ("patch"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1552 offset = 5;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1553 else if (len > 6)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1554 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1555 pfx = name.substr (0, 6);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1556
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
1557 if (pfx.compare ("figure") || pfx.compare ("uimenu"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1558 offset = 6;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1559 else if (len > 7)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1560 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1561 pfx = name.substr (0, 7);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1562
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1563 if (pfx.compare ("surface") || pfx.compare ("hggroup"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1564 offset = 7;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1565 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1566 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1567 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1568
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1569 if (offset > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1570 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1571 std::string pname = name.substr (offset);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1572
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1573 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1574 std::transform (pname.begin (), pname.end (), pname.begin (), tolower);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1575
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1576 plist_map_const_iterator p = find (pfx);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1577
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1578 if (p != end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1579 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1580 const pval_map_type& pval_map = p->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1581
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1582 pval_map_const_iterator q = pval_map.find (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1583
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1584 if (q != pval_map.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1585 retval = q->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1586 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1587 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1588 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1589
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1590 return retval;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1591 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1592
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
1593 octave_scalar_map
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1594 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
1595 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
1596 octave_scalar_map m;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1597
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1598 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
1599 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1600 std::string prefix = prefix_arg + p->first;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1601
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1602 const pval_map_type pval_map = p->second;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1603
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1604 for (pval_map_const_iterator q = pval_map.begin ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1605 q != pval_map.end ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1606 q++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1607 m.assign (prefix + q->first, q->second);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1608 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1609
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1610 return m;
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1611 }
6432
5bec61ae1576 [project @ 2007-03-23 02:19:10 by jwe]
jwe
parents: 6425
diff changeset
1612
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1613 graphics_handle::graphics_handle (const octave_value& a)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1614 : val (octave_NaN)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1615 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1616 if (a.is_empty ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1617 /* do nothing */;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1618 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1619 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1620 double tval = a.double_value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1621
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1622 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1623 val = tval;
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1624 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1625 error ("invalid graphics handle");
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1626 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1627 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1628
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1629 // Set properties given as a cs-list of name, value pairs.
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1630
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1631 void
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1632 graphics_object::set (const octave_value_list& args)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1633 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1634 int nargin = args.length ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1635
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1636 if (nargin == 0)
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1637 error ("graphics_object::set: Nothing to set");
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1638 else if (nargin % 2 == 0)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1639 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1640 for (int i = 0; i < nargin; i += 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1641 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1642 caseless_str name = args(i).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1643
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1644 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1645 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1646 octave_value val = args(i+1);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1647
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1648 set_value_or_default (name, val);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1649
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1650 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1651 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1652 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1653 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1654 error ("set: expecting argument %d to be a property name", i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1655 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1656 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1657 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1658 error ("set: invalid number of arguments");
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1659 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1660
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1661 /*
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1662 %!# test set with name, value pairs
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1663 %!test
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1664 %! set(gcf, "visible", "off");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1665 %! h = plot (1:10, 10:-1:1);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1666 %! set (h, "linewidth", 10, "marker", "x");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1667 %! assert (get (h, "linewidth"), 10);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1668 %! assert (get (h, "marker"), "x");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1669 */
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1670
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1671 // Set properties given in two cell arrays containing names and values.
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1672 void
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1673 graphics_object::set (const Array<std::string>& names,
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1674 const Cell& values, octave_idx_type row)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1675 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1676 if (names.numel () != values.columns ())
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1677 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1678 error("set: number of names must match number of value columns (%d != %d)",
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1679 names.numel (), values.columns ());
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1680 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1681
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1682 octave_idx_type k = names.columns ();
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1683
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1684 for (octave_idx_type column = 0; column < k; column++)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1685 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1686 caseless_str name = names(column);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1687 octave_value val = values(row, column);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1688
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1689 set_value_or_default (name, val);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1690
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1691 if (error_state)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1692 break;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1693 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1694 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1695
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1696 /*
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1697 %!# test set with cell array arguments
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1698 %!test
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1699 %! set (gcf, "visible", "off");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1700 %! h = plot (1:10, 10:-1:1);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1701 %! set (h, {"linewidth", "marker"}, {10, "x"});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1702 %! assert (get(h, "linewidth"), 10);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1703 %! assert (get(h, "marker"), "x");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1704
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1705 %!# test set with multiple handles and cell array arguments
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1706 %!test
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1707 %! set (gcf, "visible", "off");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1708 %! h = plot (1:10, 10:-1:1, 1:10, 1:10);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1709 %! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1710 %! assert (get (h, "linewidth"), {10; 5});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1711 %! assert (get (h, "marker"), {"x"; "o"});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1712 %! set (h, {"linewidth", "marker"}, {10, "x"});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1713 %! assert (get (h, "linewidth"), {10; 10});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1714 %! assert (get (h, "marker"), {"x"; "x"});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1715
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1716 %!error <set: number of graphics handles must match number of value rows>
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1717 %! set (gcf, "visible", "off");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1718 %! h = plot (1:10, 10:-1:1, 1:10, 1:10);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1719 %! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"; 7, "."});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1720
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1721 %!error <set: number of names must match number of value columns>
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1722 %! set (gcf, "visible", "off");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1723 %! h = plot (1:10, 10:-1:1, 1:10, 1:10);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1724 %! set (h, {"linewidth"}, {10, "x"; 5, "o"});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1725 */
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1726
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1727 // Set properties given in a struct array
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1728 void
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
1729 graphics_object::set (const octave_map& m)
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
1730 {
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
1731 for (octave_map::const_iterator p = m.begin ();
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1732 p != m.end (); p++)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1733 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1734 caseless_str name = m.key (p);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1735
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1736 octave_value val = octave_value (m.contents (p).elem (m.numel () - 1));
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1737
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1738 set_value_or_default (name, val);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1739
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1740 if (error_state)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1741 break;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1742 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1743 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1744
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1745 /*
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1746 %!# test set with struct arguments
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1747 %!test
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1748 %! set (gcf, "visible", "off");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1749 %! h = plot (1:10, 10:-1:1);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1750 %! set (h, struct ("linewidth", 10, "marker", "x"));
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1751 %! assert (get (h, "linewidth"), 10);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1752 %! assert (get (h, "marker"), "x");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1753 %! h = plot (1:10, 10:-1:1, 1:10, 1:10);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1754 %! set (h, struct ("linewidth", {5, 10}));
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1755 %! assert (get(h, "linewidth"), {10; 10});
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1756 */
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1757
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1758 // Set a property to a value or to its (factory) default value.
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1759
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1760 void
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1761 graphics_object::set_value_or_default (const caseless_str& name,
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1762 const octave_value& val)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1763 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1764 if (val.is_string ())
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1765 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1766 caseless_str tval = val.string_value ();
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1767
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1768 octave_value default_val;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1769
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1770 if (tval.compare ("default"))
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1771 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1772 default_val = get_default (name);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1773
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1774 if (error_state)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1775 return;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1776
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1777 rep->set (name, default_val);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1778 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1779 else if (tval.compare ("factory"))
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1780 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1781 default_val = get_factory_default (name);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1782
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1783 if (error_state)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1784 return;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1785
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1786 rep->set (name, default_val);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1787 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1788 else
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1789 rep->set (name, val);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1790 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1791 else
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1792 rep->set (name, val);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1793 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1794
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1795 /*
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1796 %!# test setting of default values
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1797 %!test
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1798 %! set (gcf, "visible", "off");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1799 %! h = plot (1:10, 10:-1:1);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1800 %! set (0, "defaultlinelinewidth", 20);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1801 %! set (h, "linewidth", "default");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1802 %! assert (get (h, "linewidth"), 20);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1803 %! set (h, "linewidth", "factory");
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1804 %! assert (get (h, "linewidth"), 0.5);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1805 */
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
1806
8234
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1807 static double
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1808 make_handle_fraction (void)
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1809 {
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1810 static double maxrand = RAND_MAX + 2.0;
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1811
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1812 return (rand () + 1.0) / maxrand;
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1813 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1814
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1815 graphics_handle
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1816 gh_manager::get_handle (const std::string& go_name)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1817 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1818 graphics_handle retval;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1819
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1820 if (go_name == "figure")
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1821 {
8234
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1822 // Figure handles are positive integers corresponding to the
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1823 // figure number.
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1824
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1825 // We always want the lowest unused figure number.
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1826
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1827 retval = 1;
6425
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
1828
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1829 while (handle_map.find (retval) != handle_map.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1830 retval++;
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1831 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1832 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1833 {
8234
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1834 // Other graphics handles are negative integers plus some random
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1835 // fractional part. To avoid running out of integers, we
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1836 // recycle the integer part but tack on a new random part each
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1837 // time.
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
1838
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1839 free_list_iterator p = handle_free_list.begin ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1840
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1841 if (p != handle_free_list.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1842 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1843 retval = *p;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1844 handle_free_list.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1845 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1846 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1847 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1848 retval = graphics_handle (next_handle);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1849
11450
5eb10763069f substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents: 11431
diff changeset
1850 next_handle = std::ceil (next_handle) - 1.0 - make_handle_fraction ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1851 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1852 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1853
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1854 return retval;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1855 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1856
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1857 void
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1858 gh_manager::do_free (const graphics_handle& h)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1859 {
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1860 if (h.ok ())
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1861 {
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
1862 if (h.value () != 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1863 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1864 iterator p = handle_map.find (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1865
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1866 if (p != handle_map.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1867 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1868 base_properties& bp = p->second.get_properties ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1869
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1870 bp.set_beingdeleted (true);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1871
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1872 bp.delete_children ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1873
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1874 octave_value val = bp.get_deletefcn ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1875
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1876 bp.execute_deletefcn ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1877
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1878 // Notify graphics toolkit.
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1879 graphics_toolkit toolkit = p->second.get_toolkit ();
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1880 if (toolkit)
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1881 toolkit.finalize (p->second);
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
1882
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1883 // Note: this will be valid only for first explicitly
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1884 // deleted object. All its children will then have an
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1885 // unknown graphics toolkit.
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1886
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1887 // Graphics handles for non-figure objects are negative
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1888 // integers plus some random fractional part. To avoid
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1889 // running out of integers, we recycle the integer part
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1890 // but tack on a new random part each time.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1891
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1892 handle_map.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1893
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1894 if (h.value () < 0)
11450
5eb10763069f substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents: 11431
diff changeset
1895 handle_free_list.insert (std::ceil (h.value ()) - make_handle_fraction ());
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1896 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1897 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1898 error ("graphics_handle::free: invalid object %g", h.value ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1899 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1900 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1901 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
1902 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1903 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1904
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1905 gh_manager *gh_manager::instance = 0;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1906
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1907 static void
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1908 xset (const graphics_handle& h, const caseless_str& name,
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1909 const octave_value& val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1910 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1911 graphics_object obj = gh_manager::get_object (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1912 obj.set (name, val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1913 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1914
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1915 static void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1916 xset (const graphics_handle& h, const octave_value_list& args)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1917 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1918 if (args.length () > 0)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1919 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1920 graphics_object obj = gh_manager::get_object (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1921 obj.set (args);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1922 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1923 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1924
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1925 static octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1926 xget (const graphics_handle& h, const caseless_str& name)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1927 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1928 graphics_object obj = gh_manager::get_object (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1929 return obj.get (name);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1930 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1931
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1932 static graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1933 reparent (const octave_value& ov, const std::string& who,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1934 const std::string& property, const graphics_handle& new_parent,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1935 bool adopt = true)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1936 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1937 graphics_handle h = octave_NaN;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1938
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1939 double val = ov.double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1940
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1941 if (! error_state)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1942 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1943 h = gh_manager::lookup (val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1944
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1945 if (h.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1946 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1947 graphics_object obj = gh_manager::get_object (h);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1948
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1949 graphics_handle parent_h = obj.get_parent ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1950
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1951 graphics_object parent_obj = gh_manager::get_object (parent_h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1952
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1953 parent_obj.remove_child (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1954
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1955 if (adopt)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1956 obj.set ("parent", new_parent.value ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1957 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1958 obj.reparent (new_parent);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1959 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1960 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1961 error ("%s: invalid graphics handle (= %g) for %s",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1962 who.c_str (), val, property.c_str ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1963 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1964 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1965 error ("%s: expecting %s to be a graphics handle",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1966 who.c_str (), property.c_str ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1967
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1968 return h;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1969 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1970
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1971 // 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
1972 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1973 gcf (void)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1974 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1975 octave_value val = xget (0, "currentfigure");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1976
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1977 return val.is_empty () ? octave_NaN : val.double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1978 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1979
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1980 // 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
1981 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1982 gca (void)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1983 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1984 octave_value val = xget (gcf (), "currentaxes");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1985
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1986 return val.is_empty () ? octave_NaN : val.double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1987 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1988
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1989 static void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1990 adopt (const graphics_handle& p, const graphics_handle& h)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1991 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1992 graphics_object parent_obj = gh_manager::get_object (p);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1993 parent_obj.adopt (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1994 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1995
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1996 static bool
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1997 is_handle (const graphics_handle& h)
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1998 {
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
1999 return h.ok ();
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2000 }
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2001
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2002 static bool
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2003 is_handle (double val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2004 {
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2005 graphics_handle h = gh_manager::lookup (val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2006
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2007 return h.ok ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2008 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2009
8183
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2010 static octave_value
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2011 is_handle (const octave_value& val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2012 {
8183
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2013 octave_value retval = false;
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2014
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2015 if (val.is_real_scalar () && is_handle (val.double_value ()))
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2016 retval = true;
12587
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2017 else if (val.is_numeric_type () && val.is_real_type ())
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2018 {
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2019 const NDArray handles = val.array_value ();
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2020
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2021 if (! error_state)
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2022 {
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2023 boolNDArray result (handles.dims ());
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2024
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2025 for (octave_idx_type i = 0; i < handles.numel (); i++)
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2026 result.xelem (i) = is_handle (handles (i));
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2027
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2028 retval = result;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2029 }
8183
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2030 }
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2031
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2032 return retval;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2033 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2034
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2035 static bool
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2036 is_figure (double val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2037 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2038 graphics_object obj = gh_manager::get_object (val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2039
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2040 return obj && obj.isa ("figure");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2041 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2042
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2043 static void
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2044 xcreatefcn (const graphics_handle& h)
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2045 {
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2046 graphics_object obj = gh_manager::get_object (h);
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2047 obj.get_properties ().execute_createfcn ();
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2048 }
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2049
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2050 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2051
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2052 void
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2053 base_graphics_toolkit::update (const graphics_handle& h, int id)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2054 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2055 graphics_object go = gh_manager::get_object (h);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2056
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
2057 update (go, id);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2058 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2060 void
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2061 base_graphics_toolkit::initialize (const graphics_handle& h)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2062 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2063 graphics_object go = gh_manager::get_object (h);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2064
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
2065 initialize (go);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2066 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2067
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2068 void
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2069 base_graphics_toolkit::finalize (const graphics_handle& h)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2070 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2071 graphics_object go = gh_manager::get_object (h);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2072
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
2073 finalize (go);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2074 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2075 // ---------------------------------------------------------------------
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2076
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2077 void
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2078 base_properties::set_from_list (base_graphics_object& obj,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2079 property_list& defaults)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2080 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2081 std::string go_name = graphics_object_name ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2082
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2083 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
2084
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2085 if (p != defaults.end ())
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2086 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2087 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
2088
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2089 for (property_list::pval_map_const_iterator q = pval_map.begin ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2090 q != pval_map.end ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2091 q++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2092 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2093 std::string pname = q->first;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2094
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2095 obj.set (pname, q->second);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2096
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2097 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2098 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2099 error ("error setting default property %s", pname.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2100 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2101 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2102 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2103 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2104 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2105
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2106 octave_value
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2107 base_properties::get_dynamic (const caseless_str& name) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2108 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2109 octave_value retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2110
8090
3cc1ca1b1576 MSVC compilation fix
Michael Goffioul
parents: 8081
diff changeset
2111 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it = all_props.find (name);
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2112
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2113 if (it != all_props.end ())
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2114 retval = it->second.get ();
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2115 else
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2116 error ("get: unknown property \"%s\"", name.c_str ());
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2117
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2118 return retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2119 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2120
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2121 octave_value
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2122 base_properties::get_dynamic (bool all) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2123 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2124 octave_scalar_map m;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2125
8090
3cc1ca1b1576 MSVC compilation fix
Michael Goffioul
parents: 8081
diff changeset
2126 for (std::map<caseless_str, property, cmp_caseless_str>::const_iterator it = all_props.begin ();
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2127 it != all_props.end (); ++it)
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
2128 if (all || ! it->second.is_hidden ())
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
2129 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
2130
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2131 return m;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2132 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2133
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
2134 std::set<std::string>
9972
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2135 base_properties::dynamic_property_names (void) const
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2136 {
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2137 return dynamic_properties;
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
2138 }
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
2139
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2140 bool
9972
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2141 base_properties::has_dynamic_property (const std::string& pname)
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2142 {
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2143 const std::set<std::string>& dynprops = dynamic_property_names ();
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2144
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2145 return dynprops.find (pname) != dynprops.end ();
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2146 }
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2147
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2148 void
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2149 base_properties::set_dynamic (const caseless_str& pname,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2150 const octave_value& val)
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2151 {
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2152 std::map<caseless_str, property, cmp_caseless_str>::iterator it = all_props.find (pname);
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2153
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2154 if (it != all_props.end ())
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2155 it->second.set (val);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2156 else
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2157 error ("set: unknown property \"%s\"", pname.c_str ());
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2158
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2159 if (! error_state)
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2160 {
9972
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2161 dynamic_properties.insert (pname);
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2162
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2163 mark_modified ();
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2164 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2165 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2166
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2167 property
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2168 base_properties::get_property_dynamic (const caseless_str& name)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2169 {
8090
3cc1ca1b1576 MSVC compilation fix
Michael Goffioul
parents: 8081
diff changeset
2170 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it = all_props.find (name);
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2171
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2172 if (it == all_props.end ())
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2173 {
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2174 error ("get_property: unknown property \"%s\"", name.c_str ());
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2175 return property ();
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2176 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2177 else
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2178 return it->second;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2179 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2180
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2181 void
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2182 base_properties::set_parent (const octave_value& val)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2183 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2184 double tmp = val.double_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2185
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2186 graphics_handle new_parent = octave_NaN;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2187
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2188 if (! error_state)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2189 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2190 new_parent = gh_manager::lookup (tmp);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2191
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2192 if (new_parent.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2193 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2194 graphics_object parent_obj = gh_manager::get_object (get_parent ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2195
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2196 parent_obj.remove_child (__myhandle__);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2197
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2198 parent = new_parent.as_octave_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2199
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2200 ::adopt (parent.handle_value (), __myhandle__);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2201 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2202 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2203 error ("set: invalid graphics handle (= %g) for parent", tmp);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2204 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2205 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2206 error ("set: expecting parent to be a graphics handle");
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2207 }
6432
5bec61ae1576 [project @ 2007-03-23 02:19:10 by jwe]
jwe
parents: 6425
diff changeset
2208
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2209 void
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2210 base_properties::mark_modified (void)
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2211 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2212 __modified__ = "on";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2213 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
2214 if (parent_obj)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
2215 parent_obj.mark_modified ();
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2216 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2217
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2218 void
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2219 base_properties::override_defaults (base_graphics_object& obj)
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2220 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2221 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
2222
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
2223 if (parent_obj)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
2224 parent_obj.override_defaults (obj);
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2225 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2226
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2227 void
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2228 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
2229 {
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2230 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
2231
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2232 if (obj)
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2233 obj.update_axis_limits (axis_type);
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2234 }
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2235
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2236 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2237 base_properties::update_axis_limits (const std::string& axis_type,
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2238 const graphics_handle& h) const
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2239 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2240 graphics_object obj = gh_manager::get_object (__myhandle__);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2241
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2242 if (obj)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2243 obj.update_axis_limits (axis_type, h);
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2244 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2245
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2246 graphics_toolkit
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2247 base_properties::get_toolkit (void) const
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2248 {
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2249 graphics_object go = gh_manager::get_object (get_parent ());
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2250
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2251 if (go)
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2252 return go.get_toolkit ();
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2253 else
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2254 return graphics_toolkit ();
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2255 }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
2256
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2257 void
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2258 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
2259 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2260 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
2261
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2262 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
2263 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2264 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
2265
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2266 if (go.valid_object ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2267 go.get_properties ().update_boundingbox ();
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2268 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2269 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2270
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2271 void
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2272 base_properties::update_autopos (const std::string& elem_type)
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2273 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2274 graphics_object parent_obj = gh_manager::get_object (get_parent ());
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2275
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2276 if (parent_obj.valid_object ())
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2277 parent_obj.get_properties ().update_autopos (elem_type);
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2278 }
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2279
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
2280 void
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2281 base_properties::add_listener (const caseless_str& nm, const octave_value& v,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2282 listener_mode mode)
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2283 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2284 property p = get_property (nm);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2285
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2286 if (! error_state && p.ok ())
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2287 p.add_listener (v, mode);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2288 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2289
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2290 void
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2291 base_properties::delete_listener (const caseless_str& nm,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2292 const octave_value& v, listener_mode mode)
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2293 {
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2294 property p = get_property (nm);
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2295
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2296 if (! error_state && p.ok ())
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2297 p.delete_listener (v, mode);
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2298 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2299
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2300 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2301
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2302 class gnuplot_toolkit : public base_graphics_toolkit
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2303 {
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2304 public:
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2305 gnuplot_toolkit (void)
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2306 : base_graphics_toolkit ("gnuplot") { }
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2307
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2308 ~gnuplot_toolkit (void) { }
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2309
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2310 bool is_valid (void) const { return true; }
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2311
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
2312 void finalize (const graphics_object& go)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2313 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2314 if (go.isa ("figure"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2315 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2316 const figure::properties& props =
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2317 dynamic_cast<const figure::properties&> (go.get_properties ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2318
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2319 send_quit (props.get___plot_stream__ ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2320 }
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2321 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2322
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
2323 void update (const graphics_object& go, int id)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2324 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2325 if (go.isa ("figure"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2326 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2327 graphics_object obj (go);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2328
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2329 figure::properties& props =
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2330 dynamic_cast<figure::properties&> (obj.get_properties ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2331
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2332 switch (id)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2333 {
11239
5fa7667f90e5 Add prefix ID_ to property ids to avoid name clash on windows
Kai Habel <kai.habel@gmx.de>
parents: 11175
diff changeset
2334 case base_properties::ID_VISIBLE:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2335 if (! props.is_visible ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2336 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2337 send_quit (props.get___plot_stream__ ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2338 props.set___plot_stream__ (Matrix ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2339 props.set___enhanced__ (false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2340 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2341 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2342 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2343 }
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2344 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2345
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2346 void redraw_figure (const graphics_object& go) const
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2347 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2348 octave_value_list args;
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2349 args(0) = go.get_handle ().as_octave_value ();
12221
a91037b36b4c rename gnuplot_drawnow to __gnuplot_drawnow__
John W. Eaton <jwe@octave.org>
parents: 12215
diff changeset
2350 feval ("__gnuplot_drawnow__", args);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2351 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2352
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2353 void print_figure (const graphics_object& go, const std::string& term,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2354 const std::string& file, bool mono,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2355 const std::string& debug_file) const
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2356 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2357 octave_value_list args;
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2358 if (! debug_file.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2359 args(4) = debug_file;
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2360 args(3) = mono;
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2361 args(2) = file;
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2362 args(1) = term;
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2363 args(0) = go.get_handle ().as_octave_value ();
12221
a91037b36b4c rename gnuplot_drawnow to __gnuplot_drawnow__
John W. Eaton <jwe@octave.org>
parents: 12215
diff changeset
2364 feval ("__gnuplot_drawnow__", args);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2365 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2366
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2367 Matrix get_canvas_size (const graphics_handle&) const
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2368 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2369 Matrix sz (1, 2, 0.0);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2370 return sz;
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2371 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2372
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2373 double get_screen_resolution (void) const
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2374 { return 72.0; }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2375
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2376 Matrix get_screen_size (void) const
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2377 { return Matrix (1, 2, 0.0); }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2378
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2379 private:
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2380 void send_quit (const octave_value& pstream) const
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2381 {
9561
c60a9e1a0372 try to avoid gnuplot zombies
John W. Eaton <jwe@octave.org>
parents: 9455
diff changeset
2382 if (! pstream.is_empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2383 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2384 octave_value_list args;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2385 Matrix fids = pstream.matrix_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2386
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2387 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2388 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2389 args(1) = "\nquit;\n";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2390 args(0) = fids(0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2391 feval ("fputs", args);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2392
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2393 args.resize (1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2394 feval ("fflush", args);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2395 feval ("pclose", args);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2396
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2397 if (fids.numel () > 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2398 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2399 args(0) = fids(1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2400 feval ("pclose", args);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2401
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2402 if (fids.numel () > 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2403 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2404 args(0) = fids(2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2405 feval ("waitpid", args);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2406 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2407 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2408 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2409 }
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2410 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2411 };
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2412
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2413 graphics_toolkit
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2414 graphics_toolkit::default_toolkit (void)
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2415 {
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2416 if (available_toolkits.size () == 0)
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2417 register_toolkit (new gnuplot_toolkit ());
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2418
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2419 return available_toolkits["gnuplot"];
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2420 }
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2421
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2422 std::map<std::string, graphics_toolkit> graphics_toolkit::available_toolkits;
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2423
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2424 // ---------------------------------------------------------------------
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
2425
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2426 void
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2427 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
2428 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2429 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
2430 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2431 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
2432
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2433 if (parent_obj)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2434 parent_obj.update_axis_limits (axis_type);
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2435 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2436 else
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2437 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
2438 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2439
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2440 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2441 base_graphics_object::update_axis_limits (const std::string& axis_type,
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2442 const graphics_handle& h)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2443 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2444 if (valid_object ())
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2445 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2446 graphics_object parent_obj = gh_manager::get_object (get_parent ());
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2447
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2448 if (parent_obj)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2449 parent_obj.update_axis_limits (axis_type, h);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2450 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2451 else
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2452 error ("base_graphics_object::update_axis_limits: invalid graphics object");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2453 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2454
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2455 void
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2456 base_graphics_object::remove_all_listeners (void)
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2457 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2458 octave_map m = get (true).map_value ();
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2459
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2460 for (octave_map::const_iterator pa = m.begin (); pa != m.end (); pa++)
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2461 {
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2462 // FIXME -- there has to be a better way. I think we want to
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2463 // ask whether it is OK to delete the listener for the given
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2464 // property. How can we know in advance that it will be OK?
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2465
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
2466 unwind_protect frame;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
2467
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
2468 frame.protect_var (discard_error_messages);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
2469 frame.protect_var (error_state);
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2470
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2471 discard_error_messages = true;
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2472
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2473 property p = get_properties ().get_property (pa->first);
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2474
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
2475 if (! error_state && p.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2476 p.delete_listener ();
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2477 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2478 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2479
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2480 std::string
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2481 base_graphics_object::values_as_string (void)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2482 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2483 std::string retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2484
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2485 if (valid_object ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2486 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2487 octave_map m = get ().map_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2488
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2489 for (octave_map::const_iterator pa = m.begin (); pa != m.end (); pa++)
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2490 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2491 if (pa->first != "children")
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2492 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2493 property p = get_properties ().get_property (pa->first);
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2494
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2495 if (p.ok () && ! p.is_hidden ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2496 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2497 retval += "\n\t" + std::string (pa->first) + ": ";
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2498 if (p.is_radio ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2499 retval += p.values_as_string ();
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2500 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2501 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2502 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2503 if (retval != "")
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2504 retval += "\n";
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2505 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2506 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2507 error ("base_graphics_object::values_as_string: invalid graphics object");
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2508
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2509 return retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2510 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2511
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2512 octave_scalar_map
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2513 base_graphics_object::values_as_struct (void)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2514 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2515 octave_scalar_map retval;
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2516
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2517 if (valid_object ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2518 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2519 octave_scalar_map m = get ().scalar_map_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2520
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2521 for (octave_scalar_map::const_iterator pa = m.begin ();
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2522 pa != m.end (); pa++)
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2523 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2524 if (pa->first != "children")
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2525 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2526 property p = get_properties ().get_property (pa->first);
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2527
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2528 if (p.ok () && ! p.is_hidden ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2529 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2530 if (p.is_radio ())
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2531 retval.assign (p.get_name (), p.values_as_cell ());
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2532 else
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2533 retval.assign (p.get_name (), Cell ());
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2534 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2535 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2536 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2537 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2538 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2539 error ("base_graphics_object::values_as_struct: invalid graphics object");
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2540
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2541 return retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2542 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2543
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
2544 graphics_object
11492
d86389a6dc3f graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents: 11456
diff changeset
2545 graphics_object::get_ancestor (const std::string& obj_type) const
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
2546 {
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
2547 if (valid_object ())
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
2548 {
11492
d86389a6dc3f graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents: 11456
diff changeset
2549 if (isa (obj_type))
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
2550 return *this;
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
2551 else
11492
d86389a6dc3f graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents: 11456
diff changeset
2552 return gh_manager::get_object (get_parent ()).get_ancestor (obj_type);
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
2553 }
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
2554 else
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
2555 return graphics_object ();
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
2556 }
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
2557
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2558 // ---------------------------------------------------------------------
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2559
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2560 #include "graphics-props.cc"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2561
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2562 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2563
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2564 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2565 root_figure::properties::set_currentfigure (const octave_value& v)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2566 {
7378
3771971e8891 [project @ 2008-01-15 07:40:23 by jwe]
jwe
parents: 7373
diff changeset
2567 graphics_handle val (v);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2568
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2569 if (error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2570 return;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2571
7059
8d57f66e35b8 [project @ 2007-10-24 17:16:23 by jwe]
jwe
parents: 7056
diff changeset
2572 if (xisnan (val.value ()) || is_handle (val))
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2573 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2574 currentfigure = val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2575
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2576 gh_manager::push_figure (val);
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2577 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2578 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2579 gripe_set_invalid ("currentfigure");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2580 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2581
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2582 void
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2583 root_figure::properties::set_callbackobject (const octave_value& v)
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2584 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2585 graphics_handle val (v);
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2586
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2587 if (error_state)
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2588 return;
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2589
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2590 if (xisnan (val.value ()))
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2591 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2592 if (! cbo_stack.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2593 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2594 val = cbo_stack.front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2595
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2596 cbo_stack.pop_front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2597 }
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2598
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2599 callbackobject = val;
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2600 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2601 else if (is_handle (val))
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2602 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2603 if (get_callbackobject ().ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2604 cbo_stack.push_front (get_callbackobject ());
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2605
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2606 callbackobject = val;
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2607 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2608 else
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2609 gripe_set_invalid ("callbackobject");
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2610 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
2611
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2612 // FIXME This should update monitorpositions and pointerlocation, but
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2613 // as these properties are yet used, and so it doesn't matter that they
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2614 // aren't set yet.
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2615 void
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2616 root_figure::properties::update_units (void)
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2617 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2618 caseless_str xunits = get_units ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2619
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2620 Matrix ss = default_screensize ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2621
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2622 double dpi = get_screenpixelsperinch ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2623
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2624 if (xunits.compare ("inches"))
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2625 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2626 ss(0) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2627 ss(1) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2628 ss(2) /= dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2629 ss(3) /= dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2630 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2631 else if (xunits.compare ("centimeters"))
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2632 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2633 ss(0) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2634 ss(1) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2635 ss(2) *= 2.54 / dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2636 ss(3) *= 2.54 / dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2637 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2638 else if (xunits.compare ("normalized"))
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2639 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2640 ss = Matrix (1, 4, 1.0);
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2641 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2642 else if (xunits.compare ("points"))
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2643 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2644 ss(0) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2645 ss(1) = 0;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2646 ss(2) *= 72 / dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2647 ss(3) *= 72 / dpi;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2648 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2649
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2650 set_screensize (ss);
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2651 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2652
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
2653 void
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2654 root_figure::properties::remove_child (const graphics_handle& gh)
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2655 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2656 gh_manager::pop_figure (gh);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2657
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2658 graphics_handle cf = gh_manager::current_figure ();
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2659
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2660 xset (0, "currentfigure", cf.value ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2661
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2662 base_properties::remove_child (gh);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2663 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2664
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2665 property_list
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2666 root_figure::factory_properties = root_figure::init_factory_properties ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2667
10733
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
2668 static void
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
2669 reset_default_properties (property_list& default_properties)
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2670 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2671 property_list new_defaults;
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2672
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2673 for (property_list::plist_map_const_iterator p = default_properties.begin ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2674 p != default_properties.end (); p++)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2675 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2676 const property_list::pval_map_type pval_map = p->second;
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2677 std::string prefix = p->first;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2678
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2679 for (property_list::pval_map_const_iterator q = pval_map.begin ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2680 q != pval_map.end ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2681 q++)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2682 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2683 std::string s = q->first;
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2684
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2685 if (prefix == "axes" && (s == "position" || s == "units"))
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2686 new_defaults.set (prefix + s, q->second);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2687 else if (prefix == "figure" && (s == "position" || s == "units"
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2688 || s == "windowstyle"
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2689 || s == "paperunits"))
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2690 new_defaults.set (prefix + s, q->second);
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2691 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2692 }
10733
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
2693
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2694 default_properties = new_defaults;
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2695 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
2696
10733
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
2697 void
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
2698 root_figure::reset_default_properties (void)
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
2699 {
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
2700 ::reset_default_properties (default_properties);
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
2701 }
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
2702
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2703 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2704
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2705 void
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2706 figure::properties::set_currentaxes (const octave_value& v)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2707 {
7378
3771971e8891 [project @ 2008-01-15 07:40:23 by jwe]
jwe
parents: 7373
diff changeset
2708 graphics_handle val (v);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2709
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2710 if (error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2711 return;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2712
7070
7593f8e83a2e [project @ 2007-10-25 20:41:16 by jwe]
jwe
parents: 7059
diff changeset
2713 if (xisnan (val.value ()) || is_handle (val))
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2714 currentaxes = val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2715 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2716 gripe_set_invalid ("currentaxes");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2717 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2718
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2719 void
8266
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2720 figure::properties::remove_child (const graphics_handle& gh)
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2721 {
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2722 base_properties::remove_child (gh);
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2723
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2724 if (gh == currentaxes.handle_value ())
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2725 {
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2726 graphics_handle new_currentaxes;
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2727
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2728 Matrix kids = get_children ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2729
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2730 for (octave_idx_type i = 0; i < kids.numel (); i++)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2731 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
2732 graphics_handle kid = kids(i);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2733
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2734 graphics_object go = gh_manager::get_object (kid);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2735
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2736 if (go.isa ("axes"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2737 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2738 new_currentaxes = kid;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2739 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2740 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2741 }
8266
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2742
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2743 currentaxes = new_currentaxes;
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2744 }
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2745 }
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2746
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
2747 void
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2748 figure::properties::set_visible (const octave_value& val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2749 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2750 std::string s = val.string_value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2751
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2752 if (! error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2753 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2754 if (s == "on")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2755 xset (0, "currentfigure", __myhandle__.value ());
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2756
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2757 visible = val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2758 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2759 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2760
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2761 Matrix
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2762 figure::properties::get_boundingbox (bool) const
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2763 {
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2764 Matrix screen_size = screen_size_pixels ();
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2765 Matrix pos;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2766
10949
848f3a13b7cf Backed out changeset 6b50fd2d4ca6
David Bateman <dbateman@free.fr>
parents: 10948
diff changeset
2767 pos = convert_position (get_position ().matrix_value (), get_units (),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2768 "pixels", screen_size);
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2769
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2770 pos(0)--;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2771 pos(1)--;
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2772 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
2773
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2774 return pos;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2775 }
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
2776
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2777 void
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2778 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
2779 {
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2780 Matrix screen_size = screen_size_pixels ();
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2781 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
2782
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2783 pos(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
2784 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
2785 pos(0)++;
9238
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
2786 pos = convert_position (pos, "pixels", get_units (), screen_size);
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2787
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2788 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
2789 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2790
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2791 void
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2792 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
2793 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2794 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
2795 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2796 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
2797
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2798 old_bb = get_boundingbox ();
10949
848f3a13b7cf Backed out changeset 6b50fd2d4ca6
David Bateman <dbateman@free.fr>
parents: 10948
diff changeset
2799 position = v;
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2800 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
2801
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2802 if (old_bb != new_bb)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2803 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2804 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2805 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2806 execute_resizefcn ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2807 update_boundingbox ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2808 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2809 }
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2810
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2811 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
2812 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2813 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2814
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2815 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2816 figure::properties::set_paperunits (const octave_value& v)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2817 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2818 if (! error_state)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2819 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2820 caseless_str typ = get_papertype ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2821 caseless_str punits = v.string_value ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2822 if (! error_state)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2823 {
10994
9e1270a84a10 graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents: 10991
diff changeset
2824 if (punits.compare ("normalized") && typ.compare ("<custom>"))
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2825 error ("set: can't set the paperunits to normalized when the papertype is custom");
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2826 else
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2827 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2828 caseless_str old_paperunits = get_paperunits ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2829 if (paperunits.set (v, true))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2830 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2831 update_paperunits (old_paperunits);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2832 mark_modified ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2833 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2834 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2835 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2836 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2837 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2838
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2839 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2840 figure::properties::set_papertype (const octave_value& v)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2841 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2842 if (! error_state)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2843 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2844 caseless_str typ = v.string_value ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2845 caseless_str punits = get_paperunits ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2846 if (! error_state)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2847 {
10994
9e1270a84a10 graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents: 10991
diff changeset
2848 if (punits.compare ("normalized") && typ.compare ("<custom>"))
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2849 error ("set: can't set the paperunits to normalized when the papertype is custom");
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2850 else
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2851 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2852 if (papertype.set (v, true))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2853 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2854 update_papertype ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2855 mark_modified ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2856 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2857 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2858 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2859 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2860 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2861
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2862 static Matrix
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2863 papersize_from_type (const caseless_str punits, const caseless_str typ)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2864 {
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2865 Matrix ret (1, 2, 1.0);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2866
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2867 if (! punits.compare ("normalized"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2868 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2869 double in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2870 double mm2units;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2871
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2872 if (punits.compare ("inches"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2873 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2874 in2units = 1.0;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2875 mm2units = 1 / 25.4 ;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2876 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2877 else if (punits.compare ("centimeters"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2878 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2879 in2units = 2.54;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2880 mm2units = 1 / 10.0;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2881 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2882 else // points
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2883 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2884 in2units = 72.0;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2885 mm2units = 72.0 / 25.4;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2886 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2887
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2888 if (typ.compare ("usletter"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2889 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2890 ret (0) = 8.5 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2891 ret (1) = 11.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2892 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2893 else if (typ.compare ("uslegal"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2894 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2895 ret (0) = 8.5 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2896 ret (1) = 14.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2897 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2898 else if (typ.compare ("tabloid"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2899 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2900 ret (0) = 11.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2901 ret (1) = 17.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2902 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2903 else if (typ.compare ("a0"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2904 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2905 ret (0) = 841.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2906 ret (1) = 1189.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2907 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2908 else if (typ.compare ("a1"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2909 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2910 ret (0) = 594.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2911 ret (1) = 841.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2912 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2913 else if (typ.compare ("a2"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2914 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2915 ret (0) = 420.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2916 ret (1) = 594.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2917 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2918 else if (typ.compare ("a3"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2919 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2920 ret (0) = 297.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2921 ret (1) = 420.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2922 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2923 else if (typ.compare ("a4"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2924 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2925 ret (0) = 210.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2926 ret (1) = 297.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2927 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2928 else if (typ.compare ("a5"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2929 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2930 ret (0) = 148.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2931 ret (1) = 210.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2932 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2933 else if (typ.compare ("b0"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2934 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2935 ret (0) = 1029.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2936 ret (1) = 1456.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2937 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2938 else if (typ.compare ("b1"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2939 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2940 ret (0) = 728.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2941 ret (1) = 1028.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2942 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2943 else if (typ.compare ("b2"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2944 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2945 ret (0) = 514.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2946 ret (1) = 728.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2947 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2948 else if (typ.compare ("b3"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2949 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2950 ret (0) = 364.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2951 ret (1) = 514.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2952 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2953 else if (typ.compare ("b4"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2954 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2955 ret (0) = 257.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2956 ret (1) = 364.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2957 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2958 else if (typ.compare ("b5"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2959 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2960 ret (0) = 182.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2961 ret (1) = 257.0 * mm2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2962 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2963 else if (typ.compare ("arch-a"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2964 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2965 ret (0) = 9.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2966 ret (1) = 12.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2967 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2968 else if (typ.compare ("arch-b"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2969 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2970 ret (0) = 12.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2971 ret (1) = 18.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2972 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2973 else if (typ.compare ("arch-c"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2974 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2975 ret (0) = 18.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2976 ret (1) = 24.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2977 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2978 else if (typ.compare ("arch-d"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2979 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2980 ret (0) = 24.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2981 ret (1) = 36.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2982 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2983 else if (typ.compare ("arch-e"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2984 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2985 ret (0) = 36.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2986 ret (1) = 48.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2987 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2988 else if (typ.compare ("a"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2989 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2990 ret (0) = 8.5 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2991 ret (1) = 11.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2992 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2993 else if (typ.compare ("b"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2994 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2995 ret (0) = 11.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2996 ret (1) = 17.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2997 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2998 else if (typ.compare ("c"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
2999 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3000 ret (0) = 17.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3001 ret (1) = 22.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3002 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3003 else if (typ.compare ("d"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3004 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3005 ret (0) = 22.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3006 ret (1) = 34.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3007 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3008 else if (typ.compare ("e"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3009 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3010 ret (0) = 34.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3011 ret (1) = 43.0 * in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3012 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3013 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3014
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3015 return ret;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3016 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3017
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3018 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3019 figure::properties::update_paperunits (const caseless_str& old_paperunits)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3020 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3021 Matrix pos = get_paperposition ().matrix_value ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3022 Matrix sz = get_papersize ().matrix_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3023
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3024 pos (0) = pos (0) / sz(0);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3025 pos (1) = pos (1) / sz(1);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3026 pos (2) = pos (2) / sz(0);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3027 pos (3) = pos (3) / sz(1);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3028
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3029 caseless_str punits = get_paperunits ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3030 caseless_str typ = get_papertype ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3031
10994
9e1270a84a10 graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents: 10991
diff changeset
3032 if (typ.compare ("<custom>"))
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3033 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3034 if (old_paperunits.compare ("centimeters"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3035 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3036 sz (0) = sz (0) / 2.54;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3037 sz (1) = sz (1) / 2.54;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3038 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3039 else if (old_paperunits.compare ("points"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3040 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3041 sz (0) = sz (0) / 72.0;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3042 sz (1) = sz (1) / 72.0;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3043 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3044
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3045 if (punits.compare ("centimeters"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3046 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3047 sz(0) = sz(0) * 2.54;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3048 sz(1) = sz(1) * 2.54;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3049 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3050 else if (old_paperunits.compare ("points"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3051 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3052 sz (0) = sz (0) * 72.0;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3053 sz (1) = sz (1) * 72.0;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3054 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3055 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3056 else
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3057 sz = papersize_from_type (punits, typ);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3058
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3059 pos (0) = pos (0) * sz(0);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3060 pos (1) = pos (1) * sz(1);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3061 pos (2) = pos (2) * sz(0);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3062 pos (3) = pos (3) * sz(1);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3063
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3064 papersize.set (octave_value (sz));
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3065 paperposition.set (octave_value (pos));
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3066 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3067
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3068 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3069 figure::properties::update_papertype (void)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3070 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3071 caseless_str typ = get_papertype ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3072
10994
9e1270a84a10 graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents: 10991
diff changeset
3073 if (! typ.compare ("<custom>"))
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3074 // Call papersize.set rather than set_papersize to avoid loops between
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3075 // update_papersize and update_papertype
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3076 papersize.set (octave_value (papersize_from_type (get_paperunits (), typ)));
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3077 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3078
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3079 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3080 figure::properties::update_papersize (void)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3081 {
10994
9e1270a84a10 graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents: 10991
diff changeset
3082 papertype.set ("<custom>");
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3083 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3084
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3085 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3086 figure::properties::set_units (const octave_value& v)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3087 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3088 if (! error_state)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3089 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3090 caseless_str old_units = get_units ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3091 if (units.set (v, true))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3092 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3093 update_units (old_units);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3094 mark_modified ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3095 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3096 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3097 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3098
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3099 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3100 figure::properties::update_units (const caseless_str& old_units)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3101 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3102 set_position (convert_position (get_position ().matrix_value (), old_units,
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3103 get_units (), screen_size_pixels ()));
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3104 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3105
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3106 std::string
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3107 figure::properties::get_title (void) const
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3108 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3109 if (is_numbertitle ())
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3110 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3111 std::ostringstream os;
8062
e04a4beeb283 graphics.cc (figure::properties::get_title): avoid gcc warning
John W. Eaton <jwe@octave.org>
parents: 8061
diff changeset
3112 std::string nm = get_name ();
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3113
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3114 os << "Figure " << __myhandle__.value ();
8062
e04a4beeb283 graphics.cc (figure::properties::get_title): avoid gcc warning
John W. Eaton <jwe@octave.org>
parents: 8061
diff changeset
3115 if (! nm.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3116 os << ": " << get_name ();
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3117
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3118 return os.str ();
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3119 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3120 else
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3121 return get_name ();
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3122 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3123
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3124 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
3125 figure::get_default (const caseless_str& name) const
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3126 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3127 octave_value retval = default_properties.lookup (name);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3128
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3129 if (retval.is_undefined ())
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3130 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3131 graphics_handle parent = get_parent ();
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3132 graphics_object parent_obj = gh_manager::get_object (parent);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3133
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3134 retval = parent_obj.get_default (name);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3135 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3136
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3137 return retval;
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3138 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3139
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3140 void
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3141 figure::reset_default_properties (void)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3142 {
10733
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
3143 ::reset_default_properties (default_properties);
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3144 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
3145
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3146 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3147
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3148 void
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3149 axes::properties::init (void)
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3150 {
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3151 position.add_constraint (dim_vector (1, 4));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3152 position.add_constraint (dim_vector (0, 0));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3153 outerposition.add_constraint (dim_vector (1, 4));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3154 colororder.add_constraint (dim_vector (-1, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3155 dataaspectratio.add_constraint (dim_vector (1, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3156 plotboxaspectratio.add_constraint (dim_vector (1, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3157 xlim.add_constraint (2);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3158 ylim.add_constraint (2);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3159 zlim.add_constraint (2);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3160 clim.add_constraint (2);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3161 alim.add_constraint (2);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3162 xtick.add_constraint (dim_vector (1, -1));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3163 ytick.add_constraint (dim_vector (1, -1));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3164 ztick.add_constraint (dim_vector (1, -1));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3165 Matrix vw (1, 2, 0);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3166 vw(1) = 90;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3167 view = vw;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3168 view.add_constraint (dim_vector (1, 2));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3169 cameraposition.add_constraint (dim_vector (1, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3170 Matrix upv (1, 3, 0.0);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3171 upv(2) = 1.0;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3172 cameraupvector = upv;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3173 cameraupvector.add_constraint (dim_vector (1, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3174 currentpoint.add_constraint (dim_vector (2, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3175 ticklength.add_constraint (dim_vector (1, 2));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3176 tightinset.add_constraint (dim_vector (1, 4));
12467
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3177 looseinset.add_constraint (dim_vector (1, 4));
12777
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
3178 update_font ();
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3179
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3180 x_zlim.resize (1, 2);
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3181
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3182 sx = "linear";
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3183 sy = "linear";
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3184 sz = "linear";
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3185
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3186 calc_ticklabels (xtick, xticklabel, xscale.is ("log"));
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3187 calc_ticklabels (ytick, yticklabel, yscale.is ("log"));
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3188 calc_ticklabels (ztick, zticklabel, zscale.is ("log"));
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3189
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3190 xset (xlabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3191 xset (ylabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3192 xset (zlabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3193 xset (title.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3194
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3195 xset (xlabel.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3196 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3197 xset (ylabel.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3198 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3199 xset (zlabel.handle_value (), "horizontalalignment", "right");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3200 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3201 xset (title.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3202 xset (title.handle_value (), "horizontalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3203
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3204 xset (xlabel.handle_value (), "verticalalignment", "cap");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3205 xset (xlabel.handle_value (), "verticalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3206 xset (ylabel.handle_value (), "verticalalignment", "bottom");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3207 xset (ylabel.handle_value (), "verticalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3208 xset (title.handle_value (), "verticalalignment", "bottom");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3209 xset (title.handle_value (), "verticalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3210
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3211 xset (ylabel.handle_value (), "rotation", 90.0);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3212 xset (ylabel.handle_value (), "rotationmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3213
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3214 xset (zlabel.handle_value (), "visible", "off");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3215
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3216 xset (xlabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3217 xset (ylabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3218 xset (zlabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3219 xset (title.handle_value (), "clipping", "off");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
3220
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
3221 xset (xlabel.handle_value (), "autopos_tag", "xlabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
3222 xset (ylabel.handle_value (), "autopos_tag", "ylabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
3223 xset (zlabel.handle_value (), "autopos_tag", "zlabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
3224 xset (title.handle_value (), "autopos_tag", "title");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
3225
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3226 adopt (xlabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3227 adopt (ylabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3228 adopt (zlabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3229 adopt (title.handle_value ());
12467
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3230
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3231 Matrix tlooseinset = default_axes_position ();
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3232 tlooseinset(2) = 1-tlooseinset(0)-tlooseinset(2);
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3233 tlooseinset(3) = 1-tlooseinset(1)-tlooseinset(3);
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3234 looseinset = tlooseinset;
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3235 }
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3236
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3237 Matrix
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3238 axes::properties::calc_tightbox (const Matrix& init_pos)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3239 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3240 Matrix pos = init_pos;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3241 graphics_object obj = gh_manager::get_object (get_parent ());
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3242 Matrix parent_bb = obj.get_properties ().get_boundingbox (true);
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
3243 Matrix ext = get_extent (true, true);
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3244 ext(1) = parent_bb(3) - ext(1) - ext(3);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3245 ext(0)++;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3246 ext(1)++;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3247 ext = convert_position (ext, "pixels", get_units (),
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3248 parent_bb.extract_n (0, 2, 1, 2));
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3249 if (ext(0) < pos(0))
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3250 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3251 pos(2) += pos(0)-ext(0);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3252 pos(0) = ext(0);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3253 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3254 if (ext(0)+ext(2) > pos(0)+pos(2))
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3255 pos(2) = ext(0)+ext(2)-pos(0);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3256
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3257 if (ext(1) < pos(1))
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3258 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3259 pos(3) += pos(1)-ext(1);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3260 pos(1) = ext(1);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3261 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3262 if (ext(1)+ext(3) > pos(1)+pos(3))
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3263 pos(3) = ext(1)+ext(3)-pos(1);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3264 return pos;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3265 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3266
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3267 void
7860
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3268 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
3269 {
12685
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3270 Matrix ref_linset = looseinset.get ().matrix_value ();
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3271 if (autopos_tag_is ("subplot"))
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3272 {
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3273 graphics_object parent_obj = gh_manager::get_object (get_parent ());
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3274 if (parent_obj.isa ("figure"))
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3275 {
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3276 // FIXME: temporarily changed units should be protected
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3277 // from interrupts
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3278 std::string fig_units = parent_obj.get ("units").string_value ();
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3279 parent_obj.set ("units", "pixels");
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3280
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3281 Matrix ref_outbox = outerposition.get ().matrix_value ();
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3282 ref_outbox(2) += ref_outbox(0);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3283 ref_outbox(3) += ref_outbox(1);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3284
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3285 // Find those subplots that are left, right, bottom and top aligned
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3286 // with the current subplot
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3287 Matrix kids = parent_obj.get_properties ().get_children ();
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3288 std::vector<octave_value> aligned;
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3289 std::vector<bool> l_aligned, b_aligned, r_aligned, t_aligned;
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3290 for (octave_idx_type i = 0; i < kids.numel (); i++)
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3291 {
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3292 graphics_object go = gh_manager::get_object (kids(i));
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3293 if (go.isa ("axes"))
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3294 {
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3295 axes::properties& props =
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3296 dynamic_cast<axes::properties&> (go.get_properties ());
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3297 if (props.autopos_tag_is("subplot"))
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3298 {
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3299 Matrix outpos = go.get ("outerposition").matrix_value ();
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3300 bool l_align=(std::abs (outpos(0)-ref_outbox(0)) < 1e-15);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3301 bool b_align=(std::abs (outpos(1)-ref_outbox(1)) < 1e-15);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3302 bool r_align=(std::abs (outpos(0)+outpos(2)-ref_outbox(2)) < 1e-15);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3303 bool t_align=(std::abs (outpos(1)+outpos(3)-ref_outbox(3)) < 1e-15);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3304 if (l_align || b_align || r_align || t_align)
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3305 {
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3306 aligned.push_back(kids(i));
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3307 l_aligned.push_back(l_align);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3308 b_aligned.push_back(b_align);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3309 r_aligned.push_back(r_align);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3310 t_aligned.push_back(t_align);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3311 // FIXME: the temporarily deleted tags should be
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3312 // protected from interrupts
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3313 props.set_autopos_tag ("none");
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3314 }
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3315 }
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3316 }
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3317 }
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3318 // Determine a minimum box which aligns the subplots
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3319 Matrix ref_box(1, 4, 0.);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3320 ref_box(2) = 1.;
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3321 ref_box(3) = 1.;
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3322 for (size_t i = 0; i < aligned.size (); i++)
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3323 {
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3324 graphics_object go = gh_manager::get_object (aligned[i]);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3325 axes::properties& props =
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3326 dynamic_cast<axes::properties&> (go.get_properties ());
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3327 Matrix linset = props.get_looseinset ().matrix_value ();
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3328 if (l_aligned[i])
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3329 linset(0) = std::min (0., linset(0)-0.01);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3330 if (b_aligned[i])
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3331 linset(1) = std::min (0., linset(1)-0.01);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3332 if (r_aligned[i])
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3333 linset(2) = std::min (0., linset(2)-0.01);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3334 if (t_aligned[i])
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3335 linset(3) = std::min (0., linset(3)-0.01);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3336 props.set_looseinset (linset);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3337 Matrix pos = props.get_position ().matrix_value ();
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3338 if (l_aligned[i])
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3339 ref_box(0) = std::max (ref_box(0), pos(0));
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3340 if (b_aligned[i])
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3341 ref_box(1) = std::max (ref_box(1), pos(1));
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3342 if (r_aligned[i])
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3343 ref_box(2) = std::min (ref_box(2), pos(0)+pos(2));
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3344 if (t_aligned[i])
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3345 ref_box(3) = std::min (ref_box(3), pos(1)+pos(3));
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3346 }
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3347 // Set common looseinset values for all aligned subplots and
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3348 // revert their tag values
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3349 for (size_t i = 0; i < aligned.size (); i++)
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3350 {
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3351 graphics_object go = gh_manager::get_object (aligned[i]);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3352 axes::properties& props =
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3353 dynamic_cast<axes::properties&> (go.get_properties ());
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3354 Matrix outpos = props.get_outerposition ().matrix_value ();
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3355 Matrix linset = props.get_looseinset ().matrix_value ();
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3356 if (l_aligned[i])
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3357 linset(0) = (ref_box(0)-outpos(0))/outpos(2);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3358 if (b_aligned[i])
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3359 linset(1) = (ref_box(1)-outpos(1))/outpos(3);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3360 if (r_aligned[i])
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3361 linset(2) = (outpos(0)+outpos(2)-ref_box(2))/outpos(2);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3362 if (t_aligned[i])
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3363 linset(3) = (outpos(1)+outpos(3)-ref_box(3))/outpos(3);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3364 props.set_looseinset (linset);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3365 props.set_autopos_tag ("subplot");
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3366 }
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3367 parent_obj.set ("units", fig_units);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3368 }
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3369 }
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3370 else
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3371 sync_positions (ref_linset);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3372 }
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3373
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3374 void
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3375 axes::properties::sync_positions (const Matrix& linset)
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3376 {
12445
98772e4e8a2a calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents: 12441
diff changeset
3377 Matrix pos = position.get ().matrix_value ();
98772e4e8a2a calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents: 12441
diff changeset
3378 Matrix outpos = outerposition.get ().matrix_value ();
12685
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3379 double lratio = linset(0);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3380 double bratio = linset(1);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3381 double wratio = 1-linset(0)-linset(2);
5cbf660e649d Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents: 12678
diff changeset
3382 double hratio = 1-linset(1)-linset(3);
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
3383 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
3384 {
12445
98772e4e8a2a calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents: 12441
diff changeset
3385 pos = outpos;
12467
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3386 pos(0) = outpos(0)+lratio*outpos(2);
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3387 pos(1) = outpos(1)+bratio*outpos(3);
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3388 pos(2) = wratio*outpos(2);
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3389 pos(3) = hratio*outpos(3);
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3390
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
3391 position = pos;
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3392 update_transform ();
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3393 Matrix tightpos = calc_tightbox (pos);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3394
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3395 double thrshldx = 0.005*outpos(2);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3396 double thrshldy = 0.005*outpos(3);
12441
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3397 double minsizex = 0.2*outpos(2);
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3398 double minsizey = 0.2*outpos(3);
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3399 bool updatex = true, updatey = true;
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3400 for (int i = 0; i < 10; i++)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3401 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3402 double dt;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3403 bool modified = false;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3404 dt = outpos(0)+outpos(2)-tightpos(0)-tightpos(2);
12441
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3405 if (dt < -thrshldx && updatex)
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3406 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3407 pos(2) += dt;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3408 modified = true;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3409 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3410 dt = outpos(1)+outpos(3)-tightpos(1)-tightpos(3);
12441
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3411 if (dt < -thrshldy && updatey)
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3412 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3413 pos(3) += dt;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3414 modified = true;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3415 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3416 dt = outpos(0)-tightpos(0);
12441
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3417 if (dt > thrshldx && updatex)
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3418 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3419 pos(0) += dt;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3420 pos(2) -= dt;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3421 modified = true;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3422 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3423 dt = outpos(1)-tightpos(1);
12441
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3424 if (dt > thrshldy && updatey)
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3425 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3426 pos(1) += dt;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3427 pos(3) -= dt;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3428 modified = true;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3429 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3430
12441
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3431 // Note: checking limit for minimum axes size
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3432 if (pos(2) < minsizex)
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3433 {
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3434 pos(0) -= 0.5*(minsizex-pos(2));
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3435 pos(2) = minsizex;
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3436 updatex = false;
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3437 }
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3438 if (pos(3) < minsizey)
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3439 {
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3440 pos(1) -= 0.5*(minsizey-pos(3));
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3441 pos(3) = minsizey;
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3442 updatey = false;
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3443 }
b932ae4381da improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12440
diff changeset
3444
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3445 if (modified)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3446 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3447 position = pos;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3448 update_transform ();
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3449 tightpos = calc_tightbox (pos);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3450 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3451 else
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3452 break;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3453 }
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
3454 }
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3455 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
3456 {
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3457 update_transform ();
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3458
12467
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3459 outpos(0) = pos(0)-pos(2)*lratio/wratio;
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3460 outpos(1) = pos(1)-pos(3)*bratio/hratio;
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3461 outpos(2) = pos(2)/wratio;
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3462 outpos(3) = pos(3)/hratio;
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3463
12458
68daf2a0b56d fix a small bug introduced on 2011-02-14
Konstantinos Poulios <logari81@googlemail.com>
parents: 12449
diff changeset
3464 outerposition = calc_tightbox (outpos);
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
3465 }
12445
98772e4e8a2a calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents: 12441
diff changeset
3466
98772e4e8a2a calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents: 12441
diff changeset
3467 Matrix inset (1, 4, 1.0);
98772e4e8a2a calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents: 12441
diff changeset
3468 inset(0) = pos(0)-outpos(0);
98772e4e8a2a calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents: 12441
diff changeset
3469 inset(1) = pos(1)-outpos(1);
98772e4e8a2a calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents: 12441
diff changeset
3470 inset(2) = outpos(0)+outpos(2)-pos(0)-pos(2);
98772e4e8a2a calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents: 12441
diff changeset
3471 inset(3) = outpos(1)+outpos(3)-pos(1)-pos(3);
98772e4e8a2a calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents: 12441
diff changeset
3472
98772e4e8a2a calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents: 12441
diff changeset
3473 tightinset = inset;
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
3474 }
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3475
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3476 void
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3477 axes::properties::set_text_child (handle_property& hp,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3478 const std::string& who,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3479 const octave_value& v)
6962
9ac23c7f1c37 [project @ 2007-10-05 20:52:19 by jwe]
jwe
parents: 6945
diff changeset
3480 {
10265
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3481 graphics_handle val;
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3482
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3483 if (v.is_string ())
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3484 {
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3485 val = gh_manager::make_graphics_handle ("text", __myhandle__, false);
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3486
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3487 xset (val, "string", v);
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3488 }
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3489 else
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3490 {
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3491 graphics_object go = gh_manager::get_object (gh_manager::lookup (v));
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3492
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3493 if (go.isa ("text"))
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3494 val = ::reparent (v, "set", who, __myhandle__, false);
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3495 else
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3496 {
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3497 std::string cname = v.class_name ();
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3498
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3499 error ("set: expecting text graphics object or character string for %s property, found %s",
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3500 who.c_str (), cname.c_str ());
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3501 }
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
3502 }
6962
9ac23c7f1c37 [project @ 2007-10-05 20:52:19 by jwe]
jwe
parents: 6945
diff changeset
3503
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3504 if (! error_state)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3505 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3506 xset (val, "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3507
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3508 gh_manager::free (hp.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3509
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3510 base_properties::remove_child (hp.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3511
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3512 hp = val;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3513
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3514 adopt (hp.handle_value ());
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3515 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3516 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3517
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3518 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3519 axes::properties::set_xlabel (const octave_value& v)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3520 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3521 set_text_child (xlabel, "xlabel", v);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3522 xset (xlabel.handle_value (), "positionmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3523 xset (xlabel.handle_value (), "rotationmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3524 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3525 xset (xlabel.handle_value (), "verticalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3526 xset (xlabel.handle_value (), "clipping", "off");
11598
62b7ea59a6ff fixing color mismatch between axis and axis label
Konstantinos Poulios <logari81@googlemail.com>
parents: 11586
diff changeset
3527 xset (xlabel.handle_value (), "color", get_xcolor ());
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
3528 xset (xlabel.handle_value (), "autopos_tag", "xlabel");
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
3529 update_xlabel_position ();
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3530 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3531
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3532 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3533 axes::properties::set_ylabel (const octave_value& v)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3534 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3535 set_text_child (ylabel, "ylabel", v);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3536 xset (ylabel.handle_value (), "positionmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3537 xset (ylabel.handle_value (), "rotationmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3538 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3539 xset (ylabel.handle_value (), "verticalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3540 xset (ylabel.handle_value (), "clipping", "off");
11598
62b7ea59a6ff fixing color mismatch between axis and axis label
Konstantinos Poulios <logari81@googlemail.com>
parents: 11586
diff changeset
3541 xset (ylabel.handle_value (), "color", get_ycolor ());
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
3542 xset (ylabel.handle_value (), "autopos_tag", "ylabel");
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
3543 update_ylabel_position ();
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3544 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3545
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3546 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3547 axes::properties::set_zlabel (const octave_value& v)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3548 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3549 set_text_child (zlabel, "zlabel", v);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3550 xset (zlabel.handle_value (), "positionmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3551 xset (zlabel.handle_value (), "rotationmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3552 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3553 xset (zlabel.handle_value (), "verticalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3554 xset (zlabel.handle_value (), "clipping", "off");
11598
62b7ea59a6ff fixing color mismatch between axis and axis label
Konstantinos Poulios <logari81@googlemail.com>
parents: 11586
diff changeset
3555 xset (zlabel.handle_value (), "color", get_zcolor ());
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
3556 xset (zlabel.handle_value (), "autopos_tag", "zlabel");
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
3557 update_zlabel_position ();
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3558 }
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3559
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3560 void
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3561 axes::properties::set_title (const octave_value& v)
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3562 {
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3563 set_text_child (title, "title", v);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3564 xset (title.handle_value (), "positionmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3565 xset (title.handle_value (), "horizontalalignment", "center");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3566 xset (title.handle_value (), "horizontalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3567 xset (title.handle_value (), "verticalalignment", "bottom");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3568 xset (title.handle_value (), "verticalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3569 xset (title.handle_value (), "clipping", "off");
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
3570 xset (title.handle_value (), "autopos_tag", "title");
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
3571 update_title_position ();
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3572 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3573
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3574 void
6844
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
3575 axes::properties::set_defaults (base_graphics_object& obj,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3576 const std::string& mode)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3577 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3578 box = "on";
6962
9ac23c7f1c37 [project @ 2007-10-05 20:52:19 by jwe]
jwe
parents: 6945
diff changeset
3579 colororder = default_colororder ();
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3580 dataaspectratio = Matrix (1, 3, 1.0);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3581 dataaspectratiomode = "auto";
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3582 layer = "bottom";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3583
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3584 Matrix tlim (1, 2, 0.0);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3585 tlim(1) = 1;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3586 xlim = tlim;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3587 ylim = tlim;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3588 zlim = tlim;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3589
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
3590 Matrix cl (1, 2, 0);
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
3591 cl(1) = 1;
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
3592 clim = cl;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3593
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3594 xlimmode = "auto";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3595 ylimmode = "auto";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3596 zlimmode = "auto";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3597 climmode = "auto";
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3598
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3599 xgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3600 ygrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3601 zgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3602 xminorgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3603 yminorgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3604 zminorgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3605 xtick = Matrix ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3606 ytick = Matrix ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3607 ztick = Matrix ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3608 xtickmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3609 ytickmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3610 ztickmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3611 xticklabel = "";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3612 yticklabel = "";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3613 zticklabel = "";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3614 xticklabelmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3615 yticklabelmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3616 zticklabelmode = "auto";
10565
2880a862b1a8 Make the default axes color none (bug #29060)
David Bateman <dbateman@free.fr>
parents: 10553
diff changeset
3617 color = "none";
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
3618 xcolor = color_values ("black");
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
3619 ycolor = color_values ("black");
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
3620 zcolor = color_values ("black");
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3621 xscale = "linear";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3622 yscale = "linear";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3623 zscale = "linear";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3624 xdir = "normal";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3625 ydir = "normal";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3626 zdir = "normal";
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3627 yaxislocation = "left";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3628 xaxislocation = "bottom";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3629
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3630 // Note: camera properties will be set through update_transform
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3631 camerapositionmode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3632 cameratargetmode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3633 cameraupvectormode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3634 cameraviewanglemode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3635 plotboxaspectratio = Matrix (1, 3, 1.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3636 drawmode = "normal";
7820
cb4838d70ab2 Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7680
diff changeset
3637 gridlinestyle = ":";
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3638 linestyleorder = "-";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3639 linewidth = 0.5;
7820
cb4838d70ab2 Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7680
diff changeset
3640 minorgridlinestyle = ":";
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3641 // Note: plotboxaspectratio will be set through update_aspectratiors
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3642 plotboxaspectratiomode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3643 projection = "orthographic";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3644 tickdir = "in";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3645 tickdirmode = "auto";
8740
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
3646 ticklength = default_axes_ticklength ();
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3647 tightinset = Matrix (1, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3648
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3649 sx = "linear";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3650 sy = "linear";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3651 sz = "linear";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3652
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3653 Matrix tview (1, 2, 0.0);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3654 tview(1) = 90;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3655 view = tview;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3656
6765
e6b528a3a2a9 [project @ 2007-06-28 15:25:43 by jwe]
jwe
parents: 6761
diff changeset
3657 visible = "on";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3658 nextplot = "replace";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3659
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3660 if (mode != "replace")
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3661 {
8228
53dbbd331498 Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents: 8209
diff changeset
3662 fontangle = "normal";
8944
cb0e9facc342 make default fontname * instead of Helvetica
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
3663 fontname = OCTAVE_DEFAULT_FONTNAME;
11384
1511bbfe6a6e Change axes default fontsize from 12 to 10.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11283
diff changeset
3664 fontsize = 10;
8228
53dbbd331498 Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents: 8209
diff changeset
3665 fontunits = "points";
53dbbd331498 Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents: 8209
diff changeset
3666 fontweight = "normal";
53dbbd331498 Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents: 8209
diff changeset
3667
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3668 Matrix touterposition (1, 4, 0.0);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3669 touterposition(2) = 1;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3670 touterposition(3) = 1;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3671 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
3672
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
3673 position = default_axes_position ();
8228
53dbbd331498 Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents: 8209
diff changeset
3674
12467
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3675 Matrix tlooseinset = default_axes_position ();
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3676 tlooseinset(2) = 1-tlooseinset(0)-tlooseinset(2);
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3677 tlooseinset(3) = 1-tlooseinset(1)-tlooseinset(3);
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3678 looseinset = tlooseinset;
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
3679
8228
53dbbd331498 Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents: 8209
diff changeset
3680 activepositionproperty = "outerposition";
6406
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
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3683 delete_children (true);
6432
5bec61ae1576 [project @ 2007-03-23 02:19:10 by jwe]
jwe
parents: 6425
diff changeset
3684
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3685 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__, false);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3686 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__, false);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3687 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__, false);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3688 title = gh_manager::make_graphics_handle ("text", __myhandle__, false);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3689
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3690 xset (xlabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3691 xset (ylabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3692 xset (zlabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3693 xset (title.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3694
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3695 xset (xlabel.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3696 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3697 xset (ylabel.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3698 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3699 xset (zlabel.handle_value (), "horizontalalignment", "right");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3700 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3701 xset (title.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3702 xset (title.handle_value (), "horizontalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3703
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3704 xset (xlabel.handle_value (), "verticalalignment", "cap");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3705 xset (xlabel.handle_value (), "verticalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3706 xset (ylabel.handle_value (), "verticalalignment", "bottom");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3707 xset (ylabel.handle_value (), "verticalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3708 xset (title.handle_value (), "verticalalignment", "bottom");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3709 xset (title.handle_value (), "verticalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3710
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3711 xset (ylabel.handle_value (), "rotation", 90.0);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3712 xset (ylabel.handle_value (), "rotationmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
3713
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3714 xset (zlabel.handle_value (), "visible", "off");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3715
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3716 xset (xlabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3717 xset (ylabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3718 xset (zlabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
3719 xset (title.handle_value (), "clipping", "off");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
3720
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
3721 xset (xlabel.handle_value (), "autopos_tag", "xlabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
3722 xset (ylabel.handle_value (), "autopos_tag", "ylabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
3723 xset (zlabel.handle_value (), "autopos_tag", "zlabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
3724 xset (title.handle_value (), "autopos_tag", "title");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
3725
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3726 adopt (xlabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3727 adopt (ylabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3728 adopt (zlabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3729 adopt (title.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3730
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3731 update_transform ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3732
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3733 override_defaults (obj);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3734 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3735
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3736 void
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3737 axes::properties::delete_text_child (handle_property& hp)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3738 {
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3739 graphics_handle h = hp.handle_value ();
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3740
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3741 if (h.ok ())
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3742 {
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3743 graphics_object go = gh_manager::get_object (h);
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3744
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3745 if (go.valid_object ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3746 gh_manager::free (h);
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3747
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3748 base_properties::remove_child (h);
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3749 }
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3750
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3751 // FIXME -- is it necessary to check whether the axes object is
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3752 // being deleted now? I think this function is only called when an
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3753 // individual child object is delete and not when the parent axes
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3754 // object is deleted.
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3755
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3756 if (! is_beingdeleted ())
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3757 {
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3758 hp = gh_manager::make_graphics_handle ("text", __myhandle__, false);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3759
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3760 xset (hp.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3761
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3762 adopt (hp.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3763 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3764 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3765
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3766 void
6844
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
3767 axes::properties::remove_child (const graphics_handle& h)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3768 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3769 if (xlabel.handle_value ().ok () && h == xlabel.handle_value ())
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3770 delete_text_child (xlabel);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3771 else if (ylabel.handle_value ().ok () && h == ylabel.handle_value ())
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3772 delete_text_child (ylabel);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3773 else if (zlabel.handle_value ().ok () && h == zlabel.handle_value ())
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
3774 delete_text_child (zlabel);
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3775 else if (title.handle_value ().ok () && h == title.handle_value ())
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
3776 delete_text_child (title);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3777 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3778 base_properties::remove_child (h);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3779 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3780
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3781 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3782 xform_matrix (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3783 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3784 Matrix m (4, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3785 for (int i = 0; i < 4; i++)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3786 m(i,i) = 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3787 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3788 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3789
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3790 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3791 xform_vector (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3792 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3793 ColumnVector v (4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3794 v(3) = 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3795 return v;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3796 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3797
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3798 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3799 xform_vector (double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3800 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3801 ColumnVector v (4, 1.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3802 v(0) = x; v(1) = y; v(2) = z;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3803 return v;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3804 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3805
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3806 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3807 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
3808 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3809 return (m * xform_vector (x, y, z));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3810 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3811
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3812 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3813 xform_scale (double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3814 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3815 Matrix m (4, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3816 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
3817 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3818 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3819
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3820 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3821 xform_translate (double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3822 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3823 Matrix m = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3824 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
3825 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3826 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3827
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3828 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3829 scale (Matrix& m, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3830 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3831 m = m * xform_scale (x, y, z);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3832 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3833
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3834 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3835 translate (Matrix& m, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3836 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3837 m = m * xform_translate (x, y, z);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3838 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3839
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3840 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3841 xform (ColumnVector& v, const Matrix& m)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3842 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3843 v = m*v;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3844 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3845
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3846 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3847 scale (ColumnVector& v, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3848 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3849 v(0) *= x;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3850 v(1) *= y;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3851 v(2) *= z;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3852 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3853
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3854 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3855 translate (ColumnVector& v, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3856 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3857 v(0) += x;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3858 v(1) += y;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3859 v(2) += z;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3860 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3861
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3862 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3863 normalize (ColumnVector& v)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3864 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3865 double 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
3866 scale (v, fact, fact, fact);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3867 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3868
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3869 inline double
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3870 dot (const ColumnVector& v1, const ColumnVector& v2)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3871 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3872 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
3873 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3874
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3875 inline double
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3876 norm (const ColumnVector& v)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3877 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3878 return sqrt (dot (v, v));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3879 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3880
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3881 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3882 cross (const ColumnVector& v1, const ColumnVector& v2)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3883 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3884 ColumnVector r = xform_vector ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3885 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
3886 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
3887 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
3888 return r;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3889 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3890
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3891 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3892 unit_cube (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3893 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3894 static double data[32] = {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3895 0,0,0,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3896 1,0,0,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3897 0,1,0,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3898 0,0,1,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3899 1,1,0,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3900 1,0,1,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3901 0,1,1,1,
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3902 1,1,1,1};
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3903 Matrix m (4, 8);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3904 memcpy (m.fortran_vec (), data, sizeof(double)*32);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3905 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3906 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3907
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3908 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3909 cam2xform (const Array<double>& m)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3910 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3911 ColumnVector retval (4, 1.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3912 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
3913 return retval;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3914 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3915
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3916 inline RowVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3917 xform2cam (const ColumnVector& v)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3918 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3919 return v.extract_n (0, 3).transpose ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3920 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3921
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3922 void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3923 axes::properties::update_camera (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3924 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3925 double xd = (xdir_is ("normal") ? 1 : -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3926 double yd = (ydir_is ("normal") ? 1 : -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3927 double zd = (zdir_is ("normal") ? 1 : -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3928
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
3929 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
3930 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
3931 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
3932
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
3933 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
3934 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
3935 double zo = zlimits(zd > 0 ? 0 : 1);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3936
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3937 Matrix pb = get_plotboxaspectratio ().matrix_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3938
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3939 bool autocam = (camerapositionmode_is ("auto")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3940 && cameratargetmode_is ("auto")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3941 && cameraupvectormode_is ("auto")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3942 && cameraviewanglemode_is ("auto"));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3943 bool dowarp = (autocam && dataaspectratiomode_is("auto")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3944 && plotboxaspectratiomode_is ("auto"));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3945
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3946 ColumnVector c_eye (xform_vector ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3947 ColumnVector c_center (xform_vector ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3948 ColumnVector c_upv (xform_vector ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3949
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3950 if (cameratargetmode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3951 {
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
3952 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
3953 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
3954 c_center(2) = (zlimits(0)+zlimits(1))/2;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3955
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3956 cameratarget = xform2cam (c_center);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3957 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3958 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3959 c_center = cam2xform (get_cameratarget ().matrix_value ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3960
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3961 if (camerapositionmode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3962 {
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
3963 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
3964 double az = tview(0), el = tview(1);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3965 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
3966
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3967 if (el == 90 || el == -90)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3968 c_eye(2) = d*signum(el);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3969 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3970 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3971 az *= M_PI/180.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3972 el *= M_PI/180.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3973 c_eye(0) = d*cos(el)*sin(az);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3974 c_eye(1) = -d*cos(el)*cos(az);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3975 c_eye(2) = d*sin(el);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3976 }
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
3977 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
3978 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
3979 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
3980
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3981 cameraposition = xform2cam (c_eye);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3982 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3983 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3984 c_eye = cam2xform (get_cameraposition ().matrix_value ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3985
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3986 if (cameraupvectormode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3987 {
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
3988 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
3989 double az = tview(0), el = tview(1);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3990
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3991 if (el == 90 || el == -90)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3992 {
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
3993 c_upv(0) =
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
3994 -signum(el)*sin(az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0);
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
3995 c_upv(1) =
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
3996 signum(el)*cos(az*M_PI/180.0)*(ylimits(1)-ylimits(0))/pb(1);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3997 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
3998 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3999 c_upv(2) = 1;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4000
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4001 cameraupvector = xform2cam (c_upv);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4002 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4003 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4004 c_upv = cam2xform (get_cameraupvector ().matrix_value ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4005
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4006 Matrix x_view = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4007 Matrix x_projection = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4008 Matrix x_viewport = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4009 Matrix x_normrender = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4010 Matrix x_pre = xform_matrix ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4011
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4012 x_render = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4013 x_render_inv = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4014
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4015 scale (x_pre, pb(0), pb(1), pb(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4016 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
4017 scale (x_pre, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4018 zd/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4019 translate (x_pre, -xo, -yo, -zo);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4020
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4021 xform (c_eye, x_pre);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4022 xform (c_center, x_pre);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4023 scale (c_upv, pb(0)/(xlimits(1)-xlimits(0)), pb(1)/(ylimits(1)-ylimits(0)),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4024 pb(2)/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4025 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
4026
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4027 ColumnVector F (c_center), f (F), UP (c_upv);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4028 normalize (f);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4029 normalize (UP);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4030
7440
4e3b073e910e [project @ 2008-02-02 18:23:50 by jwe]
jwe
parents: 7435
diff changeset
4031 if (std::abs (dot (f, UP)) > 1e-15)
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4032 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4033 double fa = 1/sqrt(1-f(2)*f(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4034 scale (UP, fa, fa, fa);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4035 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4036
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4037 ColumnVector s = cross (f, UP);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4038 ColumnVector u = cross (s, f);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4039
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4040 scale (x_view, 1, 1, -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4041 Matrix l = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4042 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
4043 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
4044 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
4045 x_view = x_view * l;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4046 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
4047 scale (x_view, pb(0), pb(1), pb(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4048 translate (x_view, -0.5, -0.5, -0.5);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4049
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4050 Matrix x_cube = x_view * unit_cube ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4051 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
4052 double xM = cmax(0)-cmin(0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4053 double yM = cmax(1)-cmin(1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4054
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
4055 Matrix bb = get_boundingbox (true);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4056
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4057 double v_angle;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4058
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4059 if (cameraviewanglemode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4060 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4061 double af;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4062
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8299
diff changeset
4063 // FIXME -- was this really needed? When compared to Matlab, it
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4064 // does not seem to be required. Need investigation with concrete
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
4065 // graphics toolkit to see results visually.
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4066 if (false && dowarp)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4067 af = 1.0 / (xM > yM ? xM : yM);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4068 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4069 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4070 if ((bb(2)/bb(3)) > (xM/yM))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4071 af = 1.0 / yM;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4072 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4073 af = 1.0 / xM;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4074 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4075 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
4076
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4077 cameraviewangle = v_angle;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4078 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4079 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4080 v_angle = get_cameraviewangle ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4081
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4082 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
4083 scale (x_projection, pf, pf, 1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4084
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4085 if (dowarp)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4086 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4087 xM *= pf;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4088 yM *= pf;
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
4089 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
4090 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
4091 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4092 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4093 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4094 double pix = 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4095 if (autocam)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4096 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4097 if ((bb(2)/bb(3)) > (xM/yM))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4098 pix = bb(3);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4099 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4100 pix = bb(2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4101 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4102 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4103 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
4104 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
4105 scale (x_viewport, pix, -pix, 1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4106 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4107
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4108 x_normrender = x_viewport * x_projection * x_view;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4109
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4110 x_cube = x_normrender * unit_cube ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4111 cmin = x_cube.row_min ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4112 cmax = x_cube.row_max ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4113 x_zlim.resize (1, 2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4114 x_zlim(0) = cmin(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4115 x_zlim(1) = cmax(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4116
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4117 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
4118 scale (x_render, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4119 zd/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4120 translate (x_render, -xo, -yo, -zo);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4121
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4122 x_viewtransform = x_view;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4123 x_projectiontransform = x_projection;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4124 x_viewporttransform = x_viewport;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4125 x_normrendertransform = x_normrender;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4126 x_rendertransform = x_render;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4127
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4128 x_render_inv = x_render.inverse ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4129
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4130 // 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
4131 // 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
4132 // => x_gl_mat2)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4133 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
4134 scale (x_gl_mat1, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4135 zd/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4136 translate (x_gl_mat1, -xo, -yo, -zo);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4137 x_gl_mat2 = x_viewport * x_projection;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4138 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4139
12347
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4140 static bool updating_axes_layout = false;
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4141
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4142 void
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4143 axes::properties::update_axes_layout (void)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4144 {
12347
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4145 if (updating_axes_layout)
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4146 return;
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4147
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4148 graphics_xform xform = get_transform ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4149
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4150 double xd = (xdir_is ("normal") ? 1 : -1);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4151 double yd = (ydir_is ("normal") ? 1 : -1);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4152 double zd = (zdir_is ("normal") ? 1 : -1);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4153
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4154 const Matrix xlims = xform.xscale (get_xlim ().matrix_value ());
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4155 const Matrix ylims = xform.yscale (get_ylim ().matrix_value ());
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4156 const Matrix zlims = xform.zscale (get_zlim ().matrix_value ());
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4157 double x_min = xlims(0), x_max = xlims(1);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4158 double y_min = ylims(0), y_max = ylims(1);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4159 double z_min = zlims(0), z_max = zlims(1);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4160
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4161 ColumnVector p1, p2, dir (3);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4162
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4163 xstate = ystate = zstate = AXE_ANY_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4164
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4165 p1 = xform.transform (x_min, (y_min+y_max)/2, (z_min+z_max)/2, false);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4166 p2 = xform.transform (x_max, (y_min+y_max)/2, (z_min+z_max)/2, false);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4167 dir(0) = xround (p2(0)-p1(0));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4168 dir(1) = xround (p2(1)-p1(1));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4169 dir(2) = (p2(2)-p1(2));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4170 if (dir(0) == 0 && dir(1) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4171 xstate = AXE_DEPTH_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4172 else if (dir(2) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4173 {
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4174 if (dir(0) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4175 xstate = AXE_VERT_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4176 else if (dir(1) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4177 xstate = AXE_HORZ_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4178 }
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4179
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4180 if (dir(2) == 0)
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4181 {
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4182 if (dir(1) == 0)
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4183 xPlane = (dir(0) > 0 ? x_max : x_min);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4184 else
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4185 xPlane = (dir(1) < 0 ? x_max : x_min);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4186 }
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4187 else
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4188 xPlane = (dir(2) < 0 ? x_min : x_max);
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4189
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4190 xPlaneN = (xPlane == x_min ? x_max : x_min);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4191 fx = (x_max-x_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4192
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4193 p1 = xform.transform ((x_min+x_max)/2, y_min, (z_min+z_max)/2, false);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4194 p2 = xform.transform ((x_min+x_max)/2, y_max, (z_min+z_max)/2, false);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4195 dir(0) = xround (p2(0)-p1(0));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4196 dir(1) = xround (p2(1)-p1(1));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4197 dir(2) = (p2(2)-p1(2));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4198 if (dir(0) == 0 && dir(1) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4199 ystate = AXE_DEPTH_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4200 else if (dir(2) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4201 {
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4202 if (dir(0) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4203 ystate = AXE_VERT_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4204 else if (dir(1) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4205 ystate = AXE_HORZ_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4206 }
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4207
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4208 if (dir(2) == 0)
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4209 {
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4210 if (dir(1) == 0)
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4211 yPlane = (dir(0) > 0 ? y_max : y_min);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4212 else
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4213 yPlane = (dir(1) < 0 ? y_max : y_min);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4214 }
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4215 else
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4216 yPlane = (dir(2) < 0 ? y_min : y_max);
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4217
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4218 yPlaneN = (yPlane == y_min ? y_max : y_min);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4219 fy = (y_max-y_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4220
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4221 p1 = xform.transform((x_min+x_max)/2, (y_min+y_max)/2, z_min, false);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4222 p2 = xform.transform((x_min+x_max)/2, (y_min+y_max)/2, z_max, false);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4223 dir(0) = xround(p2(0)-p1(0));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4224 dir(1) = xround (p2(1)-p1(1));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4225 dir(2) = (p2(2)-p1(2));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4226 if (dir(0) == 0 && dir(1) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4227 zstate = AXE_DEPTH_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4228 else if (dir(2) == 0)
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4229 {
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4230 if (dir(0) == 0)
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4231 zstate = AXE_VERT_DIR;
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4232 else if (dir(1) == 0)
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4233 zstate = AXE_HORZ_DIR;
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4234 }
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4235
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4236 if (dir(2) == 0)
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4237 {
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4238 if (dir(1) == 0)
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4239 zPlane = (dir(0) > 0 ? z_min : z_max);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4240 else
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4241 zPlane = (dir(1) < 0 ? z_min : z_max);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4242 }
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4243 else
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4244 zPlane = (dir(2) < 0 ? z_min : z_max);
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4245
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4246 zPlaneN = (zPlane == z_min ? z_max : z_min);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4247 fz = (z_max-z_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4248
12347
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4249 unwind_protect frame;
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4250 frame.protect_var (updating_axes_layout);
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4251 updating_axes_layout = true;
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
4252
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4253 update_ticklengths ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4254
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4255 xySym = (xd*yd*(xPlane-xPlaneN)*(yPlane-yPlaneN) > 0);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4256 zSign = (zd*(zPlane-zPlaneN) <= 0);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4257 xyzSym = zSign ? xySym : !xySym;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4258 xpTick = (zSign ? xPlaneN : xPlane);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4259 ypTick = (zSign ? yPlaneN : yPlane);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4260 zpTick = (zSign ? zPlane : zPlaneN);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4261 xpTickN = (zSign ? xPlane : xPlaneN);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4262 ypTickN = (zSign ? yPlane : yPlaneN);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4263 zpTickN = (zSign ? zPlaneN : zPlane);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4264
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4265 /* 2D mode */
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4266 x2Dtop = false;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4267 y2Dright = false;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4268 layer2Dtop = false;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4269 if (xstate == AXE_HORZ_DIR && ystate == AXE_VERT_DIR)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4270 {
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4271 if (xaxislocation_is ("top"))
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4272 {
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4273 double tmp = yPlane;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4274 yPlane = yPlaneN;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4275 yPlaneN = tmp;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4276 x2Dtop = true;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4277 }
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4278 ypTick = yPlaneN;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4279 ypTickN = yPlane;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4280 if (yaxislocation_is ("right"))
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4281 {
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4282 double tmp = xPlane;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4283 xPlane = xPlaneN;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4284 xPlaneN = tmp;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4285 y2Dright = true;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4286 }
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4287 xpTick = xPlaneN;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4288 xpTickN = xPlane;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4289 if (layer_is ("top"))
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4290 {
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4291 zpTick = zPlaneN;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4292 layer2Dtop = true;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4293 }
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4294 else
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4295 zpTick = zPlane;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4296 }
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4297
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4298 Matrix viewmat = get_view ().matrix_value ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4299 nearhoriz = std::abs(viewmat(1)) <= 5;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4300 }
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4301
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4302 void
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4303 axes::properties::update_ticklengths (void)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4304 {
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4305 bool mode2d = (((xstate > AXE_DEPTH_DIR ? 1 : 0) +
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4306 (ystate > AXE_DEPTH_DIR ? 1 : 0) +
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4307 (zstate > AXE_DEPTH_DIR ? 1 : 0)) == 2);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4308 if (tickdirmode_is ("auto"))
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4309 {
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4310 // FIXME: tickdir should be updated (code below comes
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4311 // from JHandles)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4312 //autoMode++;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4313 //TickDir.set(mode2d ? "in" : "out", true);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4314 //autoMode--;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4315 }
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4316
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4317 //double ticksign = (tickdir_is ("in") ? -1 : 1);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4318 double ticksign = (tickdirmode_is ("auto") ?
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4319 (mode2d ? -1 : 1) :
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4320 (tickdir_is ("in") ? -1 : 1));
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4321 // FIXME: use ticklength property
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4322 xticklen = ticksign*7;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4323 yticklen = ticksign*7;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4324 zticklen = ticksign*7;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4325
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4326 xtickoffset = (mode2d ? std::max (0., xticklen) : std::abs (xticklen)) + 5;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4327 ytickoffset = (mode2d ? std::max (0., yticklen) : std::abs (yticklen)) + 5;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4328 ztickoffset = (mode2d ? std::max (0., zticklen) : std::abs (zticklen)) + 5;
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4329
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4330 update_xlabel_position ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4331 update_ylabel_position ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4332 update_zlabel_position ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4333 update_title_position ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4334 }
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4335
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4336 static bool updating_xlabel_position = false;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4337
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4338 void
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4339 axes::properties::update_xlabel_position (void)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4340 {
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4341 if (updating_xlabel_position)
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4342 return;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4343
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4344 text::properties& xlabel_props = reinterpret_cast<text::properties&>
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4345 (gh_manager::get_object (get_xlabel ()).get_properties ());
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4346
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
4347 bool is_empty = xlabel_props.get_string ().is_empty ();
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4348
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4349 unwind_protect frame;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4350 frame.protect_var (updating_xlabel_position);
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4351 updating_xlabel_position = true;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4352
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4353 if (! is_empty)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4354 {
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4355 if (xlabel_props.horizontalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4356 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4357 xlabel_props.set_horizontalalignment
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4358 (xstate > AXE_DEPTH_DIR
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4359 ? "center" : (xyzSym ? "left" : "right"));
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4360
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4361 xlabel_props.set_horizontalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4362 }
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4363
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4364 if (xlabel_props.verticalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4365 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4366 xlabel_props.set_verticalalignment
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4367 (xstate == AXE_VERT_DIR || x2Dtop ? "bottom" : "top");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4368
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4369 xlabel_props.set_verticalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4370 }
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4371 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4372
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4373 if (xlabel_props.positionmode_is ("auto")
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4374 || xlabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4375 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4376 graphics_xform xform = get_transform ();
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4377
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4378 Matrix ext (1, 2, 0.0);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4379 ext = get_ticklabel_extents (get_xtick ().matrix_value (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4380 get_xticklabel ().all_strings (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4381 get_xlim ().matrix_value ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4382
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4383 double wmax = ext(0), hmax = ext(1), angle = 0;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4384 ColumnVector p =
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4385 graphics_xform::xform_vector ((xpTickN+xpTick)/2, ypTick, zpTick);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4386
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4387 bool tick_along_z = nearhoriz || xisinf (fy);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4388 if (tick_along_z)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4389 p(2) += (signum(zpTick-zpTickN)*fz*xtickoffset);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4390 else
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4391 p(1) += (signum(ypTick-ypTickN)*fy*xtickoffset);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4392
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4393 p = xform.transform (p(0), p(1), p(2), false);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4394
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4395 switch (xstate)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4396 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4397 case AXE_ANY_DIR:
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4398 p(0) += (xyzSym ? wmax : -wmax);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4399 p(1) += hmax;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4400 break;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4401
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4402 case AXE_VERT_DIR:
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4403 p(0) -= wmax;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4404 angle = 90;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4405 break;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4406
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4407 case AXE_HORZ_DIR:
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4408 p(1) += (x2Dtop ? -hmax : hmax);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4409 break;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4410 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4411
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4412 if (xlabel_props.positionmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4413 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4414 p = xform.untransform (p(0), p(1), p(2), true);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4415 xlabel_props.set_position (p.extract_n (0, 3).transpose ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4416 xlabel_props.set_positionmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4417 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4418
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4419 if (! is_empty && xlabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4420 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4421 xlabel_props.set_rotation (angle);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4422 xlabel_props.set_rotationmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4423 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4424 }
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4425 }
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4426
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4427 static bool updating_ylabel_position = false;
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4428
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4429 void
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4430 axes::properties::update_ylabel_position (void)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4431 {
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4432 if (updating_ylabel_position)
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4433 return;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4434
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4435 text::properties& ylabel_props = reinterpret_cast<text::properties&>
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4436 (gh_manager::get_object (get_ylabel ()).get_properties ());
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4437
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
4438 bool is_empty = ylabel_props.get_string ().is_empty ();
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4439
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4440 unwind_protect frame;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4441 frame.protect_var (updating_ylabel_position);
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4442 updating_ylabel_position = true;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4443
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4444 if (! is_empty)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4445 {
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4446 if (ylabel_props.horizontalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4447 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4448 ylabel_props.set_horizontalalignment
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4449 (ystate > AXE_DEPTH_DIR
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4450 ? "center" : (!xyzSym ? "left" : "right"));
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4451
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4452 ylabel_props.set_horizontalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4453 }
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4454
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4455 if (ylabel_props.verticalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4456 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4457 ylabel_props.set_verticalalignment
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4458 (ystate == AXE_VERT_DIR && !y2Dright ? "bottom" : "top");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4459
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4460 ylabel_props.set_verticalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4461 }
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4462 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4463
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4464 if (ylabel_props.positionmode_is ("auto")
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4465 || ylabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4466 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4467 graphics_xform xform = get_transform ();
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4468
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4469 Matrix ext (1, 2, 0.0);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4470 ext = get_ticklabel_extents (get_ytick ().matrix_value (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4471 get_yticklabel ().all_strings (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4472 get_ylim ().matrix_value ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4473
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4474 double wmax = ext(0), hmax = ext(1), angle = 0;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4475 ColumnVector p =
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4476 graphics_xform::xform_vector (xpTick, (ypTickN+ypTick)/2, zpTick);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4477
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4478 bool tick_along_z = nearhoriz || xisinf (fx);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4479 if (tick_along_z)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4480 p(2) += (signum(zpTick-zpTickN)*fz*ytickoffset);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4481 else
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4482 p(0) += (signum(xpTick-xpTickN)*fx*ytickoffset);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4483
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4484 p = xform.transform (p(0), p(1), p(2), false);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4485
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4486 switch (ystate)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4487 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4488 case AXE_ANY_DIR:
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4489 p(0) += (!xyzSym ? wmax : -wmax);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4490 p(1) += hmax;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4491 break;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4492
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4493 case AXE_VERT_DIR:
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4494 p(0) += (y2Dright ? wmax : -wmax);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4495 angle = 90;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4496 break;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4497
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4498 case AXE_HORZ_DIR:
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4499 p(1) += hmax;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4500 break;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4501 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4503 if (ylabel_props.positionmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4504 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4505 p = xform.untransform (p(0), p(1), p(2), true);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4506 ylabel_props.set_position (p.extract_n (0, 3).transpose ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4507 ylabel_props.set_positionmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4508 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4509
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4510 if (! is_empty && ylabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4511 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4512 ylabel_props.set_rotation (angle);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4513 ylabel_props.set_rotationmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4514 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4515 }
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4516 }
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4517
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4518 static bool updating_zlabel_position = false;
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4519
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4520 void
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4521 axes::properties::update_zlabel_position (void)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4522 {
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4523 if (updating_zlabel_position)
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4524 return;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4525
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4526 text::properties& zlabel_props = reinterpret_cast<text::properties&>
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4527 (gh_manager::get_object (get_zlabel ()).get_properties ());
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4528
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4529 bool camAuto = cameraupvectormode_is ("auto");
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
4530 bool is_empty = zlabel_props.get_string ().is_empty ();
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4531
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4532 unwind_protect frame;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4533 frame.protect_var (updating_zlabel_position);
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4534 updating_zlabel_position = true;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4535
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4536 if (! is_empty)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4537 {
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4538 if (zlabel_props.horizontalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4539 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4540 zlabel_props.set_horizontalalignment
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4541 ((zstate > AXE_DEPTH_DIR || camAuto) ? "center" : "right");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4542
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4543 zlabel_props.set_horizontalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4544 }
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4545
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4546 if (zlabel_props.verticalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4547 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4548 zlabel_props.set_verticalalignment
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4549 (zstate == AXE_VERT_DIR
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4550 ? "bottom" : ((zSign || camAuto) ? "bottom" : "top"));
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4551
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4552 zlabel_props.set_verticalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4553 }
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4554 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4555
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4556 if (zlabel_props.positionmode_is ("auto")
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4557 || zlabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4558 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4559 graphics_xform xform = get_transform ();
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4560
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4561 Matrix ext (1, 2, 0.0);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4562 ext = get_ticklabel_extents (get_ztick ().matrix_value (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4563 get_zticklabel ().all_strings (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4564 get_zlim ().matrix_value ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4565
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4566 double wmax = ext(0), hmax = ext(1), angle = 0;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4567 ColumnVector p;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4568
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4569 if (xySym)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4570 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4571 p = graphics_xform::xform_vector (xPlaneN, yPlane,
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4572 (zpTickN+zpTick)/2);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4573 if (xisinf (fy))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4574 p(0) += (signum(xPlaneN-xPlane)*fx*ztickoffset);
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4575 else
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4576 p(1) += (signum(yPlane-yPlaneN)*fy*ztickoffset);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4577 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4578 else
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4579 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4580 p = graphics_xform::xform_vector (xPlane, yPlaneN,
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4581 (zpTickN+zpTick)/2);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4582 if (xisinf (fx))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4583 p(1) += (signum(yPlaneN-yPlane)*fy*ztickoffset);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4584 else
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4585 p(0) += (signum(xPlane-xPlaneN)*fx*ztickoffset);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4586 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4587
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4588 p = xform.transform (p(0), p(1), p(2), false);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4589
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4590 switch (zstate)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4591 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4592 case AXE_ANY_DIR:
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4593 if (camAuto)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4594 {
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4595 p(0) -= wmax;
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
4596 angle = 90;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4597 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4598
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4599 // FIXME -- what's the correct offset?
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4600 //
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4601 // p[0] += (!xySym ? wmax : -wmax);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4602 // p[1] += (zSign ? hmax : -hmax);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4603
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4604 break;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4605
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4606 case AXE_VERT_DIR:
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4607 p(0) -= wmax;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4608 angle = 90;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4609 break;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4610
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4611 case AXE_HORZ_DIR:
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4612 p(1) += hmax;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4613 break;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4614 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4615
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4616 if (zlabel_props.positionmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4617 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4618 p = xform.untransform (p(0), p(1), p(2), true);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4619 zlabel_props.set_position (p.extract_n (0, 3).transpose ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4620 zlabel_props.set_positionmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4621 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4622
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4623 if (! is_empty && zlabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4624 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4625 zlabel_props.set_rotation (angle);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4626 zlabel_props.set_rotationmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4627 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4628 }
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4629 }
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4630
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4631 static bool updating_title_position = false;
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4632
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4633 void
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4634 axes::properties::update_title_position (void)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4635 {
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4636 if (updating_title_position)
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4637 return;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4638
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4639 text::properties& title_props = reinterpret_cast<text::properties&>
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4640 (gh_manager::get_object (get_title ()).get_properties ());
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4641
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4642 unwind_protect frame;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4643 frame.protect_var (updating_title_position);
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
4644 updating_title_position = true;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4645
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4646 if (title_props.positionmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4647 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4648 graphics_xform xform = get_transform ();
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4649
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4650 // FIXME: bbox should be stored in axes::properties
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4651 Matrix bbox = get_extent (false);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4652 ColumnVector p = xform.untransform (bbox(0)+bbox(2)/2, (bbox(1)-10),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4653 (x_zlim(0)+x_zlim(1))/2, true);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4654
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4655 title_props.set_position (p.extract_n(0, 3).transpose ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4656 title_props.set_positionmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4657 }
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4658 }
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4659
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4660 void
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4661 axes::properties::update_autopos (const std::string& elem_type)
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4662 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4663 if (elem_type == "xlabel")
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4664 update_xlabel_position ();
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4665 else if (elem_type == "ylabel")
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4666 update_ylabel_position ();
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4667 else if (elem_type == "zlabel")
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4668 update_zlabel_position ();
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4669 else if (elem_type == "title")
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4670 update_title_position ();
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4671 else if (elem_type == "sync")
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4672 sync_positions ();
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4673 }
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
4674
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4675 static void
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4676 normalized_aspectratios (Matrix& aspectratios, const Matrix& scalefactors,
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4677 double xlength, double ylength, double zlength)
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4678 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4679 double xval = xlength/scalefactors(0);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4680 double yval = ylength/scalefactors(1);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4681 double zval = zlength/scalefactors(2);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4682
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4683 double minval = xmin (xmin (xval, yval), zval);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4684
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4685 aspectratios(0) = xval/minval;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4686 aspectratios(1) = yval/minval;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4687 aspectratios(2) = zval/minval;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4688 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4689
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4690 static void
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4691 max_axes_scale (double& s, Matrix& limits, const Matrix& kids,
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4692 double pbfactor, double dafactor, char limit_type, bool tight)
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4693 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4694 if (tight)
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4695 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4696 double minval = octave_Inf;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4697 double maxval = -octave_Inf;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4698 double min_pos = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
4699 double max_neg = -octave_Inf;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
4700 get_children_limits (minval, maxval, min_pos, max_neg, kids, limit_type);
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4701 if (!xisinf (minval) && !xisnan (minval)
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4702 && !xisinf (maxval) && !xisnan (maxval))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4703 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4704 limits(0) = minval;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4705 limits(1) = maxval;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4706 s = xmax(s, (maxval - minval) / (pbfactor * dafactor));
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4707 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4708 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4709 else
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4710 s = xmax(s, (limits(1) - limits(0)) / (pbfactor * dafactor));
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4711 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4712
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4713 static bool updating_aspectratios = false;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4714
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4715 void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4716 axes::properties::update_aspectratios (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4717 {
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4718 if (updating_aspectratios)
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4719 return;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4720
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4721 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
4722 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
4723 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
4724
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
4725 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
4726 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
4727 double dz = (zlimits(1)-zlimits(0));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4728
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4729 Matrix da = get_dataaspectratio ().matrix_value ();
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4730 Matrix pba = get_plotboxaspectratio ().matrix_value ();
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4731
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4732 if (dataaspectratiomode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4733 {
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4734 if (plotboxaspectratiomode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4735 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4736 pba = Matrix (1, 3, 1.0);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4737 plotboxaspectratio.set (pba, false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4738 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4739
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4740 normalized_aspectratios (da, pba, dx, dy, dz);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4741 dataaspectratio.set (da, false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4742 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4743 else if (plotboxaspectratiomode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4744 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4745 normalized_aspectratios (pba, da, dx, dy, dz);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4746 plotboxaspectratio.set (pba, false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4747 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4748 else
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4749 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4750 double s = -octave_Inf;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4751 bool modified_limits = false;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4752 Matrix kids;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4753
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4754 if (xlimmode_is ("auto") && ylimmode_is ("auto") && zlimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4755 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4756 modified_limits = true;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4757 kids = get_children ();
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4758 max_axes_scale (s, xlimits, kids, pba(0), da(0), 'x', true);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4759 max_axes_scale (s, ylimits, kids, pba(1), da(1), 'y', true);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4760 max_axes_scale (s, zlimits, kids, pba(2), da(2), 'z', true);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4761 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4762 else if (xlimmode_is ("auto") && ylimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4763 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4764 modified_limits = true;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4765 max_axes_scale (s, zlimits, kids, pba(2), da(2), 'z', false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4766 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4767 else if (ylimmode_is ("auto") && zlimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4768 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4769 modified_limits = true;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4770 max_axes_scale (s, xlimits, kids, pba(0), da(0), 'x', false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4771 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4772 else if (zlimmode_is ("auto") && xlimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4773 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4774 modified_limits = true;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4775 max_axes_scale (s, ylimits, kids, pba(1), da(1), 'y', false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4776 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4777
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4778 if (modified_limits)
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4779 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4780
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4781 unwind_protect frame;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4782 frame.protect_var (updating_aspectratios);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4783
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4784 updating_aspectratios = true;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4785
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4786 dx = pba(0) *da(0);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4787 dy = pba(1) *da(1);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4788 dz = pba(2) *da(2);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4789 if (xisinf (s))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4790 s = 1 / xmin (xmin (dx, dy), dz);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4791
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4792 if (xlimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4793 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4794 dx = s * dx;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4795 xlimits(0) = 0.5 * (xlimits(0) + xlimits(1) - dx);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4796 xlimits(1) = xlimits(0) + dx;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4797 set_xlim (xlimits);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4798 set_xlimmode ("auto");
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4799 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4800
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4801 if (ylimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4802 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4803 dy = s * dy;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4804 ylimits(0) = 0.5 * (ylimits(0) + ylimits(1) - dy);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4805 ylimits(1) = ylimits(0) + dy;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4806 set_ylim (ylimits);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4807 set_ylimmode ("auto");
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4808 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4809
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4810 if (zlimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4811 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4812 dz = s * dz;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4813 zlimits(0) = 0.5 * (zlimits(0) + zlimits(1) - dz);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4814 zlimits(1) = zlimits(0) + dz;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4815 set_zlim (zlimits);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4816 set_zlimmode ("auto");
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4817 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4818 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4819 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4820 {
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4821 normalized_aspectratios (pba, da, dx, dy, dz);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
4822 plotboxaspectratio.set (pba, false);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4823 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4824 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4825 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4826
12777
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
4827 void
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
4828 axes::properties::update_font (void)
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
4829 {
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
4830 #ifdef HAVE_FREETYPE
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
4831 #ifdef HAVE_FONTCONFIG
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
4832 text_renderer.set_font (get ("fontname").string_value (),
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
4833 get ("fontweight").string_value (),
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
4834 get ("fontangle").string_value (),
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
4835 get ("fontsize").double_value ());
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
4836 #endif
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
4837 #endif
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
4838 }
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
4839
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
4840 // 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
4841
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4842 Matrix
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
4843 axes::properties::get_boundingbox (bool internal) const
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4844 {
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
4845 graphics_object obj = gh_manager::get_object (get_parent ());
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
4846 Matrix parent_bb = obj.get_properties ().get_boundingbox (true);
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
4847 Matrix pos = (internal ?
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4848 get_position ().matrix_value ()
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4849 : get_outerposition ().matrix_value ());
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
4850
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
4851 pos = convert_position (pos, get_units (), "pixels",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4852 parent_bb.extract_n (0, 2, 1, 2));
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
4853
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4854 pos(0)--;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4855 pos(1)--;
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
4856 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
4857
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4858 return pos;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4859 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4860
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4861 Matrix
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4862 axes::properties::get_extent (bool with_text, bool only_text_height) const
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4863 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4864 graphics_xform xform = get_transform ();
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4865
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4866 Matrix ext (1, 4, 0.0);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4867 ext(0) = octave_Inf;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4868 ext(1) = octave_Inf;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4869 ext(2) = -octave_Inf;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4870 ext(3) = -octave_Inf;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4871 for (int i = 0; i <= 1; i++)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4872 for (int j = 0; j <= 1; j++)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4873 for (int k = 0; k <= 1; k++)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4874 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4875 ColumnVector p = xform.transform (i ? xPlaneN : xPlane,
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4876 j ? yPlaneN : yPlane,
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4877 k ? zPlaneN : zPlane, false);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4878 ext(0) = std::min (ext(0), p(0));
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4879 ext(1) = std::min (ext(1), p(1));
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4880 ext(2) = std::max (ext(2), p(0));
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4881 ext(3) = std::max (ext(3), p(1));
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4882 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4883
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4884 if (with_text)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4885 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4886 for (int i = 0; i < 4; i++)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4887 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4888 graphics_handle text_handle;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4889 if (i == 0)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4890 text_handle = get_title ();
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4891 else if (i == 1)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4892 text_handle = get_xlabel ();
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4893 else if (i == 2)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4894 text_handle = get_ylabel ();
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4895 else if (i == 3)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4896 text_handle = get_zlabel ();
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4897
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4898 text::properties& text_props = reinterpret_cast<text::properties&>
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4899 (gh_manager::get_object (text_handle).get_properties ());
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4900
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4901 Matrix text_pos = text_props.get_position ().matrix_value ();
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4902 text_pos = xform.transform (text_pos(0), text_pos(1), text_pos(2));
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
4903 if (text_props.get_string ().is_empty ())
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4904 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4905 ext(0) = std::min (ext(0), text_pos(0));
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4906 ext(1) = std::min (ext(1), text_pos(1));
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4907 ext(2) = std::max (ext(2), text_pos(0));
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4908 ext(3) = std::max (ext(3), text_pos(1));
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4909 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
4910 else
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4911 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4912 Matrix text_ext = text_props.get_extent_matrix ();
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4913
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4914 bool ignore_horizontal = false;
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4915 bool ignore_vertical = false;
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4916 if (only_text_height)
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4917 {
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4918 double text_rotation = text_props.get_rotation();
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4919 if (text_rotation == 0. || text_rotation == 180.)
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4920 ignore_horizontal = true;
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4921 else if (text_rotation == 90. || text_rotation == 270.)
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4922 ignore_vertical = true;
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4923 }
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4924
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4925 if (! ignore_horizontal)
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4926 {
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4927 ext(0) = std::min (ext(0), text_pos(0)+text_ext(0));
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4928 ext(2) = std::max (ext(2), text_pos(0)+text_ext(0)+text_ext(2));
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4929 }
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4930
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4931 if (! ignore_vertical)
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4932 {
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4933 ext(1) = std::min (ext(1), text_pos(1)-text_ext(1)-text_ext(3));
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4934 ext(3) = std::max (ext(3), text_pos(1)-text_ext(1));
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4935 }
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4936 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4937 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4938 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4939
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4940 ext(2) = ext(2)-ext(0);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4941 ext(3) = ext(3)-ext(1);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4942
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4943 return ext;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4944 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4945
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4946 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4947 axes::properties::set_units (const octave_value& v)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4948 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4949 if (! error_state)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4950 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4951 caseless_str old_units = get_units ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4952 if (units.set (v, true))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4953 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4954 update_units (old_units);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4955 mark_modified ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4956 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4957 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4958 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4959
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4960 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4961 axes::properties::update_units (const caseless_str& old_units)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4962 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4963 graphics_object obj = gh_manager::get_object (get_parent ());
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4964 Matrix parent_bb = obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4965 caseless_str new_units = get_units ();
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4966 position.set (octave_value (convert_position (get_position().matrix_value(), old_units, new_units, parent_bb)), false);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4967 outerposition.set (octave_value (convert_position (get_outerposition().matrix_value(), old_units, new_units, parent_bb)), false);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4968 tightinset.set (octave_value (convert_position (get_tightinset().matrix_value(), old_units, new_units, parent_bb)), false);
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4969 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4970
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4971 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4972 axes::properties::set_fontunits (const octave_value& v)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4973 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4974 if (! error_state)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4975 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4976 caseless_str old_fontunits = get_fontunits ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4977 if (fontunits.set (v, true))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4978 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4979 update_fontunits (old_fontunits);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4980 mark_modified ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4981 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4982 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4983 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4984
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4985 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4986 axes::properties::update_fontunits (const caseless_str& old_units)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4987 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4988 caseless_str new_units = get_fontunits ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4989 double fsz = get_fontsize ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4990 double pixelsperinch = xget (0, "screenpixelsperinch").double_value();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4991 double parent_height = get_boundingbox (true).elem (3);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4992
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4993 if (old_units.compare ("normalized"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4994 fsz = fsz * parent_height * 72 / pixelsperinch;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4995 else if (old_units.compare ("pixels"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4996 fsz = fsz * 72 / pixelsperinch;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4997 else if (old_units.compare ("inches"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4998 fsz = fsz * 72;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4999 else if (old_units.compare ("centimeters"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5000 fsz = fsz * 72 / 2.54;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5001
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5002 if (new_units.compare ("normalized"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5003 fsz = fsz * pixelsperinch / parent_height / 72;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5004 else if (new_units.compare ("pixels"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5005 fsz = fsz * pixelsperinch / 72;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5006 else if (new_units.compare ("inches"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5007 fsz = fsz / 72;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5008 else if (new_units.compare ("centimeters"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5009 fsz = fsz * 2.54 / 72;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5010
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5011 set_fontsize (octave_value (fsz));
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5012 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
5013
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5014 ColumnVector
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5015 graphics_xform::xform_vector (double x, double y, double z)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
5016 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
5017 return ::xform_vector (x, y, z);
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
5018 }
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5019
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5020 Matrix
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5021 graphics_xform::xform_eye (void)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
5022 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
5023 return ::xform_matrix ();
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
5024 }
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5025
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5026 ColumnVector
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5027 graphics_xform::transform (double x, double y, double z,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5028 bool use_scale) const
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5029 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5030 if (use_scale)
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5031 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5032 x = sx.scale (x);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5033 y = sy.scale (y);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5034 z = sz.scale (z);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5035 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5036
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5037 return ::transform (xform, x, y, z);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5038 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5039
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5040 ColumnVector
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5041 graphics_xform::untransform (double x, double y, double z,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5042 bool use_scale) const
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5043 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5044 ColumnVector v = ::transform (xform_inv, x, y, z);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5045
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5046 if (use_scale)
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5047 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5048 v(0) = sx.unscale (v(0));
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5049 v(1) = sy.unscale (v(1));
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5050 v(2) = sz.unscale (v(2));
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5051 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5052
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5053 return v;
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5054 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
5055
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
5056 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
5057 axes::get_default (const caseless_str& name) const
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
5058 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
5059 octave_value retval = default_properties.lookup (name);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
5060
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
5061 if (retval.is_undefined ())
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
5062 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
5063 graphics_handle parent = get_parent ();
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
5064 graphics_object parent_obj = gh_manager::get_object (parent);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
5065
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
5066 retval = parent_obj.get_default (name);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
5067 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
5068
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
5069 return retval;
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
5070 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
5071
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8299
diff changeset
5072 // FIXME -- remove.
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8299
diff changeset
5073 // 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
5074 /*
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
5075 static void
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5076 check_limit_vals (double& min_val, double& max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5077 double& min_pos, double& max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5078 const array_property& data)
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
5079 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
5080 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
5081 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
5082 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
5083 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
5084 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
5085 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
5086 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
5087 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
5088 min_pos = val;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5089 val = data.max_neg ();
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5090 if (! (xisinf (val) || xisnan (val)) && val < 0 && val > max_neg)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5091 max_neg = val;
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
5092 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5093 */
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5094
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5095 static void
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5096 check_limit_vals (double& min_val, double& max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5097 double& min_pos, double& max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5098 const octave_value& data)
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5099 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5100 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
5101 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5102 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
5103
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5104 if (! error_state && m.numel () == 4)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5105 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5106 double val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5107
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5108 val = m(0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5109 if (! (xisinf (val) || xisnan (val)) && val < min_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5110 min_val = val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5111
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5112 val = m(1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5113 if (! (xisinf (val) || xisnan (val)) && val > max_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5114 max_val = val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5115
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5116 val = m(2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5117 if (! (xisinf (val) || xisnan (val)) && val > 0 && val < min_pos)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5118 min_pos = val;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5119
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5120 val = m(3);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5121 if (! (xisinf (val) || xisnan (val)) && val < 0 && val > max_neg)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5122 max_neg = val;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5123 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5124 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5125 }
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
5126
12508
919cadf334f8 Simplify calculation of number of tick labels. Bug #32692.
Marco Caliari <marco.caliari@univr.it>
parents: 12506
diff changeset
5127 // magform(x) Returns (a, b), where x = a * 10^b, abs (a) >= 1., and b is
919cadf334f8 Simplify calculation of number of tick labels. Bug #32692.
Marco Caliari <marco.caliari@univr.it>
parents: 12506
diff changeset
5128 // integer.
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5129
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
5130 static void
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
5131 magform (double x, double& a, int& b)
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5132 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5133 if (x == 0)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5134 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5135 a = 0;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5136 b = 0;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5137 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5138 else
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5139 {
12508
919cadf334f8 Simplify calculation of number of tick labels. Bug #32692.
Marco Caliari <marco.caliari@univr.it>
parents: 12506
diff changeset
5140 b = static_cast<int> (gnulib::floor (std::log10 (std::abs (x))));
919cadf334f8 Simplify calculation of number of tick labels. Bug #32692.
Marco Caliari <marco.caliari@univr.it>
parents: 12506
diff changeset
5141 a = x / std::pow (10.0, b);
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5142 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5143 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5144
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5145 // 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
5146 // 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
5147 // FIXME -- add log ticks
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5148
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5149 double
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5150 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
5151 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5152 int ticint = 5;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5153
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5154 // 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
5155 // 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
5156 // 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
5157 // 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
5158
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5159 double a;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5160 int b, x;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5161
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5162 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
5163
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5164 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
5165 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
5166 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
5167
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5168 if (a < sqrt_2)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5169 x = 1;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5170 else if (a < sqrt_10)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5171 x = 2;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5172 else if (a < sqrt_50)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5173 x = 5;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5174 else
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5175 x = 10;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5176
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5177 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
5178
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5179 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5180
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5181 // 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
5182 // 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
5183 // value.
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5184
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5185 Matrix
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
5186 axes::properties::get_axis_limits (double xmin, double xmax,
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5187 double min_pos, double max_neg,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5188 bool logscale)
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5189 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5190 Matrix retval;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5191
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5192 double min_val = xmin;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5193 double max_val = xmax;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5194
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5195 if (! (xisinf (min_val) || xisinf (max_val)))
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5196 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5197 if (logscale)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5198 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5199 if (xisinf (min_pos) && xisinf (max_neg))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5200 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5201 // TODO -- max_neg is needed for "loglog ([0 -Inf])"
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5202 // This is the only place where max_neg is needed.
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5203 // Is there another way?
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5204 retval = default_lim ();
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5205 retval(0) = pow (10., retval(0));
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5206 retval(1) = pow (10., retval(1));
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5207 return retval;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5208 }
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5209 if ((min_val <= 0 && max_val >= 0))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5210 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5211 warning ("axis: omitting nonpositive data in log plot");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5212 min_val = min_pos;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5213 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5214 // FIXME -- maybe this test should also be relative?
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5215 if (std::abs (min_val - max_val) < sqrt (DBL_EPSILON))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5216 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5217 min_val *= 0.9;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5218 max_val *= 1.1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5219 }
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5220 if (min_val > 0)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5221 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5222 // Log plots with all positive data
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5223 min_val = pow (10, gnulib::floor (log10 (min_val)));
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5224 max_val = pow (10, std::ceil (log10 (max_val)));
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5225 }
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5226 else
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5227 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5228 // Log plots with all negative data
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5229 min_val = -pow (10, gnulib::floor (log10 (-min_val)));
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5230 max_val = -pow (10, std::ceil (log10 (-max_val)));
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5231 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5232 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5233 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5234 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5235 if (min_val == 0 && max_val == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5236 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5237 min_val = -1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5238 max_val = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5239 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5240 // FIXME -- maybe this test should also be relative?
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5241 else if (std::abs (min_val - max_val) < sqrt (DBL_EPSILON))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5242 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5243 min_val -= 0.1 * std::abs (min_val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5244 max_val += 0.1 * std::abs (max_val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5245 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5246
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5247 double tick_sep = calc_tick_sep (min_val , max_val);
12549
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
5248 double min_tick = gnulib::floor (min_val / tick_sep);
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
5249 double max_tick = std::ceil (max_val / tick_sep);
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
5250 // Prevent round-off from cropping ticks
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
5251 min_val = std::min (min_val, tick_sep * min_tick);
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
5252 max_val = std::max (max_val, tick_sep * max_tick);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5253 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5254 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5255
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5256 retval.resize (1, 2);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5257
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5258 retval(0) = min_val;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5259 retval(1) = max_val;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5260
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5261 return retval;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5262 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5263
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5264 void
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
5265 axes::properties::calc_ticks_and_lims (array_property& lims,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5266 array_property& ticks,
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
5267 array_property& mticks,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5268 bool limmode_is_auto, bool is_logscale)
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
5269 {
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5270 // FIXME -- add log ticks and lims
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
5271
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
5272 if (lims.get ().is_empty ())
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
5273 return;
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
5274
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
5275 double lo = (lims.get ().matrix_value ()) (0);
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
5276 double hi = (lims.get ().matrix_value ()) (1);
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5277 bool is_negative = lo < 0 && hi < 0;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5278 double tmp;
7843
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
5279 // FIXME should this be checked for somewhere else? (i.e. set{x,y,z}lim)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5280 if (hi < lo)
7843
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
5281 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5282 tmp = hi;
7843
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
5283 hi = lo;
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
5284 lo = tmp;
d3dcfdfdc434 handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
5285 }
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
5286
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
5287 if (is_logscale)
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
5288 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5289 if (is_negative)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5290 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5291 tmp = hi;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5292 hi = std::log10 (-lo);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5293 lo = std::log10 (-tmp);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5294 }
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5295 else
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5296 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5297 hi = std::log10 (hi);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5298 lo = std::log10 (lo);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5299 }
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
5300 }
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
5301
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5302 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
5303
13106
c7512d0d52e8 src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents: 12587
diff changeset
5304 if (is_logscale && ! (xisinf (hi) || xisinf (lo)))
c7512d0d52e8 src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents: 12587
diff changeset
5305 {
c7512d0d52e8 src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents: 12587
diff changeset
5306 // FIXME - what if (hi-lo) < tick_sep?
c7512d0d52e8 src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents: 12587
diff changeset
5307 // ex: loglog ([1 1.1])
13109
8e61aa0fac77 src/graphics.cc: Fix mistake in changeset c7512d0d52e8.
Ben Abbott <bpabbott@mac.com>
parents: 13106
diff changeset
5308 tick_sep = std::max (tick_sep, 1.);
8e61aa0fac77 src/graphics.cc: Fix mistake in changeset c7512d0d52e8.
Ben Abbott <bpabbott@mac.com>
parents: 13106
diff changeset
5309 tick_sep = std::ceil (tick_sep);
13106
c7512d0d52e8 src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents: 12587
diff changeset
5310 }
c7512d0d52e8 src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents: 12587
diff changeset
5311
11450
5eb10763069f substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents: 11431
diff changeset
5312 int i1 = static_cast<int> (gnulib::floor (lo / tick_sep));
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5313 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
5314
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5315 if (limmode_is_auto)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5316 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5317 // 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
5318 Matrix tmp_lims (1,2);
12549
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
5319 tmp_lims(0) = std::min (tick_sep * i1, lo);
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
5320 tmp_lims(1) = std::max (tick_sep * i2, hi);
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5321
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5322 if (is_logscale)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5323 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5324 tmp_lims(0) = std::pow (10.,tmp_lims(0));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5325 tmp_lims(1) = std::pow (10.,tmp_lims(1));
10941
97294dd3ccd4 graphics.cc: Fix axes limits underflow to zero for logscale.
Ben Abbott <bpabbott@mac.com>
parents: 10923
diff changeset
5326 if (tmp_lims(0) <= 0)
97294dd3ccd4 graphics.cc: Fix axes limits underflow to zero for logscale.
Ben Abbott <bpabbott@mac.com>
parents: 10923
diff changeset
5327 tmp_lims(0) = std::pow (10., lo);
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5328 if (is_negative)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5329 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5330 tmp = tmp_lims(0);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5331 tmp_lims(0) = -tmp_lims(1);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5332 tmp_lims(1) = -tmp;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5333 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5334 }
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5335 lims = tmp_lims;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5336 }
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
5337 else
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5338 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5339 // 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
5340 i1 = static_cast<int> (std::ceil (lo / tick_sep));
11450
5eb10763069f substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents: 11431
diff changeset
5341 i2 = static_cast<int> (gnulib::floor (hi / tick_sep));
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5342 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5343
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5344 Matrix tmp_ticks (1, i2-i1+1);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5345 for (int i = 0; i <= i2-i1; i++)
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
5346 {
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
5347 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
5348 if (is_logscale)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5349 tmp_ticks (i) = std::pow (10., tmp_ticks (i));
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
5350 }
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5351 if (is_logscale && is_negative)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5352 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5353 Matrix rev_ticks (1, i2-i1+1);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5354 rev_ticks = -tmp_ticks;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5355 for (int i = 0; i <= i2-i1; i++)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5356 tmp_ticks (i) = rev_ticks (i2-i1-i);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5357 }
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5358
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
5359 ticks = tmp_ticks;
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
5360
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
5361 int n = is_logscale ? 9 : 4;
12157
0b9c1a7e350a fix wrong dimensions of minor ticks vector
Konstantinos Poulios <logari81@googlemail.com>
parents: 12126
diff changeset
5362 Matrix tmp_mticks (1, n * (tmp_ticks.numel () - 1));
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
5363
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
5364 for (int i = 0; i < tmp_ticks.numel ()-1; i++)
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
5365 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
5366 double d = (tmp_ticks (i+1) - tmp_ticks (i)) / (n+1);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
5367 for (int j = 0; j < n; j++)
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
5368 {
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
5369 tmp_mticks (n*i+j) = tmp_ticks (i) + d * (j+1);
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
5370 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
5371 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
5372 mticks = tmp_mticks;
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
5373 }
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
5374
9347
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
5375 void
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
5376 axes::properties::calc_ticklabels (const array_property& ticks,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5377 any_property& labels, bool /*logscale*/)
9347
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
5378 {
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
5379 Matrix values = ticks.get ().matrix_value ();
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
5380 Cell c (values.dims ());
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
5381 std::ostringstream os;
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
5382
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
5383 for (int i = 0; i < values.numel (); i++)
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
5384 {
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
5385 os.str (std::string ());
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
5386 os << values(i);
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
5387 c(i) = os.str ();
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
5388 }
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
5389
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
5390 labels = c;
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
5391 }
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
5392
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5393 Matrix
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5394 axes::properties::get_ticklabel_extents (const Matrix& ticks,
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5395 const string_vector& ticklabels,
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5396 const Matrix& limits)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5397 {
12777
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
5398 #ifndef HAVE_FREETYPE
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5399 double fontsize = get ("fontsize").double_value ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5400 #endif
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5401
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5402 Matrix ext (1, 2, 0.0);
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5403 double wmax = 0., hmax = 0.;
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5404 int n = std::min (ticklabels.numel (), ticks.numel ());
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5405 for (int i = 0; i < n; i++)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5406 {
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5407 double val = ticks(i);
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5408 if (limits(0) <= val && val <= limits(1))
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5409 {
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5410 #ifdef HAVE_FREETYPE
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5411 ext = text_renderer.get_extent (ticklabels(i));
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5412 wmax = std::max (wmax, ext(0));
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5413 hmax = std::max (hmax, ext(1));
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5414 #else
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5415 //FIXME: find a better approximation
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5416 int len = ticklabels(i).length();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5417 wmax = std::max (wmax, 0.5*fontsize*len);
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5418 hmax = fontsize;
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5419 #endif
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5420 }
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5421 }
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5422
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5423 ext(0) = wmax;
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5424 ext(1) = hmax;
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5425 return ext;
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5426 }
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5427
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5428 void
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5429 get_children_limits (double& min_val, double& max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5430 double& min_pos, double& max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5431 const Matrix& kids, char limit_type)
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5432 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5433 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
5434
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5435 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
5436 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5437 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
5438 for (octave_idx_type i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5439 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5440 graphics_object obj = gh_manager::get_object (kids(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5441
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5442 if (obj.is_xliminclude ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5443 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5444 octave_value lim = obj.get_xlim ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5445
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5446 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5447 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5448 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5449 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5450
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5451 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
5452 for (octave_idx_type i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5453 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5454 graphics_object obj = gh_manager::get_object (kids(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5455
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5456 if (obj.is_yliminclude ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5457 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5458 octave_value lim = obj.get_ylim ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5459
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5460 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5461 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5462 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5463 break;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5464
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5465 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
5466 for (octave_idx_type i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5467 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5468 graphics_object obj = gh_manager::get_object (kids(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5469
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5470 if (obj.is_zliminclude ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5471 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5472 octave_value lim = obj.get_zlim ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5473
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5474 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5475 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5476 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5477 break;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5478
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5479 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
5480 for (octave_idx_type i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5481 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5482 graphics_object obj = gh_manager::get_object (kids(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5483
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5484 if (obj.is_climinclude ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5485 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5486 octave_value lim = obj.get_clim ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5487
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5488 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5489 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5490 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5491 break;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5492
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5493 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
5494 for (octave_idx_type i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5495 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5496 graphics_object obj = gh_manager::get_object (kids(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5497
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5498 if (obj.is_aliminclude ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5499 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5500 octave_value lim = obj.get_alim ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5501
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5502 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5503 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5504 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5505 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5506
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5507 default:
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5508 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5509 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5510 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5511
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5512 static bool updating_axis_limits = false;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5513
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
5514 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5515 axes::update_axis_limits (const std::string& axis_type,
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5516 const graphics_handle& h)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5517 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5518 if (updating_axis_limits)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5519 return;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5520
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5521 Matrix kids = Matrix (1, 1, h.value ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5522
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5523 double min_val = octave_Inf;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5524 double max_val = -octave_Inf;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5525 double min_pos = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5526 double max_neg = -octave_Inf;
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5527
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5528 char update_type = 0;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5529
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5530 Matrix limits;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5531 double val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5532
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5533 #define FIX_LIMITS \
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5534 if (limits.numel() == 4) \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5535 { \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5536 val = limits(0); \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5537 if (! (xisinf (val) || xisnan (val))) \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5538 min_val = val; \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5539 val = limits(1); \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5540 if (! (xisinf (val) || xisnan (val))) \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5541 max_val = val; \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5542 val = limits(2); \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5543 if (! (xisinf (val) || xisnan (val))) \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5544 min_pos = val; \
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5545 val = limits(3); \
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5546 if (! (xisinf (val) || xisnan (val))) \
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5547 max_neg = val; \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5548 } \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5549 else \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5550 { \
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5551 limits.resize(4, 1); \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5552 limits(0) = min_val; \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5553 limits(1) = max_val; \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5554 limits(2) = min_pos; \
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5555 limits(3) = max_neg; \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5556 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5557
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5558 if (axis_type == "xdata" || axis_type == "xscale"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5559 || axis_type == "xlimmode" || axis_type == "xliminclude"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5560 || axis_type == "xlim")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5561 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5562 if (xproperties.xlimmode_is ("auto"))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5563 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5564 limits = xproperties.get_xlim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5565 FIX_LIMITS ;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5566
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5567 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'x');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5568
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5569 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5570 min_pos, max_neg,
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5571 xproperties.xscale_is ("log"));
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5572
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5573 update_type = 'x';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5574 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5575 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5576 else if (axis_type == "ydata" || axis_type == "yscale"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5577 || axis_type == "ylimmode" || axis_type == "yliminclude"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5578 || axis_type == "ylim")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5579 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5580 if (xproperties.ylimmode_is ("auto"))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5581 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5582 limits = xproperties.get_ylim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5583 FIX_LIMITS ;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5584
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5585 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'y');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5586
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5587 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5588 min_pos, max_neg,
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5589 xproperties.yscale_is ("log"));
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5590
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5591 update_type = 'y';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5592 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5593 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5594 else if (axis_type == "zdata" || axis_type == "zscale"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5595 || axis_type == "zlimmode" || axis_type == "zliminclude"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5596 || axis_type == "zlim")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5597 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5598 if (xproperties.zlimmode_is ("auto"))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5599 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5600 limits = xproperties.get_zlim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5601 FIX_LIMITS ;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5602
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5603 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'z');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5604
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5605 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5606 min_pos, max_neg,
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5607 xproperties.zscale_is ("log"));
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5608
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5609 update_type = 'z';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5610 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5611 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5612 else if (axis_type == "cdata" || axis_type == "climmode"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5613 || axis_type == "cdatamapping" || axis_type == "climinclude"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5614 || axis_type == "clim")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5615 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5616 if (xproperties.climmode_is ("auto"))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5617 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5618 limits = xproperties.get_clim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5619 FIX_LIMITS ;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5620
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5621 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'c');
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5622
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5623 if (min_val > max_val)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5624 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5625 min_val = min_pos = 0;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5626 max_val = 1;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5627 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5628 else if (min_val == max_val)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5629 max_val = min_val + 1;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5630
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5631 limits.resize (1, 2);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5632
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5633 limits(0) = min_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5634 limits(1) = max_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5635
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5636 update_type = 'c';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5637 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5638
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5639 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5640 else if (axis_type == "alphadata" || axis_type == "alimmode"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5641 || axis_type == "alphadatamapping" || axis_type == "aliminclude"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5642 || axis_type == "alim")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5643 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5644 if (xproperties.alimmode_is ("auto"))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5645 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5646 limits = xproperties.get_alim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5647 FIX_LIMITS ;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5648
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5649 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'a');
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5650
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5651 if (min_val > max_val)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5652 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5653 min_val = min_pos = 0;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5654 max_val = 1;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5655 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5656 else if (min_val == max_val)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5657 max_val = min_val + 1;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5658
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5659 limits.resize (1, 2);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5660
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5661 limits(0) = min_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5662 limits(1) = max_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5663
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5664 update_type = 'a';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5665 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5666
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5667 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5668
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5669 #undef FIX_LIMITS
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5670
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5671 unwind_protect frame;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5672 frame.protect_var (updating_axis_limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5673
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5674 updating_axis_limits = true;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5675
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5676 switch (update_type)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5677 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5678 case 'x':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5679 xproperties.set_xlim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5680 xproperties.set_xlimmode ("auto");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5681 xproperties.update_xlim ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5682 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5683
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5684 case 'y':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5685 xproperties.set_ylim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5686 xproperties.set_ylimmode ("auto");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5687 xproperties.update_ylim ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5688 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5689
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5690 case 'z':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5691 xproperties.set_zlim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5692 xproperties.set_zlimmode ("auto");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5693 xproperties.update_zlim ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5694 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5695
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5696 case 'c':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5697 xproperties.set_clim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5698 xproperties.set_climmode ("auto");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5699 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5700
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5701 case 'a':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5702 xproperties.set_alim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5703 xproperties.set_alimmode ("auto");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5704 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5705
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5706 default:
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5707 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5708 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5709
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5710 xproperties.update_transform ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5711
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5712 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5713
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
5714 void
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5715 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
5716 {
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
5717 if (updating_axis_limits || updating_aspectratios)
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5718 return;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5719
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5720 Matrix kids = xproperties.get_children ();
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5721
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5722 double min_val = octave_Inf;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5723 double max_val = -octave_Inf;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5724 double min_pos = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5725 double max_neg = -octave_Inf;
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5726
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5727 char update_type = 0;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5728
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5729 Matrix limits;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5730
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5731 if (axis_type == "xdata" || axis_type == "xscale"
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5732 || 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
5733 || axis_type == "xlim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5734 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
5735 if (xproperties.xlimmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5736 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5737 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'x');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5738
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5739 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5740 min_pos, max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5741 xproperties.xscale_is ("log"));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5742
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5743 update_type = 'x';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5744 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5745 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5746 else if (axis_type == "ydata" || axis_type == "yscale"
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5747 || axis_type == "ylimmode" || axis_type == "yliminclude"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5748 || axis_type == "ylim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5749 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
5750 if (xproperties.ylimmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5751 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5752 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'y');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5753
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5754 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5755 min_pos, max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5756 xproperties.yscale_is ("log"));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5757
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5758 update_type = 'y';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5759 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5760 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5761 else if (axis_type == "zdata" || axis_type == "zscale"
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5762 || axis_type == "zlimmode" || axis_type == "zliminclude"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5763 || axis_type == "zlim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5764 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
5765 if (xproperties.zlimmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5766 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5767 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'z');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5768
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5769 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5770 min_pos, max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5771 xproperties.zscale_is ("log"));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5772
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5773 update_type = 'z';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5774 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5775 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5776 else if (axis_type == "cdata" || axis_type == "climmode"
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5777 || axis_type == "cdatamapping" || axis_type == "climinclude"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5778 || axis_type == "clim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5779 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
5780 if (xproperties.climmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5781 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5782 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'c');
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5783
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5784 if (min_val > max_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5785 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5786 min_val = min_pos = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5787 max_val = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5788 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5789 else if (min_val == max_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5790 max_val = min_val + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5791
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5792 limits.resize (1, 2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5793
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5794 limits(0) = min_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5795 limits(1) = max_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5796
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5797 update_type = 'c';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5798 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5799
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5800 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5801 else if (axis_type == "alphadata" || axis_type == "alimmode"
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5802 || axis_type == "alphadatamapping" || axis_type == "aliminclude"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5803 || axis_type == "alim")
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5804 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5805 if (xproperties.alimmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5806 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5807 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'a');
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5808
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5809 if (min_val > max_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5810 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5811 min_val = min_pos = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5812 max_val = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5813 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5814 else if (min_val == max_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5815 max_val = min_val + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5816
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5817 limits.resize (1, 2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5818
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5819 limits(0) = min_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5820 limits(1) = max_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5821
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5822 update_type = 'a';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5823 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5824
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5825 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5826
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
5827 unwind_protect frame;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
5828 frame.protect_var (updating_axis_limits);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
5829
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5830 updating_axis_limits = true;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5831
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5832 switch (update_type)
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5833 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5834 case 'x':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5835 xproperties.set_xlim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5836 xproperties.set_xlimmode ("auto");
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
5837 xproperties.update_xlim ();
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5838 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5839
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5840 case 'y':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5841 xproperties.set_ylim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5842 xproperties.set_ylimmode ("auto");
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
5843 xproperties.update_ylim ();
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5844 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5845
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5846 case 'z':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5847 xproperties.set_zlim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5848 xproperties.set_zlimmode ("auto");
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
5849 xproperties.update_zlim ();
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5850 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5851
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5852 case 'c':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5853 xproperties.set_clim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5854 xproperties.set_climmode ("auto");
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5855 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5856
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5857 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
5858 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
5859 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
5860 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
5861
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5862 default:
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5863 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5864 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
5865
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5866 xproperties.update_transform ();
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
5867 }
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
5868
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5869 inline
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5870 double force_in_range (const double x, const double lower, const double upper)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5871 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5872 if (x < lower)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5873 { return lower; }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5874 else if (x > upper)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5875 { return upper; }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5876 else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5877 { return x; }
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5878 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5879
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5880 void
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5881 axes::properties::zoom_about_point (double x, double y, double factor,
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5882 bool push_to_zoom_stack)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5883 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5884 // FIXME: Do we need error checking here?
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5885 Matrix xlims = get_xlim ().matrix_value ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5886 Matrix ylims = get_ylim ().matrix_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5887
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5888 // Get children axes limits
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5889 Matrix kids = get_children ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5890 double minx = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5891 double maxx = -octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5892 double min_pos_x = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5893 double max_neg_x = -octave_Inf;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5894 get_children_limits (minx, maxx, min_pos_x, max_neg_x, kids, 'x');
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5895
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5896 double miny = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5897 double maxy = -octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5898 double min_pos_y = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5899 double max_neg_y = -octave_Inf;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5900 get_children_limits (miny, maxy, min_pos_y, max_neg_y, kids, 'y');
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5901
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5902 // Perform the zooming
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5903 xlims (0) = x + factor * (xlims (0) - x);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5904 xlims (1) = x + factor * (xlims (1) - x);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5905 ylims (0) = y + factor * (ylims (0) - y);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5906 ylims (1) = y + factor * (ylims (1) - y);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5907
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5908 zoom (xlims, ylims, push_to_zoom_stack);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5909 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5910
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5911 void
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5912 axes::properties::zoom (const Matrix& xl, const Matrix& yl, bool push_to_zoom_stack)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5913 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5914 if (push_to_zoom_stack)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5915 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5916 zoom_stack.push_front (xlimmode.get ());
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5917 zoom_stack.push_front (xlim.get ());
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5918 zoom_stack.push_front (ylimmode.get ());
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5919 zoom_stack.push_front (ylim.get ());
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5920 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5921
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5922 xlim = xl;
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5923 xlimmode = "manual";
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5924 ylim = yl;
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5925 ylimmode = "manual";
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5926
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5927 update_transform ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5928 update_xlim (false);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5929 update_ylim (false);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5930 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5931
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5932 void
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5933 axes::properties::translate_view (double delta_x, double delta_y)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5934 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5935 // FIXME: Do we need error checking here?
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5936 Matrix xlims = get_xlim ().matrix_value ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5937 Matrix ylims = get_ylim ().matrix_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5938
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5939 // Get children axes limits
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5940 Matrix kids = get_children ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5941 double minx = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5942 double maxx = -octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5943 double min_pos_x = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5944 double max_neg_x = -octave_Inf;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5945 get_children_limits (minx, maxx, min_pos_x, max_neg_x, kids, 'x');
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5946
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5947 double miny = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5948 double maxy = -octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5949 double min_pos_y = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5950 double max_neg_y = -octave_Inf;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
5951 get_children_limits (miny, maxy, min_pos_y, max_neg_y, kids, 'y');
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5952
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
5953 xlims (0) += delta_x;
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
5954 xlims (1) += delta_x;
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
5955 ylims (0) += delta_y;
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
5956 ylims (1) += delta_y;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5957
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5958 zoom (xlims, ylims, false);
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5959 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5960
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
5961 void
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
5962 axes::properties::rotate_view (double delta_el, double delta_az)
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
5963 {
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
5964 Matrix v = get_view ().matrix_value ();
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
5965
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
5966 v (1) += delta_el;
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5967
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5968 if(v(1) > 90)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5969 v(1) = 90;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5970 if(v(1) < -90)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5971 v(1) = -90;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5972
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5973 v (0) = fmod(v(0) - delta_az + 720,360);
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
5974
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
5975 set_view(v);
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
5976 update_transform();
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
5977 }
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
5978
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
5979 void
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5980 axes::properties::unzoom (void)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5981 {
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5982 if (zoom_stack.size () >= 4)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5983 {
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5984 ylim = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5985 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5986 ylimmode = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5987 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5988 xlim = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5989 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5990 xlimmode = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5991 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5992
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5993 update_transform ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5994 update_xlim (false);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5995 update_ylim (false);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5996 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5997 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5998
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
5999 void
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6000 axes::properties::clear_zoom_stack (void)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6001 {
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6002 while (zoom_stack.size () > 4)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6003 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6004
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6005 unzoom ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6006 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
6007
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6008 void
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6009 axes::reset_default_properties (void)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6010 {
10733
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
6011 ::reset_default_properties (default_properties);
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6012 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6013
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
6014 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
6015
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6016 Matrix
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6017 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
6018 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6019 Matrix m (1, 4);
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6020
10596
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
6021 m(0) = xdata.min_val ();
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
6022 m(1) = xdata.max_val ();
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
6023 m(2) = xdata.min_pos ();
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6024 m(3) = xdata.max_neg ();
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6025
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6026 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
6027 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6028
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6029 Matrix
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6030 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
6031 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6032 Matrix m (1, 4);
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6033
10596
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
6034 m(0) = ydata.min_val ();
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
6035 m(1) = ydata.max_val ();
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
6036 m(2) = ydata.min_pos ();
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6037 m(3) = ydata.max_neg ();
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6038
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6039 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
6040 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6041
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6042 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6043
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6044 Matrix
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6045 text::properties::get_data_position (void) const
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6046 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6047 Matrix pos = get_position ().matrix_value ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6048
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6049 if (! units_is ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6050 pos = convert_text_position (pos, *this, get_units (), "data");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6051
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6052 return pos;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6053 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6054
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6055 Matrix
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6056 text::properties::get_extent_matrix (void) const
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6057 {
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6058 return extent.get ().matrix_value ();
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6059 }
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6060
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6061 octave_value
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6062 text::properties::get_extent (void) const
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6063 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6064 Matrix m = extent.get ().matrix_value ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6065
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6066 return convert_text_position (m, *this, "pixels", get_units ());
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6067 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6068
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6069 void
12777
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6070 text::properties::update_font (void)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6071 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6072 #ifdef HAVE_FREETYPE
10526
660c244d3206 Don't call text_renderer.set_font if HAVE_FONTCONFIG is not set (bug #29570)
David Bateman <dbateman@free.fr>
parents: 10402
diff changeset
6073 #ifdef HAVE_FONTCONFIG
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6074 renderer.set_font (get ("fontname").string_value (),
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6075 get ("fontweight").string_value (),
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6076 get ("fontangle").string_value (),
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6077 get ("fontsize").double_value ());
10526
660c244d3206 Don't call text_renderer.set_font if HAVE_FONTCONFIG is not set (bug #29570)
David Bateman <dbateman@free.fr>
parents: 10402
diff changeset
6078 #endif
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6079 renderer.set_color (get_color_rgb ());
12777
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6080 #endif
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6081 }
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6082
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6083 void
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6084 text::properties::update_text_extent (void)
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6085 {
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6086 #ifdef HAVE_FREETYPE
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6087
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6088 int halign = 0, valign = 0;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6089
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6090 if (horizontalalignment_is ("center"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6091 halign = 1;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6092 else if (horizontalalignment_is ("right"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6093 halign = 2;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6094
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6095 if (verticalalignment_is ("top"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6096 valign = 2;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6097 else if (verticalalignment_is ("baseline"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6098 valign = 3;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6099 else if (verticalalignment_is ("middle"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6100 valign = 1;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6101
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6102 Matrix bbox;
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
6103
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6104 // FIXME: string should be parsed only when modified, for efficiency
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
6105
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
6106 octave_value string_prop = get_string ();
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
6107
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
6108 string_vector sv = string_prop.all_strings ();
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
6109
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
6110 renderer.text_to_pixels (sv.join ("\n"), pixels, bbox,
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6111 halign, valign, get_rotation ());
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
6112 set_extent (bbox);
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
6113
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6114 #endif
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6115
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6116 if (autopos_tag_is ("xlabel") || autopos_tag_is ("ylabel") ||
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6117 autopos_tag_is ("zlabel") || autopos_tag_is ("title"))
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6118 update_autopos ("sync");
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6119 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6120
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6121 void
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6122 text::properties::request_autopos (void)
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6123 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6124 if (autopos_tag_is ("xlabel") || autopos_tag_is ("ylabel") ||
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6125 autopos_tag_is ("zlabel") || autopos_tag_is ("title"))
12422
a3be83af8cfa simplifications in position updating functions for axes labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12389
diff changeset
6126 update_autopos (get_autopos_tag ());
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6127 }
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6128
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6129 void
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6130 text::properties::update_units (void)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6131 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6132 if (! units_is ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6133 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6134 set_xliminclude ("off");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6135 set_yliminclude ("off");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6136 set_zliminclude ("off");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6137 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6138
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6139 Matrix pos = get_position ().matrix_value ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6140
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6141 pos = convert_text_position (pos, *this, cached_units, get_units ());
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6142 // FIXME: if the current axes view is 2D, then one should
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6143 // probably drop the z-component of "pos" and leave "zliminclude"
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6144 // to "off".
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6145 set_position (pos);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6146
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6147 if (units_is ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6148 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6149 set_xliminclude ("on");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6150 set_yliminclude ("on");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6151 // FIXME: see above
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6152 set_zliminclude ("off");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6153 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6154
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6155 cached_units = get_units ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6156 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6157
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6158 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6159
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
6160 octave_value
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
6161 image::properties::get_color_data (void) const
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
6162 {
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
6163 return convert_cdata (*this, get_cdata (),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6164 cdatamapping_is ("scaled"), 3);
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
6165 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6166
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6167 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6168
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
6169 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
6170 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
6171 {
11168
36442102c340 Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents: 11167
diff changeset
6172 octave_value fvc = get_facevertexcdata();
36442102c340 Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents: 11167
diff changeset
6173 if (fvc.is_undefined () || fvc.is_empty ())
36442102c340 Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents: 11167
diff changeset
6174 return Matrix ();
36442102c340 Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents: 11167
diff changeset
6175 else
36442102c340 Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents: 11167
diff changeset
6176 return convert_cdata (*this, fvc,cdatamapping_is ("scaled"), 2);
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
6177 }
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
6178
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
6179 // ---------------------------------------------------------------------
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
6180
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6181 octave_value
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6182 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
6183 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6184 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
6185 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6186
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6187 inline void
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6188 cross_product (double x1, double y1, double z1,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6189 double x2, double y2, double z2,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6190 double& x, double& y, double& z)
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6191 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6192 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
6193 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
6194 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
6195 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6196
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6197 void
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6198 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
6199 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6200 if (normalmode_is ("auto"))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6201 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6202 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
6203 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
6204 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
6205
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6206
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6207 int p = z.columns (), q = z.rows ();
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6208 int i1 = 0, i2 = 0, i3 = 0;
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6209 int j1 = 0, j2 = 0, j3 = 0;
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6210
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6211 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
6212 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
6213
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6214 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
6215
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6216 for (int i = 0; i < p; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6217 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6218 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6219 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6220 i1 = i - 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6221 i2 = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6222 i3 = i + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6223 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6224
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6225 for (int j = 0; j < q; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6226 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6227 if (x_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6228 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6229 j1 = j - 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6230 j2 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6231 j3 = j + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6232 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6233
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6234 double& nx = n(j, i, 0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6235 double& ny = n(j, i, 1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6236 double& nz = n(j, i, 2);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6237
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6238 if ((j > 0) && (i > 0))
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6239 // upper left quadrangle
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6240 cross_product (x(j1,i-1)-x(j2,i), y(j-1,i1)-y(j,i2), z(j-1,i-1)-z(j,i),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6241 x(j2,i-1)-x(j1,i), y(j,i1)-y(j-1,i2), z(j,i-1)-z(j-1,i),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6242 nx, ny, nz);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6243
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6244 if ((j > 0) && (i < (p -1)))
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6245 // upper right quadrangle
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6246 cross_product (x(j1,i+1)-x(j2,i), y(j-1,i3)-y(j,i2), z(j-1,i+1)-z(j,i),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6247 x(j1,i)-x(j2,i+1), y(j-1,i2)-y(j,i3), z(j-1,i)-z(j,i+1),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6248 nx, ny, nz);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6249
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6250 if ((j < (q - 1)) && (i > 0))
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6251 // lower left quadrangle
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6252 cross_product (x(j2,i-1)-x(j3,i), y(j,i1)-y(j+1,i2), z(j,i-1)-z(j+1,i),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6253 x(j3,i-1)-x(j2,i), y(j+1,i1)-y(j,i2), z(j+1,i-1)-z(j,i),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6254 nx, ny, nz);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6255
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6256 if ((j < (q - 1)) && (i < (p -1)))
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6257 // lower right quadrangle
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6258 cross_product (x(j3,i)-x(j2,i+1), y(j+1,i2)-y(j,i3), z(j+1,i)-z(j,i+1),
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6259 x(j3,i+1)-x(j2,i), y(j+1,i3)-y(j,i2), z(j+1,i+1)-z(j,i),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6260 nx, ny, nz);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
6261
11450
5eb10763069f substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents: 11431
diff changeset
6262 double d = -std::max (std::max (fabs (nx), fabs (ny)), fabs (nz));
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6263
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6264 nx /= d;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6265 ny /= d;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6266 nz /= d;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6267 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6268 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6269 vertexnormals = n;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6270 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
6271 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6272
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6273 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6274
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6275 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6276 hggroup::properties::update_limits (void) const
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6277 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6278 graphics_object obj = gh_manager::get_object (__myhandle__);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6279
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6280 if (obj)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6281 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6282 obj.update_axis_limits ("xlim");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6283 obj.update_axis_limits ("ylim");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6284 obj.update_axis_limits ("zlim");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6285 obj.update_axis_limits ("clim");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6286 obj.update_axis_limits ("alim");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6287 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6288 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6289
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6290 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6291 hggroup::properties::update_limits (const graphics_handle& h) const
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6292 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6293 graphics_object obj = gh_manager::get_object (__myhandle__);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6294
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6295 if (obj)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6296 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6297 obj.update_axis_limits ("xlim", h);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6298 obj.update_axis_limits ("ylim", h);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6299 obj.update_axis_limits ("zlim", h);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6300 obj.update_axis_limits ("clim", h);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6301 obj.update_axis_limits ("alim", h);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6302 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6303 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6304
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6305 static bool updating_hggroup_limits = false;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6306
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6307 void
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6308 hggroup::update_axis_limits (const std::string& axis_type,
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6309 const graphics_handle& h)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6310 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6311 if (updating_hggroup_limits)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6312 return;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6313
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6314 Matrix kids = Matrix (1, 1, h.value ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6315
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6316 double min_val = octave_Inf;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6317 double max_val = -octave_Inf;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6318 double min_pos = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6319 double max_neg = -octave_Inf;
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6320
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6321 Matrix limits;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6322 double val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6323
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6324 char update_type = 0;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6325
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6326 if (axis_type == "xlim" || axis_type == "xliminclude")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6327 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6328 limits = xproperties.get_xlim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6329 update_type = 'x';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6330 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6331 else if (axis_type == "ylim" || axis_type == "yliminclude")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6332 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6333 limits = xproperties.get_ylim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6334 update_type = 'y';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6335 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6336 else if (axis_type == "zlim" || axis_type == "zliminclude")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6337 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6338 limits = xproperties.get_zlim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6339 update_type = 'z';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6340 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6341 else if (axis_type == "clim" || axis_type == "climinclude")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6342 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6343 limits = xproperties.get_clim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6344 update_type = 'c';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6345 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6346 else if (axis_type == "alim" || axis_type == "aliminclude")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6347 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6348 limits = xproperties.get_alim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6349 update_type = 'a';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6350 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6351
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6352 if (limits.numel() == 4)
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6353 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6354 val = limits(0);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6355 if (! (xisinf (val) || xisnan (val)))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6356 min_val = val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6357 val = limits(1);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6358 if (! (xisinf (val) || xisnan (val)))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6359 max_val = val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6360 val = limits(2);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6361 if (! (xisinf (val) || xisnan (val)))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6362 min_pos = val;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6363 val = limits(3);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6364 if (! (xisinf (val) || xisnan (val)))
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6365 max_neg = val;
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6366 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6367 else
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6368 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6369 limits.resize(4,1);
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6370 limits(0) = min_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6371 limits(1) = max_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6372 limits(2) = min_pos;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6373 limits(3) = max_neg;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6374 }
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6375
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6376 get_children_limits (min_val, max_val, min_pos, max_neg, kids, update_type);
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6377
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6378 unwind_protect frame;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6379 frame.protect_var (updating_hggroup_limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6380
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6381 updating_hggroup_limits = true;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6382
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6383 if (limits(0) != min_val || limits(1) != max_val
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6384 || limits(2) != min_pos || limits(3) != max_neg)
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6385 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6386 limits(0) = min_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6387 limits(1) = max_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6388 limits(2) = min_pos;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6389 limits(3) = max_neg;
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6390
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6391 switch (update_type)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6392 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6393 case 'x':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6394 xproperties.set_xlim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6395 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6396
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6397 case 'y':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6398 xproperties.set_ylim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6399 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6400
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6401 case 'z':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6402 xproperties.set_zlim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6403 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6404
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6405 case 'c':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6406 xproperties.set_clim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6407 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6408
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6409 case 'a':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6410 xproperties.set_alim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6411 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6412
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6413 default:
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6414 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6415 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6416
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6417 base_graphics_object::update_axis_limits (axis_type, h);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6418 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6419 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6420
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6421 void
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6422 hggroup::update_axis_limits (const std::string& axis_type)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6423 {
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6424 if (updating_hggroup_limits)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6425 return;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6426
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6427 Matrix kids = xproperties.get_children ();
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6428
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6429 double min_val = octave_Inf;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6430 double max_val = -octave_Inf;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6431 double min_pos = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6432 double max_neg = -octave_Inf;
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6433
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6434 char update_type = 0;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6435
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
6436 if (axis_type == "xlim" || axis_type == "xliminclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6437 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6438 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'x');
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6439
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6440 update_type = 'x';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6441 }
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
6442 else if (axis_type == "ylim" || axis_type == "yliminclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6443 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6444 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'y');
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6445
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6446 update_type = 'y';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6447 }
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
6448 else if (axis_type == "zlim" || axis_type == "zliminclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6449 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6450 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'z');
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6451
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6452 update_type = 'z';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6453 }
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
6454 else if (axis_type == "clim" || axis_type == "climinclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6455 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6456 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'c');
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6457
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6458 update_type = 'c';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6459 }
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
6460 else if (axis_type == "alim" || axis_type == "aliminclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6461 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6462 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'a');
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6463
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6464 update_type = 'a';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6465 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6466
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6467 unwind_protect frame;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6468 frame.protect_var (updating_hggroup_limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6469
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6470 updating_hggroup_limits = true;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
6471
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6472 Matrix limits (1, 4, 0.0);
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6473
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6474 limits(0) = min_val;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6475 limits(1) = max_val;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6476 limits(2) = min_pos;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6477 limits(3) = max_neg;
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6478
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6479 switch (update_type)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6480 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6481 case 'x':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6482 xproperties.set_xlim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6483 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6484
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6485 case 'y':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6486 xproperties.set_ylim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6487 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6488
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6489 case 'z':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6490 xproperties.set_zlim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6491 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6492
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6493 case 'c':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6494 xproperties.set_clim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6495 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6496
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6497 case 'a':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6498 xproperties.set_alim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6499 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6500
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6501 default:
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6502 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6503 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6504
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6505 base_graphics_object::update_axis_limits (axis_type);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6506 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6507
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6508 // ---------------------------------------------------------------------
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6509
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6510 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
6511 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
6512 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6513 graphics_handle parent = get_parent ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6514 graphics_object parent_obj = gh_manager::get_object (parent);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6515
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6516 return parent_obj.get_default (type () + name);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6517 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6518
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6519 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
6520 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
6521 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6522 graphics_object parent_obj = gh_manager::get_object (0);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6523
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6524 return parent_obj.get_factory_default (type () + name);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6525 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6526
7286
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
6527 // 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
6528 // scalar values for the first argument.
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6529 gh_manager::gh_manager (void)
7286
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
6530 : handle_map (), handle_free_list (),
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
6531 next_handle (-1.0 - (rand () + 1.0) / (RAND_MAX + 2.0)),
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
6532 figure_list (), graphics_lock (), event_queue (), callback_objects ()
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6533 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6534 handle_map[0] = graphics_object (new root_figure ());
7847
40b16e04172a Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7844
diff changeset
6535
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
6536 // Make sure the default graphics toolkit is registered.
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
6537 graphics_toolkit::default_toolkit ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6538 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6539
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6540 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6541 gh_manager::do_make_graphics_handle (const std::string& go_name,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6542 const graphics_handle& p, bool do_createfcn)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6543 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6544 graphics_handle h = get_handle (go_name);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6545
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6546 base_graphics_object *go = 0;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6547
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
6548 go = make_graphics_object_from_type (go_name, h, p);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6549
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6550 if (go)
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
6551 {
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
6552 graphics_object obj (go);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
6553
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
6554 handle_map[h] = obj;
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
6555 if (do_createfcn)
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
6556 go->get_properties ().execute_createfcn ();
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
6557
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
6558 // Notify graphics toolkit.
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
6559 graphics_toolkit toolkit = go->get_toolkit ();
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
6560 if (toolkit)
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
6561 toolkit.initialize (obj);
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
6562 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6563 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6564 error ("gh_manager::do_make_graphics_handle: invalid object type `%s'",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6565 go_name.c_str ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6566
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6567 return h;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6568 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6569
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6570 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6571 gh_manager::do_make_figure_handle (double val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6572 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6573 graphics_handle h = val;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6574
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
6575 base_graphics_object* go = new figure (h, 0);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
6576 graphics_object obj (go);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
6577
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
6578 handle_map[h] = obj;
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
6579
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
6580 // Notify graphics toolkit.
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
6581 graphics_toolkit toolkit = go->get_toolkit ();
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
6582 if (toolkit)
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
6583 toolkit.initialize (obj);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6584
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6585 return h;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6586 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6587
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6588 void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6589 gh_manager::do_push_figure (const graphics_handle& h)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6590 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6591 do_pop_figure (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6592
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6593 figure_list.push_front (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6594 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6595
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6596 void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6597 gh_manager::do_pop_figure (const graphics_handle& h)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6598 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6599 for (figure_list_iterator p = figure_list.begin ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6600 p != figure_list.end ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6601 p++)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6602 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6603 if (*p == h)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6604 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6605 figure_list.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6606 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6607 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6608 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6609 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6610
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6611 class
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6612 callback_event : public base_graphics_event
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6613 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6614 public:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6615 callback_event (const graphics_handle& h, const std::string& name,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6616 const octave_value& data = Matrix ())
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6617 : base_graphics_event (), handle (h), callback_name (name),
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6618 callback_data (data) { }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6619
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6620 void execute (void)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6621 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6622 gh_manager::execute_callback (handle, callback_name, callback_data);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6623 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6624
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6625 private:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6626 callback_event (void)
12174
db1f49eaba6b whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 12164
diff changeset
6627 : base_graphics_event (), handle (),
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
6628 callback_name (), callback_data ()
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
6629 { }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6630
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6631 private:
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6632 graphics_handle handle;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6633 std::string callback_name;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6634 octave_value callback_data;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6635 };
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6636
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6637 class
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6638 function_event : public base_graphics_event
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6639 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6640 public:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6641 function_event (graphics_event::event_fcn fcn, void* data = 0)
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6642 : base_graphics_event (), function (fcn),
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6643 function_data (data) { }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6644
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6645 void execute (void)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6646 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6647 function (function_data);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6648 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6649
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6650 private:
12174
db1f49eaba6b whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 12164
diff changeset
6651
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6652 graphics_event::event_fcn function;
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
6653
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6654 void* function_data;
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
6655
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
6656 // function_event objects must be created with at least a function.
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
6657 function_event (void);
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
6658
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
6659 // No copying!
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
6660
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
6661 function_event (const function_event &);
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
6662
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
6663 function_event & operator = (const function_event &);
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6664 };
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6665
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6666 class
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6667 set_event : public base_graphics_event
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6668 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6669 public:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6670 set_event (const graphics_handle& h, const std::string& name,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6671 const octave_value& value)
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6672 : base_graphics_event (), handle (h), property_name (name),
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6673 property_value (value) { }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6674
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6675 void execute (void)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6676 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6677 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6678
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6679 xset (handle, property_name, property_value);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6680 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6681
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6682 private:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6683 set_event (void)
12174
db1f49eaba6b whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 12164
diff changeset
6684 : base_graphics_event (), handle (), property_name (), property_value ()
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
6685 { }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6686
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6687 private:
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6688 graphics_handle handle;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6689 std::string property_name;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6690 octave_value property_value;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6691 };
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6692
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6693 graphics_event
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6694 graphics_event::create_callback_event (const graphics_handle& h,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6695 const std::string& name,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6696 const octave_value& data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6697 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6698 graphics_event e;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6699
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6700 e.rep = new callback_event (h, name, data);
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6701
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6702 return e;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6703 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6704
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6705 graphics_event
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6706 graphics_event::create_function_event (graphics_event::event_fcn fcn,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6707 void *data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6708 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6709 graphics_event e;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6710
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6711 e.rep = new function_event (fcn, data);
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6712
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6713 return e;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6714 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6715
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6716 graphics_event
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6717 graphics_event::create_set_event (const graphics_handle& h,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6718 const std::string& name,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6719 const octave_value& data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6720 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6721 graphics_event e;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6722
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6723 e.rep = new set_event (h, name, data);
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6724
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6725 return e;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6726 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6727
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6728 static void
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6729 xset_gcbo (const graphics_handle& h)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6730 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6731 graphics_object go = gh_manager::get_object (0);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6732 root_figure::properties& props =
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6733 dynamic_cast<root_figure::properties&> (go.get_properties ());
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6734
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6735 props.set_callbackobject (h.as_octave_value ());
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6736 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6737
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6738 void
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6739 gh_manager::do_restore_gcbo (void)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6740 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6741 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6742
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6743 callback_objects.pop_front ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6744
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6745 xset_gcbo (callback_objects.empty ()
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6746 ? graphics_handle ()
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6747 : callback_objects.front ().get_handle ());
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6748 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6749
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6750 void
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6751 gh_manager::do_execute_callback (const graphics_handle& h,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6752 const octave_value& cb_arg,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6753 const octave_value& data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6754 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6755 octave_value_list args;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6756 octave_function *fcn = 0;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6757
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6758 args(0) = h.as_octave_value ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6759 if (data.is_defined ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6760 args(1) = data;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6761 else
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6762 args(1) = Matrix ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6763
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
6764 unwind_protect_safe frame;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
6765 frame.add_fcn (gh_manager::restore_gcbo);
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6766
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6767 if (true)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6768 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6769 gh_manager::autolock guard;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6770
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6771 callback_objects.push_front (get_object (h));
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6772 xset_gcbo (h);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6773 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6774
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6775 BEGIN_INTERRUPT_WITH_EXCEPTIONS;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6776
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6777 // Copy CB because "function_value" method is non-const.
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6778
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6779 octave_value cb = cb_arg;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6780
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6781 if (cb.is_function_handle ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6782 fcn = cb.function_value ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6783 else if (cb.is_string ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6784 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6785 int status;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6786 std::string s = cb.string_value ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6787
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6788 eval_string (s, false, status);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6789 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6790 else if (cb.is_cell () && cb.length () > 0
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6791 && (cb.rows () == 1 || cb.columns () == 1)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6792 && cb.cell_value ()(0).is_function_handle ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6793 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6794 Cell c = cb.cell_value ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6795
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6796 fcn = c(0).function_value ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6797 if (! error_state)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6798 {
8052
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8021
diff changeset
6799 for (int i = 1; i < c.length () ; i++)
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8021
diff changeset
6800 args(1+i) = c(i);
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6801 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6802 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6803 else
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6804 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6805 std::string nm = cb.class_name ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6806 error ("trying to execute non-executable object (class = %s)",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6807 nm.c_str ());
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6808 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6809
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6810 if (fcn && ! error_state)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6811 feval (fcn, args);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6812
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6813 END_INTERRUPT_WITH_EXCEPTIONS;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6814 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6815
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6816 void
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6817 gh_manager::do_post_event (const graphics_event& e)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6818 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6819 event_queue.push_back (e);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6820
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6821 command_editor::add_event_hook (gh_manager::process_events);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6822 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6823
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6824 void
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6825 gh_manager::do_post_callback (const graphics_handle& h, const std::string name,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6826 const octave_value& data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6827 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6828 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6829
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6830 graphics_object go = get_object (h);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6831
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6832 if (go.valid_object ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6833 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6834 if (callback_objects.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6835 do_post_event (graphics_event::create_callback_event (h, name, data));
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6836 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6837 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6838 const graphics_object& current = callback_objects.front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6839
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6840 if (current.get_properties ().is_interruptible ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6841 do_post_event (graphics_event::create_callback_event (h, name, data));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6842 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6843 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6844 caseless_str busy_action (go.get_properties ().get_busyaction ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6845
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6846 if (busy_action.compare ("queue"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6847 do_post_event (graphics_event::create_callback_event (h, name, data));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6848 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6849 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6850 caseless_str cname (name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6851
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6852 if (cname.compare ("deletefcn")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6853 || cname.compare ("createfcn")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6854 || (go.isa ("figure")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6855 && (cname.compare ("closerequestfcn")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6856 || cname.compare ("resizefcn"))))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6857 do_post_event (graphics_event::create_callback_event (h, name, data));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6858 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6859 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6860 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6861 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6862 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6863
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6864 void
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6865 gh_manager::do_post_function (graphics_event::event_fcn fcn, void* fcn_data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6866 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6867 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6868
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6869 do_post_event (graphics_event::create_function_event (fcn, fcn_data));
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6870 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6871
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6872 void
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6873 gh_manager::do_post_set (const graphics_handle& h, const std::string name,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6874 const octave_value& value)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6875 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6876 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6877
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6878 do_post_event (graphics_event::create_set_event (h, name, value));
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6879 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6880
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6881 int
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6882 gh_manager::do_process_events (bool force)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6883 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6884 graphics_event e;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6885
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6886 do
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6887 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
6888 e = graphics_event ();
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6889
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6890 gh_manager::lock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6891
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6892 if (! event_queue.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6893 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6894 if (callback_objects.empty () || force)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6895 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6896 e = event_queue.front ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6897
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6898 event_queue.pop_front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6899 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6900 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6901 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6902 const graphics_object& go = callback_objects.front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6903
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6904 if (go.get_properties ().is_interruptible ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6905 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6906 e = event_queue.front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6907
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6908 event_queue.pop_front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6909 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6910 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6911 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6912
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6913 gh_manager::unlock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6914
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6915 if (e.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6916 e.execute ();
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6917 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6918 while (e.ok ());
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6919
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6920 gh_manager::lock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6921
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6922 if (event_queue.empty ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6923 command_editor::remove_event_hook (gh_manager::process_events);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6924
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6925 gh_manager::unlock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6926
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6927 return 0;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6928 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6929
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6930 property_list::plist_map_type
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6931 root_figure::init_factory_properties (void)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6932 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6933 property_list::plist_map_type plist_map;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6934
6844
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
6935 plist_map["figure"] = figure::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
6936 plist_map["axes"] = axes::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
6937 plist_map["line"] = line::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
6938 plist_map["text"] = text::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
6939 plist_map["image"] = image::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
6940 plist_map["patch"] = patch::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
6941 plist_map["surface"] = surface::properties::factory_defaults ();
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
6942 plist_map["hggroup"] = hggroup::properties::factory_defaults ();
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
6943 plist_map["uimenu"] = uimenu::properties::factory_defaults ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6944
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6945 return plist_map;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6946 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6947
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6948 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6949
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6950 DEFUN (ishandle, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6951 "-*- texinfo -*-\n\
6678
49724abe1236 [project @ 2007-05-31 19:44:45 by jwe]
jwe
parents: 6595
diff changeset
6952 @deftypefn {Built-in Function} {} ishandle (@var{h})\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6953 Return true if @var{h} is a graphics handle and false otherwise.\n\
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 11385
diff changeset
6954 @var{h} may also be a matrix of handles in which case a logical\n\
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 11385
diff changeset
6955 array is returned that is true where the elements of @var{h} are\n\
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 11385
diff changeset
6956 graphics handles and false where they are not.\n\
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 11385
diff changeset
6957 @seealso{isfigure}\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6958 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6959 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6960 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
6961
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6962 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6963
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6964 if (args.length () == 1)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6965 retval = is_handle (args(0));
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6966 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6967 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6968
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6969 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6970 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6971
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6972 DEFUN (reset, args, ,
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6973 "-*- texinfo -*-\n\
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6974 @deftypefn {Built-in Function} {} reset (@var{h}, @var{property})\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
6975 Remove any defaults set for the handle @var{h}. The default figure\n\
12189
9558ca33648d Add functions reset, whitebg to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12174
diff changeset
6976 properties of \"position\", \"units\", \"windowstyle\" and\n\
9558ca33648d Add functions reset, whitebg to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12174
diff changeset
6977 \"paperunits\" and the default axes properties of \"position\" and \"units\"\n\
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6978 are not reset.\n\
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6979 @end deftypefn")
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6980 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6981 int nargin = args.length ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6982
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6983 if (nargin != 1)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6984 print_usage ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6985 else
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6986 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6987 // get vector of graphics handles
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6988 ColumnVector hcv (args(0).vector_value ());
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6989
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6990 if (! error_state)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6991 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6992 // loop over graphics objects
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6993 for (octave_idx_type n = 0; n < hcv.length (); n++)
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6994 gh_manager::get_object (hcv(n)).reset_default_properties ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6995 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6996 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6997
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6998 return octave_value ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
6999 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
7000
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
7001 DEFUN (set, args, nargout,
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7002 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
7003 @deftypefn {Built-in Function} {} set (@var{h}, @var{property}, @var{value}, @dots{})\n\
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7004 @deftypefnx {Built-in Function} {} set (@var{h}, @var{properties}, @var{values})\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7005 @deftypefnx {Built-in Function} {} set (@var{h}, @var{pv})\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7006 Set named property values for the graphics handle (or vector of graphics\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7007 handles) @var{h}.\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7008 There are three ways how to give the property names and values:\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7009 \n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7010 @itemize\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7011 @item as a comma separated list of @var{property}, @var{value} pairs\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7012 \n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7013 Here, each @var{property} is a string containing the property name, each\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7014 @var{value} is a value of the appropriate type for the property.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
7015 \n\
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7016 @item as a cell array of strings @var{properties} containing property names\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7017 and a cell array @var{values} containing property values.\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7018 \n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7019 In this case, the number of columns of @var{values} must match the number of\n\
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
7020 elements in @var{properties}. The first column of @var{values} contains\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
7021 values for the first entry in @var{properties}, etc. The number of rows of\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
7022 @var{values} must be 1 or match the number of elements of @var{h}. In the\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
7023 first case, each handle in @var{h} will be assigned the same values. In the\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
7024 latter case, the first handle in @var{h} will be assigned the values from\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
7025 the first row of @var{values} and so on.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
7026 \n\
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7027 @item as a structure array @var{pv}\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7028 \n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7029 Here, the field names of @var{pv} represent the property names, and the field\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7030 values give the property values. In contrast to the previous case, all\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7031 elements of @var{pv} will be set in all handles in @var{h} independent of\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7032 the dimensions of @var{pv}.\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7033 @end itemize\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7034 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7035 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7036 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7037
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7038 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7039
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7040 int nargin = args.length ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7041
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7042 if (nargin > 0)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7043 {
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7044 // get vector of graphics handles
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7045 ColumnVector hcv (args(0).vector_value ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7046
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7047 if (! error_state)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7048 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7049 bool request_drawnow = false;
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
7050
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7051 // loop over graphics objects
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7052 for (octave_idx_type n = 0; n < hcv.length (); n++)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7053 {
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7054 graphics_object obj = gh_manager::get_object (hcv(n));
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7055
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7056 if (obj)
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7057 {
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7058 if (nargin == 3 && args(1).is_cellstr ()
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7059 && args(2).is_cell ())
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7060 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7061 if (args(2).cell_value ().rows () == 1)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7062 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7063 obj.set (args(1).cellstr_value (),
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7064 args(2).cell_value (), 0);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7065 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7066 else if (hcv.length () == args(2).cell_value ().rows ())
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7067 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7068 obj.set (args(1).cellstr_value (),
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7069 args(2).cell_value (), n);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7070 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7071 else
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7072 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7073 error("set: number of graphics handles must match number of value rows (%d != %d)",
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7074 hcv.length (), args(2).cell_value ().rows ());
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7075 break;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7076
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7077 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7078 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7079 else if (nargin == 2 && args(1).is_map ())
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7080 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7081 obj.set (args(1).map_value ());
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7082 }
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
7083 else if (nargin == 1)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
7084 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
7085 if (nargout != 0)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
7086 retval = obj.values_as_struct ();
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
7087 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
7088 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
7089 std::string s = obj.values_as_string ();
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
7090 if (! error_state)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
7091 octave_stdout << s;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
7092 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
7093 }
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7094 else
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7095 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7096 obj.set (args.splice (0, 1));
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7097 request_drawnow = true;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7098 }
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7099 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7100 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7101 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7102 error ("set: invalid handle (= %g)", hcv(n));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7103 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7104 }
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7105
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7106 if (error_state)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7107 break;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7108
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7109 request_drawnow = true;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
7110 }
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
7111
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7112 if (! error_state && request_drawnow)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7113 Vdrawnow_requested = true;
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7114 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7115 else
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7116 error ("set: expecting graphics handle as first argument");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7117 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7118 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7119 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7120
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7121 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7122 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7123
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7124 DEFUN (get, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7125 "-*- texinfo -*-\n\
6678
49724abe1236 [project @ 2007-05-31 19:44:45 by jwe]
jwe
parents: 6595
diff changeset
7126 @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
7127 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
7128 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
7129 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
7130 values or lists respectively.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7131 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7132 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7133 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7134
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7135 octave_value retval;
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
7136
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
7137 Cell vals;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7138
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7139 int nargin = args.length ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7140
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7141 if (nargin == 1 || nargin == 2)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7142 {
12678
69cd5ebe5fb5 Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents: 12587
diff changeset
7143 if (args(0).is_empty())
69cd5ebe5fb5 Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents: 12587
diff changeset
7144 {
69cd5ebe5fb5 Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents: 12587
diff changeset
7145 retval = Matrix ();
69cd5ebe5fb5 Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents: 12587
diff changeset
7146 return retval;
69cd5ebe5fb5 Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents: 12587
diff changeset
7147 }
69cd5ebe5fb5 Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents: 12587
diff changeset
7148
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7149 ColumnVector hcv (args(0).vector_value ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7150
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7151 if (! error_state)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7152 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7153 octave_idx_type len = hcv.length ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7154
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7155 vals.resize (dim_vector (len, 1));
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
7156
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
7157 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
7158 {
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7159 graphics_object obj = gh_manager::get_object (hcv(n));
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7160
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7161 if (obj)
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7162 {
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7163 if (nargin == 1)
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
7164 vals(n) = obj.get ();
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7165 else
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7166 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
7167 caseless_str property = args(1).string_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7168
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7169 if (! error_state)
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
7170 vals(n) = obj.get (property);
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7171 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7172 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7173 error ("get: expecting property name as second argument");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7174 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7175 }
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7176 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7177 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7178 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7179 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7180 error ("get: invalid handle (= %g)", hcv(n));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7181 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7182 }
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7183 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7184 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7185 else
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7186 error ("get: expecting graphics handle as first argument");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7187 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7188 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7189 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7190
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
7191 if (! error_state)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7192 {
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
7193 octave_idx_type len = vals.numel ();
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
7194
11456
fbdb95640852 get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents: 11455
diff changeset
7195 if (len == 0)
fbdb95640852 get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents: 11455
diff changeset
7196 retval = Matrix ();
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
7197 else if (len == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7198 retval = vals(0);
11456
fbdb95640852 get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents: 11455
diff changeset
7199 else
fbdb95640852 get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents: 11455
diff changeset
7200 retval = vals;
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7201 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
7202
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7203 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7204 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7205
11456
fbdb95640852 get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents: 11455
diff changeset
7206 /*
fbdb95640852 get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents: 11455
diff changeset
7207 %!assert (get (findobj (0, 'Tag', 'nonexistenttag'), 'nonexistentproperty'), [])
fbdb95640852 get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents: 11455
diff changeset
7208 */
fbdb95640852 get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents: 11455
diff changeset
7209
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8740
diff changeset
7210 // Return all properties from the graphics handle @var{h}.
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8740
diff changeset
7211 // If @var{h} is a vector, return a cell array including the
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8740
diff changeset
7212 // property values or lists respectively.
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8740
diff changeset
7213
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7214 DEFUN (__get__, args, ,
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7215 "-*- texinfo -*-\n\
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7216 @deftypefn {Built-in Function} {} __get__ (@var{h})\n\
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8740
diff changeset
7217 Undocumented internal function.\n\
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7218 @end deftypefn")
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7219 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7220 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7221
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7222 octave_value retval;
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
7223
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
7224 Cell vals;
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7225
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7226 int nargin = args.length ();
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7227
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7228 if (nargin == 1)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7229 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7230 ColumnVector hcv (args(0).vector_value ());
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7231
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7232 if (! error_state)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7233 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7234 octave_idx_type len = hcv.length ();
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7235
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
7236 vals.resize (dim_vector (len, 1));
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7237
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7238 for (octave_idx_type n = 0; n < len; n++)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7239 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7240 graphics_object obj = gh_manager::get_object (hcv(n));
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7241
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7242 if (obj)
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
7243 vals(n) = obj.get (true);
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7244 else
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7245 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7246 error ("get: invalid handle (= %g)", hcv(n));
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7247 break;
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7248 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7249 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7250 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7251 else
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7252 error ("get: expecting graphics handle as first argument");
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7253 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7254 else
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7255 print_usage ();
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7256
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7257 if (! error_state)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7258 {
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
7259 octave_idx_type len = vals.numel ();
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7260
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7261 if (len > 1)
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
7262 retval = vals;
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7263 else if (len == 1)
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
7264 retval = vals(0);
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7265 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7266
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7267 return retval;
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7268 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
7269
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7270 static octave_value
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7271 make_graphics_object (const std::string& go_name,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7272 const octave_value_list& args)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7273 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7274 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7275
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7276 double val = octave_NaN;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7277
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7278 octave_value_list xargs = args.splice (0, 1);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7279
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7280 caseless_str p ("parent");
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7281
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7282 for (int i = 0; i < xargs.length (); i++)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7283 if (xargs(i).is_string ()
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7284 && p.compare (xargs(i).string_value ()))
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7285 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7286 if (i < (xargs.length () - 1))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7287 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7288 val = xargs(i+1).double_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7289
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7290 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7291 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7292 xargs = xargs.splice (i, 2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7293 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7294 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7295 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7296 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7297 error ("__go_%s__: missing value for parent property",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7298 go_name.c_str ());
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7299 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7300
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7301 if (! error_state && xisnan (val))
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7302 val = args(0).double_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7303
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7304 if (! error_state)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7305 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7306 graphics_handle parent = gh_manager::lookup (val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7307
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
7308 if (parent.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7309 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7310 graphics_handle h
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7311 = gh_manager::make_graphics_handle (go_name, parent, false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7312
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7313 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7314 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7315 adopt (parent, h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7316
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7317 xset (h, xargs);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7318 xcreatefcn (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7319
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7320 retval = h.value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7321
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7322 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7323 Vdrawnow_requested = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7324 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7325 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7326 error ("__go%s__: unable to create graphics handle",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7327 go_name.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7328 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7329 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7330 error ("__go_%s__: invalid parent", go_name.c_str ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7331 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7332 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7333 error ("__go_%s__: invalid parent", go_name.c_str ());
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7334
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7335 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7336 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7337
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7338 DEFUN (__go_figure__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7339 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7340 @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
7341 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7342 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7343 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7344 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7345
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7346 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7347
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7348 if (args.length () > 0)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7349 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7350 double val = args(0).double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7351
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7352 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7353 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7354 if (is_figure (val))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7355 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7356 graphics_handle h = gh_manager::lookup (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7357
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7358 xset (h, args.splice (0, 1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7359
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7360 retval = h.value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7361 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7362 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7363 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7364 graphics_handle h = octave_NaN;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7365
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7366 if (xisnan (val))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7367 h = gh_manager::make_graphics_handle ("figure", 0, false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7368 else if (val > 0 && D_NINT (val) == val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7369 h = gh_manager::make_figure_handle (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7370 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7371 error ("__go_figure__: invalid figure number");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7372
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7373 if (! error_state && h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7374 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7375 adopt (0, h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7376
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7377 xset (h, args.splice (0, 1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7378 xcreatefcn (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7379
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7380 retval = h.value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7381 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7382 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7383 error ("__go_figure__: failed to create figure handle");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7384 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7385 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7386 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7387 error ("__go_figure__: expecting figure number to be double value");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7388 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7389 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7390 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7391
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7392 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7393 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7394
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7395 #define GO_BODY(TYPE) \
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7396 gh_manager::autolock guard; \
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7397 \
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7398 octave_value retval; \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7399 \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7400 if (args.length () > 0) \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7401 retval = make_graphics_object (#TYPE, args); \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7402 else \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7403 print_usage (); \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7404 \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7405 return retval
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7406
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7407 int
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7408 calc_dimensions (const graphics_object& go)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7409 {
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7410
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7411 int nd = 2;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7412
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7413 if (go.isa ("surface"))
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7414 nd = 3;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7415
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7416 if ((go.isa ("line") || go.isa ("patch")) && ! go.get("zdata").is_empty ())
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7417 nd = 3;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7418
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7419 Matrix kids = go.get_properties().get_children ();
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7420
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7421 for (octave_idx_type i = 0; i < kids.length (); i++)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7422 {
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7423 graphics_handle hnd = gh_manager::lookup (kids(i));
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7424
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7425 if (hnd.ok ())
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7426 {
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7427 const graphics_object& kid = gh_manager::get_object(hnd);
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7428
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7429 if (kid.valid_object())
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7430 nd = calc_dimensions (kid);
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7431
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7432 if (nd == 3)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7433 break;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7434 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7435 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7436
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7437 return nd;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7438 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7439
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7440 DEFUN (__calc_dimensions__, args, ,
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7441 "-*- texinfo -*-\n\
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7442 @deftypefn {Built-in Function} {} __calc_dimensions__ (@var{axes})\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
7443 Internal function. Determine the number of dimensions in a graphics\n\
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7444 object, whether 2 or 3.\n\
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7445 @end deftypefn")
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7446 {
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7447 gh_manager::autolock guard;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7448
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7449 octave_value retval;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7450
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7451 int nargin = args.length ();
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7452
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7453 if (nargin == 1)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7454 {
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7455 double h = args(0).double_value ();
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7456
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7457 if (! error_state)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7458 retval = calc_dimensions (gh_manager::get_object (h));
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7459 else
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7460 error ("__calc_dimensions__: expecting graphics handle as only argument");
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7461 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7462 else
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7463 print_usage ();
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7464
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7465 return retval;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7466 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7467
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7468 DEFUN (__go_axes__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7469 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7470 @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
7471 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7472 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7473 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7474 GO_BODY (axes);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7475 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7476
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7477 DEFUN (__go_line__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7478 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7479 @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
7480 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7481 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7482 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7483 GO_BODY (line);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7484 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7485
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7486 DEFUN (__go_text__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7487 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7488 @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
7489 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7490 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7491 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7492 GO_BODY (text);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7493 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7494
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7495 DEFUN (__go_image__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7496 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7497 @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
7498 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7499 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7500 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7501 GO_BODY (image);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7502 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7503
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7504 DEFUN (__go_surface__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7505 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7506 @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
7507 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7508 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7509 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7510 GO_BODY (surface);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7511 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7512
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
7513 DEFUN (__go_patch__, args, ,
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
7514 "-*- texinfo -*-\n\
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
7515 @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
7516 Undocumented internal function.\n\
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
7517 @end deftypefn")
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
7518 {
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
7519 GO_BODY (patch);
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
7520 }
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
7521
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7522 DEFUN (__go_hggroup__, args, ,
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7523 "-*- texinfo -*-\n\
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7524 @deftypefn {Built-in Function} {} __go_hggroup__ (@var{parent})\n\
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7525 Undocumented internal function.\n\
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7526 @end deftypefn")
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7527 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7528 GO_BODY (hggroup);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7529 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
7530
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
7531 DEFUN (__go_uimenu__, args, ,
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
7532 "-*- texinfo -*-\n\
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
7533 @deftypefn {Built-in Function} {} __go_uimenu__ (@var{parent})\n\
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
7534 Undocumented internal function.\n\
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
7535 @end deftypefn")
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
7536 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
7537 GO_BODY (uimenu);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
7538 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
7539
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7540 DEFUN (__go_delete__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7541 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7542 @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
7543 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7544 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7545 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7546 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7547
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7548 octave_value_list retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7549
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7550 if (args.length () == 1)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7551 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7552 graphics_handle h = octave_NaN;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7553
8196
32e9e8103390 Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents: 8183
diff changeset
7554 const NDArray vals = args (0).array_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7555
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7556 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7557 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7558 // Check is all the handles to delete are valid first
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7559 // as callbacks might delete one of the handles we
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7560 // later want to delete
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7561 for (octave_idx_type i = 0; i < vals.numel (); i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7562 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7563 h = gh_manager::lookup (vals.elem (i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7564
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7565 if (! h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7566 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7567 error ("delete: invalid graphics object (= %g)",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7568 vals.elem (i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7569 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7570 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7571 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7572
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7573 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7574 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7575 for (octave_idx_type i = 0; i < vals.numel (); i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7576 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7577 h = gh_manager::lookup (vals.elem (i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7578
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7579 if (h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7580 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7581 graphics_object obj = gh_manager::get_object (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7582
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7583 // Don't do recursive deleting, due to callbacks
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7584 if (! obj.get_properties ().is_beingdeleted ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7585 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7586 graphics_handle parent_h = obj.get_parent ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7587
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7588 graphics_object parent_obj =
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7589 gh_manager::get_object (parent_h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7590
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7591 // NOTE: free the handle before removing it from its
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7592 // parent's children, such that the object's
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7593 // state is correct when the deletefcn callback
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7594 // is executed
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7595
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7596 gh_manager::free (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7597
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7598 // A callback function might have already deleted
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7599 // the parent
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7600 if (parent_obj.valid_object ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7601 parent_obj.remove_child (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7602
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7603 Vdrawnow_requested = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7604 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7605 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7606 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7607 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7608 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7609 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7610 error ("delete: invalid graphics object");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7611 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7612 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7613 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7614
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7615 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7616 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7617
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7618 DEFUN (__go_axes_init__, args, ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7619 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7620 @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
7621 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7622 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7623 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7624 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7625
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7626 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7627
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7628 int nargin = args.length ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7629
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7630 std::string mode = "";
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7631
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7632 if (nargin == 2)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7633 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7634 mode = args(1).string_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7635
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7636 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7637 return retval;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7638 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7639
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7640 if (nargin == 1 || nargin == 2)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7641 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7642 graphics_handle h = octave_NaN;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7643
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7644 double val = args(0).double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7645
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7646 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7647 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7648 h = gh_manager::lookup (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7649
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7650 if (h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7651 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7652 graphics_object obj = gh_manager::get_object (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7653
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7654 obj.set_defaults (mode);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7655
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7656 h = gh_manager::lookup (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7657 if (! h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7658 error ("__go_axes_init__: axis deleted during initialization (= %g)", val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7659 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7660 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7661 error ("__go_axes_init__: invalid graphics object (= %g)", val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7662 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7663 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7664 error ("__go_axes_init__: invalid graphics object");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7665 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7666 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7667 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7668
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7669 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7670 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7671
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7672 DEFUN (__go_handles__, , ,
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7673 "-*- texinfo -*-\n\
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7674 @deftypefn {Built-in Function} {} __go_handles__ ()\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
7675 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7676 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7677 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7678 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7679
6425
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
7680 return octave_value (gh_manager::handle_list ());
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
7681 }
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
7682
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
7683 DEFUN (__go_figure_handles__, , ,
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
7684 "-*- texinfo -*-\n\
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
7685 @deftypefn {Built-in Function} {} __go_figure_handles__ ()\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
7686 Undocumented internal function.\n\
6425
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
7687 @end deftypefn")
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
7688 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7689 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7690
6425
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
7691 return octave_value (gh_manager::figure_handle_list ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7692 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7693
7967
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7694 DEFUN (__go_execute_callback__, args, ,
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7695 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
7696 @deftypefn {Built-in Function} {} __go_execute_callback__ (@var{h}, @var{name})\n\
7967
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7697 @deftypefnx {Built-in Function} {} __go_execute_callback__ (@var{h}, @var{name}, @var{param})\n\
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7698 Undocumented internal function.\n\
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7699 @end deftypefn")
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7700 {
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7701 octave_value retval;
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7702
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7703 int nargin = args.length ();
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7704
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7705 if (nargin == 2 || nargin == 3)
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7706 {
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7707 double val = args(0).double_value ();
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7708
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7709 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7710 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7711 graphics_handle h = gh_manager::lookup (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7712
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7713 if (h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7714 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7715 std::string name = args(1).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7716
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7717 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7718 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7719 if (nargin == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7720 gh_manager::execute_callback (h, name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7721 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7722 gh_manager::execute_callback (h, name, args(2));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7723 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7724 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7725 error ("__go_execute_callback__: invalid callback name");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7726 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7727 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7728 error ("__go_execute_callback__: invalid graphics object (= %g)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7729 val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7730 }
7967
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7731 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7732 error ("__go_execute_callback__: invalid graphics object");
7967
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7733 }
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7734 else
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7735 print_usage ();
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7736
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7737 return retval;
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7738 }
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
7739
11076
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7740 DEFUN (__image_pixel_size__, args, ,
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7741 "-*- texinfo -*-\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
7742 @deftypefn {Built-in Function} {@var{px}, @var{py}} __image_pixel_size__ (@var{h})\n\
11076
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7743 Internal function: returns the pixel size of the image in normalized units.\n\
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7744 @end deftypefn")
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7745 {
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7746 octave_value retval;
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7747
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7748 int nargin = args.length ();
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7749
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7750 if (nargin == 1)
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7751 {
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7752 double h = args(0).double_value ();
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7753
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7754 if (! error_state)
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7755 {
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7756 graphics_object fobj = gh_manager::get_object (h);
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7757 if (fobj && fobj.isa ("image"))
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7758 {
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7759 image::properties& ip =
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7760 dynamic_cast<image::properties&> (fobj.get_properties ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7761
11076
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7762 Matrix dp = Matrix (1, 2, 0);
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7763 dp(0, 0) = ip.pixel_xsize ();
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7764 dp(0, 1) = ip.pixel_ysize ();
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7765 retval = dp;
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7766 }
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7767 else
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7768 error ("__image_pixel_size__: object is not an image");
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7769 }
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7770 else
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7771 error ("__image_pixel_size__: argument is not a handle");
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7772 }
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7773 else
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7774 print_usage ();
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7775
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7776 return retval;
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7777 }
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
7778
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
7779 DEFUN (available_graphics_toolkits, , ,
7835
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
7780 "-*- texinfo -*-\n\
12215
4ae2a74ed04c Add fltk_gui_mode, fltk_mouse_wheel_zoom to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12189
diff changeset
7781 @deftypefn {Built-in Function} {} available_graphics_toolkits ()\n\
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
7782 Return a cell array of registered graphics toolkits.\n\
7835
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
7783 @end deftypefn")
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
7784 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7785 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7786
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
7787 return octave_value (graphics_toolkit::available_toolkits_list ());
7835
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
7788 }
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
7789
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
7790 DEFUN (drawnow, args, ,
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
7791 "-*- texinfo -*-\n\
9316
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
7792 @deftypefn {Built-in Function} {} drawnow ()\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
7793 @deftypefnx {Built-in Function} {} drawnow (\"expose\")\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
7794 @deftypefnx {Built-in Function} {} drawnow (@var{term}, @var{file}, @var{mono}, @var{debug_file})\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
7795 Update figure windows and their children. The event queue is flushed and\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
7796 any callbacks generated are executed. With the optional argument\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
7797 @code{\"expose\"}, only graphic objects are updated and no other events or\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
7798 callbacks are processed.\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
7799 The third calling form of @code{drawnow} is for debugging and is\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
7800 undocumented.\n\
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
7801 @end deftypefn")
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
7802 {
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
7803 static int drawnow_executing = 0;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
7804 static bool __go_close_all_registered__ = false;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
7805
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
7806 octave_value retval;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
7807
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7808 gh_manager::lock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7809
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
7810 unwind_protect frame;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
7811 frame.protect_var (Vdrawnow_requested, false);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
7812
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
7813 frame.protect_var (drawnow_executing);
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
7814
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
7815 if (++drawnow_executing <= 1)
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
7816 {
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
7817 if (! __go_close_all_registered__)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7818 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7819 octave_add_atexit_function ("__go_close_all__");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7820
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7821 __go_close_all_registered__ = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7822 }
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
7823
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7824 if (args.length () == 0 || args.length () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7825 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7826 Matrix hlist = gh_manager::figure_handle_list ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7827
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7828 for (int i = 0; ! error_state && i < hlist.length (); i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7829 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7830 graphics_handle h = gh_manager::lookup (hlist(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7831
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7832 if (h.ok () && h != 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7833 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7834 graphics_object go = gh_manager::get_object (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7835 figure::properties& fprops = dynamic_cast <figure::properties&> (go.get_properties ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7836
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7837 if (fprops.is_modified ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7838 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7839 if (fprops.is_visible ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7840 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7841 gh_manager::unlock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7842
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
7843 fprops.get_toolkit ().redraw_figure (go);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7844
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7845 gh_manager::lock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7846 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7847
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7848 fprops.set_modified (false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7849 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7850 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7851 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7852
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7853 bool do_events = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7854
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7855 if (args.length () == 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7856 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7857 caseless_str val (args(0).string_value ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7858
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7859 if (! error_state && val.compare ("expose"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7860 do_events = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7861 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7862 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7863 error ("drawnow: invalid argument, expected `expose' as argument");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7864 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7865 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7866 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7867
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7868 if (do_events)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7869 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7870 gh_manager::unlock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7871
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7872 gh_manager::process_events ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7873
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7874 gh_manager::lock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7875 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7876 }
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
7877 else if (args.length () >= 2 && args.length () <= 4)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7878 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7879 std::string term, file, debug_file;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7880 bool mono;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7881
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7882 term = args(0).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7883
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7884 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7885 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7886 file = args(1).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7887
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7888 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7889 {
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7890 size_t pos = file.find_first_not_of ("|");
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7891 if (pos > 0)
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7892 file = file.substr (pos);
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7893 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7894 {
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7895 pos = file.find_last_of (file_ops::dir_sep_chars ());
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7896
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7897 if (pos != std::string::npos)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7898 {
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7899 std::string dirname = file.substr (0, pos+1);
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7900
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7901 file_stat fs (dirname);
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7902
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7903 if (! (fs && fs.is_dir ()))
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7904 {
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7905 error ("drawnow: nonexistent directory `%s'",
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7906 dirname.c_str ());
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7907
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7908 return retval;
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
7909 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7910 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7911 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7912
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7913 mono = (args.length () >= 3 ? args(2).bool_value () : false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7914
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7915 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7916 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7917 debug_file = (args.length () > 3 ? args(3).string_value ()
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7918 : "");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7919
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7920 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7921 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7922 graphics_handle h = gcf ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7923
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7924 if (h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7925 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7926 graphics_object go = gh_manager::get_object (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7927
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7928 gh_manager::unlock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7929
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
7930 go.get_toolkit ()
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7931 .print_figure (go, term, file, mono, debug_file);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7932
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7933 gh_manager::lock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7934 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7935 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7936 error ("drawnow: nothing to draw");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7937 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7938 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12467
diff changeset
7939 error ("drawnow: invalid DEBUG_FILE, expected a string value");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7940 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7941 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12467
diff changeset
7942 error ("drawnow: invalid colormode MONO, expected a boolean value");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7943 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7944 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12467
diff changeset
7945 error ("drawnow: invalid FILE, expected a string value");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7946 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7947 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12467
diff changeset
7948 error ("drawnow: invalid terminal TERM, expected a string value");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7949 }
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
7950 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7951 print_usage ();
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
7952 }
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
7953
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7954 gh_manager::unlock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7955
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
7956 return retval;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
7957 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
7958
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
7959 DEFUN (addlistener, args, ,
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7960 "-*- texinfo -*-\n\
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
7961 @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
7962 Register @var{fcn} as listener for the property @var{prop} of the graphics\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
7963 object @var{h}. Property listeners are executed (in order of registration)\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
7964 when the property is set. The new value is already available when the\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7965 listeners are executed.\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7966 \n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7967 @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
7968 \n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7969 @var{fcn} can be a function handle, a string or a cell array whose first\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
7970 element is a function handle. If @var{fcn} is a function handle, the\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7971 corresponding function should accept at least 2 arguments, that will be\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
7972 set to the object handle and the empty matrix respectively. If @var{fcn}\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
7973 is a string, it must be any valid octave expression. If @var{fcn} is a cell\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7974 array, the first element must be a function handle with the same signature\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
7975 as described above. The next elements of the cell array are passed\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7976 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
7977 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
7978 Example:\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
7979 \n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7980 @example\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
7981 @group\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7982 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
7983 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
7984 endfunction\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7985 \n\
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
7986 addlistener (gcf, \"position\", @{@@my_listener, \"my string\"@})\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
7987 @end group\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7988 @end example\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7989 \n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7990 @end deftypefn")
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7991 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7992 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
7993
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7994 octave_value retval;
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7995
12506
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
7996 if (args.length () >= 3 && args.length () <= 4)
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7997 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7998 double h = args(0).double_value ();
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
7999
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
8000 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8001 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8002 std::string pname = args(1).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8003
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8004 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8005 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8006 graphics_handle gh = gh_manager::lookup (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8007
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8008 if (gh.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8009 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8010 graphics_object go = gh_manager::get_object (gh);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8011
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8012 go.add_property_listener (pname, args(2), POSTSET);
12506
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
8013
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
8014 if (args.length () == 4)
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
8015 {
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
8016 caseless_str persistent = args(3).string_value ();
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
8017 if (persistent.compare ("persistent"))
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
8018 go.add_property_listener (pname, args(2), PERSISTENT);
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
8019 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8020 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8021 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8022 error ("addlistener: invalid graphics object (= %g)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8023 h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8024 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8025 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8026 error ("addlistener: invalid property name, expected a string value");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8027 }
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
8028 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8029 error ("addlistener: invalid handle");
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
8030 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
8031 else
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
8032 print_usage ();
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
8033
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
8034 return retval;
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
8035 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
8036
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8037 DEFUN (dellistener, args, ,
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8038 "-*- texinfo -*-\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8039 @deftypefn {Built-in Function} {} dellistener (@var{h}, @var{prop}, @var{fcn})\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8040 Remove the registration of @var{fcn} as a listener for the property\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8041 @var{prop} of the graphics object @var{h}. The function @var{fcn} must\n\
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8042 be the same variable (not just the same value), as was passed to the\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8043 original call to @code{addlistener}.\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8044 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8045 If @var{fcn} is not defined then all listener functions of @var{prop}\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8046 are removed.\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8047 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8048 Example:\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8049 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8050 @example\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
8051 @group\n\
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8052 function my_listener (h, dummy, p1)\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8053 fprintf (\"my_listener called with p1=%s\\n\", p1);\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8054 endfunction\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8055 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8056 c = @{@@my_listener, \"my string\"@};\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8057 addlistener (gcf, \"position\", c);\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8058 dellistener (gcf, \"position\", c);\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
8059 @end group\n\
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8060 @end example\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8061 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8062 @end deftypefn")
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8063 {
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8064 gh_manager::autolock guard;
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8065
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8066 octave_value retval;
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8067
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8068 if (args.length () == 3 || args.length () == 2)
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8069 {
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8070 double h = args(0).double_value ();
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8071
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8072 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8073 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8074 std::string pname = args(1).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8075
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8076 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8077 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8078 graphics_handle gh = gh_manager::lookup (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8079
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8080 if (gh.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8081 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8082 graphics_object go = gh_manager::get_object (gh);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8083
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8084 if (args.length () == 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8085 go.delete_property_listener (pname, octave_value (), POSTSET);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8086 else
12506
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
8087 {
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
8088 caseless_str persistent = args(2).string_value ();
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
8089 if (persistent.compare ("persistent"))
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
8090 {
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
8091 go.delete_property_listener (pname, octave_value (), PERSISTENT);
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
8092 go.delete_property_listener (pname, octave_value (), POSTSET);
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
8093 }
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
8094 else
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
8095 go.delete_property_listener (pname, args(2), POSTSET);
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
8096 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8097 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8098 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8099 error ("dellistener: invalid graphics object (= %g)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8100 h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8101 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8102 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8103 error ("dellistener: invalid property name, expected a string value");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8104 }
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8105 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8106 error ("dellistener: invalid handle");
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8107 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8108 else
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8109 print_usage ();
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8110
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8111 return retval;
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8112 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
8113
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8114 DEFUN (addproperty, args, ,
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
8115 "-*- texinfo -*-\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
8116 @deftypefn {Built-in Function} {} addproperty (@var{name}, @var{h}, @var{type})\n\
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
8117 @deftypefnx {Built-in Function} {} addproperty (@var{name}, @var{h}, @var{type}, @var{arg}, @dots{})\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8118 Create a new property named @var{name} in graphics object @var{h}.\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8119 @var{type} determines the type of the property to create. @var{args}\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8120 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
8121 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
8122 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8123 The supported property types are:\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8124 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8125 @table @code\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8126 @item string\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8127 A string property. @var{arg} contains the default string value.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
8128 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8129 @item any\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8130 An un-typed property. This kind of property can hold any octave\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8131 value. @var{args} contains the default value.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
8132 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8133 @item radio\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8134 A string property with a limited set of accepted values. The first\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8135 argument must be a string with all accepted values separated by\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8136 a vertical bar ('|'). The default value can be marked by enclosing\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8137 it with a '@{' '@}' pair. The default value may also be given as\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8138 an optional second string argument.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
8139 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8140 @item boolean\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8141 A boolean property. This property type is equivalent to a radio\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8142 property with \"on|off\" as accepted values. @var{arg} contains\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8143 the default property value.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
8144 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8145 @item double\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8146 A scalar double property. @var{arg} contains the default value.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
8147 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8148 @item handle\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8149 A handle property. This kind of property holds the handle of a\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8150 graphics object. @var{arg} contains the default handle value.\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8151 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
8152 the empty matrix.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
8153 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8154 @item data\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8155 A data (matrix) property. @var{arg} contains the default data\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8156 value. When no default value is given, the data is initialized to\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8157 the empty matrix.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
8158 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8159 @item color\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8160 A color property. @var{arg} contains the default color value.\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8161 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
8162 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
8163 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
8164 @end table\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8165 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8166 @var{type} may also be the concatenation of a core object type and\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8167 a valid property name for that object type. The property created\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8168 then has the same characteristics as the referenced property (type,\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
8169 possible values, hidden state@dots{}). This allows to clone an existing\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8170 property into the graphics object @var{h}.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8171 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8172 Examples:\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8173 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8174 @example\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
8175 @group\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8176 addproperty (\"my_property\", gcf, \"string\", \"a string value\");\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8177 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
8178 addproperty (\"my_style\", gcf, \"linelinestyle\", \"--\");\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
8179 @end group\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8180 @end example\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8181 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8182 @end deftypefn")
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8183 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8184 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8185
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8186 octave_value retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8187
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8188 if (args.length () >= 3)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8189 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8190 std::string name = args(0).string_value ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8191
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8192 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8193 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8194 double h = args(1).double_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8195
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8196 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8197 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8198 graphics_handle gh = gh_manager::lookup (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8199
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8200 if (gh.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8201 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8202 graphics_object go = gh_manager::get_object (gh);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8203
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8204 std::string type = args(2).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8205
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8206 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8207 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8208 if (! go.get_properties ().has_property (name))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8209 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8210 property p = property::create (name, gh, type,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8211 args.splice (0, 3));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8212
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8213 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8214 go.get_properties ().insert_property (name, p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8215 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8216 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8217 error ("addproperty: a `%s' property already exists in the graphics object",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8218 name.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8219 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8220 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12467
diff changeset
8221 error ("addproperty: invalid property TYPE, expected a string value");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8222 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8223 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8224 error ("addproperty: invalid graphics object (= %g)", h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8225 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8226 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8227 error ("addproperty: invalid handle value");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8228 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8229 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 12467
diff changeset
8230 error ("addproperty: invalid property NAME, expected a string value");
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8231 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8232 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8233 print_usage ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8234
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8235 return retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8236 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
8237
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8238 octave_value
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
8239 get_property_from_handle (double handle, const std::string& property,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8240 const std::string& func)
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8241 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8242 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8243
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8244 graphics_object obj = gh_manager::get_object (handle);
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8245 octave_value retval;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8246
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8247 if (obj)
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
8248 retval = obj.get (caseless_str (property));
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8249 else
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8250 error ("%s: invalid handle (= %g)", func.c_str(), handle);
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8251
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8252 return retval;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8253 }
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8254
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8255 bool
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
8256 set_property_in_handle (double handle, const std::string& property,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8257 const octave_value& arg, const std::string& func)
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8258 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8259 gh_manager::autolock guard;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
8260
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8261 graphics_object obj = gh_manager::get_object (handle);
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8262 int ret = false;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8263
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8264 if (obj)
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8265 {
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
8266 obj.set (caseless_str (property), arg);
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
8267
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
8268 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8269 ret = true;
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8270 }
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8271 else
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8272 error ("%s: invalid handle (= %g)", func.c_str(), handle);
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8273
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8274 return ret;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
8275 }