annotate src/graphics.h.in @ 9188:9646be3a59c4

make changeset 1e5c11890f85 work
author John W. Eaton <jwe@octave.org>
date Thu, 07 May 2009 17:47:39 -0400
parents 1e5c11890f85
children 3da821b161e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1 /*
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8740
diff changeset
3 Copyright (C) 2007, 2008, 2009 John W. Eaton
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
4
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
6
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
94bda6abc224 [project @ 2007-09-06 21:34:24 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.
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
11
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
15 for more details.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
16
94bda6abc224 [project @ 2007-09-06 21:34:24 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/>.
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
20
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
21 */
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
22
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
23 #if !defined (graphics_h)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
24 #define graphics_h 1
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
25
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
26 #ifdef HAVE_CONFIG_H
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
27 #include <config.h>
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
28 #endif
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
29
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
30 #include <cctype>
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
31
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
32 #include <algorithm>
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
33 #include <list>
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
34 #include <map>
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
35 #include <set>
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
36 #include <string>
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
37
9004
17ba311ef110 add one more missing include
Jaroslav Hajek <highegg@gmail.com>
parents: 8944
diff changeset
38 #include "lo-ieee.h"
17ba311ef110 add one more missing include
Jaroslav Hajek <highegg@gmail.com>
parents: 8944
diff changeset
39
6890
b2b7526a5772 [project @ 2007-09-12 20:14:35 by jwe]
jwe
parents: 6874
diff changeset
40 #include "gripes.h"
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
41 #include "oct-map.h"
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
42 #include "oct-mutex.h"
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
43 #include "ov.h"
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
44
8944
cb0e9facc342 make default fontname * instead of Helvetica
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
45 // FIXME -- maybe this should be a configure option?
cb0e9facc342 make default fontname * instead of Helvetica
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
46 // Matlab defaults to "Helvetica", but that causes problems for many
cb0e9facc342 make default fontname * instead of Helvetica
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
47 // gnuplot users.
cb0e9facc342 make default fontname * instead of Helvetica
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
48 #if !defined (OCTAVE_DEFAULT_FONTNAME)
cb0e9facc342 make default fontname * instead of Helvetica
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
49 #define OCTAVE_DEFAULT_FONTNAME "*"
cb0e9facc342 make default fontname * instead of Helvetica
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
50 #endif
cb0e9facc342 make default fontname * instead of Helvetica
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
51
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
52 class caseless_str : public std::string
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
53 {
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
54 public:
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
55 typedef std::string::iterator iterator;
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
56 typedef std::string::const_iterator const_iterator;
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
57
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
58 caseless_str (void) : std::string () { }
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
59 caseless_str (const std::string& s) : std::string (s) { }
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
60 caseless_str (const char *s) : std::string (s) { }
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
61
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
62 caseless_str (const caseless_str& name) : std::string (name) { }
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
63
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
64 caseless_str& operator = (const caseless_str& pname)
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
65 {
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
66 std::string::operator = (pname);
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
67 return *this;
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
68 }
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
69
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
70 operator std::string (void) const { return *this; }
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
71
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
72 // Case-insensitive comparison.
8023
0ff67bd96f8d graphics.h.in: replace NPOS with std::string::npos
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
73 bool compare (const std::string& s, size_t limit = std::string::npos) const
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
74 {
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
75 const_iterator p1 = begin ();
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
76 const_iterator p2 = s.begin ();
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
77
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
78 size_t k = 0;
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
79
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
80 while (p1 != end () && p2 != s.end () && k++ < limit)
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
81 {
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
82 if (std::tolower (*p1) != std::tolower (*p2))
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
83 return false;
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
84
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
85 *p1++;
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
86 *p2++;
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
87 }
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
88
8023
0ff67bd96f8d graphics.h.in: replace NPOS with std::string::npos
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
89 return (limit == std::string::npos) ? size () == s.size () : k == limit;
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
90 }
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
91 };
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
92
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
93 // ---------------------------------------------------------------------
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
94
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
95 class graphics_handle
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
96 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
97 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
98 graphics_handle (void) : val (octave_NaN) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
99
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
100 graphics_handle (const octave_value& a);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
101
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
102 graphics_handle (int a) : val (a) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
103
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
104 graphics_handle (double a) : val (a) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
105
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
106 graphics_handle (const graphics_handle& a) : val (a.val) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
107
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
108 graphics_handle& operator = (const graphics_handle& a)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
109 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
110 if (&a != this)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
111 val = a.val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
112
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
113 return *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
114 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
115
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
116 ~graphics_handle (void) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
117
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
118 double value (void) const { return val; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
119
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
120 octave_value as_octave_value (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
121 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
122 return ok () ? octave_value (val) : octave_value (Matrix ());
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
123 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
124
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
125 graphics_handle operator ++ (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
126 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
127 ++val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
128 return *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
129 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
130
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
131 graphics_handle operator ++ (int)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
132 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
133 graphics_handle h = *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
134 ++val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
135 return h;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
136 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
137
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
138 graphics_handle operator -- (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
139 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
140 --val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
141 return *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
142 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
143
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
144 graphics_handle operator -- (int)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
145 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
146 graphics_handle h = *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
147 --val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
148 return h;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
149 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
150
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
151 bool ok (void) const { return ! xisnan (val); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
152
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
153 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
154 double val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
155 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
156
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
157 inline bool
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
158 operator == (const graphics_handle& a, const graphics_handle& b)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
159 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
160 return a.value () == b.value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
161 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
162
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
163 inline bool
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
164 operator != (const graphics_handle& a, const graphics_handle& b)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
165 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
166 return a.value () != b.value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
167 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
168
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
169 inline bool
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
170 operator < (const graphics_handle& a, const graphics_handle& b)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
171 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
172 return a.value () < b.value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
173 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
174
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
175 inline bool
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
176 operator <= (const graphics_handle& a, const graphics_handle& b)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
177 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
178 return a.value () <= b.value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
179 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
180
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
181 inline bool
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
182 operator >= (const graphics_handle& a, const graphics_handle& b)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
183 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
184 return a.value () >= b.value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
185 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
186
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
187 inline bool
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
188 operator > (const graphics_handle& a, const graphics_handle& b)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
189 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
190 return a.value () > b.value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
191 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
192
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
193 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
194
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
195 class base_scaler
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
196 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
197 public:
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
198 base_scaler (void) { }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
199
7441
0207ba146089 [project @ 2008-02-03 04:38:58 by jwe]
jwe
parents: 7440
diff changeset
200 virtual ~base_scaler (void) { }
7440
4e3b073e910e [project @ 2008-02-02 18:23:50 by jwe]
jwe
parents: 7439
diff changeset
201
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
202 virtual Matrix scale (const Matrix& m) const
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
203 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
204 error ("invalid axis scale");
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
205 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
206 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
207
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
208 virtual NDArray scale (const NDArray& m) const
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
209 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
210 error ("invalid axis scale");
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
211 return m;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
212 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
213
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
214 virtual double scale (double d) const
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
215 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
216 error ("invalid axis scale");
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
217 return d;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
218 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
219
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
220 virtual double unscale (double d) const
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
221 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
222 error ("invalid axis scale");
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
223 return d;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
224 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
225
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
226 virtual base_scaler* clone () const
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
227 { return new base_scaler (); }
7832
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
228
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
229 virtual bool is_linear (void) const
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
230 { return false; }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
231 };
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
232
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
233 class lin_scaler : public base_scaler
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
234 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
235 public:
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
236 lin_scaler (void) { }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
237
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
238 Matrix scale (const Matrix& m) const { return m; }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
239
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
240 NDArray scale (const NDArray& m) const { return m; }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
241
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
242 double scale (double d) const { return d; }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
243
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
244 double unscale (double d) const { return d; }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
245
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
246 base_scaler* clone (void) const { return new lin_scaler (); }
7832
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
247
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
248 bool is_linear (void) const { return true; }
7427
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
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
251 class log_scaler : public base_scaler
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 public:
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
254 log_scaler (void) { }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
255
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
256 Matrix scale (const Matrix& m) const
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
257 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
258 Matrix retval (m.rows (), m.cols ());
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
259
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
260 do_scale (m.data (), retval.fortran_vec (), m.numel ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
261 return retval;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
262 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
263
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
264 NDArray scale (const NDArray& m) const
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
265 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
266 NDArray retval (m.dims ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
267
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
268 do_scale (m.data (), retval.fortran_vec (), m.numel ());
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
269 return retval;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
270 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
271
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
272 double scale (double d) const
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
273 { return log10 (d); }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
274
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
275 double unscale (double d) const
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
276 { return pow (10.0, d); }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
277
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
278 base_scaler* clone (void) const
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
279 { return new log_scaler (); }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
280
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
281 private:
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
282 void do_scale (const double *src, double *dest, int n) const
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
283 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
284 for (int i = 0; i < n; i++)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
285 dest[i] = log10(src[i]);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
286 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
287 };
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
288
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
289 class scaler
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
290 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
291 public:
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
292 scaler (void) : rep (new base_scaler ()) { }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
293
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
294 scaler (const scaler& s) : rep (s.rep->clone()) { }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
295
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
296 ~scaler (void) { delete rep; }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
297
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
298 Matrix scale (const Matrix& m) const
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
299 { return rep->scale (m); }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
300
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
301 NDArray scale (const NDArray& m) const
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
302 { return rep->scale (m); }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
303
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
304 double scale (double d) const
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
305 { return rep->scale (d); }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
306
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
307 double unscale (double d) const
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
308 { return rep->unscale (d); }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
309
7832
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
310 bool is_linear (void) const
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
311 { return rep->is_linear (); }
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
312
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
313 scaler& operator = (const scaler& s)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
314 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
315 if (rep)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
316 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
317 delete rep;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
318 rep = 0;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
319 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
320
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
321 rep = s.rep->clone ();
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 return *this;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
324 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
325
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
326 scaler& operator = (const std::string& s)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
327 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
328 if (rep)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
329 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
330 delete rep;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
331 rep = 0;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
332 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
333
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
334 if (s == "log")
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
335 rep = new log_scaler ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
336 else if (s == "linear")
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
337 rep = new lin_scaler ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
338 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
339 rep = new base_scaler ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
340
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
341 return *this;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
342 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
343
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
344 private:
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
345 base_scaler *rep;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
346 };
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
347
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
348 // ---------------------------------------------------------------------
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
349
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
350 class property;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
351
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
352 enum listener_mode { POSTSET };
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
353
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
354 class base_property
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
355 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
356 public:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
357 friend class property;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
358
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
359 public:
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
360 base_property (void) : id (-1), count (1) { }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
361
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
362 base_property (const std::string& s, const graphics_handle& h)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
363 : id (-1), count (1), name (s), parent (h), hidden (false) { }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
364
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
365 base_property (const base_property& p)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
366 : id (-1), count (1), name (p.name), parent (p.parent), hidden (p.hidden) { }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
367
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
368 virtual ~base_property (void) { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
369
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
370 bool ok (void) const { return parent.ok (); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
371
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
372 std::string get_name (void) const { return name; }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
373
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
374 void set_name (const std::string& s) { name = s; }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
375
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
376 graphics_handle get_parent (void) const { return parent; }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
377
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
378 void set_parent (const graphics_handle &h) { parent = h; }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
379
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
380 bool is_hidden (void) const { return hidden; }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
381
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
382 void set_hidden (bool flag) { hidden = flag; }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
383
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
384 int get_id (void) const { return id; }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
385
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
386 void set_id (int d) { id = d; }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
387
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
388 // Sets property value, notifies backend.
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
389 // If do_run is true, runs associated listeners.
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
390 bool set (const octave_value& v, bool do_run = true);
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
391
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
392 virtual octave_value get (void) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
393 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
394 error ("get: invalid property \"%s\"", name.c_str ());
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
395 return octave_value ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
396 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
397
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
398 base_property& operator = (const octave_value& val)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
399 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
400 set (val);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
401 return *this;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
402 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
403
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
404 void add_listener (const octave_value& v, listener_mode mode = POSTSET)
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
405 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
406 octave_value_list& l = listeners[mode];
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
407 l.resize (l.length () + 1, v);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
408 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
409
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
410 void delete_listener (const octave_value& v = octave_value (),
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
411 listener_mode mode = POSTSET)
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
412 {
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
413 octave_value_list& l = listeners[mode];
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
414
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
415 if (v.is_defined ())
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
416 {
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
417 bool found = false;
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
418 int i;
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
419
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
420 for (i = 0; i < l.length (); i++)
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
421 {
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
422 if (v.internal_rep () == l(i).internal_rep ())
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
423 {
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
424 found = true;
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
425 break;
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
426 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
427 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
428 if (found)
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
429 {
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
430 for (int j = i; j < l.length() - 1; j++)
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
431 l(j) = l (j + 1);
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
432
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
433 l.resize (l.length () - 1);
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
434 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
435 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
436 else
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
437 l.resize (0);
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
438
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
439 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
440
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
441 OCTINTERP_API void run_listeners (listener_mode mode = POSTSET);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
442
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
443 virtual base_property* clone (void) const
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
444 { return new base_property (*this); }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
445
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
446 protected:
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
447 virtual bool do_set (const octave_value&)
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
448 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
449 error ("set: invalid property \"%s\"", name.c_str ());
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
450 return false;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
451 }
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
452
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
453 private:
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
454 typedef std::map<listener_mode, octave_value_list> listener_map;
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
455 typedef std::map<listener_mode, octave_value_list>::iterator listener_map_iterator;
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
456 typedef std::map<listener_mode, octave_value_list>::const_iterator listener_map_const_iterator;
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
457
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
458 private:
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
459 int id;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
460 int count;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
461 std::string name;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
462 graphics_handle parent;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
463 bool hidden;
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
464 listener_map listeners;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
465 };
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
466
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
467 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
468
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
469 class string_property : public base_property
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
470 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
471 public:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
472 string_property (const std::string& s, const graphics_handle& h,
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
473 const std::string& val = "")
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
474 : base_property (s, h), str (val) { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
475
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
476 string_property (const string_property& p)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
477 : base_property (p), str (p.str) { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
478
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
479 octave_value get (void) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
480 { return octave_value (str); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
481
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
482 std::string string_value (void) const { return str; }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
483
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
484 string_property& operator = (const octave_value& val)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
485 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
486 set (val);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
487 return *this;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
488 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
489
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
490 base_property* clone (void) const { return new string_property (*this); }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
491
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
492 protected:
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
493 bool do_set (const octave_value& val)
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
494 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
495 if (val.is_string ())
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
496 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
497 std::string new_str = val.string_value ();
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
498
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
499 if (new_str != str)
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
500 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
501 str = new_str;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
502 return true;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
503 }
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
504 }
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
505 else
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
506 error ("set: invalid string property value for \"%s\"",
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
507 get_name ().c_str ());
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
508 return false;
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
509 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
510
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
511 private:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
512 std::string str;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
513 };
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
514
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
515 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
516
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
517 class radio_values
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
518 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
519 public:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
520 OCTINTERP_API radio_values (const std::string& opt_string = std::string ());
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
521
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
522 radio_values (const radio_values& a)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
523 : default_val (a.default_val), possible_vals (a.possible_vals) { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
524
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
525 radio_values& operator = (const radio_values& a)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
526 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
527 if (&a != this)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
528 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
529 default_val = a.default_val;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
530 possible_vals = a.possible_vals;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
531 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
532
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
533 return *this;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
534 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
535
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
536 std::string default_value (void) const { return default_val; }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
537
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
538 bool validate (const std::string& val)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
539 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
540 bool retval = true;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
541
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
542 if (! contains (val))
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
543 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
544 error ("invalid value = %s", val.c_str ());
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
545 retval = false;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
546 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
547
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
548 return retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
549 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
550
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
551 bool contains (const std::string& val)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
552 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
553 return (possible_vals.find (val) != possible_vals.end ());
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
554 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
555
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
556 private:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
557 // Might also want to cache
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
558 std::string default_val;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
559 std::set<caseless_str> possible_vals;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
560 };
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
561
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
562 class radio_property : public base_property
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
563 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
564 public:
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
565 radio_property (const std::string& nm, const graphics_handle& h,
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
566 const radio_values& v = radio_values ())
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
567 : base_property (nm, h),
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
568 vals (v), current_val (v.default_value ()) { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
569
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
570 radio_property (const std::string& nm, const graphics_handle& h,
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
571 const std::string& v)
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
572 : base_property (nm, h),
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
573 vals (v), current_val (vals.default_value ()) { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
574
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
575 radio_property (const std::string& nm, const graphics_handle& h,
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
576 const radio_values& v, const std::string& def)
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
577 : base_property (nm, h),
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
578 vals (v), current_val (def) { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
579
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
580 radio_property (const radio_property& p)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
581 : base_property (p), vals (p.vals), current_val (p.current_val) { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
582
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
583 octave_value get (void) const { return octave_value (current_val); }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
584
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
585 const std::string& current_value (void) const { return current_val; }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
586
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
587 bool is (const caseless_str& v) const
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
588 { return v.compare (current_val); }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
589
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
590 radio_property& operator = (const octave_value& val)
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
591 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
592 set (val);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
593 return *this;
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
594 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
595
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
596 base_property* clone (void) const { return new radio_property (*this); }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
597
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
598 protected:
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
599 bool do_set (const octave_value& newval)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
600 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
601 if (newval.is_string ())
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
602 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
603 std::string s = newval.string_value ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
604 if (vals.validate (s))
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
605 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
606 if (s != current_val)
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
607 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
608 current_val = s;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
609 return true;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
610 }
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
611 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
612 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
613 error ("set: invalid value for radio property \"%s\" (value = %s)",
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
614 get_name ().c_str (), s.c_str ());
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
615 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
616 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
617 error ("set: invalid value for radio property \"%s\"",
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
618 get_name ().c_str ());
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
619 return false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
620 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
621
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
622 private:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
623 radio_values vals;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
624 std::string current_val;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
625 };
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
626
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
627 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
628
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
629 class color_values
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
630 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
631 public:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
632 color_values (double r = 0, double g = 0, double b = 1)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
633 : xrgb (1, 3)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
634 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
635 xrgb(0) = r;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
636 xrgb(1) = g;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
637 xrgb(2) = b;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
638
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
639 validate ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
640 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
641
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
642 color_values (std::string str)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
643 : xrgb (1, 3)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
644 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
645 if (! str2rgb (str))
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
646 error ("invalid color specification: %s", str.c_str ());
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
647 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
648
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
649 color_values (const color_values& c)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
650 : xrgb (c.xrgb)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
651 { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
652
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
653 color_values& operator = (const color_values& c)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
654 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
655 if (&c != this)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
656 xrgb = c.xrgb;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
657
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
658 return *this;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
659 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
660
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
661 bool operator == (const color_values& c) const
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
662 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
663 return (xrgb(0) == c.xrgb(0)
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
664 && xrgb(1) == c.xrgb(1)
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
665 && xrgb(2) == c.xrgb(2));
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
666 }
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
667
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
668 bool operator != (const color_values& c) const
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
669 { return ! (*this == c); }
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
670
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
671 Matrix rgb (void) const { return xrgb; }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
672
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
673 operator octave_value (void) const { return xrgb; }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
674
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
675 void validate (void) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
676 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
677 for (int i = 0; i < 3; i++)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
678 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
679 if (xrgb(i) < 0 || xrgb(i) > 1)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
680 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
681 error ("invalid RGB color specification");
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
682 break;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
683 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
684 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
685 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
686
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
687 private:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
688 Matrix xrgb;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
689
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
690 OCTINTERP_API bool str2rgb (std::string str);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
691 };
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
692
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
693 class color_property : public base_property
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
694 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
695 public:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
696 color_property (const color_values& c, const radio_values& v)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
697 : base_property ("", graphics_handle ()),
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
698 current_type (color_t), color_val (c), radio_val (v),
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
699 current_val (v.default_value ())
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
700 { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
701
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
702 color_property (const std::string& nm, const graphics_handle& h,
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
703 const color_values& c = color_values (),
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
704 const radio_values& v = radio_values ())
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
705 : base_property (nm, h),
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
706 current_type (color_t), color_val (c), radio_val (v),
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
707 current_val (v.default_value ())
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
708 { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
709
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
710 color_property (const std::string& nm, const graphics_handle& h,
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
711 const radio_values& v)
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
712 : base_property (nm, h),
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
713 current_type (radio_t), color_val (color_values ()), radio_val (v),
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
714 current_val (v.default_value ())
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
715 { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
716
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
717 color_property (const std::string& nm, const graphics_handle& h,
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
718 const std::string& v)
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
719 : base_property (nm, h),
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
720 current_type (radio_t), color_val (color_values ()), radio_val (v),
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
721 current_val (radio_val.default_value ())
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
722 { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
723
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
724 color_property (const std::string& nm, const graphics_handle& h,
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
725 const color_property& v)
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
726 : base_property (nm, h),
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
727 current_type (v.current_type), color_val (v.color_val),
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
728 radio_val (v.radio_val), current_val (v.current_val)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
729 { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
730
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
731 color_property (const color_property& p)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
732 : base_property (p), current_type (p.current_type),
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
733 color_val (p.color_val), radio_val (p.radio_val),
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
734 current_val (p.current_val) { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
735
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
736 octave_value get (void) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
737 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
738 if (current_type == color_t)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
739 return color_val.rgb ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
740
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
741 return current_val;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
742 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
743
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
744 bool is_rgb (void) const { return (current_type == color_t); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
745
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
746 bool is_radio (void) const { return (current_type == radio_t); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
747
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
748 bool is (const std::string& v) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
749 { return (is_radio () && current_val == v); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
750
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
751 Matrix rgb (void) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
752 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
753 if (current_type != color_t)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
754 error ("color has no rgb value");
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
755
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
756 return color_val.rgb ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
757 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
758
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
759 const std::string& current_value (void) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
760 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
761 if (current_type != radio_t)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
762 error ("color has no radio value");
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
763
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
764 return current_val;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
765 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
766
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
767 color_property& operator = (const octave_value& val)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
768 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
769 set (val);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
770 return *this;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
771 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
772
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
773 operator octave_value (void) const { return get (); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
774
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
775 base_property* clone (void) const { return new color_property (*this); }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
776
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
777 protected:
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
778 OCTINTERP_API bool do_set (const octave_value& newval);
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
779
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
780 private:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
781 enum current_enum { color_t, radio_t } current_type;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
782 color_values color_val;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
783 radio_values radio_val;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
784 std::string current_val;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
785 };
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
786
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
787 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
788
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
789 class double_property : public base_property
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
790 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
791 public:
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
792 double_property (const std::string& nm, const graphics_handle& h,
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
793 double d = 0)
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
794 : base_property (nm, h),
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
795 current_val (d) { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
796
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
797 double_property (const double_property& p)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
798 : base_property (p), current_val (p.current_val) { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
799
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
800 octave_value get (void) const { return octave_value (current_val); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
801
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
802 double double_value (void) const { return current_val; }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
803
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
804 double_property& operator = (const octave_value& val)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
805 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
806 set (val);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
807 return *this;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
808 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
809
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
810 base_property* clone (void) const { return new double_property (*this); }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
811
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
812 protected:
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
813 bool do_set (const octave_value& v)
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
814 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
815 if (v.is_scalar_type () && v.is_real_type ())
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
816 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
817 double new_val = v.double_value ();
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
818
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
819 if (new_val != current_val)
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
820 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
821 current_val = new_val;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
822 return true;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
823 }
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
824 }
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
825 else
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
826 error ("set: invalid value for double property \"%s\"",
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
827 get_name ().c_str ());
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
828 return false;
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
829 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
830
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
831 private:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
832 double current_val;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
833 };
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
834
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
835 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
836
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
837 class double_radio_property : public base_property
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
838 {
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
839 public:
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
840 double_radio_property (double d, const radio_values& v)
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
841 : base_property ("", graphics_handle ()),
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
842 current_type (double_t), dval (d), radio_val (v),
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
843 current_val (v.default_value ())
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
844 { }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
845
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
846 double_radio_property (const std::string& nm, const graphics_handle& h,
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
847 const std::string& v)
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
848 : base_property (nm, h),
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
849 current_type (radio_t), dval (0), radio_val (v),
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
850 current_val (radio_val.default_value ())
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
851 { }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
852
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
853 double_radio_property (const std::string& nm, const graphics_handle& h,
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
854 const double_radio_property& v)
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
855 : base_property (nm, h),
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
856 current_type (v.current_type), dval (v.dval),
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
857 radio_val (v.radio_val), current_val (v.current_val)
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
858 { }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
859
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
860 double_radio_property (const double_radio_property& p)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
861 : base_property (p), current_type (p.current_type),
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
862 dval (p.dval), radio_val (p.radio_val),
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
863 current_val (p.current_val) { }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
864
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
865 octave_value get (void) const
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
866 {
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
867 if (current_type == double_t)
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
868 return dval;
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
869
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
870 return current_val;
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
871 }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
872
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
873 bool is_double (void) const { return (current_type == double_t); }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
874
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
875 bool is_radio (void) const { return (current_type == radio_t); }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
876
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
877 bool is (const std::string& v) const
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
878 { return (is_radio () && current_val == v); }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
879
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
880 double double_value (void) const
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
881 {
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
882 if (current_type != double_t)
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
883 error ("%s: property has no double", get_name ().c_str ());
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
884
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
885 return dval;
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
886 }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
887
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
888 const std::string& current_value (void) const
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
889 {
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
890 if (current_type != radio_t)
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
891 error ("%s: property has no radio value");
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
892
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
893 return current_val;
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
894 }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
895
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
896 double_radio_property& operator = (const octave_value& val)
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
897 {
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
898 set (val);
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
899 return *this;
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
900 }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
901
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
902 operator octave_value (void) const { return get (); }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
903
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
904 base_property* clone (void) const
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
905 { return new double_radio_property (*this); }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
906
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
907 protected:
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
908 OCTINTERP_API bool do_set (const octave_value& v);
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
909
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
910 private:
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
911 enum current_enum { double_t, radio_t } current_type;
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
912 double dval;
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
913 radio_values radio_val;
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
914 std::string current_val;
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
915 };
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
916
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
917 // ---------------------------------------------------------------------
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
918
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
919 class array_property : public base_property
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
920 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
921 public:
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
922 array_property (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
923 : base_property ("", graphics_handle ()), data (Matrix ())
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
924 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
925 get_data_limits ();
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
926 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
927
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
928 array_property (const std::string& nm, const graphics_handle& h,
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
929 const octave_value& m)
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
930 : base_property (nm, h), data (m)
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
931 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
932 get_data_limits ();
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
933 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
934
7848
6bb2bbc2bf45 Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7847
diff changeset
935 // This copy constructor is only intended to be used
6bb2bbc2bf45 Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7847
diff changeset
936 // internally to access min/max values; no need to
6bb2bbc2bf45 Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7847
diff changeset
937 // copy constraints.
6bb2bbc2bf45 Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7847
diff changeset
938 array_property (const array_property& p)
6bb2bbc2bf45 Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7847
diff changeset
939 : base_property (p), data (p.data),
6bb2bbc2bf45 Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7847
diff changeset
940 xmin (p.xmin), xmax (p.xmax), xminp (p.xminp) { }
6bb2bbc2bf45 Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7847
diff changeset
941
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
942 octave_value get (void) const { return data; }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
943
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
944 void add_constraint (const std::string& type)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
945 { type_constraints.push_back (type); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
946
7524
a653856aa3e1 array_value::add_constraint: pass dim_vector as const reference, not value
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
947 void add_constraint (const dim_vector& dims)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
948 { size_constraints.push_back (dims); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
949
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
950 double min_val (void) const { return xmin; }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
951 double max_val (void) const { return xmax; }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
952 double min_pos (void) const { return xminp; }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
953
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
954 Matrix get_limits (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
955 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
956 Matrix m (1, 3);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
957
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
958 m(0) = min_val ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
959 m(1) = max_val ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
960 m(2) = min_pos ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
961
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
962 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
963 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
964
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
965 array_property& operator = (const octave_value& val)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
966 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
967 set (val);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
968 return *this;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
969 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
970
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
971 base_property* clone (void) const
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
972 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
973 array_property *p = new array_property (*this);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
974
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
975 p->type_constraints = type_constraints;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
976 p->size_constraints = size_constraints;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
977
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
978 return p;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
979 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
980
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
981 protected:
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
982 bool do_set (const octave_value& v)
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
983 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
984 if (validate (v))
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
985 {
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8300
diff changeset
986 // FIXME -- should we check for actual data change?
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
987 if (! is_equal (v))
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
988 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
989 data = v;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
990
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
991 get_data_limits ();
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
992
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
993 return true;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
994 }
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
995 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
996 else
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
997 error ("invalid value for array property \"%s\"",
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
998 get_name ().c_str ());
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
999
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1000 return false;
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1001 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1002
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1003 private:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1004 OCTINTERP_API bool validate (const octave_value& v);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1005
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1006 OCTINTERP_API bool is_equal (const octave_value& v) const;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1007
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
1008 OCTINTERP_API void 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
1009
7523
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
1010 protected:
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1011 octave_value 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
1012 double xmin;
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1013 double xmax;
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1014 double xminp;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1015 std::list<std::string> type_constraints;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1016 std::list<dim_vector> size_constraints;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1017 };
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1018
7523
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
1019 class row_vector_property : public array_property
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
1020 {
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
1021 public:
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
1022 row_vector_property (const std::string& nm, const graphics_handle& h,
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
1023 const octave_value& m)
7527
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1024 : array_property (nm, h, m)
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1025 {
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1026 add_constraint (dim_vector (-1, 1));
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1027 add_constraint (dim_vector (1, -1));
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1028 }
7523
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
1029
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1030 row_vector_property (const row_vector_property& p)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1031 : array_property (p)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1032 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1033 add_constraint (dim_vector (-1, 1));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1034 add_constraint (dim_vector (1, -1));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1035 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1036
7527
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1037 void add_constraint (const std::string& type)
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1038 {
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1039 array_property::add_constraint (type);
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1040 }
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1041
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1042 void add_constraint (const dim_vector& dims)
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1043 {
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1044 array_property::add_constraint (dims);
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1045 }
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1046
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1047 void add_constraint (octave_idx_type len)
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1048 {
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1049 size_constraints.remove (dim_vector (1, -1));
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1050 size_constraints.remove (dim_vector (-1, 1));
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1051
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1052 add_constraint (dim_vector (1, len));
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1053 add_constraint (dim_vector (len, 1));
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1054 }
7523
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
1055
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
1056 row_vector_property& operator = (const octave_value& val)
7527
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1057 {
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1058 set (val);
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1059 return *this;
d219e712c20e make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents: 7526
diff changeset
1060 }
7523
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
1061
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1062 base_property* clone (void) const
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1063 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1064 row_vector_property *p = new row_vector_property (*this);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1065
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1066 p->type_constraints = type_constraints;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1067 p->size_constraints = size_constraints;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1068
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1069 return p;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1070 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1071
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1072 protected:
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1073 bool do_set (const octave_value& v)
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1074 {
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1075 bool retval = array_property::do_set (v);
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1076
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1077 if (! error_state)
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1078 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1079 dim_vector dv = data.dims ();
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1080
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1081 if (dv(0) > 1 && dv(1) == 1)
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1082 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1083 int tmp = dv(0);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1084 dv(0) = dv(1);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1085 dv(1) = tmp;
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1086
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1087 data = data.reshape (dv);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1088 }
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1089
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1090 return retval;
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1091 }
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1092
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1093 return false;
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1094 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1095
7523
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
1096 private:
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
1097 OCTINTERP_API bool validate (const octave_value& v);
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
1098 };
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
1099
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1100 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1101
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1102 class bool_property : public radio_property
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1103 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1104 public:
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1105 bool_property (const std::string& nm, const graphics_handle& h,
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1106 bool val)
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1107 : radio_property (nm, h, radio_values (val ? "{on}|off" : "on|{off}"))
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1108 { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1109
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1110 bool_property (const std::string& nm, const graphics_handle& h,
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1111 const char* val)
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1112 : radio_property (nm, h, radio_values ("on|off"), val)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1113 { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1114
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1115 bool_property (const bool_property& p)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1116 : radio_property (p) { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1117
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1118 bool is_on (void) const { return is ("on"); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1119
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1120 bool_property& operator = (const octave_value& val)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1121 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1122 set (val);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1123 return *this;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1124 }
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1125
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1126 base_property* clone (void) const { return new bool_property (*this); }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1127
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1128 protected:
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1129 bool do_set (const octave_value& val)
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1130 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1131 if (val.is_bool_scalar ())
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1132 return radio_property::do_set (val.bool_value () ? "on" : "off");
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1133 else
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1134 return radio_property::do_set (val);
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1135 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1136 };
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1137
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1138 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1139
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1140 class handle_property : public base_property
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1141 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1142 public:
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1143 handle_property (const std::string& nm, const graphics_handle& h,
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1144 const graphics_handle& val = graphics_handle ())
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1145 : base_property (nm, h),
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1146 current_val (val) { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1147
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1148 handle_property (const handle_property& p)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1149 : base_property (p), current_val (p.current_val) { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1150
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1151 octave_value get (void) const { return current_val.as_octave_value (); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1152
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1153 graphics_handle handle_value (void) const { return current_val; }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1154
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1155 handle_property& operator = (const octave_value& val)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1156 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1157 set (val);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1158 return *this;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1159 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1160
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1161 handle_property& operator = (const graphics_handle& h)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1162 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1163 set (octave_value (h.value ()));
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1164 return *this;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1165 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1166
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1167 base_property* clone (void) const { return new handle_property (*this); }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1168
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1169 protected:
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1170 OCTINTERP_API bool do_set (const octave_value& v);
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1171
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1172 private:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1173 graphics_handle current_val;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1174 };
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1175
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1176 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1177
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1178 class any_property : public base_property
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1179 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1180 public:
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1181 any_property (const std::string& nm, const graphics_handle& h,
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1182 const octave_value& m = Matrix ())
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1183 : base_property (nm, h), data (m) { }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1184
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1185 any_property (const any_property& p)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1186 : base_property (p), data (p.data) { }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1187
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1188 octave_value get (void) const { return data; }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1189
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1190 any_property& operator = (const octave_value& val)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1191 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1192 set (val);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1193 return *this;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1194 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1195
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1196 base_property* clone (void) const { return new any_property (*this); }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1197
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1198 protected:
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1199 bool do_set (const octave_value& v)
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1200 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1201 data = v;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1202 return true;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1203 }
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1204
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1205 private:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1206 octave_value data;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1207 };
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1208
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1209 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1210
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1211 class callback_property : public base_property
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1212 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1213 public:
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1214 callback_property (const std::string& nm, const graphics_handle& h,
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1215 const octave_value& m)
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1216 : base_property (nm, h), callback (m) { }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1217
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1218 callback_property (const callback_property& p)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1219 : base_property (p), callback (p.callback) { }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1220
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1221 octave_value get (void) const { return callback; }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1222
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1223 OCTINTERP_API void execute (const octave_value& data = octave_value ()) const;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1224
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1225 callback_property& operator = (const octave_value& val)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1226 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1227 set (val);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1228 return *this;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1229 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1230
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1231 base_property* clone (void) const { return new callback_property (*this); }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1232
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1233 protected:
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1234 bool do_set (const octave_value& v)
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1235 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1236 if (validate (v))
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1237 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1238 callback = v;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1239 return true;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1240 }
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1241 else
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1242 error ("invalid value for callback property \"%s\"",
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1243 get_name ().c_str ());
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1244 return false;
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1245 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1246
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1247 private:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1248 OCTINTERP_API bool validate (const octave_value& v) const;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1249
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1250 private:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1251 octave_value callback;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1252 };
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1253
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1254 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1255
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1256 class property
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1257 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1258 public:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1259 property (void) : rep (new base_property ("", graphics_handle ()))
7850
56254a8d4d59 Smarter reference counting in base_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
1260 { }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1261
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1262 property (base_property *bp, bool persist = false) : rep (bp)
7850
56254a8d4d59 Smarter reference counting in base_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
1263 { if (persist) rep->count++; }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1264
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1265 property (const property& p)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1266 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1267 rep = p.rep;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1268 rep->count++;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1269 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1270
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1271 ~property (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1272 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1273 if (--rep->count <= 0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1274 delete rep;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1275 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1276
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1277 bool ok (void) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1278 { return rep->ok (); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1279
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1280 std::string get_name (void) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1281 { return rep->get_name (); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1282
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1283 void set_name (const std::string& name)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1284 { rep->set_name (name); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1285
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1286 graphics_handle get_parent (void) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1287 { return rep->get_parent (); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1288
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1289 void set_parent (const graphics_handle& h)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1290 { rep->set_parent (h); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1291
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1292 bool is_hidden (void) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1293 { return rep->is_hidden (); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1294
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1295 void set_hidden (bool flag)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1296 { rep->set_hidden (flag); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1297
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1298 int get_id (void) const
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1299 { return rep->get_id (); }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1300
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1301 void set_id (int d)
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1302 { rep->set_id (d); }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1303
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1304 octave_value get (void) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1305 { return rep->get (); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1306
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1307 bool set (const octave_value& val)
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8061
diff changeset
1308 { return rep->set (val); }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1309
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1310 property& operator = (const octave_value& val)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1311 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1312 *rep = val;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1313 return *this;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1314 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1315
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1316 property& operator = (const property& p)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1317 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1318 if (rep && --rep->count <= 0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1319 delete rep;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1320
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1321 rep = p.rep;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1322 rep->count++;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1323
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1324 return *this;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1325 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1326
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1327 void add_listener (const octave_value& v, listener_mode mode = POSTSET)
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1328 { rep->add_listener (v, mode); }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1329
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
1330 void delete_listener (const octave_value& v = octave_value (),
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
1331 listener_mode mode = POSTSET)
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
1332 { rep->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
1333
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1334 void run_listeners (listener_mode mode = POSTSET)
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1335 { rep->run_listeners (mode); }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1336
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1337 OCTINTERP_API static
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1338 property create (const std::string& name, const graphics_handle& parent,
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1339 const caseless_str& type,
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1340 const octave_value_list& args);
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 property clone (void) const
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1343 { return property (rep->clone ()); }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1344
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1345 /*
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1346 const string_property& as_string_property (void) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1347 { return *(dynamic_cast<string_property*> (rep)); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1348
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1349 const radio_property& as_radio_property (void) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1350 { return *(dynamic_cast<radio_property*> (rep)); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1351
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1352 const color_property& as_color_property (void) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1353 { return *(dynamic_cast<color_property*> (rep)); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1354
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1355 const double_property& as_double_property (void) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1356 { return *(dynamic_cast<double_property*> (rep)); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1357
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1358 const bool_property& as_bool_property (void) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1359 { return *(dynamic_cast<bool_property*> (rep)); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1360
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1361 const handle_property& as_handle_property (void) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1362 { return *(dynamic_cast<handle_property*> (rep)); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1363 */
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1364
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1365 private:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1366 base_property *rep;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1367 };
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1368
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1369 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1370
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1371 class property_list
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1372 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1373 public:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1374 typedef std::map<std::string, octave_value> pval_map_type;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1375 typedef std::map<std::string, pval_map_type> plist_map_type;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1376
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1377 typedef pval_map_type::iterator pval_map_iterator;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1378 typedef pval_map_type::const_iterator pval_map_const_iterator;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1379
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1380 typedef plist_map_type::iterator plist_map_iterator;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1381 typedef plist_map_type::const_iterator plist_map_const_iterator;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1382
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1383 property_list (const plist_map_type& m = plist_map_type ())
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1384 : plist_map (m) { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1385
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1386 ~property_list (void) { }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1387
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1388 void set (const caseless_str& name, const octave_value& val);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1389
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1390 octave_value lookup (const caseless_str& name) const;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1391
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1392 plist_map_iterator begin (void) { return plist_map.begin (); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1393 plist_map_const_iterator begin (void) const { return plist_map.begin (); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1394
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1395 plist_map_iterator end (void) { return plist_map.end (); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1396 plist_map_const_iterator end (void) const { return plist_map.end (); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1397
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1398 plist_map_iterator find (const std::string& go_name)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1399 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1400 return plist_map.find (go_name);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1401 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1402
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1403 plist_map_const_iterator find (const std::string& go_name) const
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1404 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1405 return plist_map.find (go_name);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1406 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1407
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1408 Octave_map as_struct (const std::string& prefix_arg) const;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1409
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1410 private:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1411 plist_map_type plist_map;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1412 };
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1413
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1414 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1415
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1416 class graphics_backend;
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1417 class graphics_object;
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1418
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1419 class base_graphics_backend
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1420 {
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1421 public:
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1422 friend class graphics_backend;
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1423
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1424 public:
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1425 base_graphics_backend (const std::string& nm)
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1426 : name (nm), count (0) { }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1427
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1428 virtual ~base_graphics_backend (void) { }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1429
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1430 std::string get_name (void) const { return name; }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1431
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1432 virtual bool is_valid (void) const { return false; }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1433
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1434 virtual void redraw_figure (const graphics_object&) const
7826
68550ad9ee9c Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7824
diff changeset
1435 { gripe_invalid ("redraw_figure"); }
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1436
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1437 virtual void print_figure (const graphics_object&, const std::string&,
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1438 const std::string&, bool,
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1439 const std::string& = "") const
7826
68550ad9ee9c Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7824
diff changeset
1440 { gripe_invalid ("print_figure"); }
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1441
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1442 virtual Matrix get_canvas_size (const graphics_handle&) const
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1443 {
7826
68550ad9ee9c Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7824
diff changeset
1444 gripe_invalid ("get_canvas_size");
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1445 return Matrix (1, 2, 0.0);
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1446 }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1447
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
1448 virtual double get_screen_resolution (void) const
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
1449 {
7826
68550ad9ee9c Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7824
diff changeset
1450 gripe_invalid ("get_screen_resolution");
68550ad9ee9c Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7824
diff changeset
1451 return 72.0;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
1452 }
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7441
diff changeset
1453
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7441
diff changeset
1454 virtual Matrix get_screen_size (void) const
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7441
diff changeset
1455 {
7826
68550ad9ee9c Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7824
diff changeset
1456 gripe_invalid ("get_screen_size");
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7441
diff changeset
1457 return Matrix (1, 2, 0.0);
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7441
diff changeset
1458 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
1459
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1460 // Called when graphics object using this backend changes it's property.
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1461 virtual void property_changed (const graphics_object&, int)
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1462 { gripe_invalid ("property_changed"); }
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1463
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1464 void property_changed (const graphics_handle&, int);
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1465
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1466 // Called when new object using this backend is created.
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1467 virtual void object_created (const graphics_object&)
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1468 { gripe_invalid ("object_created"); }
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1469
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1470 void object_created (const graphics_handle&);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1471
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1472 // Called when object using this backend is destroyed.
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1473 virtual void object_destroyed (const graphics_object&)
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1474 { gripe_invalid ("object_destroyed"); }
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1475
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1476 void object_destroyed (const graphics_handle&);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1477
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1478 private:
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1479 std::string name;
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1480 int count;
7826
68550ad9ee9c Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7824
diff changeset
1481
68550ad9ee9c Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7824
diff changeset
1482 private:
68550ad9ee9c Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7824
diff changeset
1483 void gripe_invalid (const std::string& fname) const
68550ad9ee9c Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7824
diff changeset
1484 {
68550ad9ee9c Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7824
diff changeset
1485 if (! is_valid ())
68550ad9ee9c Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7824
diff changeset
1486 error ("%s: invalid graphics backend", fname.c_str ());
68550ad9ee9c Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7824
diff changeset
1487 }
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1488 };
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1489
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1490 class graphics_backend
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1491 {
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1492 public:
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1493 graphics_backend (void)
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1494 : rep (new base_graphics_backend ("unknown"))
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1495 {
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1496 rep->count++;
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1497 }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1498
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1499 graphics_backend (base_graphics_backend* b)
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1500 : rep (b)
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1501 {
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1502 rep->count++;
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1503 }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1504
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1505 graphics_backend (const graphics_backend& b)
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1506 : rep (b.rep)
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1507 {
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1508 rep->count++;
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1509 }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1510
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1511 ~graphics_backend (void)
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1512 {
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1513 if (--rep->count == 0)
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1514 delete rep;
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1515 }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1516
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1517 graphics_backend& operator = (const graphics_backend& b)
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1518 {
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1519 if (rep != b.rep)
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1520 {
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1521 if (--rep->count == 0)
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1522 delete rep;
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1523
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1524 rep = b.rep;
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1525 rep->count++;
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1526 }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1527
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1528 return *this;
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1529 }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1530
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1531 operator bool (void) const { return rep->is_valid (); }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1532
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1533 std::string get_name (void) const { return rep->get_name (); }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1534
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1535 void redraw_figure (const graphics_object& go) const
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1536 { rep->redraw_figure (go); }
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1537
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1538 void print_figure (const graphics_object& go, const std::string& term,
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1539 const std::string& file, bool mono,
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1540 const std::string& debug_file = "") const
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1541 { rep->print_figure (go, term, file, mono, debug_file); }
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1542
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1543 Matrix get_canvas_size (const graphics_handle& fh) const
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1544 { return rep->get_canvas_size (fh); }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1545
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
1546 double get_screen_resolution (void) const
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
1547 { return rep->get_screen_resolution (); }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
1548
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7441
diff changeset
1549 Matrix get_screen_size (void) const
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7441
diff changeset
1550 { return rep->get_screen_size (); }
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7441
diff changeset
1551
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1552 // Notifies backend that object't property has changed.
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1553 void property_changed (const graphics_object& go, int id)
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1554 { rep->property_changed (go, id); }
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1555
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1556 void property_changed (const graphics_handle& h, int id)
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1557 { rep->property_changed (h, id); }
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1558
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1559 // Notifies backend that new object was created.
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1560 void object_created (const graphics_object& go)
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1561 { rep->object_created (go); }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1562
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1563 void object_created (const graphics_handle& h)
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1564 { rep->object_created (h); }
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1565
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1566 // Notifies backend that object was destroyed.
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1567 // This is called only for explicitly deleted object. Children are
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1568 // deleted implicitly and backend isn't notified.
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1569 void object_destroyed (const graphics_object& go)
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1570 { rep->object_destroyed (go); }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1571
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1572 void object_destroyed (const graphics_handle& h)
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1573 { rep->object_destroyed (h); }
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1574
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1575 OCTINTERP_API static graphics_backend default_backend (void);
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1576
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1577 static void register_backend (const graphics_backend& b)
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1578 { available_backends[b.get_name ()] = b; }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1579
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1580 static void unregister_backend (const std::string& name)
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1581 { available_backends.erase (name); }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1582
7439
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
1583 static graphics_backend find_backend (const std::string& name)
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
1584 {
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
1585 const_available_backends_iterator p = available_backends.find (name);
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
1586
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
1587 if (p != available_backends.end ())
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
1588 return p->second;
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
1589 else
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
1590 return default_backend ();
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
1591 }
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
1592
7835
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1593 static Cell available_backends_list (void)
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1594 {
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1595 Cell m (1 , available_backends.size ());
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1596 const_available_backends_iterator p;
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1597 int i;
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1598
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1599 for (i = 0,p = available_backends.begin (); p != available_backends.end (); p++,i++)
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1600 m(i) = p->first;
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1601
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1602 return m;
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1603 }
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1604
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1605 private:
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1606 base_graphics_backend *rep;
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1607
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7441
diff changeset
1608 static OCTINTERP_API std::map<std::string, graphics_backend> available_backends;
7439
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
1609
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
1610 typedef std::map<std::string, graphics_backend>::iterator available_backends_iterator;
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
1611 typedef std::map<std::string, graphics_backend>::const_iterator const_available_backends_iterator;
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1612 };
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1613
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1614 // ---------------------------------------------------------------------
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1615
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1616 class base_graphics_object;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1617
7365
f5e801eee0d1 [project @ 2008-01-13 06:33:32 by jwe]
jwe
parents: 7364
diff changeset
1618 class OCTINTERP_API base_properties
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1619 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1620 public:
7176
6525eb2fba0f [project @ 2007-11-14 20:42:06 by jwe]
jwe
parents: 7168
diff changeset
1621 base_properties (const std::string& ty = "unknown",
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1622 const graphics_handle& mh = graphics_handle (),
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1623 const graphics_handle& p = graphics_handle ());
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1624
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1625 virtual ~base_properties (void) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1626
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1627 virtual std::string graphics_object_name (void) const { return "unknonwn"; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1628
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1629 void mark_modified (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1630
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1631 void override_defaults (base_graphics_object& obj);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1632
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1633 // Look through DEFAULTS for properties with given CLASS_NAME, and
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1634 // apply them to the current object with set (virtual method).
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1635
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1636 void set_from_list (base_graphics_object& obj, property_list& defaults);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1637
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1638 void insert_property (const std::string& name, property p)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1639 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1640 p.set_name (name);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1641 p.set_parent (__myhandle__);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1642 all_props[name] = p;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1643 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1644
9188
9646be3a59c4 make changeset 1e5c11890f85 work
John W. Eaton <jwe@octave.org>
parents: 9185
diff changeset
1645 virtual void set (const caseless_str&, const octave_value&)
9646be3a59c4 make changeset 1e5c11890f85 work
John W. Eaton <jwe@octave.org>
parents: 9185
diff changeset
1646 {
9646be3a59c4 make changeset 1e5c11890f85 work
John W. Eaton <jwe@octave.org>
parents: 9185
diff changeset
1647 panic_impossible ();
9646be3a59c4 make changeset 1e5c11890f85 work
John W. Eaton <jwe@octave.org>
parents: 9185
diff changeset
1648 }
9646be3a59c4 make changeset 1e5c11890f85 work
John W. Eaton <jwe@octave.org>
parents: 9185
diff changeset
1649
9646be3a59c4 make changeset 1e5c11890f85 work
John W. Eaton <jwe@octave.org>
parents: 9185
diff changeset
1650 void set (const caseless_str& pname, const std::string& cname,
9646be3a59c4 make changeset 1e5c11890f85 work
John W. Eaton <jwe@octave.org>
parents: 9185
diff changeset
1651 const octave_value& val);
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9004
diff changeset
1652
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9004
diff changeset
1653 virtual octave_value get (const caseless_str& pname) const;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1654
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
1655 virtual octave_value get (bool all = false) const;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1656
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9004
diff changeset
1657 virtual property get_property (const caseless_str& pname);
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9004
diff changeset
1658
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9004
diff changeset
1659 bool has_property (const caseless_str& pname);
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1660
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1661 bool is_modified (void) const { return is___modified__ (); }
7251
ace1030cbe36 [project @ 2007-12-04 18:17:29 by jwe]
jwe
parents: 7240
diff changeset
1662
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1663 virtual void remove_child (const graphics_handle& h);
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1664
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1665 virtual void adopt (const graphics_handle& h)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1666 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1667 octave_idx_type n = children.numel ();
8210
a10397d26114 graphics.cc (base_graphics_properties::adopt): place new child at front of list, not end; make children a column vector instead of a row vector
John W. Eaton <jwe@octave.org>
parents: 8208
diff changeset
1668 children.resize (n+1, 1);
a10397d26114 graphics.cc (base_graphics_properties::adopt): place new child at front of list, not end; make children a column vector instead of a row vector
John W. Eaton <jwe@octave.org>
parents: 8208
diff changeset
1669 for (octave_idx_type i = n; i > 0; i--)
a10397d26114 graphics.cc (base_graphics_properties::adopt): place new child at front of list, not end; make children a column vector instead of a row vector
John W. Eaton <jwe@octave.org>
parents: 8208
diff changeset
1670 children(i) = children(i-1);
a10397d26114 graphics.cc (base_graphics_properties::adopt): place new child at front of list, not end; make children a column vector instead of a row vector
John W. Eaton <jwe@octave.org>
parents: 8208
diff changeset
1671 children(0) = h.value ();
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
1672 mark_modified ();
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1673 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1674
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1675 virtual graphics_backend get_backend (void) const;
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1676
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7524
diff changeset
1677 virtual Matrix get_boundingbox (bool /*internal*/ = false) const
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
1678 { return Matrix (1, 4, 0.0); }
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
1679
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
1680 virtual void 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
1681
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1682 virtual void add_listener (const caseless_str&, const octave_value&,
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1683 listener_mode = POSTSET);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1684
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
1685 virtual void delete_listener (const caseless_str&, const octave_value&,
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
1686 listener_mode = POSTSET);
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
1687
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1688 void set_tag (const octave_value& val) { tag = val; }
7176
6525eb2fba0f [project @ 2007-11-14 20:42:06 by jwe]
jwe
parents: 7168
diff changeset
1689
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1690 void set_parent (const octave_value& val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1691
8263
22c078fd926b make fltk backend figures work again
John W. Eaton <jwe@octave.org>
parents: 8257
diff changeset
1692 Matrix get_all_children (void) const { return children; }
22c078fd926b make fltk backend figures work again
John W. Eaton <jwe@octave.org>
parents: 8257
diff changeset
1693
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1694 void set_children (const octave_value& val);
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1695
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1696 void set_modified (const octave_value& val) { set___modified__ (val); }
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1697
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1698 void set___modified__ (const octave_value& val) { __modified__ = val; }
7366
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7365
diff changeset
1699
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1700 void reparent (const graphics_handle& new_parent) { parent = new_parent; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1701
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
1702 // Update data limits for AXIS_TYPE (xdata, ydata, etc.) in the parent
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
1703 // axes object.
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
1704
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1705 virtual void update_axis_limits (const std::string& axis_type) const;
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
1706
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1707 virtual void delete_children (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1708
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1709 static property_list::pval_map_type factory_defaults (void);
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
1710
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
1711 // FIXME -- these functions should be generated automatically by the
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
1712 // genprops.awk script.
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
1713 //
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
1714 // EMIT_BASE_PROPERTIES_GET_FUNCTIONS
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1715
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1716 virtual octave_value get_xlim (void) const { return octave_value (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1717 virtual octave_value get_ylim (void) const { return octave_value (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1718 virtual octave_value get_zlim (void) const { return octave_value (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1719 virtual octave_value get_clim (void) const { return octave_value (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1720 virtual octave_value get_alim (void) const { return octave_value (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1721
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1722 virtual bool is_xliminclude (void) const { return false; }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1723 virtual bool is_yliminclude (void) const { return false; }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1724 virtual bool is_zliminclude (void) const { return false; }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1725 virtual bool is_climinclude (void) const { return false; }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1726 virtual bool is_aliminclude (void) const { return false; }
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
1727
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
1728 bool is_handle_visible (void) const
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
1729 {
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
1730 return ! handlevisibility.is ("off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
1731 }
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9004
diff changeset
1732
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9004
diff changeset
1733 static std::map<std::string, std::set<std::string> > all_dynamic_properties;
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
1734
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9004
diff changeset
1735 static bool has_dynamic_property (const std::string& pname,
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9004
diff changeset
1736 const std::string& cname);
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9004
diff changeset
1737
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1738 protected:
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9004
diff changeset
1739 void set_dynamic (const caseless_str& pname, const std::string& cname,
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9004
diff changeset
1740 const octave_value& val);
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9004
diff changeset
1741
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9004
diff changeset
1742 octave_value get_dynamic (const caseless_str& pname) const;
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1743
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1744 octave_value get_dynamic (bool all = false) const;
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1745
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9004
diff changeset
1746 property get_property_dynamic (const caseless_str& pname);
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1747
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1748 BEGIN_BASE_PROPERTIES
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1749 // properties common to all objects
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1750 bool_property beingdeleted , "off"
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1751 radio_property busyaction , "{queue}|cancel"
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1752 callback_property buttondownfcn , Matrix ()
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8300
diff changeset
1753 // FIXME -- use a property class for children.
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
1754 Matrix children Gfs , Matrix ()
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1755 bool_property clipping , "on"
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1756 callback_property createfcn , Matrix ()
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1757 callback_property deletefcn , Matrix ()
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1758 radio_property handlevisibility , "{on}|callback|off"
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1759 bool_property hittest , "on"
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1760 bool_property interruptible , "on"
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1761 handle_property parent fs , p
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1762 bool_property selected , "off"
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1763 bool_property selectionhighlight , "on"
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1764 string_property tag s , ""
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1765 string_property type frs , ty
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1766 any_property userdata , Matrix ()
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1767 bool_property visible , "on"
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1768 // additional (octave-specific) properties
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1769 bool_property __modified__ s , "on"
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1770 graphics_handle __myhandle__ fhrs , mh
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8300
diff changeset
1771 // FIXME -- should this really be here?
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1772 handle_property uicontextmenu , graphics_handle ()
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1773 END_PROPERTIES
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1774
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1775 protected:
8052
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8023
diff changeset
1776 struct cmp_caseless_str
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8023
diff changeset
1777 {
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8023
diff changeset
1778 bool operator () (const caseless_str &a, const caseless_str &b) const
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8023
diff changeset
1779 {
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8023
diff changeset
1780 std::string a1 = a;
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8023
diff changeset
1781 std::transform (a1.begin (), a1.end (), a1.begin (), tolower);
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8023
diff changeset
1782 std::string b1 = b;
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8023
diff changeset
1783 std::transform (b1.begin (), b1.end (), b1.begin (), tolower);
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8023
diff changeset
1784
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8023
diff changeset
1785 return a1 < b1;
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8023
diff changeset
1786 }
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8023
diff changeset
1787 };
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8023
diff changeset
1788
961d4c52ffae Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents: 8023
diff changeset
1789 std::map<caseless_str, property, cmp_caseless_str> all_props;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1790
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1791 protected:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1792 void insert_static_property (const std::string& name, base_property& p)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1793 { insert_property (name, property (&p, true)); }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1794
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
1795 virtual void init (void) { }
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1796 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1797
7365
f5e801eee0d1 [project @ 2008-01-13 06:33:32 by jwe]
jwe
parents: 7364
diff changeset
1798 class OCTINTERP_API base_graphics_object
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1799 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1800 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1801 friend class graphics_object;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1802
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1803 base_graphics_object (void) : count (1) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1804
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1805 base_graphics_object (const base_graphics_object&) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1806
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1807 virtual ~base_graphics_object (void) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1808
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1809 virtual void mark_modified (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1810 {
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1811 if (valid_object ())
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1812 get_properties ().mark_modified ();
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1813 else
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1814 error ("base_graphics_object::mark_modified: invalid graphics object");
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1815 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1816
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1817 virtual void override_defaults (base_graphics_object& obj)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1818 {
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1819 if (valid_object ())
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1820 get_properties ().override_defaults (obj);
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1821 else
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1822 error ("base_graphics_object::override_defaults: invalid graphics object");
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1823 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1824
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1825 virtual void set_from_list (property_list& plist)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1826 {
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1827 if (valid_object ())
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1828 get_properties ().set_from_list (*this, plist);
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1829 else
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1830 error ("base_graphics_object::set_from_list: invalid graphics object");
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1831 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1832
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1833 virtual void set (const caseless_str& pname, const octave_value& pval)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1834 {
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1835 if (valid_object ())
9188
9646be3a59c4 make changeset 1e5c11890f85 work
John W. Eaton <jwe@octave.org>
parents: 9185
diff changeset
1836 get_properties ().set (pname, pval);
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1837 else
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1838 error ("base_graphics_object::set: invalid graphics object");
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1839 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1840
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1841 virtual void set_defaults (const std::string&)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1842 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1843 error ("base_graphics_object::set_defaults: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1844 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1845
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
1846 virtual octave_value get (bool all = false) const
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1847 {
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1848 if (valid_object ())
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1849 return get_properties ().get (all);
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1850 else
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1851 {
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1852 error ("base_graphics_object::get: invalid graphics object");
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1853 return octave_value ();
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1854 }
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1855 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1856
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1857 virtual octave_value get (const caseless_str& pname) const
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1858 {
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1859 if (valid_object ())
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1860 return get_properties ().get (pname);
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1861 else
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1862 {
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1863 error ("base_graphics_object::get: invalid graphics object");
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1864 return octave_value ();
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1865 }
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1866 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1867
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1868 virtual octave_value get_default (const caseless_str&) const;
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1869
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1870 virtual octave_value get_factory_default (const caseless_str&) const;
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1871
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1872 virtual octave_value get_defaults (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1873 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1874 error ("base_graphics_object::get_defaults: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1875 return octave_value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1876 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1877
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1878 virtual octave_value get_factory_defaults (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1879 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1880 error ("base_graphics_object::get_factory_defaults: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1881 return octave_value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1882 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1883
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1884 virtual graphics_handle get_parent (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1885 {
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1886 if (valid_object ())
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1887 return get_properties ().get_parent ();
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1888 else
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1889 {
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1890 error ("base_graphics_object::get_parent: invalid graphics object");
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1891 return graphics_handle ();
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1892 }
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1893 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1894
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
1895 graphics_handle get_handle (void) const
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
1896 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
1897 if (valid_object ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
1898 return get_properties ().get___myhandle__ ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
1899 else
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
1900 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
1901 error ("base_graphics_object::get_handle: invalid graphics object");
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
1902 return graphics_handle ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
1903 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
1904 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
1905
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1906 virtual void remove_child (const graphics_handle& h)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1907 {
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1908 if (valid_object ())
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1909 get_properties ().remove_child (h);
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1910 else
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1911 error ("base_graphics_object::remove_child: invalid graphics object");
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1912 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1913
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1914 virtual void adopt (const graphics_handle& h)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1915 {
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1916 if (valid_object ())
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1917 get_properties ().adopt (h);
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1918 else
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1919 error ("base_graphics_object::adopt: invalid graphics object");
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1920 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1921
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1922 virtual void reparent (const graphics_handle& np)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1923 {
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1924 if (valid_object ())
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1925 get_properties ().reparent (np);
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1926 else
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1927 error ("base_graphics_object::reparent: invalid graphics object");
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1928 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1929
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1930 virtual void defaults (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1931 {
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1932 if (valid_object ())
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1933 {
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1934 std::string msg = (type () + "::defaults");
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1935 gripe_not_implemented (msg.c_str ());
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1936 }
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1937 else
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1938 error ("base_graphics_object::default: invalid graphics object");
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1939 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1940
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1941 virtual base_properties& get_properties (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1942 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1943 static base_properties properties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1944 error ("base_graphics_object::get_properties: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1945 return properties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1946 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1947
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
1948 virtual const base_properties& get_properties (void) const
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
1949 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
1950 static base_properties properties;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
1951 error ("base_graphics_object::get_properties: invalid graphics object");
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
1952 return properties;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
1953 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
1954
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
1955 virtual void update_axis_limits (const std::string& axis_type);
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
1956
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1957 virtual bool valid_object (void) const { return false; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1958
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1959 virtual std::string type (void) const
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1960 {
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1961 return (valid_object () ? get_properties ().graphics_object_name ()
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1962 : "unknown");
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
1963 }
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1964
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1965 bool isa (const std::string& go_name) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1966 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1967 return type () == go_name;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1968 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1969
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1970 virtual graphics_backend get_backend (void) const
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1971 {
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1972 if (valid_object ())
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1973 return get_properties ().get_backend ();
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1974 else
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1975 {
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1976 error ("base_graphics_object::get_backend: invalid graphics object");
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1977 return graphics_backend ();
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1978 }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1979 }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
1980
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1981 virtual void add_property_listener (const std::string& nm,
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1982 const octave_value& v,
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1983 listener_mode mode = POSTSET)
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1984 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1985 if (valid_object ())
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1986 get_properties ().add_listener (nm, v, mode);
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1987 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1988
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
1989 virtual void delete_property_listener (const std::string& nm,
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
1990 const octave_value& v,
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
1991 listener_mode mode = POSTSET)
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
1992 {
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
1993 if (valid_object ())
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
1994 get_properties ().delete_listener (nm, v, mode);
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
1995 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
1996
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
1997 virtual void 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
1998
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1999 protected:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2000 // A reference count.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2001 int count;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2002 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2003
7365
f5e801eee0d1 [project @ 2008-01-13 06:33:32 by jwe]
jwe
parents: 7364
diff changeset
2004 class OCTINTERP_API graphics_object
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2005 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2006 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2007 graphics_object (void) : rep (new base_graphics_object ()) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2008
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2009 graphics_object (base_graphics_object *new_rep)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2010 : rep (new_rep) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2011
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2012 graphics_object (const graphics_object& obj)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2013 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2014 rep = obj.rep;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2015 rep->count++;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2016 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2017
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2018 graphics_object& operator = (const graphics_object& obj)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2019 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2020 if (rep != obj.rep)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2021 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2022 if (--rep->count == 0)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2023 delete rep;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2024
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2025 rep = obj.rep;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2026 rep->count++;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2027 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2028
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2029 return *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2030 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2031
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2032 ~graphics_object (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2033 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2034 if (--rep->count == 0)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2035 delete rep;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2036 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2037
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2038 void mark_modified (void) { rep->mark_modified (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2039
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2040 void override_defaults (base_graphics_object& obj)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2041 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2042 rep->override_defaults (obj);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2043 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2044
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2045 void set_from_list (property_list& plist) { rep->set_from_list (plist); }
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2046
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2047 void set (const caseless_str& name, const octave_value& val)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2048 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2049 rep->set (name, val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2050 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2051
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2052 void set (const octave_value_list& args);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2053
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2054 void set_defaults (const std::string& mode) { rep->set_defaults (mode); }
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2055
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
2056 octave_value get (bool all = false) const { return rep->get (all); }
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2057
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2058 octave_value get (const caseless_str& name) const
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2059 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2060 return name.compare ("default")
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2061 ? get_defaults ()
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2062 : (name.compare ("factory")
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2063 ? get_factory_defaults () : rep->get (name));
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2064 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2065
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2066 octave_value get_default (const caseless_str& name) const
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2067 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2068 return rep->get_default (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2069 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2070
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2071 octave_value get_factory_default (const caseless_str& name) const
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2072 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2073 return rep->get_factory_default (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2074 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2075
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2076 octave_value get_defaults (void) const { return rep->get_defaults (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2077
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2078 octave_value get_factory_defaults (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2079 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2080 return rep->get_factory_defaults ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2081 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2082
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2083 graphics_handle get_parent (void) const { return rep->get_parent (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2084
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
2085 graphics_handle get_handle (void) const { return rep->get_handle (); }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
2086
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2087 void remove_child (const graphics_handle& h) { rep->remove_child (h); }
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2088
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2089 void adopt (const graphics_handle& h) { rep->adopt (h); }
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2090
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2091 void reparent (const graphics_handle& h) { rep->reparent (h); }
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2092
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2093 void defaults (void) const { rep->defaults (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2094
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2095 bool isa (const std::string& go_name) const { return rep->isa (go_name); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2096
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2097 base_properties& get_properties (void) { return rep->get_properties (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2098
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2099 const base_properties& get_properties (void) const
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2100 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2101 return rep->get_properties ();
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2102 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2103
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2104 void update_axis_limits (const std::string& axis_type)
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2105 {
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2106 rep->update_axis_limits (axis_type);
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2107 }
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2108
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2109 bool valid_object (void) const { return rep->valid_object (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2110
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8102
diff changeset
2111 std::string type (void) const { return rep->type (); }
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8102
diff changeset
2112
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2113 operator bool (void) const { return rep->valid_object (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2114
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2115 // FIXME -- these functions should be generated automatically by the
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2116 // genprops.awk script.
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2117 //
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2118 // EMIT_GRAPHICS_OBJECT_GET_FUNCTIONS
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2119
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2120 octave_value get_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
2121 { return get_properties ().get_xlim (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2122
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2123 octave_value get_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
2124 { return get_properties ().get_ylim (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2125
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2126 octave_value get_zlim (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
2127 { return get_properties ().get_zlim (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2128
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2129 octave_value get_clim (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
2130 { return get_properties ().get_clim (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2131
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2132 octave_value get_alim (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
2133 { return get_properties ().get_alim (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2134
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2135 bool is_xliminclude (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
2136 { return get_properties ().is_xliminclude (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2137
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2138 bool is_yliminclude (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
2139 { return get_properties ().is_yliminclude (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2140
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2141 bool is_zliminclude (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
2142 { return get_properties ().is_zliminclude (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2143
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2144 bool is_climinclude (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
2145 { return get_properties ().is_climinclude (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2146
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2147 bool is_aliminclude (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
2148 { return get_properties ().is_aliminclude (); }
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
2149
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
2150 bool is_handle_visible (void) const
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
2151 { return get_properties ().is_handle_visible (); }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2152
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
2153 graphics_backend get_backend (void) const { return rep->get_backend (); }
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2154
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2155 void add_property_listener (const std::string& nm, const octave_value& v,
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2156 listener_mode mode = POSTSET)
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2157 { rep->add_property_listener (nm, v, mode); }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
2158
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2159 void delete_property_listener (const std::string& nm, const octave_value& v,
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2160 listener_mode mode = POSTSET)
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2161 { rep->delete_property_listener (nm, v, mode); }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2162
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2163 private:
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7408
diff changeset
2164 base_graphics_object *rep;
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2165 };
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2166
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2167 // ---------------------------------------------------------------------
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2168
7365
f5e801eee0d1 [project @ 2008-01-13 06:33:32 by jwe]
jwe
parents: 7364
diff changeset
2169 class OCTINTERP_API root_figure : public base_graphics_object
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2170 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2171 public:
7821
f79dcba526a8 Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7527
diff changeset
2172 class OCTINTERP_API properties : public base_properties
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2173 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2174 public:
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2175 void remove_child (const graphics_handle& h);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2176
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2177 // See the genprops.awk script for an explanation of the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2178 // properties declarations.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2179
8247
e41f420875db set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents: 8222
diff changeset
2180 BEGIN_PROPERTIES (root_figure, root)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2181 handle_property currentfigure S , graphics_handle ()
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7821
diff changeset
2182 handle_property callbackobject Sr , graphics_handle ()
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8465
diff changeset
2183 double_property screendepth r , default_screendepth ()
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8465
diff changeset
2184 array_property screensize r , default_screensize ()
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8465
diff changeset
2185 double_property screenpixelsperinch r , default_screenpixelsperinch ()
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8465
diff changeset
2186 radio_property units U , "inches|centimeters|normalized|points|{pixels}"
8070
3b53b25e2550 Add data sources and line series
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
2187 bool_property showhiddenhandles , "off"
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2188 END_PROPERTIES
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7821
diff changeset
2189
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7821
diff changeset
2190 private:
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7821
diff changeset
2191 std::list<graphics_handle> cbo_stack;
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2192 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2193
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2194 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2195 properties xproperties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2196
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2197 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2198
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2199 root_figure (void) : xproperties (0, graphics_handle ()), default_properties () { }
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2200
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2201 ~root_figure (void) { xproperties.delete_children (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2202
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2203 void mark_modified (void) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2204
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2205 void override_defaults (base_graphics_object& obj)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2206 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2207 // Now override with our defaults. If the default_properties
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2208 // list includes the properties for all defaults (line,
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2209 // surface, etc.) then we don't have to know the type of OBJ
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2210 // here, we just call its set function and let it decide which
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2211 // properties from the list to use.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2212 obj.set_from_list (default_properties);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2213 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2214
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2215 void set (const caseless_str& name, const octave_value& value)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2216 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2217 if (name.compare ("default", 7))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2218 // strip "default", pass rest to function that will
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2219 // parse the remainder and add the element to the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2220 // default_properties map.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2221 default_properties.set (name.substr (7), value);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2222 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2223 xproperties.set (name, value);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2224 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2225
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2226 octave_value get (const caseless_str& name) const
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2227 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2228 octave_value retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2229
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2230 if (name.compare ("default", 7))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2231 return get_default (name.substr (7));
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2232 else if (name.compare ("factory", 7))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2233 return get_factory_default (name.substr (7));
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2234 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2235 retval = xproperties.get (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2236
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2237 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2238 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2239
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2240 octave_value get_default (const caseless_str& name) const
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2241 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2242 octave_value retval = default_properties.lookup (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2243
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2244 if (retval.is_undefined ())
7847
40b16e04172a Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7846
diff changeset
2245 {
40b16e04172a Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7846
diff changeset
2246 // no default property found, use factory default
40b16e04172a Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7846
diff changeset
2247 retval = factory_properties.lookup (name);
40b16e04172a Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7846
diff changeset
2248
40b16e04172a Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7846
diff changeset
2249 if (retval.is_undefined ())
40b16e04172a Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7846
diff changeset
2250 error ("get: invalid default property `%s'", name.c_str ());
40b16e04172a Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7846
diff changeset
2251 }
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2252
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2253 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2254 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2255
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2256 octave_value get_factory_default (const caseless_str& name) const
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2257 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2258 octave_value retval = factory_properties.lookup (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2259
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2260 if (retval.is_undefined ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2261 error ("get: invalid factory default property `%s'", name.c_str ());
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2262
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2263 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2264 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2265
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2266 octave_value get_defaults (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2267 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2268 return default_properties.as_struct ("default");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2269 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2270
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2271 octave_value get_factory_defaults (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2272 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2273 return factory_properties.as_struct ("factory");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2274 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2275
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2276 base_properties& get_properties (void) { return xproperties; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2277
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2278 const base_properties& get_properties (void) const { return xproperties; }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2279
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2280 bool valid_object (void) const { return true; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2281
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2282 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2283 property_list default_properties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2284
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2285 static property_list factory_properties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2286
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2287 static property_list::plist_map_type init_factory_properties (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2288 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2289
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2290 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2291
7365
f5e801eee0d1 [project @ 2008-01-13 06:33:32 by jwe]
jwe
parents: 7364
diff changeset
2292 class OCTINTERP_API figure : public base_graphics_object
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2293 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2294 public:
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7441
diff changeset
2295 class OCTINTERP_API properties : public base_properties
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2296 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2297 public:
8266
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2298 void remove_child (const graphics_handle& h);
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2299
7366
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7365
diff changeset
2300 void set_visible (const octave_value& val);
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2301
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2302 graphics_backend get_backend (void) const
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2303 {
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2304 if (! backend)
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2305 backend = graphics_backend::default_backend ();
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2306
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2307 return backend;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2308 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2309
7439
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2310 void set_backend (const graphics_backend& b)
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2311 {
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2312 if (backend)
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2313 backend.object_destroyed (__myhandle__);
7439
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2314 backend = b;
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2315 __backend__ = b.get_name ();
7847
40b16e04172a Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7846
diff changeset
2316 __plot_stream__ = Matrix ();
7439
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2317 mark_modified ();
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2318 }
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2319
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2320 void set___backend__ (const octave_value& val)
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2321 {
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2322 if (! error_state)
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2323 {
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2324 if (val.is_string ())
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2325 {
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2326 std::string nm = val.string_value ();
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2327 graphics_backend b = graphics_backend::find_backend (nm);
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2328 if (b.get_name () != nm)
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2329 {
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7865
diff changeset
2330 error ("set___backend__: invalid backend");
7439
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2331 }
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2332 else
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2333 {
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2334 set_backend (b);
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2335 mark_modified ();
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2336 }
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2337 }
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2338 else
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7865
diff changeset
2339 error ("set___backend__ must be a string");
7439
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2340 }
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2341 }
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2342
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2343 Matrix get_boundingbox (bool internal = false) const;
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7441
diff changeset
2344
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2345 void set_boundingbox (const Matrix& bb);
7826
68550ad9ee9c Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7824
diff changeset
2346
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2347 std::string get_title (void) const;
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2348
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2349 // See the genprops.awk script for an explanation of the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2350 // properties declarations.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2351
8247
e41f420875db set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents: 8222
diff changeset
2352 BEGIN_PROPERTIES (figure)
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
2353 any_property __plot_stream__ h , Matrix ()
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
2354 bool_property __enhanced__ h , "on"
7405
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2355 radio_property nextplot , "new|{add}|replace_children|replace"
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2356 callback_property closerequestfcn , "closereq"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2357 handle_property currentaxes S , graphics_handle ()
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2358 array_property colormap , jet_colormap ()
7405
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2359 radio_property paperorientation , "{portrait}|landscape|rotated"
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2360 color_property color , color_values (1, 1, 1)
7405
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2361 array_property alphamap , Matrix (64, 1, 1)
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2362 string_property currentcharacter r , ""
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2363 handle_property currentobject r , graphics_handle ()
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2364 array_property current_point r , Matrix (2, 1, 0)
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2365 bool_property dockcontrols , "off"
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2366 bool_property doublebuffer , "on"
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2367 string_property filename r , ""
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2368 bool_property integerhandle , "on"
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2369 bool_property inverthardcopy , "off"
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2370 callback_property keypressfcn , Matrix ()
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2371 callback_property keyreleasefcn , Matrix ()
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2372 radio_property menubar , "none|{figure}"
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2373 double_property mincolormap , 64
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2374 string_property name , ""
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2375 bool_property numbertitle , "on"
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2376 radio_property paperunits , "{inches}|centimeters|normalized|points"
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
2377 array_property paperposition , default_figure_paperposition ()
7405
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2378 radio_property paperpositionmode , "auto|{manual}"
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
2379 array_property papersize , default_figure_papersize ()
8355
a8019b9644ca graphics.h.in: Add props screensize & screenpixelsperinch.
Ben Abbott <bpabbott@mac.com>
parents: 8333
diff changeset
2380 radio_property papertype , "{usletter}|uslegal|a0|a1|a2|a3|a4|a5|b0|b1|b2|b3|b4|b5|arch-a|arch-b|arch-c|arch-d|arch-e|a|b|c|d|e|tabloid|<custom>"
7405
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2381 radio_property pointer , "crosshair|fullcrosshair|{arrow}|ibeam|watch|topl|topr|botl|botr|left|top|right|bottom|circle|cross|fleur|custom|hand"
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2382 array_property pointershapecdata , Matrix (16, 16, 0)
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2383 array_property pointershapehotspot , Matrix (1, 2, 0)
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2384 array_property position S , default_figure_position ()
7405
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2385 radio_property renderer , "{painters}|zbuffer|opengl|none"
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2386 radio_property renderermode , "{auto}|manual"
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2387 bool_property resize , "on"
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2388 callback_property resizefcn , Matrix ()
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2389 radio_property selectiontype , "{normal}|open|alt|extend"
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2390 radio_property toolbar , "none|{auto}|figure"
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2391 radio_property units , "inches|centimeters|normalized|points|{pixels}|characters"
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2392 callback_property windowbuttondownfcn , Matrix ()
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2393 callback_property windowbuttonmotionfcn , Matrix ()
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2394 callback_property windowbuttonupfcn , Matrix ()
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2395 callback_property windowbuttonwheelfcn , Matrix ()
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2396 radio_property windowstyle , "{normal}|modal|docked"
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2397 string_property wvisual , ""
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2398 radio_property wvisualmode , "{auto}|manual"
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2399 string_property xdisplay , ""
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2400 string_property xvisual , ""
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2401 radio_property xvisualmode , "{auto}|manual"
b0734cf13ad4 [project @ 2008-01-19 07:33:00 by jwe]
jwe
parents: 7404
diff changeset
2402 callback_property buttondownfcn , Matrix ()
7439
1867156fc552 [project @ 2008-02-02 07:56:53 by jwe]
jwe
parents: 7435
diff changeset
2403 string_property __backend__ s , "gnuplot"
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2404 END_PROPERTIES
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2405
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2406 protected:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2407 void init (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2408 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2409 colormap.add_constraint (dim_vector (-1, 3));
7406
e9b2e44f9341 [project @ 2008-01-19 07:37:56 by jwe]
jwe
parents: 7405
diff changeset
2410 alphamap.add_constraint (dim_vector (-1, 1));
e9b2e44f9341 [project @ 2008-01-19 07:37:56 by jwe]
jwe
parents: 7405
diff changeset
2411 paperposition.add_constraint (dim_vector (1, 4));
e9b2e44f9341 [project @ 2008-01-19 07:37:56 by jwe]
jwe
parents: 7405
diff changeset
2412 pointershapecdata.add_constraint (dim_vector (16, 16));
e9b2e44f9341 [project @ 2008-01-19 07:37:56 by jwe]
jwe
parents: 7405
diff changeset
2413 pointershapehotspot.add_constraint (dim_vector (1, 2));
e9b2e44f9341 [project @ 2008-01-19 07:37:56 by jwe]
jwe
parents: 7405
diff changeset
2414 position.add_constraint (dim_vector (1, 4));
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2415 }
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2416
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2417 private:
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7406
diff changeset
2418 mutable graphics_backend backend;
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2419 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2420
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2421 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2422 properties xproperties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2423
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2424 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2425 figure (const graphics_handle& mh, const graphics_handle& p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2426 : base_graphics_object (), xproperties (mh, p), default_properties ()
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2427 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2428 xproperties.override_defaults (*this);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2429 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2430
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2431 ~figure (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2432 {
7386
22815fa9c368 [project @ 2008-01-15 21:28:43 by jwe]
jwe
parents: 7384
diff changeset
2433 xproperties.delete_children ();
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2434 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2435
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2436 void override_defaults (base_graphics_object& obj)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2437 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2438 // Allow parent (root figure) to override first (properties knows how
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2439 // to find the parent object).
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2440 xproperties.override_defaults (obj);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2441
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2442 // Now override with our defaults. If the default_properties
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2443 // list includes the properties for all defaults (line,
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2444 // surface, etc.) then we don't have to know the type of OBJ
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2445 // here, we just call its set function and let it decide which
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2446 // properties from the list to use.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2447 obj.set_from_list (default_properties);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2448 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2449
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2450 void set (const caseless_str& name, const octave_value& value)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2451 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2452 if (name.compare ("default", 7))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2453 // strip "default", pass rest to function that will
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2454 // parse the remainder and add the element to the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2455 // default_properties map.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2456 default_properties.set (name.substr (7), value);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2457 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2458 xproperties.set (name, value);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2459 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2460
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2461 octave_value get (const caseless_str& name) const
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2462 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2463 octave_value retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2464
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2465 if (name.compare ("default", 7))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2466 retval = get_default (name.substr (7));
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2467 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2468 retval = xproperties.get (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2469
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2470 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2471 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2472
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2473 octave_value get_default (const caseless_str& name) const;
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2474
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2475 octave_value get_defaults (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2476 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2477 return default_properties.as_struct ("default");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2478 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2479
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2480 base_properties& get_properties (void) { return xproperties; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2481
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2482 const base_properties& get_properties (void) const { return xproperties; }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2483
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2484 bool valid_object (void) const { return true; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2485
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2486 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2487 property_list default_properties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2488 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2489
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2490 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2491
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2492 class OCTINTERP_API graphics_xform
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2493 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2494 public:
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2495 graphics_xform (void)
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2496 : xform (xform_eye ()), xform_inv (xform_eye ())
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2497 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2498 sx = sy = sz = "linear";
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2499 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2500
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2501 graphics_xform (const Matrix& xm, const Matrix& xim,
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2502 const scaler& x, const scaler& y, const scaler& z)
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2503 : xform (xm), xform_inv (xim), sx (x), sy (y), sz (z) { }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2504
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2505 graphics_xform (const graphics_xform& g)
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2506 : xform (g.xform), xform_inv (g.xform_inv), sx (g.sx),
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2507 sy (g.sy), sz (g.sz) { }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2508
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2509 ~graphics_xform (void) { }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2510
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2511 graphics_xform& operator = (const graphics_xform& g)
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2512 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2513 xform = g.xform;
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2514 xform_inv = g.xform_inv;
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2515 sx = g.sx;
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2516 sy = g.sy;
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2517 sz = g.sz;
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2518
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2519 return *this;
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2520 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2521
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2522 static ColumnVector xform_vector (double x, double y, double z);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2523
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2524 static Matrix xform_eye (void);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2525
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2526 ColumnVector transform (double x, double y, double z,
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2527 bool scale = true) const;
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2528
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2529 ColumnVector untransform (double x, double y, double z,
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2530 bool scale = true) const;
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2531
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2532 Matrix xscale (const Matrix& m) const { return sx.scale (m); }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2533 Matrix yscale (const Matrix& m) const { return sy.scale (m); }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2534 Matrix zscale (const Matrix& m) const { return sz.scale (m); }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2535
7832
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2536 Matrix scale (const Matrix& m) const
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2537 {
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2538 bool has_z = (m.columns () > 2);
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2539
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2540 if (sx.is_linear () && sy.is_linear ()
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2541 && (! has_z || sz.is_linear ()))
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2542 return m;
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2543
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2544 Matrix retval (m.dims ());
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2545
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2546 int r = m.rows ();
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2547
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2548 for (int i = 0; i < r; i++)
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2549 {
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2550 retval(i,0) = sx.scale (m(i,0));
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2551 retval(i,1) = sy.scale (m(i,1));
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2552 if (has_z)
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2553 retval(i,2) = sz.scale (m(i,2));
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2554 }
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2555
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2556 return retval;
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2557 }
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
2558
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2559 private:
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2560 Matrix xform;
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2561 Matrix xform_inv;
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2562 scaler sx, sy, sz;
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2563 };
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2564
7365
f5e801eee0d1 [project @ 2008-01-13 06:33:32 by jwe]
jwe
parents: 7364
diff changeset
2565 class OCTINTERP_API axes : public base_graphics_object
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2566 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2567 public:
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7441
diff changeset
2568 class OCTINTERP_API properties : public base_properties
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2569 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2570 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2571 void set_defaults (base_graphics_object& obj, const std::string& mode);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2572
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2573 void remove_child (const graphics_handle& h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2574
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2575 const scaler& get_x_scaler (void) const { return sx; }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2576 const scaler& get_y_scaler (void) const { return sy; }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2577 const scaler& get_z_scaler (void) const { return sz; }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2578
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
2579 Matrix get_boundingbox (bool internal = false) const;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2580
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2581 void 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
2582 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2583 if (units_is ("normalized"))
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2584 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2585 update_transform ();
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2586 base_properties::update_boundingbox ();
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2587 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2588 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
2589
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2590 void update_camera (void);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2591 void update_aspectratios (void);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2592 void update_transform (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2593 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2594 update_aspectratios ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2595 update_camera ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2596 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2597
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2598 graphics_xform get_transform (void) const
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2599 { return graphics_xform (x_render, x_render_inv, sx, sy, sz); }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2600
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2601 Matrix get_transform_matrix (void) const { return x_render; }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2602 Matrix get_inverse_transform_matrix (void) const { return x_render_inv; }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2603 Matrix get_opengl_matrix_1 (void) const { return x_gl_mat1; }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2604 Matrix get_opengl_matrix_2 (void) const { return x_gl_mat2; }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2605 Matrix get_transform_zlim (void) const { return x_zlim; }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
2606
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
2607 ColumnVector pixel2coord (double px, double py) const
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7854
diff changeset
2608 { return get_transform ().untransform (px, py, (x_zlim(0)+x_zlim(1))/2); }
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
2609
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
2610 ColumnVector coord2pixel (double x, double y, double z) const
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
2611 { return get_transform ().transform (x, y, z); }
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
2612
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7854
diff changeset
2613 void zoom (const Matrix& xl, const Matrix& yl);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7854
diff changeset
2614 void unzoom (void);
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7854
diff changeset
2615 void clear_zoom_stack (void);
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7836
diff changeset
2616
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2617 private:
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2618 scaler sx, sy, sz;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2619 Matrix x_render, x_render_inv;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2620 Matrix x_gl_mat1, x_gl_mat2;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2621 Matrix x_zlim;
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7854
diff changeset
2622 std::list<octave_value> zoom_stack;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2623
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
2624 void set_text_child (handle_property& h, const std::string& who,
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
2625 const octave_value& v);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
2626
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8102
diff changeset
2627 void delete_text_child (handle_property& h);
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8102
diff changeset
2628
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2629 // See the genprops.awk script for an explanation of the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2630 // properties declarations.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2631
8222
11badf6c9e9f __go_draw_axes__.m: Support axes interpreter poperty for tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 8210
diff changeset
2632 // properties which are not in matlab: interpreter
11badf6c9e9f __go_draw_axes__.m: Support axes interpreter poperty for tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 8210
diff changeset
2633
8247
e41f420875db set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents: 8222
diff changeset
2634 BEGIN_PROPERTIES (axes)
7860
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7857
diff changeset
2635 array_property position u , default_axes_position ()
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2636 bool_property box , "on"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2637 bool_property key , "off"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2638 bool_property keybox , "off"
8291
53f35799b235 Add support for left/right argument to the legend function
David Bateman <dbateman@free.fr>
parents: 8266
diff changeset
2639 bool_property keyreverse , "off"
7902
c51ae36fcbce graphics.h.in (axes::properties::keypos): Declare as any_property instead of double_property
John W. Eaton <jwe@octave.org>
parents: 7870
diff changeset
2640 any_property keypos , 1
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2641 array_property colororder , default_colororder ()
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2642 array_property dataaspectratio m , Matrix (1, 3, 1.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2643 radio_property dataaspectratiomode , "{auto}|manual"
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
2644 radio_property layer , "{bottom}|top"
7523
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
2645 row_vector_property xlim mu , default_lim ()
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
2646 row_vector_property ylim mu , default_lim ()
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
2647 row_vector_property zlim mu , default_lim ()
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
2648 row_vector_property clim m , default_lim ()
f2000f1971ab new row_vector_property class
John W. Eaton <jwe@octave.org>
parents: 7471
diff changeset
2649 row_vector_property alim m , default_lim ()
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2650 radio_property xlimmode al , "{auto}|manual"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2651 radio_property ylimmode al , "{auto}|manual"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2652 radio_property zlimmode al , "{auto}|manual"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2653 radio_property climmode al , "{auto}|manual"
7403
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2654 radio_property alimmode , "{auto}|manual"
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
2655 handle_property xlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false)
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
2656 handle_property ylabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false)
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
2657 handle_property zlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false)
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
2658 handle_property title SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2659 bool_property xgrid , "off"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2660 bool_property ygrid , "off"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2661 bool_property zgrid , "off"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2662 bool_property xminorgrid , "off"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2663 bool_property yminorgrid , "off"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2664 bool_property zminorgrid , "off"
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
2665 row_vector_property xtick m , default_axes_tick ()
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
2666 row_vector_property ytick m , default_axes_tick ()
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
2667 row_vector_property ztick m , default_axes_tick ()
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2668 radio_property xtickmode , "{auto}|manual"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2669 radio_property ytickmode , "{auto}|manual"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2670 radio_property ztickmode , "{auto}|manual"
7403
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2671 bool_property xminortick , "off"
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2672 bool_property yminortick , "off"
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2673 bool_property zminortick , "off"
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8300
diff changeset
2674 // FIXME -- should be kind of string array.
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2675 any_property xticklabel m , ""
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2676 any_property yticklabel m , ""
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2677 any_property zticklabel m , ""
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2678 radio_property xticklabelmode , "{auto}|manual"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2679 radio_property yticklabelmode , "{auto}|manual"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2680 radio_property zticklabelmode , "{auto}|manual"
8222
11badf6c9e9f __go_draw_axes__.m: Support axes interpreter poperty for tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 8210
diff changeset
2681 radio_property interpreter , "tex|{none}|latex"
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
2682 color_property color , color_property (color_values (1, 1, 1), radio_values ("none"))
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2683 color_property xcolor , color_values (0, 0, 0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2684 color_property ycolor , color_values (0, 0, 0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2685 color_property zcolor , color_values (0, 0, 0)
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2686 radio_property xscale alu , "{linear}|log"
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2687 radio_property yscale alu , "{linear}|log"
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2688 radio_property zscale alu , "{linear}|log"
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2689 radio_property xdir u , "{normal}|reverse"
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2690 radio_property ydir u , "{normal}|reverse"
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2691 radio_property zdir u , "{normal}|reverse"
7365
f5e801eee0d1 [project @ 2008-01-13 06:33:32 by jwe]
jwe
parents: 7364
diff changeset
2692 radio_property yaxislocation , "{left}|right|zero"
f5e801eee0d1 [project @ 2008-01-13 06:33:32 by jwe]
jwe
parents: 7364
diff changeset
2693 radio_property xaxislocation , "{bottom}|top|zero"
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2694 array_property view u , Matrix ()
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2695 radio_property nextplot , "add|replace_children|{replace}"
7860
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7857
diff changeset
2696 array_property outerposition u , default_axes_outerposition ()
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
2697 radio_property activepositionproperty , "{outerposition}|position"
7403
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2698 color_property ambientlightcolor , color_values (1, 1, 1)
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2699 array_property cameraposition m , Matrix (1, 3, 0.0)
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2700 array_property cameratarget m , Matrix (1, 3, 0.0)
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2701 array_property cameraupvector m , Matrix ()
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2702 double_property cameraviewangle m , 10.0
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2703 radio_property camerapositionmode , "{auto}|manual"
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2704 radio_property cameratargetmode , "{auto}|manual"
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2705 radio_property cameraupvectormode , "{auto}|manual"
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2706 radio_property cameraviewanglemode , "{auto}|manual"
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2707 array_property currentpoint , Matrix (2, 3, 0.0)
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2708 radio_property drawmode , "{normal}|fast"
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2709 radio_property fontangle , "{normal}|italic|oblique"
8944
cb0e9facc342 make default fontname * instead of Helvetica
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
2710 string_property fontname , OCTAVE_DEFAULT_FONTNAME
7403
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2711 double_property fontsize , 12
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2712 radio_property fontunits , "{points}|normalized|inches|centimeters|pixels"
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2713 radio_property fontweight , "{normal}|light|demi|bold"
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7441
diff changeset
2714 radio_property gridlinestyle , "-|--|{:}|-.|none"
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8300
diff changeset
2715 // FIXME -- should be kind of string array.
7403
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2716 string_property linestyleorder , "-"
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2717 double_property linewidth , 0.5
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7441
diff changeset
2718 radio_property minorgridlinestyle , "-|--|{:}|-.|none"
7403
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2719 array_property plotboxaspectratio m , Matrix (1, 3, 1.0)
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2720 radio_property plotboxaspectratiomode , "{auto}|manual"
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2721 radio_property projection , "{orthographic}|perpective"
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2722 radio_property tickdir m , "{in}|out"
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2723 radio_property tickdirmode , "{auto}|manual"
8740
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8599
diff changeset
2724 array_property ticklength , default_axes_ticklength ()
7403
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2725 array_property tightinset r , Matrix (1, 4, 0.0)
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8300
diff changeset
2726 // FIXME -- uicontextmenu should be moved here.
7403
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2727 radio_property units , "{normalized}|inches|centimeters|points|pixels|characters"
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2728 // hidden properties for transformation computation
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2729 array_property x_viewtransform h , Matrix (4, 4, 0.0)
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2730 array_property x_projectiontransform h , Matrix (4, 4, 0.0)
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2731 array_property x_viewporttransform h , Matrix (4, 4, 0.0)
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2732 array_property x_normrendertransform h , Matrix (4, 4, 0.0)
135c13496faf [project @ 2008-01-19 06:06:46 by jwe]
jwe
parents: 7395
diff changeset
2733 array_property x_rendertransform h , Matrix (4, 4, 0.0)
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2734 END_PROPERTIES
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2735
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2736 protected:
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
2737 void init (void);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2738
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2739 private:
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2740 void update_xscale (void) { sx = get_xscale (); }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2741 void update_yscale (void) { sy = get_yscale (); }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2742 void update_zscale (void) { sz = get_zscale (); }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2743
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2744 void update_view (void) { update_camera (); }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2745
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2746 void update_xdir (void) { update_camera (); }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2747 void update_ydir (void) { update_camera (); }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
2748 void update_zdir (void) { update_camera (); }
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
2749
7860
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7857
diff changeset
2750 void sync_positions (void);
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7857
diff changeset
2751 void update_outerposition (void) { sync_positions ();}
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7857
diff changeset
2752 void update_position (void) { sync_positions (); }
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7857
diff changeset
2753
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7826
diff changeset
2754 double calc_tick_sep (double minval, double maxval);
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
2755 void calc_ticks_and_lims (array_property& lims, array_property& ticks, bool limmode_is_auto, bool is_logscale);
7854
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2756 void fix_limits (array_property& lims)
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2757 {
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2758 if (lims.get ().is_empty ())
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2759 return;
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2760
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2761 Matrix l = lims.get ().matrix_value ();
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2762 if (l(0) > l(1))
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2763 {
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2764 l(0) = 0;
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2765 l(1) = 1;
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2766 lims = l;
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2767 }
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2768 else if (l(0) == l(1))
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2769 {
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2770 l(0) -= 0.5;
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2771 l(1) += 0.5;
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2772 lims = l;
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2773 }
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2774 }
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
2775
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
2776 public:
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7826
diff changeset
2777 Matrix get_axis_limits (double xmin, double xmax, double min_pos, bool logscale);
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7854
diff changeset
2778
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7854
diff changeset
2779 void update_xlim (bool do_clr_zoom = true)
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
2780 {
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
2781 if (xtickmode.is ("auto"))
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
2782 calc_ticks_and_lims (xlim, xtick, xlimmode.is ("auto"), xscale.is ("log"));
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7854
diff changeset
2783
7854
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2784 fix_limits (xlim);
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7854
diff changeset
2785
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7854
diff changeset
2786 if (do_clr_zoom)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7854
diff changeset
2787 zoom_stack.clear ();
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
2788 }
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
2789
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7854
diff changeset
2790 void update_ylim (bool do_clr_zoom = true)
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
2791 {
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
2792 if (ytickmode.is ("auto"))
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
2793 calc_ticks_and_lims (ylim, ytick, ylimmode.is ("auto"), yscale.is ("log"));
7854
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2794
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2795 fix_limits (ylim);
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7854
diff changeset
2796
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7854
diff changeset
2797 if (do_clr_zoom)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7854
diff changeset
2798 zoom_stack.clear ();
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
2799 }
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
2800
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
2801 void update_zlim (void)
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
2802 {
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
2803 if (ztickmode.is ("auto"))
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
2804 calc_ticks_and_lims (zlim, ztick, zlimmode.is ("auto"), zscale.is ("log"));
7854
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2805
228858e69bd1 added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7850
diff changeset
2806 fix_limits (zlim);
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7854
diff changeset
2807
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7854
diff changeset
2808 zoom_stack.clear ();
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
2809 }
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
2810
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2811 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2812
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2813 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2814 properties xproperties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2815
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2816 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2817 axes (const graphics_handle& mh, const graphics_handle& p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2818 : base_graphics_object (), xproperties (mh, p), default_properties ()
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2819 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2820 xproperties.override_defaults (*this);
7830
61aee739a4da Make sure to initialize axes xform data.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
2821 xproperties.update_transform ();
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2822 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2823
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2824 ~axes (void) { xproperties.delete_children (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2825
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2826 void override_defaults (base_graphics_object& obj)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2827 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2828 // Allow parent (figure) to override first (properties knows how
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2829 // to find the parent object).
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2830 xproperties.override_defaults (obj);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2831
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2832 // Now override with our defaults. If the default_properties
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2833 // list includes the properties for all defaults (line,
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2834 // surface, etc.) then we don't have to know the type of OBJ
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2835 // here, we just call its set function and let it decide which
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2836 // properties from the list to use.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2837 obj.set_from_list (default_properties);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2838 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2839
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2840 void set (const caseless_str& name, const octave_value& value)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2841 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2842 if (name.compare ("default", 7))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2843 // strip "default", pass rest to function that will
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2844 // parse the remainder and add the element to the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2845 // default_properties map.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2846 default_properties.set (name.substr (7), value);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2847 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2848 xproperties.set (name, value);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2849 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2850
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2851 void set_defaults (const std::string& mode)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2852 {
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
2853 remove_all_listeners ();
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2854 xproperties.set_defaults (*this, mode);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2855 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2856
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2857 octave_value get (const caseless_str& name) const
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2858 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2859 octave_value retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2860
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2861 // FIXME -- finish this.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2862 if (name.compare ("default", 7))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2863 retval = get_default (name.substr (7));
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2864 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2865 retval = xproperties.get (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2866
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2867 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2868 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2869
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2870 octave_value get_default (const caseless_str& name) const;
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2871
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2872 octave_value get_defaults (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2873 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2874 return default_properties.as_struct ("default");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2875 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2876
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2877 base_properties& get_properties (void) { return xproperties; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2878
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2879 const base_properties& get_properties (void) const { return xproperties; }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2880
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2881 void update_axis_limits (const std::string& axis_type);
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
2882
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2883 bool valid_object (void) const { return true; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2884
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2885 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2886 property_list default_properties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2887 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2888
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2889 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2890
7365
f5e801eee0d1 [project @ 2008-01-13 06:33:32 by jwe]
jwe
parents: 7364
diff changeset
2891 class OCTINTERP_API line : public base_graphics_object
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2892 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2893 public:
7821
f79dcba526a8 Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7527
diff changeset
2894 class OCTINTERP_API properties : public base_properties
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2895 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2896 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2897 // See the genprops.awk script for an explanation of the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2898 // properties declarations.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2899
7366
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7365
diff changeset
2900 // properties which are not in matlab:
7384
47c919254791 [project @ 2008-01-15 20:27:01 by jwe]
jwe
parents: 7380
diff changeset
2901 // ldata, udata, xldata, xudata, keylabel, interpreter
7366
2a2115742cb5 [project @ 2008-01-13 06:46:39 by jwe]
jwe
parents: 7365
diff changeset
2902
8247
e41f420875db set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents: 8222
diff changeset
2903 BEGIN_PROPERTIES (line)
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2904 row_vector_property xdata u , default_data ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2905 row_vector_property ydata u , default_data ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2906 row_vector_property zdata u , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2907 row_vector_property ldata u , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2908 row_vector_property udata u , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2909 row_vector_property xldata u , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2910 row_vector_property xudata u , Matrix ()
8257
79c874fe5100 More plot object updates
David Bateman <dbateman@free.fr>
parents: 8254
diff changeset
2911 string_property xdatasource , ""
79c874fe5100 More plot object updates
David Bateman <dbateman@free.fr>
parents: 8254
diff changeset
2912 string_property ydatasource , ""
79c874fe5100 More plot object updates
David Bateman <dbateman@free.fr>
parents: 8254
diff changeset
2913 string_property zdatasource , ""
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2914 color_property color , color_values (0, 0, 0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2915 radio_property linestyle , "{-}|--|:|-.|none"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2916 double_property linewidth , 0.5
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2917 radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2918 color_property markeredgecolor , "{auto}|none"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2919 color_property markerfacecolor , "auto|{none}"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2920 double_property markersize , 6
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2921 string_property keylabel , ""
7384
47c919254791 [project @ 2008-01-15 20:27:01 by jwe]
jwe
parents: 7380
diff changeset
2922 radio_property interpreter , "{tex}|none|latex"
7377
46b58515067d [project @ 2008-01-15 06:57:15 by jwe]
jwe
parents: 7370
diff changeset
2923 string_property displayname , ""
7380
2ba95a933d3e [project @ 2008-01-15 19:04:27 by jwe]
jwe
parents: 7379
diff changeset
2924 radio_property erasemode , "{normal}|none|xor|background"
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2925 // hidden properties for limit computation
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2926 row_vector_property xlim hlr , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2927 row_vector_property ylim hlr , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2928 row_vector_property zlim hlr , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2929 bool_property xliminclude hl , "on"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2930 bool_property yliminclude hl , "on"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2931 bool_property zliminclude hl , "off"
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2932 END_PROPERTIES
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2933
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2934 private:
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2935 Matrix 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
2936 Matrix 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
2937
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2938 void update_xdata (void) { set_xlim (compute_xlim ()); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2939 void update_xldata (void) { set_xlim (compute_xlim ()); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2940 void update_xudata (void) { set_xlim (compute_xlim ()); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2941
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2942 void update_ydata (void) { set_ylim (compute_ylim ()); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2943 void update_ldata (void) { set_ylim (compute_ylim ()); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2944 void update_udata (void) { set_ylim (compute_ylim ()); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2945
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2946 void update_zdata (void)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2947 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2948 set_zlim (zdata.get_limits ());
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2949 set_zliminclude (get_zdata ().numel () > 0);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2950 }
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2951 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2952
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2953 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2954 properties xproperties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2955
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2956 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2957 line (const graphics_handle& mh, const graphics_handle& p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2958 : base_graphics_object (), xproperties (mh, p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2959 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2960 xproperties.override_defaults (*this);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2961 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2962
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2963 ~line (void) { xproperties.delete_children (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2964
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2965 base_properties& get_properties (void) { return xproperties; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2966
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2967 const base_properties& get_properties (void) const { return xproperties; }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
2968
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2969 bool valid_object (void) const { return true; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2970 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2971
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2972 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2973
7365
f5e801eee0d1 [project @ 2008-01-13 06:33:32 by jwe]
jwe
parents: 7364
diff changeset
2974 class OCTINTERP_API text : public base_graphics_object
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2975 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2976 public:
7821
f79dcba526a8 Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7527
diff changeset
2977 class OCTINTERP_API properties : public base_properties
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2978 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2979 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2980 // See the genprops.awk script for an explanation of the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2981 // properties declarations.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2982
8247
e41f420875db set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents: 8222
diff changeset
2983 BEGIN_PROPERTIES (text)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2984 string_property string , ""
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2985 radio_property units , "{data}|pixels|normalized|inches|centimeters|points"
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
2986 array_property position u , Matrix (1, 3, 0.0)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2987 double_property rotation , 0
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2988 radio_property horizontalalignment , "{left}|center|right"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2989 color_property color , color_values (0, 0, 0)
8944
cb0e9facc342 make default fontname * instead of Helvetica
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
2990 string_property fontname , OCTAVE_DEFAULT_FONTNAME
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
2991 double_property fontsize , 10
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
2992 radio_property fontangle , "{normal}|italic|oblique"
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
2993 radio_property fontweight , "light|{normal}|demi|bold"
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
2994 radio_property interpreter , "{tex}|none|latex"
7377
46b58515067d [project @ 2008-01-15 06:57:15 by jwe]
jwe
parents: 7370
diff changeset
2995 color_property backgroundcolor , "{none}"
46b58515067d [project @ 2008-01-15 06:57:15 by jwe]
jwe
parents: 7370
diff changeset
2996 string_property displayname , ""
46b58515067d [project @ 2008-01-15 06:57:15 by jwe]
jwe
parents: 7370
diff changeset
2997 color_property edgecolor , "{none}"
7380
2ba95a933d3e [project @ 2008-01-15 19:04:27 by jwe]
jwe
parents: 7379
diff changeset
2998 radio_property erasemode , "{normal}|none|xor|background"
7377
46b58515067d [project @ 2008-01-15 06:57:15 by jwe]
jwe
parents: 7370
diff changeset
2999 bool_property editing , "off"
8465
cddf85b1524a graphics.h.in: fix typo
Ben Abbott <bpabbott@mac.com>
parents: 8355
diff changeset
3000 radio_property fontunits , "inches|centimeters|normalized|{points}|pixels"
7377
46b58515067d [project @ 2008-01-15 06:57:15 by jwe]
jwe
parents: 7370
diff changeset
3001 radio_property linestyle , "{-}|--|:|-.|none"
46b58515067d [project @ 2008-01-15 06:57:15 by jwe]
jwe
parents: 7370
diff changeset
3002 double_property linewidth , 0.5
46b58515067d [project @ 2008-01-15 06:57:15 by jwe]
jwe
parents: 7370
diff changeset
3003 double_property margin , 1
46b58515067d [project @ 2008-01-15 06:57:15 by jwe]
jwe
parents: 7370
diff changeset
3004 radio_property verticalalignment , "top|cap|{middle}|baseline|bottom"
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3005 // hidden properties for limit computation
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3006 row_vector_property xlim hlr , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3007 row_vector_property ylim hlr , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3008 row_vector_property zlim hlr , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3009 bool_property xliminclude hl , "on"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3010 bool_property yliminclude hl , "on"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3011 bool_property zliminclude hl , "off"
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3012 END_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3013
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3014 protected:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3015 void init (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3016 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3017 position.add_constraint (dim_vector (1, 3));
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3018 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3019
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3020 private:
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3021 void update_position (void)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3022 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3023 Matrix pos = get_position ().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
3024 Matrix lim;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3025
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3026 lim = Matrix (1, 3, pos(0));
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3027 lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2));
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3028 set_xlim (lim);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3029
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3030 lim = Matrix (1, 3, pos(1));
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3031 lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2));
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3032 set_ylim (lim);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3033
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3034 if (pos.numel () == 3)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3035 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3036 lim = Matrix (1, 3, pos(2));
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3037 lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2));
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3038 set_zliminclude ("on");
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3039 set_zlim (lim);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3040 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3041 else
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3042 set_zliminclude ("off");
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3043 }
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3044 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3045
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3046 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3047 properties xproperties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3048
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3049 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3050 text (const graphics_handle& mh, const graphics_handle& p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3051 : base_graphics_object (), xproperties (mh, p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3052 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3053 xproperties.override_defaults (*this);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3054 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3055
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3056 ~text (void) { xproperties.delete_children (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3057
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3058 base_properties& get_properties (void) { return xproperties; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3059
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3060 const base_properties& get_properties (void) const { return xproperties; }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3061
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3062 bool valid_object (void) const { return true; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3063 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3064
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3065 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3066
7365
f5e801eee0d1 [project @ 2008-01-13 06:33:32 by jwe]
jwe
parents: 7364
diff changeset
3067 class OCTINTERP_API image : public base_graphics_object
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3068 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3069 public:
7821
f79dcba526a8 Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7527
diff changeset
3070 class OCTINTERP_API properties : public base_properties
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3071 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3072 public:
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3073 bool is_climinclude (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
3074 { return (climinclude.is_on () && cdatamapping.is ("scaled")); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3075 std::string get_climinclude (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
3076 { return climinclude.current_value (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3077
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3078 // See the genprops.awk script for an explanation of the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3079 // properties declarations.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3080
8247
e41f420875db set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents: 8222
diff changeset
3081 BEGIN_PROPERTIES (image)
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3082 row_vector_property xdata u , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3083 row_vector_property ydata u , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3084 array_property cdata u , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3085 radio_property cdatamapping al , "{scaled}|direct"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3086 // hidden properties for limit computation
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3087 row_vector_property xlim hlr , Matrix()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3088 row_vector_property ylim hlr , Matrix()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3089 row_vector_property clim hlr , Matrix()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3090 bool_property xliminclude hl , "on"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3091 bool_property yliminclude hl , "on"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3092 bool_property climinclude hlg , "on"
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3093 END_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3094
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3095 protected:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3096 void init (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3097 {
7848
6bb2bbc2bf45 Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7847
diff changeset
3098 xdata.add_constraint (2);
6bb2bbc2bf45 Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7847
diff changeset
3099 ydata.add_constraint (2);
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
3100 cdata.add_constraint ("double");
8300
4b9bce36109b Add constraint for logical image cdata
David Bateman <dbateman@free.fr>
parents: 8299
diff changeset
3101 cdata.add_constraint ("logical");
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
3102 cdata.add_constraint ("uint8");
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
3103 cdata.add_constraint (dim_vector (-1, -1));
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
3104 cdata.add_constraint (dim_vector (-1, -1, 3));
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3105 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3106
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3107 private:
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8300
diff changeset
3108 // FIXME -- limits should take pixel width into account.
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3109 void update_xdata (void)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3110 { set_xlim (xdata.get_limits ()); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3111
8333
9238637cb81c style fixes
John W. Eaton <jwe@octave.org>
parents: 8300
diff changeset
3112 // FIXME -- idem.
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3113 void update_ydata (void)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3114 { set_ylim (ydata.get_limits ()); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3115
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3116 void update_cdata (void)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3117 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3118 if (cdatamapping_is ("scaled"))
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3119 set_clim (cdata.get_limits ());
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3120 else
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3121 clim = cdata.get_limits ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3122 }
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3123 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3124
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3125 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3126 properties xproperties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3127
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3128 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3129 image (const graphics_handle& mh, const graphics_handle& p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3130 : base_graphics_object (), xproperties (mh, p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3131 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3132 xproperties.override_defaults (*this);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3133 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3134
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3135 ~image (void) { xproperties.delete_children (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3136
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3137 base_properties& get_properties (void) { return xproperties; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3138
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3139 const base_properties& get_properties (void) const { return xproperties; }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3140
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3141 bool valid_object (void) const { return true; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3142 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3143
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3144 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3145
7365
f5e801eee0d1 [project @ 2008-01-13 06:33:32 by jwe]
jwe
parents: 7364
diff changeset
3146 class OCTINTERP_API patch : public base_graphics_object
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3147 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3148 public:
7821
f79dcba526a8 Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7527
diff changeset
3149 class OCTINTERP_API properties : public base_properties
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3150 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3151 public:
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: 7832
diff changeset
3152 octave_value 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: 7832
diff changeset
3153
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3154 bool is_climinclude (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
3155 { return (climinclude.is_on () && cdatamapping.is ("scaled")); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3156 std::string get_climinclude (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
3157 { return climinclude.current_value (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3158
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3159 bool is_aliminclude (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
3160 { return (aliminclude.is_on () && alphadatamapping.is ("scaled")); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3161 std::string get_aliminclude (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
3162 { return aliminclude.current_value (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3163
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3164 // See the genprops.awk script for an explanation of the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3165 // properties declarations.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3166
8247
e41f420875db set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents: 8222
diff changeset
3167 BEGIN_PROPERTIES (patch)
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3168 array_property xdata u , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3169 array_property ydata u , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3170 array_property zdata u , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3171 array_property cdata u , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3172 radio_property cdatamapping l , "{scaled}|direct"
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3173 array_property faces , Matrix ()
7848
6bb2bbc2bf45 Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7847
diff changeset
3174 array_property facevertexalphadata , Matrix ()
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
3175 array_property facevertexcdata , Matrix ()
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3176 array_property vertices , Matrix ()
7368
68269e42f573 [project @ 2008-01-14 09:18:38 by jwe]
jwe
parents: 7367
diff changeset
3177 array_property vertexnormals , Matrix ()
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
3178 radio_property normalmode , "{auto}|manual"
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
3179 color_property facecolor , "{flat}|none|interp"
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7842
diff changeset
3180 double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp"))
7832
e06fdf7ea647 Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7830
diff changeset
3181 radio_property facelighting , "flat|{none}|gouraud|phong"
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
3182 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp"))
7846
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7844
diff changeset
3183 double_radio_property edgealpha , double_radio_property (1.0, radio_values ("flat|interp"))
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
3184 radio_property edgelighting , "{none}|flat|gouraud|phong"
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
3185 radio_property backfacelighting , "{reverselit}|unlit|lit"
7368
68269e42f573 [project @ 2008-01-14 09:18:38 by jwe]
jwe
parents: 7367
diff changeset
3186 double_property ambientstrength , 0.3
68269e42f573 [project @ 2008-01-14 09:18:38 by jwe]
jwe
parents: 7367
diff changeset
3187 double_property diffusestrength , 0.6
68269e42f573 [project @ 2008-01-14 09:18:38 by jwe]
jwe
parents: 7367
diff changeset
3188 double_property specularstrength , 0.6
68269e42f573 [project @ 2008-01-14 09:18:38 by jwe]
jwe
parents: 7367
diff changeset
3189 double_property specularexponent , 10.0
68269e42f573 [project @ 2008-01-14 09:18:38 by jwe]
jwe
parents: 7367
diff changeset
3190 double_property specularcolorreflectance , 1.0
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
3191 radio_property erasemode , "{normal}|background|xor|none"
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3192 radio_property linestyle , "{-}|--|:|-.|none"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3193 double_property linewidth , 0.5
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3194 radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3195 color_property markeredgecolor , "{auto}|none"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3196 color_property markerfacecolor , "auto|{none}"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3197 double_property markersize , 6
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3198 string_property keylabel , ""
7384
47c919254791 [project @ 2008-01-15 20:27:01 by jwe]
jwe
parents: 7380
diff changeset
3199 radio_property interpreter , "{tex}|none|latex"
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3200 radio_property alphadatamapping l , "none|{scaled}|direct"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3201 // hidden properties for limit computation
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3202 row_vector_property xlim hlr , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3203 row_vector_property ylim hlr , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3204 row_vector_property zlim hlr , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3205 row_vector_property clim hlr , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3206 row_vector_property alim hlr , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3207 bool_property xliminclude hl , "on"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3208 bool_property yliminclude hl , "on"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3209 bool_property zliminclude hl , "on"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3210 bool_property climinclude hlg , "on"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3211 bool_property aliminclude hlg , "on"
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3212 END_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3213
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3214 protected:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3215 void init (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3216 {
7848
6bb2bbc2bf45 Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7847
diff changeset
3217 xdata.add_constraint (dim_vector (-1, -1));
6bb2bbc2bf45 Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7847
diff changeset
3218 ydata.add_constraint (dim_vector (-1, -1));
6bb2bbc2bf45 Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7847
diff changeset
3219 zdata.add_constraint (dim_vector (-1, -1));
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3220 vertices.add_constraint (dim_vector (-1, 2));
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3221 vertices.add_constraint (dim_vector (-1, 3));
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
3222 cdata.add_constraint (dim_vector (-1, -1));
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
3223 cdata.add_constraint (dim_vector (-1, -1, 3));
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
3224 facevertexcdata.add_constraint (dim_vector (-1, 1));
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
3225 facevertexcdata.add_constraint (dim_vector (-1, 3));
7848
6bb2bbc2bf45 Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7847
diff changeset
3226 facevertexalphadata.add_constraint (dim_vector (-1, 1));
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3227 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3228
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3229 private:
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3230 void update_xdata (void) { set_xlim (xdata.get_limits ()); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3231 void update_ydata (void) { set_ylim (ydata.get_limits ()); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3232 void update_zdata (void) { set_zlim (zdata.get_limits ()); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3233
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3234 void update_cdata (void)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3235 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3236 if (cdatamapping_is ("scaled"))
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3237 set_clim (cdata.get_limits ());
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3238 else
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3239 clim = cdata.get_limits ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3240 }
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3241 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3242
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3243 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3244 properties xproperties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3245
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3246 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3247 patch (const graphics_handle& mh, const graphics_handle& p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3248 : base_graphics_object (), xproperties (mh, p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3249 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3250 xproperties.override_defaults (*this);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3251 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3252
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3253 ~patch (void) { xproperties.delete_children (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3254
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3255 base_properties& get_properties (void) { return xproperties; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3256
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3257 const base_properties& get_properties (void) const { return xproperties; }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3258
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3259 bool valid_object (void) const { return true; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3260 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3261
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3262 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3263
7365
f5e801eee0d1 [project @ 2008-01-13 06:33:32 by jwe]
jwe
parents: 7364
diff changeset
3264 class OCTINTERP_API surface : public base_graphics_object
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3265 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3266 public:
7821
f79dcba526a8 Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7527
diff changeset
3267 class OCTINTERP_API properties : public base_properties
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3268 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3269 public:
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3270 octave_value 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
3271
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3272 bool is_climinclude (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
3273 { return (climinclude.is_on () && cdatamapping.is ("scaled")); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3274 std::string get_climinclude (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
3275 { return climinclude.current_value (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3276
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3277 bool is_aliminclude (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
3278 { return (aliminclude.is_on () && alphadatamapping.is ("scaled")); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3279 std::string get_aliminclude (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
3280 { return aliminclude.current_value (); }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3281
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3282 // See the genprops.awk script for an explanation of the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3283 // properties declarations.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3284
8247
e41f420875db set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents: 8222
diff changeset
3285 BEGIN_PROPERTIES (surface)
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3286 array_property xdata u , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3287 array_property ydata u , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3288 array_property zdata u , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3289 array_property cdata u , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3290 radio_property cdatamapping al , "{scaled}|direct"
8257
79c874fe5100 More plot object updates
David Bateman <dbateman@free.fr>
parents: 8254
diff changeset
3291 string_property xdatasource , ""
79c874fe5100 More plot object updates
David Bateman <dbateman@free.fr>
parents: 8254
diff changeset
3292 string_property ydatasource , ""
79c874fe5100 More plot object updates
David Bateman <dbateman@free.fr>
parents: 8254
diff changeset
3293 string_property zdatasource , ""
79c874fe5100 More plot object updates
David Bateman <dbateman@free.fr>
parents: 8254
diff changeset
3294 string_property cdatasource , ""
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3295 color_property facecolor , "{flat}|none|interp|texturemap"
7846
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7844
diff changeset
3296 double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp"))
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
3297 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp"))
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3298 radio_property linestyle , "{-}|--|:|-.|none"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3299 double_property linewidth , 0.5
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3300 radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3301 color_property markeredgecolor , "{auto}|none"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3302 color_property markerfacecolor , "auto|{none}"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3303 double_property markersize , 6
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3304 string_property keylabel , ""
7384
47c919254791 [project @ 2008-01-15 20:27:01 by jwe]
jwe
parents: 7380
diff changeset
3305 radio_property interpreter , "{tex}|none|latex"
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3306 array_property alphadata u , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3307 radio_property alphadatamapping l , "none|direct|{scaled}"
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3308 double_property ambientstrength , 0.3
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3309 radio_property backfacelighting , "unlit|lit|{reverselit}"
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3310 double_property diffusestrength , 0.6
7846
d7737a4268b7 Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7844
diff changeset
3311 double_radio_property edgealpha , double_radio_property (1.0, radio_values ("flat|interp"))
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3312 radio_property edgelighting , "{none}|flat|gouraud|phong"
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3313 radio_property erasemode , "{normal}|none|xor|background"
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3314 radio_property facelighting , "{none}|flat|gouraud|phong"
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3315 radio_property meshstyle , "{both}|row|column"
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3316 radio_property normalmode u , "{auto}|manual"
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3317 double_property specularcolorreflectance , 1
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3318 double_property specularexponent , 10
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3319 double_property specularstrength , 0.9
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3320 array_property vertexnormals u , Matrix ()
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3321 // hidden properties for limit computation
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3322 row_vector_property xlim hlr , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3323 row_vector_property ylim hlr , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3324 row_vector_property zlim hlr , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3325 row_vector_property clim hlr , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3326 row_vector_property alim hlr , Matrix ()
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3327 bool_property xliminclude hl , "on"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3328 bool_property yliminclude hl , "on"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3329 bool_property zliminclude hl , "on"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3330 bool_property climinclude hlg , "on"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3331 bool_property aliminclude hlg , "on"
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3332 END_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3333
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3334 protected:
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3335 void init (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3336 {
7848
6bb2bbc2bf45 Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7847
diff changeset
3337 xdata.add_constraint (dim_vector (-1, -1));
6bb2bbc2bf45 Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7847
diff changeset
3338 ydata.add_constraint (dim_vector (-1, -1));
6bb2bbc2bf45 Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7847
diff changeset
3339 zdata.add_constraint (dim_vector (-1, -1));
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3340 alphadata.add_constraint ("double");
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3341 alphadata.add_constraint ("uint8");
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3342 alphadata.add_constraint (dim_vector (-1, -1));
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3343 vertexnormals.add_constraint (dim_vector (-1, -1, 3));
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
3344 cdata.add_constraint ("double");
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
3345 cdata.add_constraint ("uint8");
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
3346 cdata.add_constraint (dim_vector (-1, -1));
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
3347 cdata.add_constraint (dim_vector (-1, -1, 3));
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3348 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3349
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3350 private:
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3351 void update_normals (void);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3352
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3353 void update_xdata (void)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3354 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3355 update_normals ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3356 set_xlim (xdata.get_limits ());
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3357 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3358
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3359 void update_ydata (void)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3360 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3361 update_normals ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3362 set_ylim (ydata.get_limits ());
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3363 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3364
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3365 void update_zdata (void)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3366 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3367 update_normals ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3368 set_zlim (zdata.get_limits ());
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3369 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3370
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3371 void update_cdata (void)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3372 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3373 if (cdatamapping_is ("scaled"))
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3374 set_clim (cdata.get_limits ());
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3375 else
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3376 clim = cdata.get_limits ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3377 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3378
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3379 void update_alphadata (void)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3380 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3381 if (alphadatamapping_is ("scaled"))
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3382 set_alim (alphadata.get_limits ());
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3383 else
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3384 alim = alphadata.get_limits ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3385 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3386
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3387 void update_normalmode (void)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3388 { update_normals (); }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3389
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3390 void update_vertexnormals (void)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
3391 { set_normalmode ("manual"); }
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3392 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3393
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3394 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3395 properties xproperties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3396
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3397 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3398 surface (const graphics_handle& mh, const graphics_handle& p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3399 : base_graphics_object (), xproperties (mh, p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3400 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3401 xproperties.override_defaults (*this);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3402 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3403
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3404 ~surface (void) { xproperties.delete_children (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3405
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3406 base_properties& get_properties (void) { return xproperties; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3407
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3408 const base_properties& get_properties (void) const { return xproperties; }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
3409
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3410 bool valid_object (void) const { return true; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3411 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3412
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3413 // ---------------------------------------------------------------------
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3414
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3415 class OCTINTERP_API hggroup : public base_graphics_object
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3416 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3417 public:
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3418 class OCTINTERP_API properties : public base_properties
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3419 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3420 public:
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3421 void remove_child (const graphics_handle& h)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3422 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3423 base_properties::remove_child (h);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3424 update_limits ();
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3425 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3426
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3427 void adopt (const graphics_handle& h)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3428 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3429 base_properties::adopt (h);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3430 update_limits ();
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3431 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3432
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3433 // See the genprops.awk script for an explanation of the
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3434 // properties declarations.
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3435
8247
e41f420875db set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents: 8222
diff changeset
3436 BEGIN_PROPERTIES (hggroup)
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3437 // hidden properties for limit computation
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3438 row_vector_property xlim hr , Matrix()
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3439 row_vector_property ylim hr , Matrix()
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3440 row_vector_property zlim hr , Matrix()
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3441 row_vector_property clim hr , Matrix()
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3442 row_vector_property alim hr , Matrix()
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3443 bool_property xliminclude h , "on"
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3444 bool_property yliminclude h , "on"
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3445 bool_property zliminclude h , "on"
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3446 bool_property climinclude h , "on"
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3447 bool_property aliminclude h , "on"
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3448 END_PROPERTIES
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3449
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3450 private:
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3451 void update_limits (void)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3452 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3453 update_axis_limits ("xlim");
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3454 update_axis_limits ("ylim");
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3455 update_axis_limits ("zlim");
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3456 update_axis_limits ("clim");
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3457 update_axis_limits ("alim");
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3458 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3459
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3460 protected:
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3461 void init (void)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3462 { }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3463 };
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3464
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3465 private:
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3466 properties xproperties;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3467
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3468 public:
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3469 hggroup (const graphics_handle& mh, const graphics_handle& p)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3470 : base_graphics_object (), xproperties (mh, p)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3471 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3472 xproperties.override_defaults (*this);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3473 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3474
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3475 ~hggroup (void) { xproperties.delete_children (); }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3476
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3477 base_properties& get_properties (void) { return xproperties; }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3478
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3479 const base_properties& get_properties (void) const { return xproperties; }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3480
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3481 bool valid_object (void) const { return true; }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3482
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3483 void update_axis_limits (const std::string& axis_type);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3484 };
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3485
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3486 // ---------------------------------------------------------------------
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
3487
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3488 octave_value
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3489 get_property_from_handle (double handle, const std::string &property,
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3490 const std::string &func);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3491 bool
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3492 set_property_in_handle (double handle, const std::string &property,
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3493 const octave_value &arg, const std::string &func);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3494
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3495 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3496
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3497 class graphics_event;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3498
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3499 class
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3500 base_graphics_event
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3501 {
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3502 public:
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3503 friend class graphics_event;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3504
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3505 base_graphics_event (void) : count (1) { }
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3506
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3507 virtual ~base_graphics_event (void) { }
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3508
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3509 virtual void execute (void) = 0;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3510
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3511 private:
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3512 int count;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3513 };
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3514
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3515 class
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3516 graphics_event
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3517 {
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3518 public:
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3519 typedef void (*event_fcn) (void*);
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3520
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3521 graphics_event (void) : rep (0) { }
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3522
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3523 graphics_event (const graphics_event& e)
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3524 {
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3525 rep = e.rep;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3526 rep->count++;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3527 }
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3528
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3529 ~graphics_event (void)
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3530 {
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3531 if (rep && --rep->count == 0)
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3532 delete rep;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3533 }
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3534
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3535 graphics_event& operator = (const graphics_event& e)
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3536 {
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3537 if (rep != e.rep)
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3538 {
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3539 if (rep && --rep->count == 0)
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3540 delete rep;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3541
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3542 rep = e.rep;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3543 if (rep)
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3544 rep->count++;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3545 }
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3546
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3547 return *this;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3548 }
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3549
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3550 void execute (void)
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3551 { if (rep) rep->execute (); }
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3552
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3553 bool ok (void) const
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3554 { return (rep != 0); }
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3555
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3556 static graphics_event
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3557 create_callback_event (const graphics_handle& h,
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3558 const std::string& name,
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3559 const octave_value& data = Matrix ());
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3560
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3561 static graphics_event
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3562 create_function_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
3563
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3564 static graphics_event
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3565 create_set_event (const graphics_handle& h,
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3566 const std::string& name,
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3567 const octave_value& value);
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3568 private:
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3569 base_graphics_event *rep;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3570 };
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3571
7365
f5e801eee0d1 [project @ 2008-01-13 06:33:32 by jwe]
jwe
parents: 7364
diff changeset
3572 class OCTINTERP_API gh_manager
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3573 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3574 protected:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3575
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3576 gh_manager (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3577
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3578 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3579
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3580 static bool instance_ok (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3581 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3582 bool retval = true;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3583
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3584 if (! instance)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3585 instance = new gh_manager ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3586
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3587 if (! instance)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3588 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3589 ::error ("unable to create gh_manager!");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3590
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3591 retval = false;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3592 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3593
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3594 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3595 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3596
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3597 static void free (const graphics_handle& h)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3598 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3599 if (instance_ok ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3600 instance->do_free (h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3601 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3602
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3603 static graphics_handle lookup (double val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3604 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3605 return instance_ok () ? instance->do_lookup (val) : graphics_handle ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3606 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3607
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3608 static graphics_object get_object (const graphics_handle& h)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3609 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3610 return instance_ok () ? instance->do_get_object (h) : graphics_object ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3611 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3612
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3613 static graphics_handle
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3614 make_graphics_handle (const std::string& go_name,
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7368
diff changeset
3615 const graphics_handle& parent, bool do_createfcn = true)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3616 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3617 return instance_ok ()
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7368
diff changeset
3618 ? instance->do_make_graphics_handle (go_name, parent, do_createfcn)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3619 : graphics_handle ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3620 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3621
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3622 static graphics_handle make_figure_handle (double val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3623 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3624 return instance_ok ()
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3625 ? instance->do_make_figure_handle (val) : graphics_handle ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3626 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3627
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3628 static void push_figure (const graphics_handle& h)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3629 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3630 if (instance_ok ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3631 instance->do_push_figure (h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3632 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3633
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3634 static void pop_figure (const graphics_handle& h)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3635 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3636 if (instance_ok ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3637 instance->do_pop_figure (h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3638 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3639
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3640 static graphics_handle current_figure (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3641 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3642 return instance_ok ()
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3643 ? instance->do_current_figure () : graphics_handle ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3644 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3645
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3646 static Matrix handle_list (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3647 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3648 return instance_ok () ? instance->do_handle_list () : Matrix ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3649 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3650
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3651 static void lock (void)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3652 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3653 if (instance_ok ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3654 instance->do_lock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3655 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3656
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3657 static void unlock (void)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3658 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3659 if (instance_ok ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3660 instance->do_unlock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3661 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3662
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3663 static Matrix figure_handle_list (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3664 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3665 return instance_ok () ? instance->do_figure_handle_list () : Matrix ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3666 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3667
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3668 static void execute_callback (const graphics_handle& h,
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3669 const std::string& name,
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3670 const octave_value& data = Matrix ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3671 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3672 graphics_object go = get_object (h);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3673
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3674 if (go.valid_object ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3675 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3676 octave_value cb = go.get (name);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3677
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3678 if (! error_state)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3679 execute_callback (h, cb, data);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3680 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3681 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3682
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3683 static void execute_callback (const graphics_handle& h,
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3684 const octave_value& cb,
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3685 const octave_value& data = Matrix ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3686 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3687 if (instance_ok ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3688 instance->do_execute_callback (h, cb, data);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3689 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3690
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3691 static void post_callback (const graphics_handle& h,
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3692 const std::string& name,
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3693 const octave_value& data = Matrix ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3694 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3695 if (instance_ok ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3696 instance->do_post_callback (h, name, data);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3697 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3698
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3699 static void post_function (graphics_event::event_fcn fcn, void* data = 0)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3700 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3701 if (instance_ok ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3702 instance->do_post_function (fcn, data);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3703 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3704
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3705 static void post_set (const graphics_handle& h,
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3706 const std::string& name,
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3707 const octave_value& value)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3708 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3709 if (instance_ok ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3710 instance->do_post_set (h, name, value);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3711 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3712
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3713 static int process_events (void)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3714 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3715 return (instance_ok () ? instance->do_process_events () : 0);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3716 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3717
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3718 static int flush_events (void)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3719 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3720 return (instance_ok () ? instance->do_process_events (true) : 0);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3721 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3722
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
3723 static bool is_handle_visible (const graphics_handle& h)
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
3724 {
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
3725 bool retval = false;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
3726
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
3727 graphics_object go = get_object (h);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
3728
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
3729 if (go.valid_object ())
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
3730 retval = go.is_handle_visible ();
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
3731
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
3732 return retval;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
3733 }
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8247
diff changeset
3734
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3735 public:
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3736 class autolock
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3737 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3738 public:
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3739 autolock (void) { lock (); }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3740
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3741 ~autolock (void) { unlock (); }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3742
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3743 private:
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3744
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3745 // No copying!
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3746 autolock (const autolock&);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3747 autolock& operator = (const autolock&);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3748 };
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3749
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3750 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3751
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3752 static gh_manager *instance;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3753
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3754 typedef std::map<graphics_handle, graphics_object>::iterator iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3755 typedef std::map<graphics_handle, graphics_object>::const_iterator const_iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3756
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3757 typedef std::set<graphics_handle>::iterator free_list_iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3758 typedef std::set<graphics_handle>::const_iterator const_free_list_iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3759
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3760 typedef std::list<graphics_handle>::iterator figure_list_iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3761 typedef std::list<graphics_handle>::const_iterator const_figure_list_iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3762
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3763 // A map of handles to graphics objects.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3764 std::map<graphics_handle, graphics_object> handle_map;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3765
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3766 // The available graphics handles.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3767 std::set<graphics_handle> handle_free_list;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3768
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3769 // The next handle available if handle_free_list is empty.
7286
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
3770 double next_handle;
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3771
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3772 // The allocated figure handles. Top of the stack is most recently
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3773 // created.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3774 std::list<graphics_handle> figure_list;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3775
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3776 // The lock for accessing the graphics sytsem
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3777 octave_mutex graphics_lock;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3778
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3779 // The list of event queued by backends
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3780 std::list<graphics_event> event_queue;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3781
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3782 // The stack of callback objects
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3783 std::list<graphics_object> callback_objects;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3784
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3785 graphics_handle get_handle (const std::string& go_name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3786
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3787 void do_free (const graphics_handle& h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3788
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3789 graphics_handle do_lookup (double val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3790 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7307
diff changeset
3791 iterator p = (xisnan (val) ? handle_map.end () : handle_map.find (val));
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3792
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3793 return (p != handle_map.end ()) ? p->first : graphics_handle ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3794 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3795
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3796 graphics_object do_get_object (const graphics_handle& h)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3797 {
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7377
diff changeset
3798 iterator p = (h.ok () ? handle_map.find (h) : handle_map.end ());
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3799
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3800 return (p != handle_map.end ()) ? p->second : graphics_object ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3801 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3802
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3803 graphics_handle do_make_graphics_handle (const std::string& go_name,
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7368
diff changeset
3804 const graphics_handle& p, bool do_createfcn);
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3805
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3806 graphics_handle do_make_figure_handle (double val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3807
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3808 Matrix do_handle_list (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3809 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3810 Matrix retval (1, handle_map.size ());
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3811 octave_idx_type i = 0;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3812 for (const_iterator p = handle_map.begin (); p != handle_map.end (); p++)
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7020
diff changeset
3813 {
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7020
diff changeset
3814 graphics_handle h = p->first;
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7020
diff changeset
3815 retval(i++) = h.value ();
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7020
diff changeset
3816 }
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3817 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3818 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3819
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3820 Matrix do_figure_handle_list (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3821 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3822 Matrix retval (1, figure_list.size ());
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3823 octave_idx_type i = 0;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3824 for (const_figure_list_iterator p = figure_list.begin ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3825 p != figure_list.end ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3826 p++)
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7020
diff changeset
3827 {
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7020
diff changeset
3828 graphics_handle h = *p;
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7020
diff changeset
3829 retval(i++) = h.value ();
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7020
diff changeset
3830 }
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3831 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3832 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3833
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3834 void do_push_figure (const graphics_handle& h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3835
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3836 void do_pop_figure (const graphics_handle& h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3837
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3838 graphics_handle do_current_figure (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3839 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3840 return figure_list.empty () ? graphics_handle () : figure_list.front ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3841 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3842
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3843 void do_lock (void) { graphics_lock.lock (); }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3844
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3845 void do_unlock (void) { graphics_lock.unlock (); }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3846
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3847 void do_execute_callback (const graphics_handle& h, const octave_value& cb,
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3848 const octave_value& data);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3849
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3850 void do_post_callback (const graphics_handle& h, const std::string name,
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3851 const octave_value& data);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3852
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3853 void 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: 7902
diff changeset
3854
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3855 void do_post_set (const graphics_handle& h, const std::string name,
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3856 const octave_value& value);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3857
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3858 int do_process_events (bool force = false);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3859
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3860 static void restore_gcbo (void*)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3861 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3862 if (instance_ok ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3863 instance->do_restore_gcbo ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3864 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3865
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3866 void do_restore_gcbo (void);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7902
diff changeset
3867
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
3868 void do_post_event (const graphics_event& e);
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3869 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3870
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3871
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3872 // This function is NOT equivalent to the scripting language function gcf.
7365
f5e801eee0d1 [project @ 2008-01-13 06:33:32 by jwe]
jwe
parents: 7364
diff changeset
3873 OCTINTERP_API graphics_handle gcf (void);
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3875 // This function is NOT equivalent to the scripting language function gca.
7365
f5e801eee0d1 [project @ 2008-01-13 06:33:32 by jwe]
jwe
parents: 7364
diff changeset
3876 OCTINTERP_API graphics_handle gca (void);
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3877
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3878 #endif
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3879
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3880 /*
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3881 ;;; Local Variables: ***
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3882 ;;; mode: C++ ***
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3883 ;;; End: ***
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3884 */