00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #if !defined (graphics_h)
00026 #define graphics_h 1
00027
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031
00032 #include <cctype>
00033
00034 #include <algorithm>
00035 #include <list>
00036 #include <map>
00037 #include <set>
00038 #include <string>
00039
00040 #include "caseless-str.h"
00041 #include "lo-ieee.h"
00042
00043 #include "gripes.h"
00044 #include "oct-map.h"
00045 #include "oct-mutex.h"
00046 #include "ov.h"
00047 #include "txt-eng-ft.h"
00048
00049
00050
00051
00052 #if !defined (OCTAVE_DEFAULT_FONTNAME)
00053 #define OCTAVE_DEFAULT_FONTNAME "*"
00054 #endif
00055
00056
00057
00058 class graphics_handle
00059 {
00060 public:
00061 graphics_handle (void) : val (octave_NaN) { }
00062
00063 graphics_handle (const octave_value& a);
00064
00065 graphics_handle (int a) : val (a) { }
00066
00067 graphics_handle (double a) : val (a) { }
00068
00069 graphics_handle (const graphics_handle& a) : val (a.val) { }
00070
00071 graphics_handle& operator = (const graphics_handle& a)
00072 {
00073 if (&a != this)
00074 val = a.val;
00075
00076 return *this;
00077 }
00078
00079 ~graphics_handle (void) { }
00080
00081 double value (void) const { return val; }
00082
00083 octave_value as_octave_value (void) const
00084 {
00085 return ok () ? octave_value (val) : octave_value (Matrix ());
00086 }
00087
00088
00089 graphics_handle& operator ++ (void)
00090 {
00091 ++val;
00092 return *this;
00093 }
00094
00095 graphics_handle& operator -- (void)
00096 {
00097 --val;
00098 return *this;
00099 }
00100
00101
00102 const graphics_handle operator ++ (int)
00103 {
00104 graphics_handle old_value = *this;
00105 ++(*this);
00106 return old_value;
00107 }
00108
00109 const graphics_handle operator -- (int)
00110 {
00111 graphics_handle old_value = *this;
00112 --(*this);
00113 return old_value;
00114 }
00115
00116 bool ok (void) const { return ! xisnan (val); }
00117
00118 private:
00119 double val;
00120 };
00121
00122 inline bool
00123 operator == (const graphics_handle& a, const graphics_handle& b)
00124 {
00125 return a.value () == b.value ();
00126 }
00127
00128 inline bool
00129 operator != (const graphics_handle& a, const graphics_handle& b)
00130 {
00131 return a.value () != b.value ();
00132 }
00133
00134 inline bool
00135 operator < (const graphics_handle& a, const graphics_handle& b)
00136 {
00137 return a.value () < b.value ();
00138 }
00139
00140 inline bool
00141 operator <= (const graphics_handle& a, const graphics_handle& b)
00142 {
00143 return a.value () <= b.value ();
00144 }
00145
00146 inline bool
00147 operator >= (const graphics_handle& a, const graphics_handle& b)
00148 {
00149 return a.value () >= b.value ();
00150 }
00151
00152 inline bool
00153 operator > (const graphics_handle& a, const graphics_handle& b)
00154 {
00155 return a.value () > b.value ();
00156 }
00157
00158
00159
00160 class base_scaler
00161 {
00162 public:
00163 base_scaler (void) { }
00164
00165 virtual ~base_scaler (void) { }
00166
00167 virtual Matrix scale (const Matrix& m) const
00168 {
00169 error ("invalid axis scale");
00170 return m;
00171 }
00172
00173 virtual NDArray scale (const NDArray& m) const
00174 {
00175 error ("invalid axis scale");
00176 return m;
00177 }
00178
00179 virtual double scale (double d) const
00180 {
00181 error ("invalid axis scale");
00182 return d;
00183 }
00184
00185 virtual double unscale (double d) const
00186 {
00187 error ("invalid axis scale");
00188 return d;
00189 }
00190
00191 virtual base_scaler* clone () const
00192 { return new base_scaler (); }
00193
00194 virtual bool is_linear (void) const
00195 { return false; }
00196 };
00197
00198 class lin_scaler : public base_scaler
00199 {
00200 public:
00201 lin_scaler (void) { }
00202
00203 Matrix scale (const Matrix& m) const { return m; }
00204
00205 NDArray scale (const NDArray& m) const { return m; }
00206
00207 double scale (double d) const { return d; }
00208
00209 double unscale (double d) const { return d; }
00210
00211 base_scaler* clone (void) const { return new lin_scaler (); }
00212
00213 bool is_linear (void) const { return true; }
00214 };
00215
00216 class log_scaler : public base_scaler
00217 {
00218 public:
00219 log_scaler (void) { }
00220
00221 Matrix scale (const Matrix& m) const
00222 {
00223 Matrix retval (m.rows (), m.cols ());
00224
00225 do_scale (m.data (), retval.fortran_vec (), m.numel ());
00226 return retval;
00227 }
00228
00229 NDArray scale (const NDArray& m) const
00230 {
00231 NDArray retval (m.dims ());
00232
00233 do_scale (m.data (), retval.fortran_vec (), m.numel ());
00234 return retval;
00235 }
00236
00237 double scale (double d) const
00238 { return log10 (d); }
00239
00240 double unscale (double d) const
00241 { return pow (10.0, d); }
00242
00243 base_scaler* clone (void) const
00244 { return new log_scaler (); }
00245
00246 private:
00247 void do_scale (const double *src, double *dest, int n) const
00248 {
00249 for (int i = 0; i < n; i++)
00250 dest[i] = log10(src[i]);
00251 }
00252 };
00253
00254 class scaler
00255 {
00256 public:
00257 scaler (void) : rep (new base_scaler ()) { }
00258
00259 scaler (const scaler& s) : rep (s.rep->clone()) { }
00260
00261 scaler (const std::string& s)
00262 : rep (s == "log"
00263 ? new log_scaler ()
00264 : (s == "linear" ? new lin_scaler () : new base_scaler ()))
00265 { }
00266
00267 ~scaler (void) { delete rep; }
00268
00269 Matrix scale (const Matrix& m) const
00270 { return rep->scale (m); }
00271
00272 NDArray scale (const NDArray& m) const
00273 { return rep->scale (m); }
00274
00275 double scale (double d) const
00276 { return rep->scale (d); }
00277
00278 double unscale (double d) const
00279 { return rep->unscale (d); }
00280
00281 bool is_linear (void) const
00282 { return rep->is_linear (); }
00283
00284 scaler& operator = (const scaler& s)
00285 {
00286 if (rep)
00287 {
00288 delete rep;
00289 rep = 0;
00290 }
00291
00292 rep = s.rep->clone ();
00293
00294 return *this;
00295 }
00296
00297 scaler& operator = (const std::string& s)
00298 {
00299 if (rep)
00300 {
00301 delete rep;
00302 rep = 0;
00303 }
00304
00305 if (s == "log")
00306 rep = new log_scaler ();
00307 else if (s == "linear")
00308 rep = new lin_scaler ();
00309 else
00310 rep = new base_scaler ();
00311
00312 return *this;
00313 }
00314
00315 private:
00316 base_scaler *rep;
00317 };
00318
00319
00320
00321 class property;
00322
00323 enum listener_mode { POSTSET };
00324
00325 class base_property
00326 {
00327 public:
00328 friend class property;
00329
00330 public:
00331 base_property (void)
00332 : id (-1), count (1), name (), parent (), hidden (), listeners ()
00333 { }
00334
00335 base_property (const std::string& s, const graphics_handle& h)
00336 : id (-1), count (1), name (s), parent (h), hidden (false), listeners ()
00337 { }
00338
00339 base_property (const base_property& p)
00340 : id (-1), count (1), name (p.name), parent (p.parent),
00341 hidden (p.hidden), listeners ()
00342 { }
00343
00344 virtual ~base_property (void) { }
00345
00346 bool ok (void) const { return parent.ok (); }
00347
00348 std::string get_name (void) const { return name; }
00349
00350 void set_name (const std::string& s) { name = s; }
00351
00352 graphics_handle get_parent (void) const { return parent; }
00353
00354 void set_parent (const graphics_handle &h) { parent = h; }
00355
00356 bool is_hidden (void) const { return hidden; }
00357
00358 void set_hidden (bool flag) { hidden = flag; }
00359
00360 virtual bool is_radio (void) const { return false; }
00361
00362 int get_id (void) const { return id; }
00363
00364 void set_id (int d) { id = d; }
00365
00366
00367
00368 bool set (const octave_value& v, bool do_run = true);
00369
00370 virtual octave_value get (void) const
00371 {
00372 error ("get: invalid property \"%s\"", name.c_str ());
00373 return octave_value ();
00374 }
00375
00376
00377 virtual std::string values_as_string (void) const
00378 {
00379 error ("values_as_string: invalid property \"%s\"", name.c_str ());
00380 return std::string ();
00381 }
00382
00383 virtual Cell values_as_cell (void) const
00384 {
00385 error ("values_as_cell: invalid property \"%s\"", name.c_str ());
00386 return Cell ();
00387 }
00388
00389 base_property& operator = (const octave_value& val)
00390 {
00391 set (val);
00392 return *this;
00393 }
00394
00395 void add_listener (const octave_value& v, listener_mode mode = POSTSET)
00396 {
00397 octave_value_list& l = listeners[mode];
00398 l.resize (l.length () + 1, v);
00399 }
00400
00401 void delete_listener (const octave_value& v = octave_value (),
00402 listener_mode mode = POSTSET)
00403 {
00404 octave_value_list& l = listeners[mode];
00405
00406 if (v.is_defined ())
00407 {
00408 bool found = false;
00409 int i;
00410
00411 for (i = 0; i < l.length (); i++)
00412 {
00413 if (v.internal_rep () == l(i).internal_rep ())
00414 {
00415 found = true;
00416 break;
00417 }
00418 }
00419 if (found)
00420 {
00421 for (int j = i; j < l.length() - 1; j++)
00422 l(j) = l (j + 1);
00423
00424 l.resize (l.length () - 1);
00425 }
00426 }
00427 else
00428 l.resize (0);
00429
00430 }
00431
00432 OCTINTERP_API void run_listeners (listener_mode mode = POSTSET);
00433
00434 virtual base_property* clone (void) const
00435 { return new base_property (*this); }
00436
00437 protected:
00438 virtual bool do_set (const octave_value&)
00439 {
00440 error ("set: invalid property \"%s\"", name.c_str ());
00441 return false;
00442 }
00443
00444 private:
00445 typedef std::map<listener_mode, octave_value_list> listener_map;
00446 typedef std::map<listener_mode, octave_value_list>::iterator listener_map_iterator;
00447 typedef std::map<listener_mode, octave_value_list>::const_iterator listener_map_const_iterator;
00448
00449 private:
00450 int id;
00451 int count;
00452 std::string name;
00453 graphics_handle parent;
00454 bool hidden;
00455 listener_map listeners;
00456 };
00457
00458
00459
00460 class string_property : public base_property
00461 {
00462 public:
00463 string_property (const std::string& s, const graphics_handle& h,
00464 const std::string& val = "")
00465 : base_property (s, h), str (val) { }
00466
00467 string_property (const string_property& p)
00468 : base_property (p), str (p.str) { }
00469
00470 octave_value get (void) const
00471 { return octave_value (str); }
00472
00473 std::string string_value (void) const { return str; }
00474
00475 string_property& operator = (const octave_value& val)
00476 {
00477 set (val);
00478 return *this;
00479 }
00480
00481 base_property* clone (void) const { return new string_property (*this); }
00482
00483 protected:
00484 bool do_set (const octave_value& val)
00485 {
00486 if (val.is_string ())
00487 {
00488 std::string new_str = val.string_value ();
00489
00490 if (new_str != str)
00491 {
00492 str = new_str;
00493 return true;
00494 }
00495 }
00496 else
00497 error ("set: invalid string property value for \"%s\"",
00498 get_name ().c_str ());
00499 return false;
00500 }
00501
00502 private:
00503 std::string str;
00504 };
00505
00506
00507
00508 class string_array_property : public base_property
00509 {
00510 public:
00511 enum desired_enum { string_t, cell_t };
00512
00513 string_array_property (const std::string& s, const graphics_handle& h,
00514 const std::string& val = "", const char& sep = '|',
00515 const desired_enum& typ = string_t)
00516 : base_property (s, h), desired_type (typ), separator (sep), str ()
00517 {
00518 size_t pos = 0;
00519
00520 while (true)
00521 {
00522 size_t new_pos = val.find_first_of (separator, pos);
00523
00524 if (new_pos == std::string::npos)
00525 {
00526 str.append (val.substr (pos));
00527 break;
00528 }
00529 else
00530 str.append (val.substr (pos, new_pos - pos));
00531
00532 pos = new_pos + 1;
00533 }
00534 }
00535
00536 string_array_property (const std::string& s, const graphics_handle& h,
00537 const Cell& c, const char& sep = '|',
00538 const desired_enum& typ = string_t)
00539 : base_property (s, h), desired_type (typ), separator (sep), str ()
00540 {
00541 if (c.is_cellstr ())
00542 {
00543 string_vector strings (c.numel ());
00544
00545 for (octave_idx_type i = 0; i < c.numel (); i++)
00546 strings[i] = c(i).string_value ();
00547
00548 str = strings;
00549 }
00550 else
00551 error ("set: invalid order property value for \"%s\"",
00552 get_name ().c_str ());
00553 }
00554
00555 string_array_property (const string_array_property& p)
00556 : base_property (p), desired_type (p.desired_type),
00557 separator (p.separator), str (p.str) { }
00558
00559 octave_value get (void) const
00560 {
00561 if (desired_type == string_t)
00562 return octave_value (string_value ());
00563 else
00564 return octave_value (cell_value ());
00565 }
00566
00567 std::string string_value (void) const
00568 {
00569 std::string s;
00570
00571 for (octave_idx_type i = 0; i < str.length (); i++)
00572 {
00573 s += str[i];
00574 if (i != str.length () - 1)
00575 s += separator;
00576 }
00577
00578 return s;
00579 }
00580
00581 Cell cell_value (void) const {return Cell (str);}
00582
00583 string_array_property& operator = (const octave_value& val)
00584 {
00585 set (val);
00586 return *this;
00587 }
00588
00589 base_property* clone (void) const { return new string_array_property (*this); }
00590
00591 protected:
00592 bool do_set (const octave_value& val)
00593 {
00594 if (val.is_string ())
00595 {
00596 bool replace = false;
00597 std::string new_str = val.string_value ();
00598 string_vector strings;
00599 size_t pos = 0;
00600
00601 while (pos != std::string::npos)
00602 {
00603 size_t new_pos = new_str.find_first_of (separator, pos);
00604
00605 if (new_pos == std::string::npos)
00606 {
00607 strings.append (new_str.substr (pos));
00608 break;
00609 }
00610 else
00611 strings.append (new_str.substr (pos, new_pos - pos));
00612
00613 pos = new_pos + 1;
00614 }
00615
00616 if (str.numel () == strings.numel ())
00617 {
00618 for (octave_idx_type i = 0; i < str.numel (); i++)
00619 if (strings[i] != str[i])
00620 {
00621 replace = true;
00622 break;
00623 }
00624 }
00625 else
00626 replace = true;
00627
00628 if (replace)
00629 {
00630 str = strings;
00631 return true;
00632 }
00633 }
00634 else if (val.is_cellstr ())
00635 {
00636 bool replace = false;
00637 Cell new_cell = val.cell_value ();
00638
00639 string_vector strings = new_cell.cellstr_value ();
00640
00641 octave_idx_type nel = strings.length ();
00642
00643 if (nel != str.length ())
00644 replace = true;
00645 else
00646 {
00647 for (octave_idx_type i = 0; i < nel; i++)
00648 {
00649 if (strings[i] != str[i])
00650 {
00651 replace = true;
00652 break;
00653 }
00654 }
00655 }
00656
00657 if (replace)
00658 {
00659 str = strings;
00660 return true;
00661 }
00662 }
00663 else
00664 error ("set: invalid string property value for \"%s\"",
00665 get_name ().c_str ());
00666 return false;
00667 }
00668
00669 private:
00670 desired_enum desired_type;
00671 char separator;
00672 string_vector str;
00673 };
00674
00675
00676
00677 class radio_values
00678 {
00679 public:
00680 OCTINTERP_API radio_values (const std::string& opt_string = std::string ());
00681
00682 radio_values (const radio_values& a)
00683 : default_val (a.default_val), possible_vals (a.possible_vals) { }
00684
00685 radio_values& operator = (const radio_values& a)
00686 {
00687 if (&a != this)
00688 {
00689 default_val = a.default_val;
00690 possible_vals = a.possible_vals;
00691 }
00692
00693 return *this;
00694 }
00695
00696 std::string default_value (void) const { return default_val; }
00697
00698 bool validate (const std::string& val)
00699 {
00700 bool retval = true;
00701
00702 if (! contains (val))
00703 {
00704 error ("invalid value = %s", val.c_str ());
00705 retval = false;
00706 }
00707
00708 return retval;
00709 }
00710
00711 bool contains (const std::string& val)
00712 {
00713 return (possible_vals.find (val) != possible_vals.end ());
00714 }
00715
00716 std::string values_as_string (void) const;
00717
00718 Cell values_as_cell (void) const;
00719
00720 octave_idx_type nelem (void) const { return possible_vals.size (); }
00721
00722 private:
00723
00724 std::string default_val;
00725 std::set<caseless_str> possible_vals;
00726 };
00727
00728 class radio_property : public base_property
00729 {
00730 public:
00731 radio_property (const std::string& nm, const graphics_handle& h,
00732 const radio_values& v = radio_values ())
00733 : base_property (nm, h),
00734 vals (v), current_val (v.default_value ()) { }
00735
00736 radio_property (const std::string& nm, const graphics_handle& h,
00737 const std::string& v)
00738 : base_property (nm, h),
00739 vals (v), current_val (vals.default_value ()) { }
00740
00741 radio_property (const std::string& nm, const graphics_handle& h,
00742 const radio_values& v, const std::string& def)
00743 : base_property (nm, h),
00744 vals (v), current_val (def) { }
00745
00746 radio_property (const radio_property& p)
00747 : base_property (p), vals (p.vals), current_val (p.current_val) { }
00748
00749 octave_value get (void) const { return octave_value (current_val); }
00750
00751 const std::string& current_value (void) const { return current_val; }
00752
00753 std::string values_as_string (void) const { return vals.values_as_string (); }
00754
00755 Cell values_as_cell (void) const { return vals.values_as_cell (); }
00756
00757 bool is (const caseless_str& v) const
00758 { return v.compare (current_val); }
00759
00760 bool is_radio (void) const { return true; }
00761
00762 radio_property& operator = (const octave_value& val)
00763 {
00764 set (val);
00765 return *this;
00766 }
00767
00768 base_property* clone (void) const { return new radio_property (*this); }
00769
00770 protected:
00771 bool do_set (const octave_value& newval)
00772 {
00773 if (newval.is_string ())
00774 {
00775 std::string s = newval.string_value ();
00776 if (vals.validate (s))
00777 {
00778 if (s != current_val)
00779 {
00780 current_val = s;
00781 return true;
00782 }
00783 }
00784 else
00785 error ("set: invalid value for radio property \"%s\" (value = %s)",
00786 get_name ().c_str (), s.c_str ());
00787 }
00788 else
00789 error ("set: invalid value for radio property \"%s\"",
00790 get_name ().c_str ());
00791 return false;
00792 }
00793
00794 private:
00795 radio_values vals;
00796 std::string current_val;
00797 };
00798
00799
00800
00801 class color_values
00802 {
00803 public:
00804 color_values (double r = 0, double g = 0, double b = 1)
00805 : xrgb (1, 3)
00806 {
00807 xrgb(0) = r;
00808 xrgb(1) = g;
00809 xrgb(2) = b;
00810
00811 validate ();
00812 }
00813
00814 color_values (std::string str)
00815 : xrgb (1, 3)
00816 {
00817 if (! str2rgb (str))
00818 error ("invalid color specification: %s", str.c_str ());
00819 }
00820
00821 color_values (const color_values& c)
00822 : xrgb (c.xrgb)
00823 { }
00824
00825 color_values& operator = (const color_values& c)
00826 {
00827 if (&c != this)
00828 xrgb = c.xrgb;
00829
00830 return *this;
00831 }
00832
00833 bool operator == (const color_values& c) const
00834 {
00835 return (xrgb(0) == c.xrgb(0)
00836 && xrgb(1) == c.xrgb(1)
00837 && xrgb(2) == c.xrgb(2));
00838 }
00839
00840 bool operator != (const color_values& c) const
00841 { return ! (*this == c); }
00842
00843 Matrix rgb (void) const { return xrgb; }
00844
00845 operator octave_value (void) const { return xrgb; }
00846
00847 void validate (void) const
00848 {
00849 for (int i = 0; i < 3; i++)
00850 {
00851 if (xrgb(i) < 0 || xrgb(i) > 1)
00852 {
00853 error ("invalid RGB color specification");
00854 break;
00855 }
00856 }
00857 }
00858
00859 private:
00860 Matrix xrgb;
00861
00862 OCTINTERP_API bool str2rgb (std::string str);
00863 };
00864
00865 class color_property : public base_property
00866 {
00867 public:
00868 color_property (const color_values& c, const radio_values& v)
00869 : base_property ("", graphics_handle ()),
00870 current_type (color_t), color_val (c), radio_val (v),
00871 current_val (v.default_value ())
00872 { }
00873
00874 color_property (const std::string& nm, const graphics_handle& h,
00875 const color_values& c = color_values (),
00876 const radio_values& v = radio_values ())
00877 : base_property (nm, h),
00878 current_type (color_t), color_val (c), radio_val (v),
00879 current_val (v.default_value ())
00880 { }
00881
00882 color_property (const std::string& nm, const graphics_handle& h,
00883 const radio_values& v)
00884 : base_property (nm, h),
00885 current_type (radio_t), color_val (color_values ()), radio_val (v),
00886 current_val (v.default_value ())
00887 { }
00888
00889 color_property (const std::string& nm, const graphics_handle& h,
00890 const std::string& v)
00891 : base_property (nm, h),
00892 current_type (radio_t), color_val (color_values ()), radio_val (v),
00893 current_val (radio_val.default_value ())
00894 { }
00895
00896 color_property (const std::string& nm, const graphics_handle& h,
00897 const color_property& v)
00898 : base_property (nm, h),
00899 current_type (v.current_type), color_val (v.color_val),
00900 radio_val (v.radio_val), current_val (v.current_val)
00901 { }
00902
00903 color_property (const color_property& p)
00904 : base_property (p), current_type (p.current_type),
00905 color_val (p.color_val), radio_val (p.radio_val),
00906 current_val (p.current_val) { }
00907
00908 octave_value get (void) const
00909 {
00910 if (current_type == color_t)
00911 return color_val.rgb ();
00912
00913 return current_val;
00914 }
00915
00916 bool is_rgb (void) const { return (current_type == color_t); }
00917
00918 bool is_radio (void) const { return (current_type == radio_t); }
00919
00920 bool is (const std::string& v) const
00921 { return (is_radio () && current_val == v); }
00922
00923 Matrix rgb (void) const
00924 {
00925 if (current_type != color_t)
00926 error ("color has no rgb value");
00927
00928 return color_val.rgb ();
00929 }
00930
00931 const std::string& current_value (void) const
00932 {
00933 if (current_type != radio_t)
00934 error ("color has no radio value");
00935
00936 return current_val;
00937 }
00938
00939 color_property& operator = (const octave_value& val)
00940 {
00941 set (val);
00942 return *this;
00943 }
00944
00945 operator octave_value (void) const { return get (); }
00946
00947 base_property* clone (void) const { return new color_property (*this); }
00948
00949 std::string values_as_string (void) const { return radio_val.values_as_string (); }
00950
00951 Cell values_as_cell (void) const { return radio_val.values_as_cell (); }
00952
00953 protected:
00954 OCTINTERP_API bool do_set (const octave_value& newval);
00955
00956 private:
00957 enum current_enum { color_t, radio_t } current_type;
00958 color_values color_val;
00959 radio_values radio_val;
00960 std::string current_val;
00961 };
00962
00963
00964
00965 class double_property : public base_property
00966 {
00967 public:
00968 double_property (const std::string& nm, const graphics_handle& h,
00969 double d = 0)
00970 : base_property (nm, h),
00971 current_val (d) { }
00972
00973 double_property (const double_property& p)
00974 : base_property (p), current_val (p.current_val) { }
00975
00976 octave_value get (void) const { return octave_value (current_val); }
00977
00978 double double_value (void) const { return current_val; }
00979
00980 double_property& operator = (const octave_value& val)
00981 {
00982 set (val);
00983 return *this;
00984 }
00985
00986 base_property* clone (void) const { return new double_property (*this); }
00987
00988 protected:
00989 bool do_set (const octave_value& v)
00990 {
00991 if (v.is_scalar_type () && v.is_real_type ())
00992 {
00993 double new_val = v.double_value ();
00994
00995 if (new_val != current_val)
00996 {
00997 current_val = new_val;
00998 return true;
00999 }
01000 }
01001 else
01002 error ("set: invalid value for double property \"%s\"",
01003 get_name ().c_str ());
01004 return false;
01005 }
01006
01007 private:
01008 double current_val;
01009 };
01010
01011
01012
01013 class double_radio_property : public base_property
01014 {
01015 public:
01016 double_radio_property (double d, const radio_values& v)
01017 : base_property ("", graphics_handle ()),
01018 current_type (double_t), dval (d), radio_val (v),
01019 current_val (v.default_value ())
01020 { }
01021
01022 double_radio_property (const std::string& nm, const graphics_handle& h,
01023 const std::string& v)
01024 : base_property (nm, h),
01025 current_type (radio_t), dval (0), radio_val (v),
01026 current_val (radio_val.default_value ())
01027 { }
01028
01029 double_radio_property (const std::string& nm, const graphics_handle& h,
01030 const double_radio_property& v)
01031 : base_property (nm, h),
01032 current_type (v.current_type), dval (v.dval),
01033 radio_val (v.radio_val), current_val (v.current_val)
01034 { }
01035
01036 double_radio_property (const double_radio_property& p)
01037 : base_property (p), current_type (p.current_type),
01038 dval (p.dval), radio_val (p.radio_val),
01039 current_val (p.current_val) { }
01040
01041 octave_value get (void) const
01042 {
01043 if (current_type == double_t)
01044 return dval;
01045
01046 return current_val;
01047 }
01048
01049 bool is_double (void) const { return (current_type == double_t); }
01050
01051 bool is_radio (void) const { return (current_type == radio_t); }
01052
01053 bool is (const std::string& v) const
01054 { return (is_radio () && current_val == v); }
01055
01056 double double_value (void) const
01057 {
01058 if (current_type != double_t)
01059 error ("%s: property has no double", get_name ().c_str ());
01060
01061 return dval;
01062 }
01063
01064 const std::string& current_value (void) const
01065 {
01066 if (current_type != radio_t)
01067 error ("%s: property has no radio value");
01068
01069 return current_val;
01070 }
01071
01072 double_radio_property& operator = (const octave_value& val)
01073 {
01074 set (val);
01075 return *this;
01076 }
01077
01078 operator octave_value (void) const { return get (); }
01079
01080 base_property* clone (void) const
01081 { return new double_radio_property (*this); }
01082
01083 protected:
01084 OCTINTERP_API bool do_set (const octave_value& v);
01085
01086 private:
01087 enum current_enum { double_t, radio_t } current_type;
01088 double dval;
01089 radio_values radio_val;
01090 std::string current_val;
01091 };
01092
01093
01094
01095 class array_property : public base_property
01096 {
01097 public:
01098 array_property (void)
01099 : base_property ("", graphics_handle ()), data (Matrix ()),
01100 xmin (), xmax (), xminp (), type_constraints (), size_constraints ()
01101 {
01102 get_data_limits ();
01103 }
01104
01105 array_property (const std::string& nm, const graphics_handle& h,
01106 const octave_value& m)
01107 : base_property (nm, h), data (m),
01108 xmin (), xmax (), xminp (), type_constraints (), size_constraints ()
01109 {
01110 get_data_limits ();
01111 }
01112
01113
01114
01115
01116 array_property (const array_property& p)
01117 : base_property (p), data (p.data),
01118 xmin (p.xmin), xmax (p.xmax), xminp (p.xminp),
01119 type_constraints (), size_constraints ()
01120 { }
01121
01122 octave_value get (void) const { return data; }
01123
01124 void add_constraint (const std::string& type)
01125 { type_constraints.push_back (type); }
01126
01127 void add_constraint (const dim_vector& dims)
01128 { size_constraints.push_back (dims); }
01129
01130 double min_val (void) const { return xmin; }
01131 double max_val (void) const { return xmax; }
01132 double min_pos (void) const { return xminp; }
01133
01134 Matrix get_limits (void) const
01135 {
01136 Matrix m (1, 3);
01137
01138 m(0) = min_val ();
01139 m(1) = max_val ();
01140 m(2) = min_pos ();
01141
01142 return m;
01143 }
01144
01145 array_property& operator = (const octave_value& val)
01146 {
01147 set (val);
01148 return *this;
01149 }
01150
01151 base_property* clone (void) const
01152 {
01153 array_property *p = new array_property (*this);
01154
01155 p->type_constraints = type_constraints;
01156 p->size_constraints = size_constraints;
01157
01158 return p;
01159 }
01160
01161 protected:
01162 bool do_set (const octave_value& v)
01163 {
01164 if (validate (v))
01165 {
01166
01167 if (! is_equal (v))
01168 {
01169 data = v;
01170
01171 get_data_limits ();
01172
01173 return true;
01174 }
01175 }
01176 else
01177 error ("invalid value for array property \"%s\"",
01178 get_name ().c_str ());
01179
01180 return false;
01181 }
01182
01183 private:
01184 OCTINTERP_API bool validate (const octave_value& v);
01185
01186 OCTINTERP_API bool is_equal (const octave_value& v) const;
01187
01188 OCTINTERP_API void get_data_limits (void);
01189
01190 protected:
01191 octave_value data;
01192 double xmin;
01193 double xmax;
01194 double xminp;
01195 std::list<std::string> type_constraints;
01196 std::list<dim_vector> size_constraints;
01197 };
01198
01199 class row_vector_property : public array_property
01200 {
01201 public:
01202 row_vector_property (const std::string& nm, const graphics_handle& h,
01203 const octave_value& m)
01204 : array_property (nm, h, m)
01205 {
01206 add_constraint (dim_vector (-1, 1));
01207 add_constraint (dim_vector (1, -1));
01208 }
01209
01210 row_vector_property (const row_vector_property& p)
01211 : array_property (p)
01212 {
01213 add_constraint (dim_vector (-1, 1));
01214 add_constraint (dim_vector (1, -1));
01215 }
01216
01217 void add_constraint (const std::string& type)
01218 {
01219 array_property::add_constraint (type);
01220 }
01221
01222 void add_constraint (const dim_vector& dims)
01223 {
01224 array_property::add_constraint (dims);
01225 }
01226
01227 void add_constraint (octave_idx_type len)
01228 {
01229 size_constraints.remove (dim_vector (1, -1));
01230 size_constraints.remove (dim_vector (-1, 1));
01231
01232 add_constraint (dim_vector (1, len));
01233 add_constraint (dim_vector (len, 1));
01234 }
01235
01236 row_vector_property& operator = (const octave_value& val)
01237 {
01238 set (val);
01239 return *this;
01240 }
01241
01242 base_property* clone (void) const
01243 {
01244 row_vector_property *p = new row_vector_property (*this);
01245
01246 p->type_constraints = type_constraints;
01247 p->size_constraints = size_constraints;
01248
01249 return p;
01250 }
01251
01252 protected:
01253 bool do_set (const octave_value& v)
01254 {
01255 bool retval = array_property::do_set (v);
01256
01257 if (! error_state)
01258 {
01259 dim_vector dv = data.dims ();
01260
01261 if (dv(0) > 1 && dv(1) == 1)
01262 {
01263 int tmp = dv(0);
01264 dv(0) = dv(1);
01265 dv(1) = tmp;
01266
01267 data = data.reshape (dv);
01268 }
01269
01270 return retval;
01271 }
01272
01273 return false;
01274 }
01275
01276 private:
01277 OCTINTERP_API bool validate (const octave_value& v);
01278 };
01279
01280
01281
01282 class bool_property : public radio_property
01283 {
01284 public:
01285 bool_property (const std::string& nm, const graphics_handle& h,
01286 bool val)
01287 : radio_property (nm, h, radio_values (val ? "{on}|off" : "on|{off}"))
01288 { }
01289
01290 bool_property (const std::string& nm, const graphics_handle& h,
01291 const char* val)
01292 : radio_property (nm, h, radio_values ("on|off"), val)
01293 { }
01294
01295 bool_property (const bool_property& p)
01296 : radio_property (p) { }
01297
01298 bool is_on (void) const { return is ("on"); }
01299
01300 bool_property& operator = (const octave_value& val)
01301 {
01302 set (val);
01303 return *this;
01304 }
01305
01306 base_property* clone (void) const { return new bool_property (*this); }
01307
01308 protected:
01309 bool do_set (const octave_value& val)
01310 {
01311 if (val.is_bool_scalar ())
01312 return radio_property::do_set (val.bool_value () ? "on" : "off");
01313 else
01314 return radio_property::do_set (val);
01315 }
01316 };
01317
01318
01319
01320 class handle_property : public base_property
01321 {
01322 public:
01323 handle_property (const std::string& nm, const graphics_handle& h,
01324 const graphics_handle& val = graphics_handle ())
01325 : base_property (nm, h),
01326 current_val (val) { }
01327
01328 handle_property (const handle_property& p)
01329 : base_property (p), current_val (p.current_val) { }
01330
01331 octave_value get (void) const { return current_val.as_octave_value (); }
01332
01333 graphics_handle handle_value (void) const { return current_val; }
01334
01335 handle_property& operator = (const octave_value& val)
01336 {
01337 set (val);
01338 return *this;
01339 }
01340
01341 handle_property& operator = (const graphics_handle& h)
01342 {
01343 set (octave_value (h.value ()));
01344 return *this;
01345 }
01346
01347 base_property* clone (void) const { return new handle_property (*this); }
01348
01349 protected:
01350 OCTINTERP_API bool do_set (const octave_value& v);
01351
01352 private:
01353 graphics_handle current_val;
01354 };
01355
01356
01357
01358 class any_property : public base_property
01359 {
01360 public:
01361 any_property (const std::string& nm, const graphics_handle& h,
01362 const octave_value& m = Matrix ())
01363 : base_property (nm, h), data (m) { }
01364
01365 any_property (const any_property& p)
01366 : base_property (p), data (p.data) { }
01367
01368 octave_value get (void) const { return data; }
01369
01370 any_property& operator = (const octave_value& val)
01371 {
01372 set (val);
01373 return *this;
01374 }
01375
01376 base_property* clone (void) const { return new any_property (*this); }
01377
01378 protected:
01379 bool do_set (const octave_value& v)
01380 {
01381 data = v;
01382 return true;
01383 }
01384
01385 private:
01386 octave_value data;
01387 };
01388
01389
01390
01391 class children_property : public base_property
01392 {
01393 public:
01394 children_property (void)
01395 : base_property ("", graphics_handle ()), children_list ()
01396 {
01397 do_init_children (Matrix ());
01398 }
01399
01400 children_property (const std::string& nm, const graphics_handle& h,
01401 const Matrix &val)
01402 : base_property (nm, h), children_list ()
01403 {
01404 do_init_children (val);
01405 }
01406
01407 children_property (const children_property& p)
01408 : base_property (p), children_list ()
01409 {
01410 do_init_children (p.children_list);
01411 }
01412
01413 children_property& operator = (const octave_value& val)
01414 {
01415 set (val);
01416 return *this;
01417 }
01418
01419 base_property* clone (void) const { return new children_property (*this); }
01420
01421 bool remove_child (const double &val)
01422 {
01423 return do_remove_child (val);
01424 }
01425
01426 void adopt (const double &val)
01427 {
01428 do_adopt_child (val);
01429 }
01430
01431 Matrix get_children (void) const
01432 {
01433 return do_get_children (false);
01434 }
01435
01436 Matrix get_hidden (void) const
01437 {
01438 return do_get_children (true);
01439 }
01440
01441 Matrix get_all (void) const
01442 {
01443 return do_get_all_children ();
01444 }
01445
01446 octave_value get (void) const
01447 {
01448 return octave_value (get_children ());
01449 }
01450
01451 void delete_children (bool clear = false)
01452 {
01453 do_delete_children (clear);
01454 }
01455
01456 private:
01457 typedef std::list<double>::iterator children_list_iterator;
01458 typedef std::list<double>::const_iterator const_children_list_iterator;
01459 std::list<double> children_list;
01460
01461 protected:
01462 bool do_set (const octave_value& val)
01463 {
01464 const Matrix new_kids = val.matrix_value ();
01465
01466 octave_idx_type nel = new_kids.numel ();
01467
01468 const Matrix new_kids_column = new_kids.reshape (dim_vector (nel, 1));
01469
01470 bool is_ok = true;
01471
01472 if (! error_state)
01473 {
01474 const Matrix visible_kids = do_get_children (false);
01475
01476 if (visible_kids.numel () == new_kids.numel ())
01477 {
01478 Matrix t1 = visible_kids.sort ();
01479 Matrix t2 = new_kids_column.sort ();
01480
01481 if (t1 != t2)
01482 is_ok = false;
01483 }
01484 else
01485 is_ok = false;
01486
01487 if (! is_ok)
01488 error ("set: new children must be a permutation of existing children");
01489 }
01490 else
01491 {
01492 is_ok = false;
01493 error ("set: expecting children to be array of graphics handles");
01494 }
01495
01496 if (is_ok)
01497 {
01498 Matrix tmp = new_kids_column.stack (get_hidden ());
01499
01500 children_list.clear ();
01501
01502
01503
01504
01505
01506 for (octave_idx_type i = 0; i < tmp.numel (); i++)
01507 children_list.push_back (tmp.xelem (i));
01508 }
01509
01510 return is_ok;
01511 }
01512
01513 private:
01514 void do_init_children (const Matrix &val)
01515 {
01516 children_list.clear ();
01517 for (octave_idx_type i = 0; i < val.numel (); i++)
01518 children_list.push_front (val.xelem (i));
01519 }
01520
01521 void do_init_children (const std::list<double> &val)
01522 {
01523 children_list.clear ();
01524 for (const_children_list_iterator p = val.begin (); p != val.end (); p++)
01525 children_list.push_front (*p);
01526 }
01527
01528 Matrix do_get_children (bool return_hidden) const;
01529
01530 Matrix do_get_all_children (void) const
01531 {
01532 Matrix retval (children_list.size (), 1);
01533 octave_idx_type i = 0;
01534
01535 for (const_children_list_iterator p = children_list.begin ();
01536 p != children_list.end (); p++)
01537 retval(i++) = *p;
01538 return retval;
01539 }
01540
01541 bool do_remove_child (double child)
01542 {
01543 for (children_list_iterator p = children_list.begin ();
01544 p != children_list.end (); p++)
01545 {
01546 if (*p == child)
01547 {
01548 children_list.erase (p);
01549 return true;
01550 }
01551 }
01552 return false;
01553 }
01554
01555 void do_adopt_child (const double &val)
01556 {
01557 children_list.push_front (val);
01558 }
01559
01560 void do_delete_children (bool clear);
01561 };
01562
01563
01564
01565
01566
01567 class callback_property : public base_property
01568 {
01569 public:
01570 callback_property (const std::string& nm, const graphics_handle& h,
01571 const octave_value& m)
01572 : base_property (nm, h), callback (m) { }
01573
01574 callback_property (const callback_property& p)
01575 : base_property (p), callback (p.callback) { }
01576
01577 octave_value get (void) const { return callback; }
01578
01579 OCTINTERP_API void execute (const octave_value& data = octave_value ()) const;
01580
01581 bool is_defined (void) const
01582 {
01583 return (callback.is_defined () && ! callback.is_empty ());
01584 }
01585
01586 callback_property& operator = (const octave_value& val)
01587 {
01588 set (val);
01589 return *this;
01590 }
01591
01592 base_property* clone (void) const { return new callback_property (*this); }
01593
01594 protected:
01595 bool do_set (const octave_value& v)
01596 {
01597 if (validate (v))
01598 {
01599 callback = v;
01600 return true;
01601 }
01602 else
01603 error ("invalid value for callback property \"%s\"",
01604 get_name ().c_str ());
01605 return false;
01606 }
01607
01608 private:
01609 OCTINTERP_API bool validate (const octave_value& v) const;
01610
01611 private:
01612 octave_value callback;
01613 };
01614
01615
01616
01617 class property
01618 {
01619 public:
01620 property (void) : rep (new base_property ("", graphics_handle ()))
01621 { }
01622
01623 property (base_property *bp, bool persist = false) : rep (bp)
01624 { if (persist) rep->count++; }
01625
01626 property (const property& p) : rep (p.rep)
01627 {
01628 rep->count++;
01629 }
01630
01631 ~property (void)
01632 {
01633 if (--rep->count <= 0)
01634 delete rep;
01635 }
01636
01637 bool ok (void) const
01638 { return rep->ok (); }
01639
01640 std::string get_name (void) const
01641 { return rep->get_name (); }
01642
01643 void set_name (const std::string& name)
01644 { rep->set_name (name); }
01645
01646 graphics_handle get_parent (void) const
01647 { return rep->get_parent (); }
01648
01649 void set_parent (const graphics_handle& h)
01650 { rep->set_parent (h); }
01651
01652 bool is_hidden (void) const
01653 { return rep->is_hidden (); }
01654
01655 void set_hidden (bool flag)
01656 { rep->set_hidden (flag); }
01657
01658 bool is_radio (void) const
01659 { return rep->is_radio (); }
01660
01661 int get_id (void) const
01662 { return rep->get_id (); }
01663
01664 void set_id (int d)
01665 { rep->set_id (d); }
01666
01667 octave_value get (void) const
01668 { return rep->get (); }
01669
01670 bool set (const octave_value& val)
01671 { return rep->set (val); }
01672
01673 std::string values_as_string (void) const
01674 { return rep->values_as_string (); }
01675
01676 Cell values_as_cell (void) const
01677 { return rep->values_as_cell (); }
01678
01679 property& operator = (const octave_value& val)
01680 {
01681 *rep = val;
01682 return *this;
01683 }
01684
01685 property& operator = (const property& p)
01686 {
01687 if (rep && --rep->count <= 0)
01688 delete rep;
01689
01690 rep = p.rep;
01691 rep->count++;
01692
01693 return *this;
01694 }
01695
01696 void add_listener (const octave_value& v, listener_mode mode = POSTSET)
01697 { rep->add_listener (v, mode); }
01698
01699 void delete_listener (const octave_value& v = octave_value (),
01700 listener_mode mode = POSTSET)
01701 { rep->delete_listener (v, mode); }
01702
01703 void run_listeners (listener_mode mode = POSTSET)
01704 { rep->run_listeners (mode); }
01705
01706 OCTINTERP_API static
01707 property create (const std::string& name, const graphics_handle& parent,
01708 const caseless_str& type,
01709 const octave_value_list& args);
01710
01711 property clone (void) const
01712 { return property (rep->clone ()); }
01713
01714
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734 private:
01735 base_property *rep;
01736 };
01737
01738
01739
01740 class property_list
01741 {
01742 public:
01743 typedef std::map<std::string, octave_value> pval_map_type;
01744 typedef std::map<std::string, pval_map_type> plist_map_type;
01745
01746 typedef pval_map_type::iterator pval_map_iterator;
01747 typedef pval_map_type::const_iterator pval_map_const_iterator;
01748
01749 typedef plist_map_type::iterator plist_map_iterator;
01750 typedef plist_map_type::const_iterator plist_map_const_iterator;
01751
01752 property_list (const plist_map_type& m = plist_map_type ())
01753 : plist_map (m) { }
01754
01755 ~property_list (void) { }
01756
01757 void set (const caseless_str& name, const octave_value& val);
01758
01759 octave_value lookup (const caseless_str& name) const;
01760
01761 plist_map_iterator begin (void) { return plist_map.begin (); }
01762 plist_map_const_iterator begin (void) const { return plist_map.begin (); }
01763
01764 plist_map_iterator end (void) { return plist_map.end (); }
01765 plist_map_const_iterator end (void) const { return plist_map.end (); }
01766
01767 plist_map_iterator find (const std::string& go_name)
01768 {
01769 return plist_map.find (go_name);
01770 }
01771
01772 plist_map_const_iterator find (const std::string& go_name) const
01773 {
01774 return plist_map.find (go_name);
01775 }
01776
01777 octave_scalar_map as_struct (const std::string& prefix_arg) const;
01778
01779 private:
01780 plist_map_type plist_map;
01781 };
01782
01783
01784
01785 class graphics_toolkit;
01786 class graphics_object;
01787
01788 class base_graphics_toolkit
01789 {
01790 public:
01791 friend class graphics_toolkit;
01792
01793 public:
01794 base_graphics_toolkit (const std::string& nm)
01795 : name (nm), count (0) { }
01796
01797 virtual ~base_graphics_toolkit (void) { }
01798
01799 std::string get_name (void) const { return name; }
01800
01801 virtual bool is_valid (void) const { return false; }
01802
01803 virtual void redraw_figure (const graphics_object&) const
01804 { gripe_invalid ("redraw_figure"); }
01805
01806 virtual void print_figure (const graphics_object&, const std::string&,
01807 const std::string&, bool,
01808 const std::string& = "") const
01809 { gripe_invalid ("print_figure"); }
01810
01811 virtual Matrix get_canvas_size (const graphics_handle&) const
01812 {
01813 gripe_invalid ("get_canvas_size");
01814 return Matrix (1, 2, 0.0);
01815 }
01816
01817 virtual double get_screen_resolution (void) const
01818 {
01819 gripe_invalid ("get_screen_resolution");
01820 return 72.0;
01821 }
01822
01823 virtual Matrix get_screen_size (void) const
01824 {
01825 gripe_invalid ("get_screen_size");
01826 return Matrix (1, 2, 0.0);
01827 }
01828
01829
01830
01831
01832 virtual void update (const graphics_object&, int)
01833 { gripe_invalid ("base_graphics_toolkit::update"); }
01834
01835 void update (const graphics_handle&, int);
01836
01837
01838
01839
01840 virtual void initialize (const graphics_object&)
01841 { gripe_invalid ("base_graphics_toolkit::initialize"); }
01842
01843 void initialize (const graphics_handle&);
01844
01845
01846
01847
01848 virtual void finalize (const graphics_object&)
01849 { gripe_invalid ("base_graphics_toolkit::finalize"); }
01850
01851 void finalize (const graphics_handle&);
01852
01853 private:
01854 std::string name;
01855 int count;
01856
01857 private:
01858 void gripe_invalid (const std::string& fname) const
01859 {
01860 if (! is_valid ())
01861 error ("%s: invalid graphics toolkit", fname.c_str ());
01862 }
01863 };
01864
01865 class graphics_toolkit
01866 {
01867 public:
01868 graphics_toolkit (void)
01869 : rep (new base_graphics_toolkit ("unknown"))
01870 {
01871 rep->count++;
01872 }
01873
01874 graphics_toolkit (base_graphics_toolkit* b)
01875 : rep (b)
01876 {
01877 rep->count++;
01878 }
01879
01880 graphics_toolkit (const graphics_toolkit& b)
01881 : rep (b.rep)
01882 {
01883 rep->count++;
01884 }
01885
01886 ~graphics_toolkit (void)
01887 {
01888 if (--rep->count == 0)
01889 delete rep;
01890 }
01891
01892 graphics_toolkit& operator = (const graphics_toolkit& b)
01893 {
01894 if (rep != b.rep)
01895 {
01896 if (--rep->count == 0)
01897 delete rep;
01898
01899 rep = b.rep;
01900 rep->count++;
01901 }
01902
01903 return *this;
01904 }
01905
01906 operator bool (void) const { return rep->is_valid (); }
01907
01908 std::string get_name (void) const { return rep->get_name (); }
01909
01910 void redraw_figure (const graphics_object& go) const
01911 { rep->redraw_figure (go); }
01912
01913 void print_figure (const graphics_object& go, const std::string& term,
01914 const std::string& file, bool mono,
01915 const std::string& debug_file = "") const
01916 { rep->print_figure (go, term, file, mono, debug_file); }
01917
01918 Matrix get_canvas_size (const graphics_handle& fh) const
01919 { return rep->get_canvas_size (fh); }
01920
01921 double get_screen_resolution (void) const
01922 { return rep->get_screen_resolution (); }
01923
01924 Matrix get_screen_size (void) const
01925 { return rep->get_screen_size (); }
01926
01927
01928 void update (const graphics_object& go, int id)
01929 { rep->update (go, id); }
01930
01931 void update (const graphics_handle& h, int id)
01932 { rep->update (h, id); }
01933
01934
01935 void initialize (const graphics_object& go)
01936 { rep->initialize (go); }
01937
01938 void initialize (const graphics_handle& h)
01939 { rep->initialize (h); }
01940
01941
01942
01943
01944 void finalize (const graphics_object& go)
01945 { rep->finalize (go); }
01946
01947 void finalize (const graphics_handle& h)
01948 { rep->finalize (h); }
01949
01950 OCTINTERP_API static graphics_toolkit default_toolkit (void);
01951
01952 static void register_toolkit (const graphics_toolkit& b)
01953 { available_toolkits[b.get_name ()] = b; }
01954
01955 static void unregister_toolkit (const std::string& name)
01956 { available_toolkits.erase (name); }
01957
01958 static graphics_toolkit find_toolkit (const std::string& name)
01959 {
01960 const_available_toolkits_iterator p = available_toolkits.find (name);
01961
01962 if (p != available_toolkits.end ())
01963 return p->second;
01964 else
01965 return default_toolkit ();
01966 }
01967
01968 static Cell available_toolkits_list (void)
01969 {
01970 Cell m (1 , available_toolkits.size ());
01971 const_available_toolkits_iterator p;
01972 int i;
01973
01974 for (i = 0, p = available_toolkits.begin ();
01975 p != available_toolkits.end (); p++, i++)
01976 m(i) = p->first;
01977
01978 return m;
01979 }
01980
01981 private:
01982 base_graphics_toolkit *rep;
01983
01984 static OCTINTERP_API std::map<std::string, graphics_toolkit>
01985 available_toolkits;
01986
01987 typedef std::map<std::string, graphics_toolkit>::iterator
01988 available_toolkits_iterator;
01989
01990 typedef std::map<std::string, graphics_toolkit>::const_iterator
01991 const_available_toolkits_iterator;
01992 };
01993
01994
01995
01996 class base_graphics_object;
01997
01998 class OCTINTERP_API base_properties
01999 {
02000 public:
02001 base_properties (const std::string& ty = "unknown",
02002 const graphics_handle& mh = graphics_handle (),
02003 const graphics_handle& p = graphics_handle ());
02004
02005 virtual ~base_properties (void) { }
02006
02007 virtual std::string graphics_object_name (void) const { return "unknonwn"; }
02008
02009 void mark_modified (void);
02010
02011 void override_defaults (base_graphics_object& obj);
02012
02013
02014
02015
02016 void set_from_list (base_graphics_object& obj, property_list& defaults);
02017
02018 void insert_property (const std::string& name, property p)
02019 {
02020 p.set_name (name);
02021 p.set_parent (__myhandle__);
02022 all_props[name] = p;
02023 }
02024
02025 virtual void set (const caseless_str&, const octave_value&);
02026
02027 virtual octave_value get (const caseless_str& pname) const;
02028
02029 virtual octave_value get (const std::string& pname) const
02030 {
02031 return get (caseless_str (pname));
02032 }
02033
02034 virtual octave_value get (const char *pname) const
02035 {
02036 return get (caseless_str (pname));
02037 }
02038
02039 virtual octave_value get (bool all = false) const;
02040
02041 virtual property get_property (const caseless_str& pname);
02042
02043 virtual bool has_property (const caseless_str&) const
02044 {
02045 panic_impossible ();
02046 return false;
02047 }
02048
02049 bool is_modified (void) const { return is___modified__ (); }
02050
02051 virtual void remove_child (const graphics_handle& h)
02052 {
02053 if (children.remove_child (h.value ()))
02054 mark_modified ();
02055 }
02056
02057 virtual void adopt (const graphics_handle& h)
02058 {
02059 children.adopt (h.value ());
02060 mark_modified ();
02061 }
02062
02063 virtual graphics_toolkit get_toolkit (void) const;
02064
02065 virtual Matrix get_boundingbox (bool = false) const
02066 { return Matrix (1, 4, 0.0); }
02067
02068 virtual void update_boundingbox (void);
02069
02070 virtual void update_autopos (const std::string& elem_type);
02071
02072 virtual void add_listener (const caseless_str&, const octave_value&,
02073 listener_mode = POSTSET);
02074
02075 virtual void delete_listener (const caseless_str&, const octave_value&,
02076 listener_mode = POSTSET);
02077
02078 void set_tag (const octave_value& val) { tag = val; }
02079
02080 void set_parent (const octave_value& val);
02081
02082 Matrix get_children (void) const
02083 {
02084 return children.get_children ();
02085 }
02086
02087 Matrix get_all_children (void) const
02088 {
02089 return children.get_all ();
02090 }
02091
02092 Matrix get_hidden_children (void) const
02093 {
02094 return children.get_hidden ();
02095 }
02096
02097 void set_modified (const octave_value& val) { set___modified__ (val); }
02098
02099 void set___modified__ (const octave_value& val) { __modified__ = val; }
02100
02101 void reparent (const graphics_handle& new_parent) { parent = new_parent; }
02102
02103
02104
02105
02106 virtual void update_axis_limits (const std::string& axis_type) const;
02107
02108 virtual void update_axis_limits (const std::string& axis_type,
02109 const graphics_handle& h) const;
02110
02111 virtual void delete_children (bool clear = false)
02112 {
02113 children.delete_children (clear);
02114 }
02115
02116 static property_list::pval_map_type factory_defaults (void);
02117
02118
02119
02120
02121
02122
02123 virtual octave_value get_xlim (void) const { return octave_value (); }
02124 virtual octave_value get_ylim (void) const { return octave_value (); }
02125 virtual octave_value get_zlim (void) const { return octave_value (); }
02126 virtual octave_value get_clim (void) const { return octave_value (); }
02127 virtual octave_value get_alim (void) const { return octave_value (); }
02128
02129 virtual bool is_xliminclude (void) const { return false; }
02130 virtual bool is_yliminclude (void) const { return false; }
02131 virtual bool is_zliminclude (void) const { return false; }
02132 virtual bool is_climinclude (void) const { return false; }
02133 virtual bool is_aliminclude (void) const { return false; }
02134
02135 bool is_handle_visible (void) const
02136 {
02137 return ! handlevisibility.is ("off");
02138 }
02139
02140 std::set<std::string> dynamic_property_names (void) const;
02141
02142 bool has_dynamic_property (const std::string& pname);
02143
02144 protected:
02145 std::set<std::string> dynamic_properties;
02146
02147 void set_dynamic (const caseless_str& pname, const octave_value& val);
02148
02149 octave_value get_dynamic (const caseless_str& pname) const;
02150
02151 octave_value get_dynamic (bool all = false) const;
02152
02153 property get_property_dynamic (const caseless_str& pname);
02154
02155 public:
02156
02157
02158 static std::set<std::string> core_property_names (void);
02159
02160 static bool has_core_property (const caseless_str& pname);
02161
02162 std::set<std::string> all_property_names (void) const;
02163
02164 protected:
02165
02166 bool_property beingdeleted;
02167 radio_property busyaction;
02168 callback_property buttondownfcn;
02169 children_property children;
02170 bool_property clipping;
02171 callback_property createfcn;
02172 callback_property deletefcn;
02173 radio_property handlevisibility;
02174 bool_property hittest;
02175 bool_property interruptible;
02176 handle_property parent;
02177 bool_property selected;
02178 bool_property selectionhighlight;
02179 string_property tag;
02180 string_property type;
02181 any_property userdata;
02182 bool_property visible;
02183 bool_property __modified__;
02184 graphics_handle __myhandle__;
02185 handle_property uicontextmenu;
02186
02187 public:
02188
02189 enum
02190 {
02191 ID_BEINGDELETED = 0,
02192 ID_BUSYACTION = 1,
02193 ID_BUTTONDOWNFCN = 2,
02194 ID_CHILDREN = 3,
02195 ID_CLIPPING = 4,
02196 ID_CREATEFCN = 5,
02197 ID_DELETEFCN = 6,
02198 ID_HANDLEVISIBILITY = 7,
02199 ID_HITTEST = 8,
02200 ID_INTERRUPTIBLE = 9,
02201 ID_PARENT = 10,
02202 ID_SELECTED = 11,
02203 ID_SELECTIONHIGHLIGHT = 12,
02204 ID_TAG = 13,
02205 ID_TYPE = 14,
02206 ID_USERDATA = 15,
02207 ID_VISIBLE = 16,
02208 ID___MODIFIED__ = 17,
02209 ID___MYHANDLE__ = 18,
02210 ID_UICONTEXTMENU = 19
02211 };
02212
02213 bool is_beingdeleted (void) const { return beingdeleted.is_on (); }
02214 std::string get_beingdeleted (void) const { return beingdeleted.current_value (); }
02215
02216 bool busyaction_is (const std::string& v) const { return busyaction.is (v); }
02217 std::string get_busyaction (void) const { return busyaction.current_value (); }
02218
02219 void execute_buttondownfcn (const octave_value& data = octave_value ()) const { buttondownfcn.execute (data); }
02220 octave_value get_buttondownfcn (void) const { return buttondownfcn.get (); }
02221
02222 bool is_clipping (void) const { return clipping.is_on (); }
02223 std::string get_clipping (void) const { return clipping.current_value (); }
02224
02225 void execute_createfcn (const octave_value& data = octave_value ()) const { createfcn.execute (data); }
02226 octave_value get_createfcn (void) const { return createfcn.get (); }
02227
02228 void execute_deletefcn (const octave_value& data = octave_value ()) const { deletefcn.execute (data); }
02229 octave_value get_deletefcn (void) const { return deletefcn.get (); }
02230
02231 bool handlevisibility_is (const std::string& v) const { return handlevisibility.is (v); }
02232 std::string get_handlevisibility (void) const { return handlevisibility.current_value (); }
02233
02234 bool is_hittest (void) const { return hittest.is_on (); }
02235 std::string get_hittest (void) const { return hittest.current_value (); }
02236
02237 bool is_interruptible (void) const { return interruptible.is_on (); }
02238 std::string get_interruptible (void) const { return interruptible.current_value (); }
02239
02240 graphics_handle get_parent (void) const { return parent.handle_value (); }
02241
02242 bool is_selected (void) const { return selected.is_on (); }
02243 std::string get_selected (void) const { return selected.current_value (); }
02244
02245 bool is_selectionhighlight (void) const { return selectionhighlight.is_on (); }
02246 std::string get_selectionhighlight (void) const { return selectionhighlight.current_value (); }
02247
02248 std::string get_tag (void) const { return tag.string_value (); }
02249
02250 std::string get_type (void) const { return type.string_value (); }
02251
02252 octave_value get_userdata (void) const { return userdata.get (); }
02253
02254 bool is_visible (void) const { return visible.is_on (); }
02255 std::string get_visible (void) const { return visible.current_value (); }
02256
02257 bool is___modified__ (void) const { return __modified__.is_on (); }
02258 std::string get___modified__ (void) const { return __modified__.current_value (); }
02259
02260 graphics_handle get___myhandle__ (void) const { return __myhandle__; }
02261
02262 graphics_handle get_uicontextmenu (void) const { return uicontextmenu.handle_value (); }
02263
02264
02265 void set_beingdeleted (const octave_value& val)
02266 {
02267 if (! error_state)
02268 {
02269 if (beingdeleted.set (val, true))
02270 {
02271 mark_modified ();
02272 }
02273 }
02274 }
02275
02276 void set_busyaction (const octave_value& val)
02277 {
02278 if (! error_state)
02279 {
02280 if (busyaction.set (val, true))
02281 {
02282 mark_modified ();
02283 }
02284 }
02285 }
02286
02287 void set_buttondownfcn (const octave_value& val)
02288 {
02289 if (! error_state)
02290 {
02291 if (buttondownfcn.set (val, true))
02292 {
02293 mark_modified ();
02294 }
02295 }
02296 }
02297
02298 void set_children (const octave_value& val)
02299 {
02300 if (! error_state)
02301 {
02302 if (children.set (val, true))
02303 {
02304 mark_modified ();
02305 }
02306 }
02307 }
02308
02309 void set_clipping (const octave_value& val)
02310 {
02311 if (! error_state)
02312 {
02313 if (clipping.set (val, true))
02314 {
02315 mark_modified ();
02316 }
02317 }
02318 }
02319
02320 void set_createfcn (const octave_value& val)
02321 {
02322 if (! error_state)
02323 {
02324 if (createfcn.set (val, true))
02325 {
02326 mark_modified ();
02327 }
02328 }
02329 }
02330
02331 void set_deletefcn (const octave_value& val)
02332 {
02333 if (! error_state)
02334 {
02335 if (deletefcn.set (val, true))
02336 {
02337 mark_modified ();
02338 }
02339 }
02340 }
02341
02342 void set_handlevisibility (const octave_value& val)
02343 {
02344 if (! error_state)
02345 {
02346 if (handlevisibility.set (val, true))
02347 {
02348 mark_modified ();
02349 }
02350 }
02351 }
02352
02353 void set_hittest (const octave_value& val)
02354 {
02355 if (! error_state)
02356 {
02357 if (hittest.set (val, true))
02358 {
02359 mark_modified ();
02360 }
02361 }
02362 }
02363
02364 void set_interruptible (const octave_value& val)
02365 {
02366 if (! error_state)
02367 {
02368 if (interruptible.set (val, true))
02369 {
02370 mark_modified ();
02371 }
02372 }
02373 }
02374
02375 void set_selected (const octave_value& val)
02376 {
02377 if (! error_state)
02378 {
02379 if (selected.set (val, true))
02380 {
02381 mark_modified ();
02382 }
02383 }
02384 }
02385
02386 void set_selectionhighlight (const octave_value& val)
02387 {
02388 if (! error_state)
02389 {
02390 if (selectionhighlight.set (val, true))
02391 {
02392 mark_modified ();
02393 }
02394 }
02395 }
02396
02397 void set_userdata (const octave_value& val)
02398 {
02399 if (! error_state)
02400 {
02401 if (userdata.set (val, true))
02402 {
02403 mark_modified ();
02404 }
02405 }
02406 }
02407
02408 void set_visible (const octave_value& val)
02409 {
02410 if (! error_state)
02411 {
02412 if (visible.set (val, true))
02413 {
02414 mark_modified ();
02415 }
02416 }
02417 }
02418
02419 void set_uicontextmenu (const octave_value& val)
02420 {
02421 if (! error_state)
02422 {
02423 if (uicontextmenu.set (val, true))
02424 {
02425 mark_modified ();
02426 }
02427 }
02428 }
02429
02430
02431 protected:
02432 struct cmp_caseless_str
02433 {
02434 bool operator () (const caseless_str &a, const caseless_str &b) const
02435 {
02436 std::string a1 = a;
02437 std::transform (a1.begin (), a1.end (), a1.begin (), tolower);
02438 std::string b1 = b;
02439 std::transform (b1.begin (), b1.end (), b1.begin (), tolower);
02440
02441 return a1 < b1;
02442 }
02443 };
02444
02445 std::map<caseless_str, property, cmp_caseless_str> all_props;
02446
02447 protected:
02448 void insert_static_property (const std::string& name, base_property& p)
02449 { insert_property (name, property (&p, true)); }
02450
02451 virtual void init (void) { }
02452 };
02453
02454 class OCTINTERP_API base_graphics_object
02455 {
02456 public:
02457 friend class graphics_object;
02458
02459 base_graphics_object (void) : count (1) { }
02460
02461 virtual ~base_graphics_object (void) { }
02462
02463 virtual void mark_modified (void)
02464 {
02465 if (valid_object ())
02466 get_properties ().mark_modified ();
02467 else
02468 error ("base_graphics_object::mark_modified: invalid graphics object");
02469 }
02470
02471 virtual void override_defaults (base_graphics_object& obj)
02472 {
02473 if (valid_object ())
02474 get_properties ().override_defaults (obj);
02475 else
02476 error ("base_graphics_object::override_defaults: invalid graphics object");
02477 }
02478
02479 virtual void set_from_list (property_list& plist)
02480 {
02481 if (valid_object ())
02482 get_properties ().set_from_list (*this, plist);
02483 else
02484 error ("base_graphics_object::set_from_list: invalid graphics object");
02485 }
02486
02487 virtual void set (const caseless_str& pname, const octave_value& pval)
02488 {
02489 if (valid_object ())
02490 get_properties ().set (pname, pval);
02491 else
02492 error ("base_graphics_object::set: invalid graphics object");
02493 }
02494
02495 virtual void set_defaults (const std::string&)
02496 {
02497 error ("base_graphics_object::set_defaults: invalid graphics object");
02498 }
02499
02500 virtual octave_value get (bool all = false) const
02501 {
02502 if (valid_object ())
02503 return get_properties ().get (all);
02504 else
02505 {
02506 error ("base_graphics_object::get: invalid graphics object");
02507 return octave_value ();
02508 }
02509 }
02510
02511 virtual octave_value get (const caseless_str& pname) const
02512 {
02513 if (valid_object ())
02514 return get_properties ().get (pname);
02515 else
02516 {
02517 error ("base_graphics_object::get: invalid graphics object");
02518 return octave_value ();
02519 }
02520 }
02521
02522 virtual octave_value get_default (const caseless_str&) const;
02523
02524 virtual octave_value get_factory_default (const caseless_str&) const;
02525
02526 virtual octave_value get_defaults (void) const
02527 {
02528 error ("base_graphics_object::get_defaults: invalid graphics object");
02529 return octave_value ();
02530 }
02531
02532 virtual octave_value get_factory_defaults (void) const
02533 {
02534 error ("base_graphics_object::get_factory_defaults: invalid graphics object");
02535 return octave_value ();
02536 }
02537
02538 virtual std::string values_as_string (void);
02539
02540 virtual octave_scalar_map values_as_struct (void);
02541
02542 virtual graphics_handle get_parent (void) const
02543 {
02544 if (valid_object ())
02545 return get_properties ().get_parent ();
02546 else
02547 {
02548 error ("base_graphics_object::get_parent: invalid graphics object");
02549 return graphics_handle ();
02550 }
02551 }
02552
02553 graphics_handle get_handle (void) const
02554 {
02555 if (valid_object ())
02556 return get_properties ().get___myhandle__ ();
02557 else
02558 {
02559 error ("base_graphics_object::get_handle: invalid graphics object");
02560 return graphics_handle ();
02561 }
02562 }
02563
02564 virtual void remove_child (const graphics_handle& h)
02565 {
02566 if (valid_object ())
02567 get_properties ().remove_child (h);
02568 else
02569 error ("base_graphics_object::remove_child: invalid graphics object");
02570 }
02571
02572 virtual void adopt (const graphics_handle& h)
02573 {
02574 if (valid_object ())
02575 get_properties ().adopt (h);
02576 else
02577 error ("base_graphics_object::adopt: invalid graphics object");
02578 }
02579
02580 virtual void reparent (const graphics_handle& np)
02581 {
02582 if (valid_object ())
02583 get_properties ().reparent (np);
02584 else
02585 error ("base_graphics_object::reparent: invalid graphics object");
02586 }
02587
02588 virtual void defaults (void) const
02589 {
02590 if (valid_object ())
02591 {
02592 std::string msg = (type () + "::defaults");
02593 gripe_not_implemented (msg.c_str ());
02594 }
02595 else
02596 error ("base_graphics_object::default: invalid graphics object");
02597 }
02598
02599 virtual base_properties& get_properties (void)
02600 {
02601 static base_properties properties;
02602 error ("base_graphics_object::get_properties: invalid graphics object");
02603 return properties;
02604 }
02605
02606 virtual const base_properties& get_properties (void) const
02607 {
02608 static base_properties properties;
02609 error ("base_graphics_object::get_properties: invalid graphics object");
02610 return properties;
02611 }
02612
02613 virtual void update_axis_limits (const std::string& axis_type);
02614
02615 virtual void update_axis_limits (const std::string& axis_type,
02616 const graphics_handle& h);
02617
02618 virtual bool valid_object (void) const { return false; }
02619
02620 virtual std::string type (void) const
02621 {
02622 return (valid_object () ? get_properties ().graphics_object_name ()
02623 : "unknown");
02624 }
02625
02626 bool isa (const std::string& go_name) const
02627 {
02628 return type () == go_name;
02629 }
02630
02631 virtual graphics_toolkit get_toolkit (void) const
02632 {
02633 if (valid_object ())
02634 return get_properties ().get_toolkit ();
02635 else
02636 {
02637 error ("base_graphics_object::get_toolkit: invalid graphics object");
02638 return graphics_toolkit ();
02639 }
02640 }
02641
02642 virtual void add_property_listener (const std::string& nm,
02643 const octave_value& v,
02644 listener_mode mode = POSTSET)
02645 {
02646 if (valid_object ())
02647 get_properties ().add_listener (nm, v, mode);
02648 }
02649
02650 virtual void delete_property_listener (const std::string& nm,
02651 const octave_value& v,
02652 listener_mode mode = POSTSET)
02653 {
02654 if (valid_object ())
02655 get_properties ().delete_listener (nm, v, mode);
02656 }
02657
02658 virtual void remove_all_listeners (void);
02659
02660 virtual void reset_default_properties (void)
02661 {
02662 if (valid_object ())
02663 {
02664 std::string msg = (type () + "::reset_default_properties");
02665 gripe_not_implemented (msg.c_str ());
02666 }
02667 else
02668 error ("base_graphics_object::default: invalid graphics object");
02669 }
02670
02671 protected:
02672
02673 int count;
02674
02675
02676
02677 base_graphics_object (const base_graphics_object&);
02678
02679 base_graphics_object& operator = (const base_graphics_object&);
02680 };
02681
02682 class OCTINTERP_API graphics_object
02683 {
02684 public:
02685 graphics_object (void) : rep (new base_graphics_object ()) { }
02686
02687 graphics_object (base_graphics_object *new_rep)
02688 : rep (new_rep) { }
02689
02690 graphics_object (const graphics_object& obj) : rep (obj.rep)
02691 {
02692 rep->count++;
02693 }
02694
02695 graphics_object& operator = (const graphics_object& obj)
02696 {
02697 if (rep != obj.rep)
02698 {
02699 if (--rep->count == 0)
02700 delete rep;
02701
02702 rep = obj.rep;
02703 rep->count++;
02704 }
02705
02706 return *this;
02707 }
02708
02709 ~graphics_object (void)
02710 {
02711 if (--rep->count == 0)
02712 delete rep;
02713 }
02714
02715 void mark_modified (void) { rep->mark_modified (); }
02716
02717 void override_defaults (base_graphics_object& obj)
02718 {
02719 rep->override_defaults (obj);
02720 }
02721
02722 void set_from_list (property_list& plist) { rep->set_from_list (plist); }
02723
02724 void set (const caseless_str& name, const octave_value& val)
02725 {
02726 rep->set (name, val);
02727 }
02728
02729 void set (const octave_value_list& args);
02730
02731 void set (const Array<std::string>& names, const Cell& values,
02732 octave_idx_type row);
02733
02734 void set (const octave_map& m);
02735
02736 void set_value_or_default (const caseless_str& name,
02737 const octave_value& val);
02738
02739 void set_defaults (const std::string& mode) { rep->set_defaults (mode); }
02740
02741 octave_value get (bool all = false) const { return rep->get (all); }
02742
02743 octave_value get (const caseless_str& name) const
02744 {
02745 return name.compare ("default")
02746 ? get_defaults ()
02747 : (name.compare ("factory")
02748 ? get_factory_defaults () : rep->get (name));
02749 }
02750
02751 octave_value get (const std::string& name) const
02752 {
02753 return get (caseless_str (name));
02754 }
02755
02756 octave_value get (const char *name) const
02757 {
02758 return get (caseless_str (name));
02759 }
02760
02761 octave_value get_default (const caseless_str& name) const
02762 {
02763 return rep->get_default (name);
02764 }
02765
02766 octave_value get_factory_default (const caseless_str& name) const
02767 {
02768 return rep->get_factory_default (name);
02769 }
02770
02771 octave_value get_defaults (void) const { return rep->get_defaults (); }
02772
02773 octave_value get_factory_defaults (void) const
02774 {
02775 return rep->get_factory_defaults ();
02776 }
02777
02778 std::string values_as_string (void) { return rep->values_as_string (); }
02779
02780 octave_map values_as_struct (void) { return rep->values_as_struct (); }
02781
02782 graphics_handle get_parent (void) const { return rep->get_parent (); }
02783
02784 graphics_handle get_handle (void) const { return rep->get_handle (); }
02785
02786 graphics_object get_ancestor (const std::string& type) const;
02787
02788 void remove_child (const graphics_handle& h) { rep->remove_child (h); }
02789
02790 void adopt (const graphics_handle& h) { rep->adopt (h); }
02791
02792 void reparent (const graphics_handle& h) { rep->reparent (h); }
02793
02794 void defaults (void) const { rep->defaults (); }
02795
02796 bool isa (const std::string& go_name) const { return rep->isa (go_name); }
02797
02798 base_properties& get_properties (void) { return rep->get_properties (); }
02799
02800 const base_properties& get_properties (void) const
02801 {
02802 return rep->get_properties ();
02803 }
02804
02805 void update_axis_limits (const std::string& axis_type)
02806 {
02807 rep->update_axis_limits (axis_type);
02808 }
02809
02810 void update_axis_limits (const std::string& axis_type,
02811 const graphics_handle& h)
02812 {
02813 rep->update_axis_limits (axis_type, h);
02814 }
02815
02816 bool valid_object (void) const { return rep->valid_object (); }
02817
02818 std::string type (void) const { return rep->type (); }
02819
02820 operator bool (void) const { return rep->valid_object (); }
02821
02822
02823
02824
02825
02826
02827 octave_value get_xlim (void) const
02828 { return get_properties ().get_xlim (); }
02829
02830 octave_value get_ylim (void) const
02831 { return get_properties ().get_ylim (); }
02832
02833 octave_value get_zlim (void) const
02834 { return get_properties ().get_zlim (); }
02835
02836 octave_value get_clim (void) const
02837 { return get_properties ().get_clim (); }
02838
02839 octave_value get_alim (void) const
02840 { return get_properties ().get_alim (); }
02841
02842 bool is_xliminclude (void) const
02843 { return get_properties ().is_xliminclude (); }
02844
02845 bool is_yliminclude (void) const
02846 { return get_properties ().is_yliminclude (); }
02847
02848 bool is_zliminclude (void) const
02849 { return get_properties ().is_zliminclude (); }
02850
02851 bool is_climinclude (void) const
02852 { return get_properties ().is_climinclude (); }
02853
02854 bool is_aliminclude (void) const
02855 { return get_properties ().is_aliminclude (); }
02856
02857 bool is_handle_visible (void) const
02858 { return get_properties ().is_handle_visible (); }
02859
02860 graphics_toolkit get_toolkit (void) const { return rep->get_toolkit (); }
02861
02862 void add_property_listener (const std::string& nm, const octave_value& v,
02863 listener_mode mode = POSTSET)
02864 { rep->add_property_listener (nm, v, mode); }
02865
02866 void delete_property_listener (const std::string& nm, const octave_value& v,
02867 listener_mode mode = POSTSET)
02868 { rep->delete_property_listener (nm, v, mode); }
02869
02870 void reset_default_properties (void)
02871 { rep->reset_default_properties (); }
02872
02873 private:
02874 base_graphics_object *rep;
02875 };
02876
02877
02878
02879 class OCTINTERP_API root_figure : public base_graphics_object
02880 {
02881 public:
02882 class OCTINTERP_API properties : public base_properties
02883 {
02884 public:
02885 void remove_child (const graphics_handle& h);
02886
02887
02888
02889
02890
02891
02892
02893
02894
02895
02896
02897
02898
02899 public:
02900 properties (const graphics_handle& mh, const graphics_handle& p);
02901
02902 ~properties (void) { }
02903
02904 void set (const caseless_str& pname, const octave_value& val);
02905
02906 octave_value get (bool all = false) const;
02907
02908 octave_value get (const caseless_str& pname) const;
02909
02910 octave_value get (const std::string& pname) const
02911 {
02912 return get (caseless_str (pname));
02913 }
02914
02915 octave_value get (const char *pname) const
02916 {
02917 return get (caseless_str (pname));
02918 }
02919
02920 property get_property (const caseless_str& pname);
02921
02922 std::string graphics_object_name (void) const { return go_name; }
02923
02924 static property_list::pval_map_type factory_defaults (void);
02925
02926 private:
02927 static std::string go_name;
02928
02929 public:
02930
02931
02932 static std::set<std::string> core_property_names (void);
02933
02934 static bool has_core_property (const caseless_str& pname);
02935
02936 std::set<std::string> all_property_names (void) const;
02937
02938 bool has_property (const caseless_str& pname) const;
02939
02940 private:
02941
02942 handle_property callbackobject;
02943 array_property commandwindowsize;
02944 handle_property currentfigure;
02945 bool_property diary;
02946 string_property diaryfile;
02947 bool_property echo;
02948 radio_property format;
02949 radio_property formatspacing;
02950 string_property language;
02951 array_property monitorpositions;
02952 array_property pointerlocation;
02953 double_property pointerwindow;
02954 double_property recursionlimit;
02955 double_property screendepth;
02956 double_property screenpixelsperinch;
02957 array_property screensize;
02958 bool_property showhiddenhandles;
02959 radio_property units;
02960
02961 public:
02962
02963 enum
02964 {
02965 ID_CALLBACKOBJECT = 1000,
02966 ID_COMMANDWINDOWSIZE = 1001,
02967 ID_CURRENTFIGURE = 1002,
02968 ID_DIARY = 1003,
02969 ID_DIARYFILE = 1004,
02970 ID_ECHO = 1005,
02971 ID_FORMAT = 1006,
02972 ID_FORMATSPACING = 1007,
02973 ID_LANGUAGE = 1008,
02974 ID_MONITORPOSITIONS = 1009,
02975 ID_POINTERLOCATION = 1010,
02976 ID_POINTERWINDOW = 1011,
02977 ID_RECURSIONLIMIT = 1012,
02978 ID_SCREENDEPTH = 1013,
02979 ID_SCREENPIXELSPERINCH = 1014,
02980 ID_SCREENSIZE = 1015,
02981 ID_SHOWHIDDENHANDLES = 1016,
02982 ID_UNITS = 1017
02983 };
02984
02985 graphics_handle get_callbackobject (void) const { return callbackobject.handle_value (); }
02986
02987 octave_value get_commandwindowsize (void) const { return commandwindowsize.get (); }
02988
02989 graphics_handle get_currentfigure (void) const { return currentfigure.handle_value (); }
02990
02991 bool is_diary (void) const { return diary.is_on (); }
02992 std::string get_diary (void) const { return diary.current_value (); }
02993
02994 std::string get_diaryfile (void) const { return diaryfile.string_value (); }
02995
02996 bool is_echo (void) const { return echo.is_on (); }
02997 std::string get_echo (void) const { return echo.current_value (); }
02998
02999 bool format_is (const std::string& v) const { return format.is (v); }
03000 std::string get_format (void) const { return format.current_value (); }
03001
03002 bool formatspacing_is (const std::string& v) const { return formatspacing.is (v); }
03003 std::string get_formatspacing (void) const { return formatspacing.current_value (); }
03004
03005 std::string get_language (void) const { return language.string_value (); }
03006
03007 octave_value get_monitorpositions (void) const { return monitorpositions.get (); }
03008
03009 octave_value get_pointerlocation (void) const { return pointerlocation.get (); }
03010
03011 double get_pointerwindow (void) const { return pointerwindow.double_value (); }
03012
03013 double get_recursionlimit (void) const { return recursionlimit.double_value (); }
03014
03015 double get_screendepth (void) const { return screendepth.double_value (); }
03016
03017 double get_screenpixelsperinch (void) const { return screenpixelsperinch.double_value (); }
03018
03019 octave_value get_screensize (void) const { return screensize.get (); }
03020
03021 bool is_showhiddenhandles (void) const { return showhiddenhandles.is_on (); }
03022 std::string get_showhiddenhandles (void) const { return showhiddenhandles.current_value (); }
03023
03024 bool units_is (const std::string& v) const { return units.is (v); }
03025 std::string get_units (void) const { return units.current_value (); }
03026
03027
03028 void set_callbackobject (const octave_value& val);
03029
03030 void set_commandwindowsize (const octave_value& val)
03031 {
03032 if (! error_state)
03033 {
03034 if (commandwindowsize.set (val, true))
03035 {
03036 mark_modified ();
03037 }
03038 }
03039 }
03040
03041 void set_currentfigure (const octave_value& val);
03042
03043 void set_diary (const octave_value& val)
03044 {
03045 if (! error_state)
03046 {
03047 if (diary.set (val, true))
03048 {
03049 mark_modified ();
03050 }
03051 }
03052 }
03053
03054 void set_diaryfile (const octave_value& val)
03055 {
03056 if (! error_state)
03057 {
03058 if (diaryfile.set (val, true))
03059 {
03060 mark_modified ();
03061 }
03062 }
03063 }
03064
03065 void set_echo (const octave_value& val)
03066 {
03067 if (! error_state)
03068 {
03069 if (echo.set (val, true))
03070 {
03071 mark_modified ();
03072 }
03073 }
03074 }
03075
03076 void set_format (const octave_value& val)
03077 {
03078 if (! error_state)
03079 {
03080 if (format.set (val, true))
03081 {
03082 mark_modified ();
03083 }
03084 }
03085 }
03086
03087 void set_formatspacing (const octave_value& val)
03088 {
03089 if (! error_state)
03090 {
03091 if (formatspacing.set (val, true))
03092 {
03093 mark_modified ();
03094 }
03095 }
03096 }
03097
03098 void set_language (const octave_value& val)
03099 {
03100 if (! error_state)
03101 {
03102 if (language.set (val, true))
03103 {
03104 mark_modified ();
03105 }
03106 }
03107 }
03108
03109 void set_monitorpositions (const octave_value& val)
03110 {
03111 if (! error_state)
03112 {
03113 if (monitorpositions.set (val, true))
03114 {
03115 mark_modified ();
03116 }
03117 }
03118 }
03119
03120 void set_pointerlocation (const octave_value& val)
03121 {
03122 if (! error_state)
03123 {
03124 if (pointerlocation.set (val, true))
03125 {
03126 mark_modified ();
03127 }
03128 }
03129 }
03130
03131 void set_pointerwindow (const octave_value& val)
03132 {
03133 if (! error_state)
03134 {
03135 if (pointerwindow.set (val, true))
03136 {
03137 mark_modified ();
03138 }
03139 }
03140 }
03141
03142 void set_recursionlimit (const octave_value& val)
03143 {
03144 if (! error_state)
03145 {
03146 if (recursionlimit.set (val, true))
03147 {
03148 mark_modified ();
03149 }
03150 }
03151 }
03152
03153 void set_screendepth (const octave_value& val)
03154 {
03155 if (! error_state)
03156 {
03157 if (screendepth.set (val, true))
03158 {
03159 mark_modified ();
03160 }
03161 }
03162 }
03163
03164 void set_screenpixelsperinch (const octave_value& val)
03165 {
03166 if (! error_state)
03167 {
03168 if (screenpixelsperinch.set (val, true))
03169 {
03170 mark_modified ();
03171 }
03172 }
03173 }
03174
03175 void set_screensize (const octave_value& val)
03176 {
03177 if (! error_state)
03178 {
03179 if (screensize.set (val, true))
03180 {
03181 mark_modified ();
03182 }
03183 }
03184 }
03185
03186 void set_showhiddenhandles (const octave_value& val)
03187 {
03188 if (! error_state)
03189 {
03190 if (showhiddenhandles.set (val, true))
03191 {
03192 mark_modified ();
03193 }
03194 }
03195 }
03196
03197 void set_units (const octave_value& val)
03198 {
03199 if (! error_state)
03200 {
03201 if (units.set (val, true))
03202 {
03203 update_units ();
03204 mark_modified ();
03205 }
03206 }
03207 }
03208
03209 void update_units (void);
03210
03211
03212 private:
03213 std::list<graphics_handle> cbo_stack;
03214 };
03215
03216 private:
03217 properties xproperties;
03218
03219 public:
03220
03221 root_figure (void) : xproperties (0, graphics_handle ()), default_properties () { }
03222
03223 ~root_figure (void) { xproperties.delete_children (); }
03224
03225 void mark_modified (void) { }
03226
03227 void override_defaults (base_graphics_object& obj)
03228 {
03229
03230
03231
03232
03233
03234 obj.set_from_list (default_properties);
03235 }
03236
03237 void set (const caseless_str& name, const octave_value& value)
03238 {
03239 if (name.compare ("default", 7))
03240
03241
03242
03243 default_properties.set (name.substr (7), value);
03244 else
03245 xproperties.set (name, value);
03246 }
03247
03248 octave_value get (const caseless_str& name) const
03249 {
03250 octave_value retval;
03251
03252 if (name.compare ("default", 7))
03253 return get_default (name.substr (7));
03254 else if (name.compare ("factory", 7))
03255 return get_factory_default (name.substr (7));
03256 else
03257 retval = xproperties.get (name);
03258
03259 return retval;
03260 }
03261
03262 octave_value get_default (const caseless_str& name) const
03263 {
03264 octave_value retval = default_properties.lookup (name);
03265
03266 if (retval.is_undefined ())
03267 {
03268
03269 retval = factory_properties.lookup (name);
03270
03271 if (retval.is_undefined ())
03272 error ("get: invalid default property `%s'", name.c_str ());
03273 }
03274
03275 return retval;
03276 }
03277
03278 octave_value get_factory_default (const caseless_str& name) const
03279 {
03280 octave_value retval = factory_properties.lookup (name);
03281
03282 if (retval.is_undefined ())
03283 error ("get: invalid factory default property `%s'", name.c_str ());
03284
03285 return retval;
03286 }
03287
03288 octave_value get_defaults (void) const
03289 {
03290 return default_properties.as_struct ("default");
03291 }
03292
03293 octave_value get_factory_defaults (void) const
03294 {
03295 return factory_properties.as_struct ("factory");
03296 }
03297
03298 base_properties& get_properties (void) { return xproperties; }
03299
03300 const base_properties& get_properties (void) const { return xproperties; }
03301
03302 bool valid_object (void) const { return true; }
03303
03304 void reset_default_properties (void);
03305
03306 private:
03307 property_list default_properties;
03308
03309 static property_list factory_properties;
03310
03311 static property_list::plist_map_type init_factory_properties (void);
03312 };
03313
03314
03315
03316 class OCTINTERP_API figure : public base_graphics_object
03317 {
03318 public:
03319 class OCTINTERP_API properties : public base_properties
03320 {
03321 public:
03322 void remove_child (const graphics_handle& h);
03323
03324 void set_visible (const octave_value& val);
03325
03326 graphics_toolkit get_toolkit (void) const
03327 {
03328 if (! toolkit)
03329 toolkit = graphics_toolkit::default_toolkit ();
03330
03331 return toolkit;
03332 }
03333
03334 void set_toolkit (const graphics_toolkit& b)
03335 {
03336 if (toolkit)
03337 toolkit.finalize (__myhandle__);
03338 toolkit = b;
03339 __graphics_toolkit__ = b.get_name ();
03340 __plot_stream__ = Matrix ();
03341 mark_modified ();
03342 }
03343
03344 void set___graphics_toolkit__ (const octave_value& val)
03345 {
03346 if (! error_state)
03347 {
03348 if (val.is_string ())
03349 {
03350 std::string nm = val.string_value ();
03351 graphics_toolkit b = graphics_toolkit::find_toolkit (nm);
03352 if (b.get_name () != nm)
03353 {
03354 error ("set___graphics_toolkit__: invalid graphics toolkit");
03355 }
03356 else
03357 {
03358 set_toolkit (b);
03359 mark_modified ();
03360 }
03361 }
03362 else
03363 error ("set___graphics_toolkit__ must be a string");
03364 }
03365 }
03366
03367 Matrix get_boundingbox (bool internal = false) const;
03368
03369 void set_boundingbox (const Matrix& bb);
03370
03371 void update_units (const caseless_str& old_units);
03372
03373 void update_paperunits (const caseless_str& old_paperunits);
03374
03375 std::string get_title (void) const;
03376
03377
03378
03379
03380 public:
03381 properties (const graphics_handle& mh, const graphics_handle& p);
03382
03383 ~properties (void) { }
03384
03385 void set (const caseless_str& pname, const octave_value& val);
03386
03387 octave_value get (bool all = false) const;
03388
03389 octave_value get (const caseless_str& pname) const;
03390
03391 octave_value get (const std::string& pname) const
03392 {
03393 return get (caseless_str (pname));
03394 }
03395
03396 octave_value get (const char *pname) const
03397 {
03398 return get (caseless_str (pname));
03399 }
03400
03401 property get_property (const caseless_str& pname);
03402
03403 std::string graphics_object_name (void) const { return go_name; }
03404
03405 static property_list::pval_map_type factory_defaults (void);
03406
03407 private:
03408 static std::string go_name;
03409
03410 public:
03411
03412
03413 static std::set<std::string> core_property_names (void);
03414
03415 static bool has_core_property (const caseless_str& pname);
03416
03417 std::set<std::string> all_property_names (void) const;
03418
03419 bool has_property (const caseless_str& pname) const;
03420
03421 private:
03422
03423 any_property __plot_stream__;
03424 bool_property __enhanced__;
03425 radio_property nextplot;
03426 callback_property closerequestfcn;
03427 handle_property currentaxes;
03428 array_property colormap;
03429 radio_property paperorientation;
03430 color_property color;
03431 array_property alphamap;
03432 string_property currentcharacter;
03433 handle_property currentobject;
03434 array_property currentpoint;
03435 bool_property dockcontrols;
03436 bool_property doublebuffer;
03437 string_property filename;
03438 bool_property integerhandle;
03439 bool_property inverthardcopy;
03440 callback_property keypressfcn;
03441 callback_property keyreleasefcn;
03442 radio_property menubar;
03443 double_property mincolormap;
03444 string_property name;
03445 bool_property numbertitle;
03446 radio_property paperunits;
03447 array_property paperposition;
03448 radio_property paperpositionmode;
03449 array_property papersize;
03450 radio_property papertype;
03451 radio_property pointer;
03452 array_property pointershapecdata;
03453 array_property pointershapehotspot;
03454 array_property position;
03455 radio_property renderer;
03456 radio_property renderermode;
03457 bool_property resize;
03458 callback_property resizefcn;
03459 radio_property selectiontype;
03460 radio_property toolbar;
03461 radio_property units;
03462 callback_property windowbuttondownfcn;
03463 callback_property windowbuttonmotionfcn;
03464 callback_property windowbuttonupfcn;
03465 callback_property windowbuttonwheelfcn;
03466 radio_property windowstyle;
03467 string_property wvisual;
03468 radio_property wvisualmode;
03469 string_property xdisplay;
03470 string_property xvisual;
03471 radio_property xvisualmode;
03472 callback_property buttondownfcn;
03473 string_property __graphics_toolkit__;
03474
03475 public:
03476
03477 enum
03478 {
03479 ID___PLOT_STREAM__ = 2000,
03480 ID___ENHANCED__ = 2001,
03481 ID_NEXTPLOT = 2002,
03482 ID_CLOSEREQUESTFCN = 2003,
03483 ID_CURRENTAXES = 2004,
03484 ID_COLORMAP = 2005,
03485 ID_PAPERORIENTATION = 2006,
03486 ID_COLOR = 2007,
03487 ID_ALPHAMAP = 2008,
03488 ID_CURRENTCHARACTER = 2009,
03489 ID_CURRENTOBJECT = 2010,
03490 ID_CURRENTPOINT = 2011,
03491 ID_DOCKCONTROLS = 2012,
03492 ID_DOUBLEBUFFER = 2013,
03493 ID_FILENAME = 2014,
03494 ID_INTEGERHANDLE = 2015,
03495 ID_INVERTHARDCOPY = 2016,
03496 ID_KEYPRESSFCN = 2017,
03497 ID_KEYRELEASEFCN = 2018,
03498 ID_MENUBAR = 2019,
03499 ID_MINCOLORMAP = 2020,
03500 ID_NAME = 2021,
03501 ID_NUMBERTITLE = 2022,
03502 ID_PAPERUNITS = 2023,
03503 ID_PAPERPOSITION = 2024,
03504 ID_PAPERPOSITIONMODE = 2025,
03505 ID_PAPERSIZE = 2026,
03506 ID_PAPERTYPE = 2027,
03507 ID_POINTER = 2028,
03508 ID_POINTERSHAPECDATA = 2029,
03509 ID_POINTERSHAPEHOTSPOT = 2030,
03510 ID_POSITION = 2031,
03511 ID_RENDERER = 2032,
03512 ID_RENDERERMODE = 2033,
03513 ID_RESIZE = 2034,
03514 ID_RESIZEFCN = 2035,
03515 ID_SELECTIONTYPE = 2036,
03516 ID_TOOLBAR = 2037,
03517 ID_UNITS = 2038,
03518 ID_WINDOWBUTTONDOWNFCN = 2039,
03519 ID_WINDOWBUTTONMOTIONFCN = 2040,
03520 ID_WINDOWBUTTONUPFCN = 2041,
03521 ID_WINDOWBUTTONWHEELFCN = 2042,
03522 ID_WINDOWSTYLE = 2043,
03523 ID_WVISUAL = 2044,
03524 ID_WVISUALMODE = 2045,
03525 ID_XDISPLAY = 2046,
03526 ID_XVISUAL = 2047,
03527 ID_XVISUALMODE = 2048,
03528 ID_BUTTONDOWNFCN = 2049,
03529 ID___GRAPHICS_TOOLKIT__ = 2050
03530 };
03531
03532 octave_value get___plot_stream__ (void) const { return __plot_stream__.get (); }
03533
03534 bool is___enhanced__ (void) const { return __enhanced__.is_on (); }
03535 std::string get___enhanced__ (void) const { return __enhanced__.current_value (); }
03536
03537 bool nextplot_is (const std::string& v) const { return nextplot.is (v); }
03538 std::string get_nextplot (void) const { return nextplot.current_value (); }
03539
03540 void execute_closerequestfcn (const octave_value& data = octave_value ()) const { closerequestfcn.execute (data); }
03541 octave_value get_closerequestfcn (void) const { return closerequestfcn.get (); }
03542
03543 graphics_handle get_currentaxes (void) const { return currentaxes.handle_value (); }
03544
03545 octave_value get_colormap (void) const { return colormap.get (); }
03546
03547 bool paperorientation_is (const std::string& v) const { return paperorientation.is (v); }
03548 std::string get_paperorientation (void) const { return paperorientation.current_value (); }
03549
03550 bool color_is_rgb (void) const { return color.is_rgb (); }
03551 bool color_is (const std::string& v) const { return color.is (v); }
03552 Matrix get_color_rgb (void) const { return (color.is_rgb () ? color.rgb () : Matrix ()); }
03553 octave_value get_color (void) const { return color.get (); }
03554
03555 octave_value get_alphamap (void) const { return alphamap.get (); }
03556
03557 std::string get_currentcharacter (void) const { return currentcharacter.string_value (); }
03558
03559 graphics_handle get_currentobject (void) const { return currentobject.handle_value (); }
03560
03561 octave_value get_currentpoint (void) const { return currentpoint.get (); }
03562
03563 bool is_dockcontrols (void) const { return dockcontrols.is_on (); }
03564 std::string get_dockcontrols (void) const { return dockcontrols.current_value (); }
03565
03566 bool is_doublebuffer (void) const { return doublebuffer.is_on (); }
03567 std::string get_doublebuffer (void) const { return doublebuffer.current_value (); }
03568
03569 std::string get_filename (void) const { return filename.string_value (); }
03570
03571 bool is_integerhandle (void) const { return integerhandle.is_on (); }
03572 std::string get_integerhandle (void) const { return integerhandle.current_value (); }
03573
03574 bool is_inverthardcopy (void) const { return inverthardcopy.is_on (); }
03575 std::string get_inverthardcopy (void) const { return inverthardcopy.current_value (); }
03576
03577 void execute_keypressfcn (const octave_value& data = octave_value ()) const { keypressfcn.execute (data); }
03578 octave_value get_keypressfcn (void) const { return keypressfcn.get (); }
03579
03580 void execute_keyreleasefcn (const octave_value& data = octave_value ()) const { keyreleasefcn.execute (data); }
03581 octave_value get_keyreleasefcn (void) const { return keyreleasefcn.get (); }
03582
03583 bool menubar_is (const std::string& v) const { return menubar.is (v); }
03584 std::string get_menubar (void) const { return menubar.current_value (); }
03585
03586 double get_mincolormap (void) const { return mincolormap.double_value (); }
03587
03588 std::string get_name (void) const { return name.string_value (); }
03589
03590 bool is_numbertitle (void) const { return numbertitle.is_on (); }
03591 std::string get_numbertitle (void) const { return numbertitle.current_value (); }
03592
03593 bool paperunits_is (const std::string& v) const { return paperunits.is (v); }
03594 std::string get_paperunits (void) const { return paperunits.current_value (); }
03595
03596 octave_value get_paperposition (void) const { return paperposition.get (); }
03597
03598 bool paperpositionmode_is (const std::string& v) const { return paperpositionmode.is (v); }
03599 std::string get_paperpositionmode (void) const { return paperpositionmode.current_value (); }
03600
03601 octave_value get_papersize (void) const { return papersize.get (); }
03602
03603 bool papertype_is (const std::string& v) const { return papertype.is (v); }
03604 std::string get_papertype (void) const { return papertype.current_value (); }
03605
03606 bool pointer_is (const std::string& v) const { return pointer.is (v); }
03607 std::string get_pointer (void) const { return pointer.current_value (); }
03608
03609 octave_value get_pointershapecdata (void) const { return pointershapecdata.get (); }
03610
03611 octave_value get_pointershapehotspot (void) const { return pointershapehotspot.get (); }
03612
03613 octave_value get_position (void) const { return position.get (); }
03614
03615 bool renderer_is (const std::string& v) const { return renderer.is (v); }
03616 std::string get_renderer (void) const { return renderer.current_value (); }
03617
03618 bool renderermode_is (const std::string& v) const { return renderermode.is (v); }
03619 std::string get_renderermode (void) const { return renderermode.current_value (); }
03620
03621 bool is_resize (void) const { return resize.is_on (); }
03622 std::string get_resize (void) const { return resize.current_value (); }
03623
03624 void execute_resizefcn (const octave_value& data = octave_value ()) const { resizefcn.execute (data); }
03625 octave_value get_resizefcn (void) const { return resizefcn.get (); }
03626
03627 bool selectiontype_is (const std::string& v) const { return selectiontype.is (v); }
03628 std::string get_selectiontype (void) const { return selectiontype.current_value (); }
03629
03630 bool toolbar_is (const std::string& v) const { return toolbar.is (v); }
03631 std::string get_toolbar (void) const { return toolbar.current_value (); }
03632
03633 bool units_is (const std::string& v) const { return units.is (v); }
03634 std::string get_units (void) const { return units.current_value (); }
03635
03636 void execute_windowbuttondownfcn (const octave_value& data = octave_value ()) const { windowbuttondownfcn.execute (data); }
03637 octave_value get_windowbuttondownfcn (void) const { return windowbuttondownfcn.get (); }
03638
03639 void execute_windowbuttonmotionfcn (const octave_value& data = octave_value ()) const { windowbuttonmotionfcn.execute (data); }
03640 octave_value get_windowbuttonmotionfcn (void) const { return windowbuttonmotionfcn.get (); }
03641
03642 void execute_windowbuttonupfcn (const octave_value& data = octave_value ()) const { windowbuttonupfcn.execute (data); }
03643 octave_value get_windowbuttonupfcn (void) const { return windowbuttonupfcn.get (); }
03644
03645 void execute_windowbuttonwheelfcn (const octave_value& data = octave_value ()) const { windowbuttonwheelfcn.execute (data); }
03646 octave_value get_windowbuttonwheelfcn (void) const { return windowbuttonwheelfcn.get (); }
03647
03648 bool windowstyle_is (const std::string& v) const { return windowstyle.is (v); }
03649 std::string get_windowstyle (void) const { return windowstyle.current_value (); }
03650
03651 std::string get_wvisual (void) const { return wvisual.string_value (); }
03652
03653 bool wvisualmode_is (const std::string& v) const { return wvisualmode.is (v); }
03654 std::string get_wvisualmode (void) const { return wvisualmode.current_value (); }
03655
03656 std::string get_xdisplay (void) const { return xdisplay.string_value (); }
03657
03658 std::string get_xvisual (void) const { return xvisual.string_value (); }
03659
03660 bool xvisualmode_is (const std::string& v) const { return xvisualmode.is (v); }
03661 std::string get_xvisualmode (void) const { return xvisualmode.current_value (); }
03662
03663 void execute_buttondownfcn (const octave_value& data = octave_value ()) const { buttondownfcn.execute (data); }
03664 octave_value get_buttondownfcn (void) const { return buttondownfcn.get (); }
03665
03666 std::string get___graphics_toolkit__ (void) const { return __graphics_toolkit__.string_value (); }
03667
03668
03669 void set___plot_stream__ (const octave_value& val)
03670 {
03671 if (! error_state)
03672 {
03673 if (__plot_stream__.set (val, true))
03674 {
03675 mark_modified ();
03676 }
03677 }
03678 }
03679
03680 void set___enhanced__ (const octave_value& val)
03681 {
03682 if (! error_state)
03683 {
03684 if (__enhanced__.set (val, true))
03685 {
03686 mark_modified ();
03687 }
03688 }
03689 }
03690
03691 void set_nextplot (const octave_value& val)
03692 {
03693 if (! error_state)
03694 {
03695 if (nextplot.set (val, true))
03696 {
03697 mark_modified ();
03698 }
03699 }
03700 }
03701
03702 void set_closerequestfcn (const octave_value& val)
03703 {
03704 if (! error_state)
03705 {
03706 if (closerequestfcn.set (val, true))
03707 {
03708 mark_modified ();
03709 }
03710 }
03711 }
03712
03713 void set_currentaxes (const octave_value& val);
03714
03715 void set_colormap (const octave_value& val)
03716 {
03717 if (! error_state)
03718 {
03719 if (colormap.set (val, true))
03720 {
03721 mark_modified ();
03722 }
03723 }
03724 }
03725
03726 void set_paperorientation (const octave_value& val)
03727 {
03728 if (! error_state)
03729 {
03730 if (paperorientation.set (val, true))
03731 {
03732 mark_modified ();
03733 }
03734 }
03735 }
03736
03737 void set_color (const octave_value& val)
03738 {
03739 if (! error_state)
03740 {
03741 if (color.set (val, true))
03742 {
03743 mark_modified ();
03744 }
03745 }
03746 }
03747
03748 void set_alphamap (const octave_value& val)
03749 {
03750 if (! error_state)
03751 {
03752 if (alphamap.set (val, true))
03753 {
03754 mark_modified ();
03755 }
03756 }
03757 }
03758
03759 void set_currentcharacter (const octave_value& val)
03760 {
03761 if (! error_state)
03762 {
03763 if (currentcharacter.set (val, true))
03764 {
03765 mark_modified ();
03766 }
03767 }
03768 }
03769
03770 void set_currentobject (const octave_value& val)
03771 {
03772 if (! error_state)
03773 {
03774 if (currentobject.set (val, true))
03775 {
03776 mark_modified ();
03777 }
03778 }
03779 }
03780
03781 void set_currentpoint (const octave_value& val)
03782 {
03783 if (! error_state)
03784 {
03785 if (currentpoint.set (val, true))
03786 {
03787 mark_modified ();
03788 }
03789 }
03790 }
03791
03792 void set_dockcontrols (const octave_value& val)
03793 {
03794 if (! error_state)
03795 {
03796 if (dockcontrols.set (val, true))
03797 {
03798 mark_modified ();
03799 }
03800 }
03801 }
03802
03803 void set_doublebuffer (const octave_value& val)
03804 {
03805 if (! error_state)
03806 {
03807 if (doublebuffer.set (val, true))
03808 {
03809 mark_modified ();
03810 }
03811 }
03812 }
03813
03814 void set_filename (const octave_value& val)
03815 {
03816 if (! error_state)
03817 {
03818 if (filename.set (val, true))
03819 {
03820 mark_modified ();
03821 }
03822 }
03823 }
03824
03825 void set_integerhandle (const octave_value& val)
03826 {
03827 if (! error_state)
03828 {
03829 if (integerhandle.set (val, true))
03830 {
03831 mark_modified ();
03832 }
03833 }
03834 }
03835
03836 void set_inverthardcopy (const octave_value& val)
03837 {
03838 if (! error_state)
03839 {
03840 if (inverthardcopy.set (val, true))
03841 {
03842 mark_modified ();
03843 }
03844 }
03845 }
03846
03847 void set_keypressfcn (const octave_value& val)
03848 {
03849 if (! error_state)
03850 {
03851 if (keypressfcn.set (val, true))
03852 {
03853 mark_modified ();
03854 }
03855 }
03856 }
03857
03858 void set_keyreleasefcn (const octave_value& val)
03859 {
03860 if (! error_state)
03861 {
03862 if (keyreleasefcn.set (val, true))
03863 {
03864 mark_modified ();
03865 }
03866 }
03867 }
03868
03869 void set_menubar (const octave_value& val)
03870 {
03871 if (! error_state)
03872 {
03873 if (menubar.set (val, true))
03874 {
03875 mark_modified ();
03876 }
03877 }
03878 }
03879
03880 void set_mincolormap (const octave_value& val)
03881 {
03882 if (! error_state)
03883 {
03884 if (mincolormap.set (val, true))
03885 {
03886 mark_modified ();
03887 }
03888 }
03889 }
03890
03891 void set_name (const octave_value& val)
03892 {
03893 if (! error_state)
03894 {
03895 if (name.set (val, true))
03896 {
03897 mark_modified ();
03898 }
03899 }
03900 }
03901
03902 void set_numbertitle (const octave_value& val)
03903 {
03904 if (! error_state)
03905 {
03906 if (numbertitle.set (val, true))
03907 {
03908 mark_modified ();
03909 }
03910 }
03911 }
03912
03913 void set_paperunits (const octave_value& val);
03914
03915 void set_paperposition (const octave_value& val)
03916 {
03917 if (! error_state)
03918 {
03919 if (paperposition.set (val, true))
03920 {
03921 mark_modified ();
03922 }
03923 }
03924 }
03925
03926 void set_paperpositionmode (const octave_value& val)
03927 {
03928 if (! error_state)
03929 {
03930 if (paperpositionmode.set (val, true))
03931 {
03932 mark_modified ();
03933 }
03934 }
03935 }
03936
03937 void set_papersize (const octave_value& val)
03938 {
03939 if (! error_state)
03940 {
03941 if (papersize.set (val, true))
03942 {
03943 update_papersize ();
03944 mark_modified ();
03945 }
03946 }
03947 }
03948
03949 void update_papersize (void);
03950
03951 void set_papertype (const octave_value& val);
03952
03953 void update_papertype (void);
03954
03955 void set_pointer (const octave_value& val)
03956 {
03957 if (! error_state)
03958 {
03959 if (pointer.set (val, true))
03960 {
03961 mark_modified ();
03962 }
03963 }
03964 }
03965
03966 void set_pointershapecdata (const octave_value& val)
03967 {
03968 if (! error_state)
03969 {
03970 if (pointershapecdata.set (val, true))
03971 {
03972 mark_modified ();
03973 }
03974 }
03975 }
03976
03977 void set_pointershapehotspot (const octave_value& val)
03978 {
03979 if (! error_state)
03980 {
03981 if (pointershapehotspot.set (val, true))
03982 {
03983 mark_modified ();
03984 }
03985 }
03986 }
03987
03988 void set_position (const octave_value& val);
03989
03990 void set_renderer (const octave_value& val)
03991 {
03992 if (! error_state)
03993 {
03994 if (renderer.set (val, true))
03995 {
03996 mark_modified ();
03997 }
03998 }
03999 }
04000
04001 void set_renderermode (const octave_value& val)
04002 {
04003 if (! error_state)
04004 {
04005 if (renderermode.set (val, true))
04006 {
04007 mark_modified ();
04008 }
04009 }
04010 }
04011
04012 void set_resize (const octave_value& val)
04013 {
04014 if (! error_state)
04015 {
04016 if (resize.set (val, true))
04017 {
04018 mark_modified ();
04019 }
04020 }
04021 }
04022
04023 void set_resizefcn (const octave_value& val)
04024 {
04025 if (! error_state)
04026 {
04027 if (resizefcn.set (val, true))
04028 {
04029 mark_modified ();
04030 }
04031 }
04032 }
04033
04034 void set_selectiontype (const octave_value& val)
04035 {
04036 if (! error_state)
04037 {
04038 if (selectiontype.set (val, true))
04039 {
04040 mark_modified ();
04041 }
04042 }
04043 }
04044
04045 void set_toolbar (const octave_value& val)
04046 {
04047 if (! error_state)
04048 {
04049 if (toolbar.set (val, true))
04050 {
04051 mark_modified ();
04052 }
04053 }
04054 }
04055
04056 void set_units (const octave_value& val);
04057
04058 void set_windowbuttondownfcn (const octave_value& val)
04059 {
04060 if (! error_state)
04061 {
04062 if (windowbuttondownfcn.set (val, true))
04063 {
04064 mark_modified ();
04065 }
04066 }
04067 }
04068
04069 void set_windowbuttonmotionfcn (const octave_value& val)
04070 {
04071 if (! error_state)
04072 {
04073 if (windowbuttonmotionfcn.set (val, true))
04074 {
04075 mark_modified ();
04076 }
04077 }
04078 }
04079
04080 void set_windowbuttonupfcn (const octave_value& val)
04081 {
04082 if (! error_state)
04083 {
04084 if (windowbuttonupfcn.set (val, true))
04085 {
04086 mark_modified ();
04087 }
04088 }
04089 }
04090
04091 void set_windowbuttonwheelfcn (const octave_value& val)
04092 {
04093 if (! error_state)
04094 {
04095 if (windowbuttonwheelfcn.set (val, true))
04096 {
04097 mark_modified ();
04098 }
04099 }
04100 }
04101
04102 void set_windowstyle (const octave_value& val)
04103 {
04104 if (! error_state)
04105 {
04106 if (windowstyle.set (val, true))
04107 {
04108 mark_modified ();
04109 }
04110 }
04111 }
04112
04113 void set_wvisual (const octave_value& val)
04114 {
04115 if (! error_state)
04116 {
04117 if (wvisual.set (val, true))
04118 {
04119 mark_modified ();
04120 }
04121 }
04122 }
04123
04124 void set_wvisualmode (const octave_value& val)
04125 {
04126 if (! error_state)
04127 {
04128 if (wvisualmode.set (val, true))
04129 {
04130 mark_modified ();
04131 }
04132 }
04133 }
04134
04135 void set_xdisplay (const octave_value& val)
04136 {
04137 if (! error_state)
04138 {
04139 if (xdisplay.set (val, true))
04140 {
04141 mark_modified ();
04142 }
04143 }
04144 }
04145
04146 void set_xvisual (const octave_value& val)
04147 {
04148 if (! error_state)
04149 {
04150 if (xvisual.set (val, true))
04151 {
04152 mark_modified ();
04153 }
04154 }
04155 }
04156
04157 void set_xvisualmode (const octave_value& val)
04158 {
04159 if (! error_state)
04160 {
04161 if (xvisualmode.set (val, true))
04162 {
04163 mark_modified ();
04164 }
04165 }
04166 }
04167
04168 void set_buttondownfcn (const octave_value& val)
04169 {
04170 if (! error_state)
04171 {
04172 if (buttondownfcn.set (val, true))
04173 {
04174 mark_modified ();
04175 }
04176 }
04177 }
04178
04179
04180 protected:
04181 void init (void)
04182 {
04183 colormap.add_constraint (dim_vector (-1, 3));
04184 alphamap.add_constraint (dim_vector (-1, 1));
04185 paperposition.add_constraint (dim_vector (1, 4));
04186 pointershapecdata.add_constraint (dim_vector (16, 16));
04187 pointershapehotspot.add_constraint (dim_vector (1, 2));
04188 position.add_constraint (dim_vector (1, 4));
04189 }
04190
04191 private:
04192 mutable graphics_toolkit toolkit;
04193 };
04194
04195 private:
04196 properties xproperties;
04197
04198 public:
04199 figure (const graphics_handle& mh, const graphics_handle& p)
04200 : base_graphics_object (), xproperties (mh, p), default_properties ()
04201 {
04202 xproperties.override_defaults (*this);
04203 }
04204
04205 ~figure (void)
04206 {
04207 xproperties.delete_children ();
04208 }
04209
04210 void override_defaults (base_graphics_object& obj)
04211 {
04212
04213
04214 xproperties.override_defaults (obj);
04215
04216
04217
04218
04219
04220
04221 obj.set_from_list (default_properties);
04222 }
04223
04224 void set (const caseless_str& name, const octave_value& value)
04225 {
04226 if (name.compare ("default", 7))
04227
04228
04229
04230 default_properties.set (name.substr (7), value);
04231 else
04232 xproperties.set (name, value);
04233 }
04234
04235 octave_value get (const caseless_str& name) const
04236 {
04237 octave_value retval;
04238
04239 if (name.compare ("default", 7))
04240 retval = get_default (name.substr (7));
04241 else
04242 retval = xproperties.get (name);
04243
04244 return retval;
04245 }
04246
04247 octave_value get_default (const caseless_str& name) const;
04248
04249 octave_value get_defaults (void) const
04250 {
04251 return default_properties.as_struct ("default");
04252 }
04253
04254 base_properties& get_properties (void) { return xproperties; }
04255
04256 const base_properties& get_properties (void) const { return xproperties; }
04257
04258 bool valid_object (void) const { return true; }
04259
04260 void reset_default_properties (void);
04261
04262 private:
04263 property_list default_properties;
04264 };
04265
04266
04267
04268 class OCTINTERP_API graphics_xform
04269 {
04270 public:
04271 graphics_xform (void)
04272 : xform (xform_eye ()), xform_inv (xform_eye ()),
04273 sx ("linear"), sy ("linear"), sz ("linear"), zlim (1, 2, 0.0)
04274 {
04275 zlim(1) = 1.0;
04276 }
04277
04278 graphics_xform (const Matrix& xm, const Matrix& xim,
04279 const scaler& x, const scaler& y, const scaler& z,
04280 const Matrix& zl)
04281 : xform (xm), xform_inv (xim), sx (x), sy (y), sz (z), zlim (zl) { }
04282
04283 graphics_xform (const graphics_xform& g)
04284 : xform (g.xform), xform_inv (g.xform_inv), sx (g.sx),
04285 sy (g.sy), sz (g.sz), zlim (g.zlim) { }
04286
04287 ~graphics_xform (void) { }
04288
04289 graphics_xform& operator = (const graphics_xform& g)
04290 {
04291 xform = g.xform;
04292 xform_inv = g.xform_inv;
04293 sx = g.sx;
04294 sy = g.sy;
04295 sz = g.sz;
04296 zlim = g.zlim;
04297
04298 return *this;
04299 }
04300
04301 static ColumnVector xform_vector (double x, double y, double z);
04302
04303 static Matrix xform_eye (void);
04304
04305 ColumnVector transform (double x, double y, double z,
04306 bool use_scale = true) const;
04307
04308 ColumnVector untransform (double x, double y, double z,
04309 bool use_scale = true) const;
04310
04311 ColumnVector untransform (double x, double y, bool use_scale = true) const
04312 { return untransform (x, y, (zlim(0)+zlim(1))/2, use_scale); }
04313
04314 Matrix xscale (const Matrix& m) const { return sx.scale (m); }
04315 Matrix yscale (const Matrix& m) const { return sy.scale (m); }
04316 Matrix zscale (const Matrix& m) const { return sz.scale (m); }
04317
04318 Matrix scale (const Matrix& m) const
04319 {
04320 bool has_z = (m.columns () > 2);
04321
04322 if (sx.is_linear () && sy.is_linear ()
04323 && (! has_z || sz.is_linear ()))
04324 return m;
04325
04326 Matrix retval (m.dims ());
04327
04328 int r = m.rows ();
04329
04330 for (int i = 0; i < r; i++)
04331 {
04332 retval(i,0) = sx.scale (m(i,0));
04333 retval(i,1) = sy.scale (m(i,1));
04334 if (has_z)
04335 retval(i,2) = sz.scale (m(i,2));
04336 }
04337
04338 return retval;
04339 }
04340
04341 private:
04342 Matrix xform;
04343 Matrix xform_inv;
04344 scaler sx, sy, sz;
04345 Matrix zlim;
04346 };
04347
04348 enum {
04349 AXE_ANY_DIR = 0,
04350 AXE_DEPTH_DIR = 1,
04351 AXE_HORZ_DIR = 2,
04352 AXE_VERT_DIR = 3
04353 };
04354
04355 class OCTINTERP_API axes : public base_graphics_object
04356 {
04357 public:
04358 class OCTINTERP_API properties : public base_properties
04359 {
04360 public:
04361 void set_defaults (base_graphics_object& obj, const std::string& mode);
04362
04363 void remove_child (const graphics_handle& h);
04364
04365 const scaler& get_x_scaler (void) const { return sx; }
04366 const scaler& get_y_scaler (void) const { return sy; }
04367 const scaler& get_z_scaler (void) const { return sz; }
04368
04369 Matrix get_boundingbox (bool internal = false) const;
04370
04371 void update_boundingbox (void)
04372 {
04373 if (units_is ("normalized"))
04374 {
04375 update_transform ();
04376 base_properties::update_boundingbox ();
04377 }
04378 }
04379
04380 void update_camera (void);
04381 void update_axes_layout (void);
04382 void update_aspectratios (void);
04383 void update_transform (void)
04384 {
04385 update_aspectratios ();
04386 update_camera ();
04387 update_axes_layout ();
04388 }
04389
04390 void update_autopos (const std::string& elem_type);
04391 void update_xlabel_position (void);
04392 void update_ylabel_position (void);
04393 void update_zlabel_position (void);
04394 void update_title_position (void);
04395
04396 graphics_xform get_transform (void) const
04397 { return graphics_xform (x_render, x_render_inv, sx, sy, sz, x_zlim); }
04398
04399 Matrix get_transform_matrix (void) const { return x_render; }
04400 Matrix get_inverse_transform_matrix (void) const { return x_render_inv; }
04401 Matrix get_opengl_matrix_1 (void) const { return x_gl_mat1; }
04402 Matrix get_opengl_matrix_2 (void) const { return x_gl_mat2; }
04403 Matrix get_transform_zlim (void) const { return x_zlim; }
04404
04405 int get_xstate (void) const { return xstate; }
04406 int get_ystate (void) const { return ystate; }
04407 int get_zstate (void) const { return zstate; }
04408 double get_xPlane (void) const { return xPlane; }
04409 double get_xPlaneN (void) const { return xPlaneN; }
04410 double get_yPlane (void) const { return yPlane; }
04411 double get_yPlaneN (void) const { return yPlaneN; }
04412 double get_zPlane (void) const { return zPlane; }
04413 double get_zPlaneN (void) const { return zPlaneN; }
04414 double get_xpTick (void) const { return xpTick; }
04415 double get_xpTickN (void) const { return xpTickN; }
04416 double get_ypTick (void) const { return ypTick; }
04417 double get_ypTickN (void) const { return ypTickN; }
04418 double get_zpTick (void) const { return zpTick; }
04419 double get_zpTickN (void) const { return zpTickN; }
04420 double get_x_min (void) const { return std::min (xPlane, xPlaneN); }
04421 double get_x_max (void) const { return std::max (xPlane, xPlaneN); }
04422 double get_y_min (void) const { return std::min (yPlane, yPlaneN); }
04423 double get_y_max (void) const { return std::max (yPlane, yPlaneN); }
04424 double get_z_min (void) const { return std::min (zPlane, zPlaneN); }
04425 double get_z_max (void) const { return std::max (zPlane, zPlaneN); }
04426 double get_fx (void) const { return fx; }
04427 double get_fy (void) const { return fy; }
04428 double get_fz (void) const { return fz; }
04429 double get_xticklen (void) const { return xticklen; }
04430 double get_yticklen (void) const { return yticklen; }
04431 double get_zticklen (void) const { return zticklen; }
04432 double get_xtickoffset (void) const { return xtickoffset; }
04433 double get_ytickoffset (void) const { return ytickoffset; }
04434 double get_ztickoffset (void) const { return ztickoffset; }
04435 bool get_x2Dtop (void) const { return x2Dtop; }
04436 bool get_y2Dright (void) const { return y2Dright; }
04437 bool get_layer2Dtop (void) const { return layer2Dtop; }
04438 bool get_xySym (void) const { return xySym; }
04439 bool get_xyzSym (void) const { return xyzSym; }
04440 bool get_zSign (void) const { return zSign; }
04441 bool get_nearhoriz (void) const { return nearhoriz; }
04442
04443 ColumnVector pixel2coord (double px, double py) const
04444 { return get_transform ().untransform (px, py, (x_zlim(0)+x_zlim(1))/2); }
04445
04446 ColumnVector coord2pixel (double x, double y, double z) const
04447 { return get_transform ().transform (x, y, z); }
04448
04449 void zoom_about_point (double x, double y, double factor,
04450 bool push_to_zoom_stack = true);
04451 void zoom (const Matrix& xl, const Matrix& yl, bool push_to_zoom_stack = true);
04452 void translate_view (double delta_x, double delta_y);
04453 void rotate_view (double delta_az, double delta_el);
04454 void unzoom (void);
04455 void clear_zoom_stack (void);
04456
04457 void update_units (const caseless_str& old_units);
04458
04459 void update_fontunits (const caseless_str& old_fontunits);
04460
04461 private:
04462 scaler sx, sy, sz;
04463 Matrix x_render, x_render_inv;
04464 Matrix x_gl_mat1, x_gl_mat2;
04465 Matrix x_zlim;
04466 std::list<octave_value> zoom_stack;
04467
04468
04469 int xstate, ystate, zstate;
04470 double xPlane, xPlaneN, yPlane, yPlaneN, zPlane, zPlaneN;
04471 double xpTick, xpTickN, ypTick, ypTickN, zpTick, zpTickN;
04472 double fx, fy, fz;
04473 double xticklen, yticklen, zticklen;
04474 double xtickoffset, ytickoffset, ztickoffset;
04475 bool x2Dtop, y2Dright, layer2Dtop;
04476 bool xySym, xyzSym, zSign, nearhoriz;
04477
04478 void set_text_child (handle_property& h, const std::string& who,
04479 const octave_value& v);
04480
04481 void delete_text_child (handle_property& h);
04482
04483
04484
04485
04486
04487
04488 public:
04489 properties (const graphics_handle& mh, const graphics_handle& p);
04490
04491 ~properties (void) { }
04492
04493 void set (const caseless_str& pname, const octave_value& val);
04494
04495 octave_value get (bool all = false) const;
04496
04497 octave_value get (const caseless_str& pname) const;
04498
04499 octave_value get (const std::string& pname) const
04500 {
04501 return get (caseless_str (pname));
04502 }
04503
04504 octave_value get (const char *pname) const
04505 {
04506 return get (caseless_str (pname));
04507 }
04508
04509 property get_property (const caseless_str& pname);
04510
04511 std::string graphics_object_name (void) const { return go_name; }
04512
04513 static property_list::pval_map_type factory_defaults (void);
04514
04515 private:
04516 static std::string go_name;
04517
04518 public:
04519
04520
04521 static std::set<std::string> core_property_names (void);
04522
04523 static bool has_core_property (const caseless_str& pname);
04524
04525 std::set<std::string> all_property_names (void) const;
04526
04527 bool has_property (const caseless_str& pname) const;
04528
04529 private:
04530
04531 array_property position;
04532 bool_property box;
04533 array_property colororder;
04534 array_property dataaspectratio;
04535 radio_property dataaspectratiomode;
04536 radio_property layer;
04537 row_vector_property xlim;
04538 row_vector_property ylim;
04539 row_vector_property zlim;
04540 row_vector_property clim;
04541 row_vector_property alim;
04542 radio_property xlimmode;
04543 radio_property ylimmode;
04544 radio_property zlimmode;
04545 radio_property climmode;
04546 radio_property alimmode;
04547 handle_property xlabel;
04548 handle_property ylabel;
04549 handle_property zlabel;
04550 handle_property title;
04551 bool_property xgrid;
04552 bool_property ygrid;
04553 bool_property zgrid;
04554 bool_property xminorgrid;
04555 bool_property yminorgrid;
04556 bool_property zminorgrid;
04557 row_vector_property xtick;
04558 row_vector_property ytick;
04559 row_vector_property ztick;
04560 radio_property xtickmode;
04561 radio_property ytickmode;
04562 radio_property ztickmode;
04563 bool_property xminortick;
04564 bool_property yminortick;
04565 bool_property zminortick;
04566 any_property xticklabel;
04567 any_property yticklabel;
04568 any_property zticklabel;
04569 radio_property xticklabelmode;
04570 radio_property yticklabelmode;
04571 radio_property zticklabelmode;
04572 radio_property interpreter;
04573 color_property color;
04574 color_property xcolor;
04575 color_property ycolor;
04576 color_property zcolor;
04577 radio_property xscale;
04578 radio_property yscale;
04579 radio_property zscale;
04580 radio_property xdir;
04581 radio_property ydir;
04582 radio_property zdir;
04583 radio_property yaxislocation;
04584 radio_property xaxislocation;
04585 array_property view;
04586 bool_property __hold_all__;
04587 radio_property nextplot;
04588 array_property outerposition;
04589 radio_property activepositionproperty;
04590 color_property ambientlightcolor;
04591 array_property cameraposition;
04592 array_property cameratarget;
04593 array_property cameraupvector;
04594 double_property cameraviewangle;
04595 radio_property camerapositionmode;
04596 radio_property cameratargetmode;
04597 radio_property cameraupvectormode;
04598 radio_property cameraviewanglemode;
04599 array_property currentpoint;
04600 radio_property drawmode;
04601 radio_property fontangle;
04602 string_property fontname;
04603 double_property fontsize;
04604 radio_property fontunits;
04605 radio_property fontweight;
04606 radio_property gridlinestyle;
04607 string_array_property linestyleorder;
04608 double_property linewidth;
04609 radio_property minorgridlinestyle;
04610 array_property plotboxaspectratio;
04611 radio_property plotboxaspectratiomode;
04612 radio_property projection;
04613 radio_property tickdir;
04614 radio_property tickdirmode;
04615 array_property ticklength;
04616 array_property tightinset;
04617 radio_property units;
04618 array_property x_viewtransform;
04619 array_property x_projectiontransform;
04620 array_property x_viewporttransform;
04621 array_property x_normrendertransform;
04622 array_property x_rendertransform;
04623 row_vector_property xmtick;
04624 row_vector_property ymtick;
04625 row_vector_property zmtick;
04626
04627 public:
04628
04629 enum
04630 {
04631 ID_POSITION = 3000,
04632 ID_BOX = 3001,
04633 ID_COLORORDER = 3002,
04634 ID_DATAASPECTRATIO = 3003,
04635 ID_DATAASPECTRATIOMODE = 3004,
04636 ID_LAYER = 3005,
04637 ID_XLIM = 3006,
04638 ID_YLIM = 3007,
04639 ID_ZLIM = 3008,
04640 ID_CLIM = 3009,
04641 ID_ALIM = 3010,
04642 ID_XLIMMODE = 3011,
04643 ID_YLIMMODE = 3012,
04644 ID_ZLIMMODE = 3013,
04645 ID_CLIMMODE = 3014,
04646 ID_ALIMMODE = 3015,
04647 ID_XLABEL = 3016,
04648 ID_YLABEL = 3017,
04649 ID_ZLABEL = 3018,
04650 ID_TITLE = 3019,
04651 ID_XGRID = 3020,
04652 ID_YGRID = 3021,
04653 ID_ZGRID = 3022,
04654 ID_XMINORGRID = 3023,
04655 ID_YMINORGRID = 3024,
04656 ID_ZMINORGRID = 3025,
04657 ID_XTICK = 3026,
04658 ID_YTICK = 3027,
04659 ID_ZTICK = 3028,
04660 ID_XTICKMODE = 3029,
04661 ID_YTICKMODE = 3030,
04662 ID_ZTICKMODE = 3031,
04663 ID_XMINORTICK = 3032,
04664 ID_YMINORTICK = 3033,
04665 ID_ZMINORTICK = 3034,
04666 ID_XTICKLABEL = 3035,
04667 ID_YTICKLABEL = 3036,
04668 ID_ZTICKLABEL = 3037,
04669 ID_XTICKLABELMODE = 3038,
04670 ID_YTICKLABELMODE = 3039,
04671 ID_ZTICKLABELMODE = 3040,
04672 ID_INTERPRETER = 3041,
04673 ID_COLOR = 3042,
04674 ID_XCOLOR = 3043,
04675 ID_YCOLOR = 3044,
04676 ID_ZCOLOR = 3045,
04677 ID_XSCALE = 3046,
04678 ID_YSCALE = 3047,
04679 ID_ZSCALE = 3048,
04680 ID_XDIR = 3049,
04681 ID_YDIR = 3050,
04682 ID_ZDIR = 3051,
04683 ID_YAXISLOCATION = 3052,
04684 ID_XAXISLOCATION = 3053,
04685 ID_VIEW = 3054,
04686 ID___HOLD_ALL__ = 3055,
04687 ID_NEXTPLOT = 3056,
04688 ID_OUTERPOSITION = 3057,
04689 ID_ACTIVEPOSITIONPROPERTY = 3058,
04690 ID_AMBIENTLIGHTCOLOR = 3059,
04691 ID_CAMERAPOSITION = 3060,
04692 ID_CAMERATARGET = 3061,
04693 ID_CAMERAUPVECTOR = 3062,
04694 ID_CAMERAVIEWANGLE = 3063,
04695 ID_CAMERAPOSITIONMODE = 3064,
04696 ID_CAMERATARGETMODE = 3065,
04697 ID_CAMERAUPVECTORMODE = 3066,
04698 ID_CAMERAVIEWANGLEMODE = 3067,
04699 ID_CURRENTPOINT = 3068,
04700 ID_DRAWMODE = 3069,
04701 ID_FONTANGLE = 3070,
04702 ID_FONTNAME = 3071,
04703 ID_FONTSIZE = 3072,
04704 ID_FONTUNITS = 3073,
04705 ID_FONTWEIGHT = 3074,
04706 ID_GRIDLINESTYLE = 3075,
04707 ID_LINESTYLEORDER = 3076,
04708 ID_LINEWIDTH = 3077,
04709 ID_MINORGRIDLINESTYLE = 3078,
04710 ID_PLOTBOXASPECTRATIO = 3079,
04711 ID_PLOTBOXASPECTRATIOMODE = 3080,
04712 ID_PROJECTION = 3081,
04713 ID_TICKDIR = 3082,
04714 ID_TICKDIRMODE = 3083,
04715 ID_TICKLENGTH = 3084,
04716 ID_TIGHTINSET = 3085,
04717 ID_UNITS = 3086,
04718 ID_X_VIEWTRANSFORM = 3087,
04719 ID_X_PROJECTIONTRANSFORM = 3088,
04720 ID_X_VIEWPORTTRANSFORM = 3089,
04721 ID_X_NORMRENDERTRANSFORM = 3090,
04722 ID_X_RENDERTRANSFORM = 3091,
04723 ID_XMTICK = 3092,
04724 ID_YMTICK = 3093,
04725 ID_ZMTICK = 3094
04726 };
04727
04728 octave_value get_position (void) const { return position.get (); }
04729
04730 bool is_box (void) const { return box.is_on (); }
04731 std::string get_box (void) const { return box.current_value (); }
04732
04733 octave_value get_colororder (void) const { return colororder.get (); }
04734
04735 octave_value get_dataaspectratio (void) const { return dataaspectratio.get (); }
04736
04737 bool dataaspectratiomode_is (const std::string& v) const { return dataaspectratiomode.is (v); }
04738 std::string get_dataaspectratiomode (void) const { return dataaspectratiomode.current_value (); }
04739
04740 bool layer_is (const std::string& v) const { return layer.is (v); }
04741 std::string get_layer (void) const { return layer.current_value (); }
04742
04743 octave_value get_xlim (void) const { return xlim.get (); }
04744
04745 octave_value get_ylim (void) const { return ylim.get (); }
04746
04747 octave_value get_zlim (void) const { return zlim.get (); }
04748
04749 octave_value get_clim (void) const { return clim.get (); }
04750
04751 octave_value get_alim (void) const { return alim.get (); }
04752
04753 bool xlimmode_is (const std::string& v) const { return xlimmode.is (v); }
04754 std::string get_xlimmode (void) const { return xlimmode.current_value (); }
04755
04756 bool ylimmode_is (const std::string& v) const { return ylimmode.is (v); }
04757 std::string get_ylimmode (void) const { return ylimmode.current_value (); }
04758
04759 bool zlimmode_is (const std::string& v) const { return zlimmode.is (v); }
04760 std::string get_zlimmode (void) const { return zlimmode.current_value (); }
04761
04762 bool climmode_is (const std::string& v) const { return climmode.is (v); }
04763 std::string get_climmode (void) const { return climmode.current_value (); }
04764
04765 bool alimmode_is (const std::string& v) const { return alimmode.is (v); }
04766 std::string get_alimmode (void) const { return alimmode.current_value (); }
04767
04768 graphics_handle get_xlabel (void) const { return xlabel.handle_value (); }
04769
04770 graphics_handle get_ylabel (void) const { return ylabel.handle_value (); }
04771
04772 graphics_handle get_zlabel (void) const { return zlabel.handle_value (); }
04773
04774 graphics_handle get_title (void) const { return title.handle_value (); }
04775
04776 bool is_xgrid (void) const { return xgrid.is_on (); }
04777 std::string get_xgrid (void) const { return xgrid.current_value (); }
04778
04779 bool is_ygrid (void) const { return ygrid.is_on (); }
04780 std::string get_ygrid (void) const { return ygrid.current_value (); }
04781
04782 bool is_zgrid (void) const { return zgrid.is_on (); }
04783 std::string get_zgrid (void) const { return zgrid.current_value (); }
04784
04785 bool is_xminorgrid (void) const { return xminorgrid.is_on (); }
04786 std::string get_xminorgrid (void) const { return xminorgrid.current_value (); }
04787
04788 bool is_yminorgrid (void) const { return yminorgrid.is_on (); }
04789 std::string get_yminorgrid (void) const { return yminorgrid.current_value (); }
04790
04791 bool is_zminorgrid (void) const { return zminorgrid.is_on (); }
04792 std::string get_zminorgrid (void) const { return zminorgrid.current_value (); }
04793
04794 octave_value get_xtick (void) const { return xtick.get (); }
04795
04796 octave_value get_ytick (void) const { return ytick.get (); }
04797
04798 octave_value get_ztick (void) const { return ztick.get (); }
04799
04800 bool xtickmode_is (const std::string& v) const { return xtickmode.is (v); }
04801 std::string get_xtickmode (void) const { return xtickmode.current_value (); }
04802
04803 bool ytickmode_is (const std::string& v) const { return ytickmode.is (v); }
04804 std::string get_ytickmode (void) const { return ytickmode.current_value (); }
04805
04806 bool ztickmode_is (const std::string& v) const { return ztickmode.is (v); }
04807 std::string get_ztickmode (void) const { return ztickmode.current_value (); }
04808
04809 bool is_xminortick (void) const { return xminortick.is_on (); }
04810 std::string get_xminortick (void) const { return xminortick.current_value (); }
04811
04812 bool is_yminortick (void) const { return yminortick.is_on (); }
04813 std::string get_yminortick (void) const { return yminortick.current_value (); }
04814
04815 bool is_zminortick (void) const { return zminortick.is_on (); }
04816 std::string get_zminortick (void) const { return zminortick.current_value (); }
04817
04818 octave_value get_xticklabel (void) const { return xticklabel.get (); }
04819
04820 octave_value get_yticklabel (void) const { return yticklabel.get (); }
04821
04822 octave_value get_zticklabel (void) const { return zticklabel.get (); }
04823
04824 bool xticklabelmode_is (const std::string& v) const { return xticklabelmode.is (v); }
04825 std::string get_xticklabelmode (void) const { return xticklabelmode.current_value (); }
04826
04827 bool yticklabelmode_is (const std::string& v) const { return yticklabelmode.is (v); }
04828 std::string get_yticklabelmode (void) const { return yticklabelmode.current_value (); }
04829
04830 bool zticklabelmode_is (const std::string& v) const { return zticklabelmode.is (v); }
04831 std::string get_zticklabelmode (void) const { return zticklabelmode.current_value (); }
04832
04833 bool interpreter_is (const std::string& v) const { return interpreter.is (v); }
04834 std::string get_interpreter (void) const { return interpreter.current_value (); }
04835
04836 bool color_is_rgb (void) const { return color.is_rgb (); }
04837 bool color_is (const std::string& v) const { return color.is (v); }
04838 Matrix get_color_rgb (void) const { return (color.is_rgb () ? color.rgb () : Matrix ()); }
04839 octave_value get_color (void) const { return color.get (); }
04840
04841 bool xcolor_is_rgb (void) const { return xcolor.is_rgb (); }
04842 bool xcolor_is (const std::string& v) const { return xcolor.is (v); }
04843 Matrix get_xcolor_rgb (void) const { return (xcolor.is_rgb () ? xcolor.rgb () : Matrix ()); }
04844 octave_value get_xcolor (void) const { return xcolor.get (); }
04845
04846 bool ycolor_is_rgb (void) const { return ycolor.is_rgb (); }
04847 bool ycolor_is (const std::string& v) const { return ycolor.is (v); }
04848 Matrix get_ycolor_rgb (void) const { return (ycolor.is_rgb () ? ycolor.rgb () : Matrix ()); }
04849 octave_value get_ycolor (void) const { return ycolor.get (); }
04850
04851 bool zcolor_is_rgb (void) const { return zcolor.is_rgb (); }
04852 bool zcolor_is (const std::string& v) const { return zcolor.is (v); }
04853 Matrix get_zcolor_rgb (void) const { return (zcolor.is_rgb () ? zcolor.rgb () : Matrix ()); }
04854 octave_value get_zcolor (void) const { return zcolor.get (); }
04855
04856 bool xscale_is (const std::string& v) const { return xscale.is (v); }
04857 std::string get_xscale (void) const { return xscale.current_value (); }
04858
04859 bool yscale_is (const std::string& v) const { return yscale.is (v); }
04860 std::string get_yscale (void) const { return yscale.current_value (); }
04861
04862 bool zscale_is (const std::string& v) const { return zscale.is (v); }
04863 std::string get_zscale (void) const { return zscale.current_value (); }
04864
04865 bool xdir_is (const std::string& v) const { return xdir.is (v); }
04866 std::string get_xdir (void) const { return xdir.current_value (); }
04867
04868 bool ydir_is (const std::string& v) const { return ydir.is (v); }
04869 std::string get_ydir (void) const { return ydir.current_value (); }
04870
04871 bool zdir_is (const std::string& v) const { return zdir.is (v); }
04872 std::string get_zdir (void) const { return zdir.current_value (); }
04873
04874 bool yaxislocation_is (const std::string& v) const { return yaxislocation.is (v); }
04875 std::string get_yaxislocation (void) const { return yaxislocation.current_value (); }
04876
04877 bool xaxislocation_is (const std::string& v) const { return xaxislocation.is (v); }
04878 std::string get_xaxislocation (void) const { return xaxislocation.current_value (); }
04879
04880 octave_value get_view (void) const { return view.get (); }
04881
04882 bool is___hold_all__ (void) const { return __hold_all__.is_on (); }
04883 std::string get___hold_all__ (void) const { return __hold_all__.current_value (); }
04884
04885 bool nextplot_is (const std::string& v) const { return nextplot.is (v); }
04886 std::string get_nextplot (void) const { return nextplot.current_value (); }
04887
04888 octave_value get_outerposition (void) const { return outerposition.get (); }
04889
04890 bool activepositionproperty_is (const std::string& v) const { return activepositionproperty.is (v); }
04891 std::string get_activepositionproperty (void) const { return activepositionproperty.current_value (); }
04892
04893 bool ambientlightcolor_is_rgb (void) const { return ambientlightcolor.is_rgb (); }
04894 bool ambientlightcolor_is (const std::string& v) const { return ambientlightcolor.is (v); }
04895 Matrix get_ambientlightcolor_rgb (void) const { return (ambientlightcolor.is_rgb () ? ambientlightcolor.rgb () : Matrix ()); }
04896 octave_value get_ambientlightcolor (void) const { return ambientlightcolor.get (); }
04897
04898 octave_value get_cameraposition (void) const { return cameraposition.get (); }
04899
04900 octave_value get_cameratarget (void) const { return cameratarget.get (); }
04901
04902 octave_value get_cameraupvector (void) const { return cameraupvector.get (); }
04903
04904 double get_cameraviewangle (void) const { return cameraviewangle.double_value (); }
04905
04906 bool camerapositionmode_is (const std::string& v) const { return camerapositionmode.is (v); }
04907 std::string get_camerapositionmode (void) const { return camerapositionmode.current_value (); }
04908
04909 bool cameratargetmode_is (const std::string& v) const { return cameratargetmode.is (v); }
04910 std::string get_cameratargetmode (void) const { return cameratargetmode.current_value (); }
04911
04912 bool cameraupvectormode_is (const std::string& v) const { return cameraupvectormode.is (v); }
04913 std::string get_cameraupvectormode (void) const { return cameraupvectormode.current_value (); }
04914
04915 bool cameraviewanglemode_is (const std::string& v) const { return cameraviewanglemode.is (v); }
04916 std::string get_cameraviewanglemode (void) const { return cameraviewanglemode.current_value (); }
04917
04918 octave_value get_currentpoint (void) const { return currentpoint.get (); }
04919
04920 bool drawmode_is (const std::string& v) const { return drawmode.is (v); }
04921 std::string get_drawmode (void) const { return drawmode.current_value (); }
04922
04923 bool fontangle_is (const std::string& v) const { return fontangle.is (v); }
04924 std::string get_fontangle (void) const { return fontangle.current_value (); }
04925
04926 std::string get_fontname (void) const { return fontname.string_value (); }
04927
04928 double get_fontsize (void) const { return fontsize.double_value (); }
04929
04930 bool fontunits_is (const std::string& v) const { return fontunits.is (v); }
04931 std::string get_fontunits (void) const { return fontunits.current_value (); }
04932
04933 bool fontweight_is (const std::string& v) const { return fontweight.is (v); }
04934 std::string get_fontweight (void) const { return fontweight.current_value (); }
04935
04936 bool gridlinestyle_is (const std::string& v) const { return gridlinestyle.is (v); }
04937 std::string get_gridlinestyle (void) const { return gridlinestyle.current_value (); }
04938
04939 octave_value get_linestyleorder (void) const { return linestyleorder.get (); }
04940
04941 double get_linewidth (void) const { return linewidth.double_value (); }
04942
04943 bool minorgridlinestyle_is (const std::string& v) const { return minorgridlinestyle.is (v); }
04944 std::string get_minorgridlinestyle (void) const { return minorgridlinestyle.current_value (); }
04945
04946 octave_value get_plotboxaspectratio (void) const { return plotboxaspectratio.get (); }
04947
04948 bool plotboxaspectratiomode_is (const std::string& v) const { return plotboxaspectratiomode.is (v); }
04949 std::string get_plotboxaspectratiomode (void) const { return plotboxaspectratiomode.current_value (); }
04950
04951 bool projection_is (const std::string& v) const { return projection.is (v); }
04952 std::string get_projection (void) const { return projection.current_value (); }
04953
04954 bool tickdir_is (const std::string& v) const { return tickdir.is (v); }
04955 std::string get_tickdir (void) const { return tickdir.current_value (); }
04956
04957 bool tickdirmode_is (const std::string& v) const { return tickdirmode.is (v); }
04958 std::string get_tickdirmode (void) const { return tickdirmode.current_value (); }
04959
04960 octave_value get_ticklength (void) const { return ticklength.get (); }
04961
04962 octave_value get_tightinset (void) const { return tightinset.get (); }
04963
04964 bool units_is (const std::string& v) const { return units.is (v); }
04965 std::string get_units (void) const { return units.current_value (); }
04966
04967 octave_value get_x_viewtransform (void) const { return x_viewtransform.get (); }
04968
04969 octave_value get_x_projectiontransform (void) const { return x_projectiontransform.get (); }
04970
04971 octave_value get_x_viewporttransform (void) const { return x_viewporttransform.get (); }
04972
04973 octave_value get_x_normrendertransform (void) const { return x_normrendertransform.get (); }
04974
04975 octave_value get_x_rendertransform (void) const { return x_rendertransform.get (); }
04976
04977 octave_value get_xmtick (void) const { return xmtick.get (); }
04978
04979 octave_value get_ymtick (void) const { return ymtick.get (); }
04980
04981 octave_value get_zmtick (void) const { return zmtick.get (); }
04982
04983
04984 void set_position (const octave_value& val)
04985 {
04986 if (! error_state)
04987 {
04988 if (position.set (val, true))
04989 {
04990 update_position ();
04991 mark_modified ();
04992 }
04993 }
04994 }
04995
04996 void set_box (const octave_value& val)
04997 {
04998 if (! error_state)
04999 {
05000 if (box.set (val, true))
05001 {
05002 mark_modified ();
05003 }
05004 }
05005 }
05006
05007 void set_colororder (const octave_value& val)
05008 {
05009 if (! error_state)
05010 {
05011 if (colororder.set (val, true))
05012 {
05013 mark_modified ();
05014 }
05015 }
05016 }
05017
05018 void set_dataaspectratio (const octave_value& val)
05019 {
05020 if (! error_state)
05021 {
05022 if (dataaspectratio.set (val, false))
05023 {
05024 set_dataaspectratiomode ("manual");
05025 update_dataaspectratio ();
05026 dataaspectratio.run_listeners (POSTSET);
05027 mark_modified ();
05028 }
05029 else
05030 set_dataaspectratiomode ("manual");
05031 }
05032 }
05033
05034 void set_dataaspectratiomode (const octave_value& val)
05035 {
05036 if (! error_state)
05037 {
05038 if (dataaspectratiomode.set (val, true))
05039 {
05040 update_dataaspectratiomode ();
05041 mark_modified ();
05042 }
05043 }
05044 }
05045
05046 void set_layer (const octave_value& val)
05047 {
05048 if (! error_state)
05049 {
05050 if (layer.set (val, true))
05051 {
05052 update_layer ();
05053 mark_modified ();
05054 }
05055 }
05056 }
05057
05058 void set_xlim (const octave_value& val)
05059 {
05060 if (! error_state)
05061 {
05062 if (xlim.set (val, false))
05063 {
05064 set_xlimmode ("manual");
05065 update_xlim ();
05066 xlim.run_listeners (POSTSET);
05067 mark_modified ();
05068 }
05069 else
05070 set_xlimmode ("manual");
05071 }
05072 }
05073
05074 void set_ylim (const octave_value& val)
05075 {
05076 if (! error_state)
05077 {
05078 if (ylim.set (val, false))
05079 {
05080 set_ylimmode ("manual");
05081 update_ylim ();
05082 ylim.run_listeners (POSTSET);
05083 mark_modified ();
05084 }
05085 else
05086 set_ylimmode ("manual");
05087 }
05088 }
05089
05090 void set_zlim (const octave_value& val)
05091 {
05092 if (! error_state)
05093 {
05094 if (zlim.set (val, false))
05095 {
05096 set_zlimmode ("manual");
05097 update_zlim ();
05098 zlim.run_listeners (POSTSET);
05099 mark_modified ();
05100 }
05101 else
05102 set_zlimmode ("manual");
05103 }
05104 }
05105
05106 void set_clim (const octave_value& val)
05107 {
05108 if (! error_state)
05109 {
05110 if (clim.set (val, false))
05111 {
05112 set_climmode ("manual");
05113 clim.run_listeners (POSTSET);
05114 mark_modified ();
05115 }
05116 else
05117 set_climmode ("manual");
05118 }
05119 }
05120
05121 void set_alim (const octave_value& val)
05122 {
05123 if (! error_state)
05124 {
05125 if (alim.set (val, false))
05126 {
05127 set_alimmode ("manual");
05128 alim.run_listeners (POSTSET);
05129 mark_modified ();
05130 }
05131 else
05132 set_alimmode ("manual");
05133 }
05134 }
05135
05136 void set_xlimmode (const octave_value& val)
05137 {
05138 if (! error_state)
05139 {
05140 if (xlimmode.set (val, false))
05141 {
05142 update_axis_limits ("xlimmode");
05143 xlimmode.run_listeners (POSTSET);
05144 mark_modified ();
05145 }
05146 }
05147 }
05148
05149 void set_ylimmode (const octave_value& val)
05150 {
05151 if (! error_state)
05152 {
05153 if (ylimmode.set (val, false))
05154 {
05155 update_axis_limits ("ylimmode");
05156 ylimmode.run_listeners (POSTSET);
05157 mark_modified ();
05158 }
05159 }
05160 }
05161
05162 void set_zlimmode (const octave_value& val)
05163 {
05164 if (! error_state)
05165 {
05166 if (zlimmode.set (val, false))
05167 {
05168 update_axis_limits ("zlimmode");
05169 zlimmode.run_listeners (POSTSET);
05170 mark_modified ();
05171 }
05172 }
05173 }
05174
05175 void set_climmode (const octave_value& val)
05176 {
05177 if (! error_state)
05178 {
05179 if (climmode.set (val, false))
05180 {
05181 update_axis_limits ("climmode");
05182 climmode.run_listeners (POSTSET);
05183 mark_modified ();
05184 }
05185 }
05186 }
05187
05188 void set_alimmode (const octave_value& val)
05189 {
05190 if (! error_state)
05191 {
05192 if (alimmode.set (val, true))
05193 {
05194 mark_modified ();
05195 }
05196 }
05197 }
05198
05199 void set_xlabel (const octave_value& val);
05200
05201 void set_ylabel (const octave_value& val);
05202
05203 void set_zlabel (const octave_value& val);
05204
05205 void set_title (const octave_value& val);
05206
05207 void set_xgrid (const octave_value& val)
05208 {
05209 if (! error_state)
05210 {
05211 if (xgrid.set (val, true))
05212 {
05213 mark_modified ();
05214 }
05215 }
05216 }
05217
05218 void set_ygrid (const octave_value& val)
05219 {
05220 if (! error_state)
05221 {
05222 if (ygrid.set (val, true))
05223 {
05224 mark_modified ();
05225 }
05226 }
05227 }
05228
05229 void set_zgrid (const octave_value& val)
05230 {
05231 if (! error_state)
05232 {
05233 if (zgrid.set (val, true))
05234 {
05235 mark_modified ();
05236 }
05237 }
05238 }
05239
05240 void set_xminorgrid (const octave_value& val)
05241 {
05242 if (! error_state)
05243 {
05244 if (xminorgrid.set (val, true))
05245 {
05246 mark_modified ();
05247 }
05248 }
05249 }
05250
05251 void set_yminorgrid (const octave_value& val)
05252 {
05253 if (! error_state)
05254 {
05255 if (yminorgrid.set (val, true))
05256 {
05257 mark_modified ();
05258 }
05259 }
05260 }
05261
05262 void set_zminorgrid (const octave_value& val)
05263 {
05264 if (! error_state)
05265 {
05266 if (zminorgrid.set (val, true))
05267 {
05268 mark_modified ();
05269 }
05270 }
05271 }
05272
05273 void set_xtick (const octave_value& val)
05274 {
05275 if (! error_state)
05276 {
05277 if (xtick.set (val, false))
05278 {
05279 set_xtickmode ("manual");
05280 update_xtick ();
05281 xtick.run_listeners (POSTSET);
05282 mark_modified ();
05283 }
05284 else
05285 set_xtickmode ("manual");
05286 }
05287 }
05288
05289 void set_ytick (const octave_value& val)
05290 {
05291 if (! error_state)
05292 {
05293 if (ytick.set (val, false))
05294 {
05295 set_ytickmode ("manual");
05296 update_ytick ();
05297 ytick.run_listeners (POSTSET);
05298 mark_modified ();
05299 }
05300 else
05301 set_ytickmode ("manual");
05302 }
05303 }
05304
05305 void set_ztick (const octave_value& val)
05306 {
05307 if (! error_state)
05308 {
05309 if (ztick.set (val, false))
05310 {
05311 set_ztickmode ("manual");
05312 update_ztick ();
05313 ztick.run_listeners (POSTSET);
05314 mark_modified ();
05315 }
05316 else
05317 set_ztickmode ("manual");
05318 }
05319 }
05320
05321 void set_xtickmode (const octave_value& val)
05322 {
05323 if (! error_state)
05324 {
05325 if (xtickmode.set (val, true))
05326 {
05327 update_xtickmode ();
05328 mark_modified ();
05329 }
05330 }
05331 }
05332
05333 void set_ytickmode (const octave_value& val)
05334 {
05335 if (! error_state)
05336 {
05337 if (ytickmode.set (val, true))
05338 {
05339 update_ytickmode ();
05340 mark_modified ();
05341 }
05342 }
05343 }
05344
05345 void set_ztickmode (const octave_value& val)
05346 {
05347 if (! error_state)
05348 {
05349 if (ztickmode.set (val, true))
05350 {
05351 update_ztickmode ();
05352 mark_modified ();
05353 }
05354 }
05355 }
05356
05357 void set_xminortick (const octave_value& val)
05358 {
05359 if (! error_state)
05360 {
05361 if (xminortick.set (val, true))
05362 {
05363 mark_modified ();
05364 }
05365 }
05366 }
05367
05368 void set_yminortick (const octave_value& val)
05369 {
05370 if (! error_state)
05371 {
05372 if (yminortick.set (val, true))
05373 {
05374 mark_modified ();
05375 }
05376 }
05377 }
05378
05379 void set_zminortick (const octave_value& val)
05380 {
05381 if (! error_state)
05382 {
05383 if (zminortick.set (val, true))
05384 {
05385 mark_modified ();
05386 }
05387 }
05388 }
05389
05390 void set_xticklabel (const octave_value& val)
05391 {
05392 if (! error_state)
05393 {
05394 if (xticklabel.set (val, false))
05395 {
05396 set_xticklabelmode ("manual");
05397 xticklabel.run_listeners (POSTSET);
05398 mark_modified ();
05399 }
05400 else
05401 set_xticklabelmode ("manual");
05402 }
05403 }
05404
05405 void set_yticklabel (const octave_value& val)
05406 {
05407 if (! error_state)
05408 {
05409 if (yticklabel.set (val, false))
05410 {
05411 set_yticklabelmode ("manual");
05412 yticklabel.run_listeners (POSTSET);
05413 mark_modified ();
05414 }
05415 else
05416 set_yticklabelmode ("manual");
05417 }
05418 }
05419
05420 void set_zticklabel (const octave_value& val)
05421 {
05422 if (! error_state)
05423 {
05424 if (zticklabel.set (val, false))
05425 {
05426 set_zticklabelmode ("manual");
05427 zticklabel.run_listeners (POSTSET);
05428 mark_modified ();
05429 }
05430 else
05431 set_zticklabelmode ("manual");
05432 }
05433 }
05434
05435 void set_xticklabelmode (const octave_value& val)
05436 {
05437 if (! error_state)
05438 {
05439 if (xticklabelmode.set (val, true))
05440 {
05441 update_xticklabelmode ();
05442 mark_modified ();
05443 }
05444 }
05445 }
05446
05447 void set_yticklabelmode (const octave_value& val)
05448 {
05449 if (! error_state)
05450 {
05451 if (yticklabelmode.set (val, true))
05452 {
05453 update_yticklabelmode ();
05454 mark_modified ();
05455 }
05456 }
05457 }
05458
05459 void set_zticklabelmode (const octave_value& val)
05460 {
05461 if (! error_state)
05462 {
05463 if (zticklabelmode.set (val, true))
05464 {
05465 update_zticklabelmode ();
05466 mark_modified ();
05467 }
05468 }
05469 }
05470
05471 void set_interpreter (const octave_value& val)
05472 {
05473 if (! error_state)
05474 {
05475 if (interpreter.set (val, true))
05476 {
05477 mark_modified ();
05478 }
05479 }
05480 }
05481
05482 void set_color (const octave_value& val)
05483 {
05484 if (! error_state)
05485 {
05486 if (color.set (val, true))
05487 {
05488 mark_modified ();
05489 }
05490 }
05491 }
05492
05493 void set_xcolor (const octave_value& val)
05494 {
05495 if (! error_state)
05496 {
05497 if (xcolor.set (val, true))
05498 {
05499 mark_modified ();
05500 }
05501 }
05502 }
05503
05504 void set_ycolor (const octave_value& val)
05505 {
05506 if (! error_state)
05507 {
05508 if (ycolor.set (val, true))
05509 {
05510 mark_modified ();
05511 }
05512 }
05513 }
05514
05515 void set_zcolor (const octave_value& val)
05516 {
05517 if (! error_state)
05518 {
05519 if (zcolor.set (val, true))
05520 {
05521 mark_modified ();
05522 }
05523 }
05524 }
05525
05526 void set_xscale (const octave_value& val)
05527 {
05528 if (! error_state)
05529 {
05530 if (xscale.set (val, false))
05531 {
05532 update_xscale ();
05533 update_axis_limits ("xscale");
05534 xscale.run_listeners (POSTSET);
05535 mark_modified ();
05536 }
05537 }
05538 }
05539
05540 void set_yscale (const octave_value& val)
05541 {
05542 if (! error_state)
05543 {
05544 if (yscale.set (val, false))
05545 {
05546 update_yscale ();
05547 update_axis_limits ("yscale");
05548 yscale.run_listeners (POSTSET);
05549 mark_modified ();
05550 }
05551 }
05552 }
05553
05554 void set_zscale (const octave_value& val)
05555 {
05556 if (! error_state)
05557 {
05558 if (zscale.set (val, false))
05559 {
05560 update_zscale ();
05561 update_axis_limits ("zscale");
05562 zscale.run_listeners (POSTSET);
05563 mark_modified ();
05564 }
05565 }
05566 }
05567
05568 void set_xdir (const octave_value& val)
05569 {
05570 if (! error_state)
05571 {
05572 if (xdir.set (val, true))
05573 {
05574 update_xdir ();
05575 mark_modified ();
05576 }
05577 }
05578 }
05579
05580 void set_ydir (const octave_value& val)
05581 {
05582 if (! error_state)
05583 {
05584 if (ydir.set (val, true))
05585 {
05586 update_ydir ();
05587 mark_modified ();
05588 }
05589 }
05590 }
05591
05592 void set_zdir (const octave_value& val)
05593 {
05594 if (! error_state)
05595 {
05596 if (zdir.set (val, true))
05597 {
05598 update_zdir ();
05599 mark_modified ();
05600 }
05601 }
05602 }
05603
05604 void set_yaxislocation (const octave_value& val)
05605 {
05606 if (! error_state)
05607 {
05608 if (yaxislocation.set (val, true))
05609 {
05610 update_yaxislocation ();
05611 mark_modified ();
05612 }
05613 }
05614 }
05615
05616 void set_xaxislocation (const octave_value& val)
05617 {
05618 if (! error_state)
05619 {
05620 if (xaxislocation.set (val, true))
05621 {
05622 update_xaxislocation ();
05623 mark_modified ();
05624 }
05625 }
05626 }
05627
05628 void set_view (const octave_value& val)
05629 {
05630 if (! error_state)
05631 {
05632 if (view.set (val, true))
05633 {
05634 update_view ();
05635 mark_modified ();
05636 }
05637 }
05638 }
05639
05640 void set___hold_all__ (const octave_value& val)
05641 {
05642 if (! error_state)
05643 {
05644 if (__hold_all__.set (val, true))
05645 {
05646 mark_modified ();
05647 }
05648 }
05649 }
05650
05651 void set_nextplot (const octave_value& val)
05652 {
05653 if (! error_state)
05654 {
05655 if (nextplot.set (val, true))
05656 {
05657 mark_modified ();
05658 }
05659 }
05660 }
05661
05662 void set_outerposition (const octave_value& val)
05663 {
05664 if (! error_state)
05665 {
05666 if (outerposition.set (val, true))
05667 {
05668 update_outerposition ();
05669 mark_modified ();
05670 }
05671 }
05672 }
05673
05674 void set_activepositionproperty (const octave_value& val)
05675 {
05676 if (! error_state)
05677 {
05678 if (activepositionproperty.set (val, true))
05679 {
05680 mark_modified ();
05681 }
05682 }
05683 }
05684
05685 void set_ambientlightcolor (const octave_value& val)
05686 {
05687 if (! error_state)
05688 {
05689 if (ambientlightcolor.set (val, true))
05690 {
05691 mark_modified ();
05692 }
05693 }
05694 }
05695
05696 void set_cameraposition (const octave_value& val)
05697 {
05698 if (! error_state)
05699 {
05700 if (cameraposition.set (val, false))
05701 {
05702 set_camerapositionmode ("manual");
05703 cameraposition.run_listeners (POSTSET);
05704 mark_modified ();
05705 }
05706 else
05707 set_camerapositionmode ("manual");
05708 }
05709 }
05710
05711 void set_cameratarget (const octave_value& val)
05712 {
05713 if (! error_state)
05714 {
05715 if (cameratarget.set (val, false))
05716 {
05717 set_cameratargetmode ("manual");
05718 cameratarget.run_listeners (POSTSET);
05719 mark_modified ();
05720 }
05721 else
05722 set_cameratargetmode ("manual");
05723 }
05724 }
05725
05726 void set_cameraupvector (const octave_value& val)
05727 {
05728 if (! error_state)
05729 {
05730 if (cameraupvector.set (val, false))
05731 {
05732 set_cameraupvectormode ("manual");
05733 cameraupvector.run_listeners (POSTSET);
05734 mark_modified ();
05735 }
05736 else
05737 set_cameraupvectormode ("manual");
05738 }
05739 }
05740
05741 void set_cameraviewangle (const octave_value& val)
05742 {
05743 if (! error_state)
05744 {
05745 if (cameraviewangle.set (val, false))
05746 {
05747 set_cameraviewanglemode ("manual");
05748 cameraviewangle.run_listeners (POSTSET);
05749 mark_modified ();
05750 }
05751 else
05752 set_cameraviewanglemode ("manual");
05753 }
05754 }
05755
05756 void set_camerapositionmode (const octave_value& val)
05757 {
05758 if (! error_state)
05759 {
05760 if (camerapositionmode.set (val, true))
05761 {
05762 mark_modified ();
05763 }
05764 }
05765 }
05766
05767 void set_cameratargetmode (const octave_value& val)
05768 {
05769 if (! error_state)
05770 {
05771 if (cameratargetmode.set (val, true))
05772 {
05773 mark_modified ();
05774 }
05775 }
05776 }
05777
05778 void set_cameraupvectormode (const octave_value& val)
05779 {
05780 if (! error_state)
05781 {
05782 if (cameraupvectormode.set (val, true))
05783 {
05784 mark_modified ();
05785 }
05786 }
05787 }
05788
05789 void set_cameraviewanglemode (const octave_value& val)
05790 {
05791 if (! error_state)
05792 {
05793 if (cameraviewanglemode.set (val, true))
05794 {
05795 mark_modified ();
05796 }
05797 }
05798 }
05799
05800 void set_currentpoint (const octave_value& val)
05801 {
05802 if (! error_state)
05803 {
05804 if (currentpoint.set (val, true))
05805 {
05806 mark_modified ();
05807 }
05808 }
05809 }
05810
05811 void set_drawmode (const octave_value& val)
05812 {
05813 if (! error_state)
05814 {
05815 if (drawmode.set (val, true))
05816 {
05817 mark_modified ();
05818 }
05819 }
05820 }
05821
05822 void set_fontangle (const octave_value& val)
05823 {
05824 if (! error_state)
05825 {
05826 if (fontangle.set (val, true))
05827 {
05828 mark_modified ();
05829 }
05830 }
05831 }
05832
05833 void set_fontname (const octave_value& val)
05834 {
05835 if (! error_state)
05836 {
05837 if (fontname.set (val, true))
05838 {
05839 mark_modified ();
05840 }
05841 }
05842 }
05843
05844 void set_fontsize (const octave_value& val)
05845 {
05846 if (! error_state)
05847 {
05848 if (fontsize.set (val, true))
05849 {
05850 mark_modified ();
05851 }
05852 }
05853 }
05854
05855 void set_fontunits (const octave_value& val);
05856
05857 void update_fontunits (void);
05858
05859 void set_fontweight (const octave_value& val)
05860 {
05861 if (! error_state)
05862 {
05863 if (fontweight.set (val, true))
05864 {
05865 mark_modified ();
05866 }
05867 }
05868 }
05869
05870 void set_gridlinestyle (const octave_value& val)
05871 {
05872 if (! error_state)
05873 {
05874 if (gridlinestyle.set (val, true))
05875 {
05876 mark_modified ();
05877 }
05878 }
05879 }
05880
05881 void set_linestyleorder (const octave_value& val)
05882 {
05883 if (! error_state)
05884 {
05885 if (linestyleorder.set (val, true))
05886 {
05887 mark_modified ();
05888 }
05889 }
05890 }
05891
05892 void set_linewidth (const octave_value& val)
05893 {
05894 if (! error_state)
05895 {
05896 if (linewidth.set (val, true))
05897 {
05898 mark_modified ();
05899 }
05900 }
05901 }
05902
05903 void set_minorgridlinestyle (const octave_value& val)
05904 {
05905 if (! error_state)
05906 {
05907 if (minorgridlinestyle.set (val, true))
05908 {
05909 mark_modified ();
05910 }
05911 }
05912 }
05913
05914 void set_plotboxaspectratio (const octave_value& val)
05915 {
05916 if (! error_state)
05917 {
05918 if (plotboxaspectratio.set (val, false))
05919 {
05920 set_plotboxaspectratiomode ("manual");
05921 update_plotboxaspectratio ();
05922 plotboxaspectratio.run_listeners (POSTSET);
05923 mark_modified ();
05924 }
05925 else
05926 set_plotboxaspectratiomode ("manual");
05927 }
05928 }
05929
05930 void set_plotboxaspectratiomode (const octave_value& val)
05931 {
05932 if (! error_state)
05933 {
05934 if (plotboxaspectratiomode.set (val, true))
05935 {
05936 update_plotboxaspectratiomode ();
05937 mark_modified ();
05938 }
05939 }
05940 }
05941
05942 void set_projection (const octave_value& val)
05943 {
05944 if (! error_state)
05945 {
05946 if (projection.set (val, true))
05947 {
05948 mark_modified ();
05949 }
05950 }
05951 }
05952
05953 void set_tickdir (const octave_value& val)
05954 {
05955 if (! error_state)
05956 {
05957 if (tickdir.set (val, false))
05958 {
05959 set_tickdirmode ("manual");
05960 update_tickdir ();
05961 tickdir.run_listeners (POSTSET);
05962 mark_modified ();
05963 }
05964 else
05965 set_tickdirmode ("manual");
05966 }
05967 }
05968
05969 void set_tickdirmode (const octave_value& val)
05970 {
05971 if (! error_state)
05972 {
05973 if (tickdirmode.set (val, true))
05974 {
05975 update_tickdirmode ();
05976 mark_modified ();
05977 }
05978 }
05979 }
05980
05981 void set_ticklength (const octave_value& val)
05982 {
05983 if (! error_state)
05984 {
05985 if (ticklength.set (val, true))
05986 {
05987 mark_modified ();
05988 }
05989 }
05990 }
05991
05992 void set_tightinset (const octave_value& val)
05993 {
05994 if (! error_state)
05995 {
05996 if (tightinset.set (val, true))
05997 {
05998 mark_modified ();
05999 }
06000 }
06001 }
06002
06003 void set_units (const octave_value& val);
06004
06005 void update_units (void);
06006
06007 void set_x_viewtransform (const octave_value& val)
06008 {
06009 if (! error_state)
06010 {
06011 if (x_viewtransform.set (val, true))
06012 {
06013 mark_modified ();
06014 }
06015 }
06016 }
06017
06018 void set_x_projectiontransform (const octave_value& val)
06019 {
06020 if (! error_state)
06021 {
06022 if (x_projectiontransform.set (val, true))
06023 {
06024 mark_modified ();
06025 }
06026 }
06027 }
06028
06029 void set_x_viewporttransform (const octave_value& val)
06030 {
06031 if (! error_state)
06032 {
06033 if (x_viewporttransform.set (val, true))
06034 {
06035 mark_modified ();
06036 }
06037 }
06038 }
06039
06040 void set_x_normrendertransform (const octave_value& val)
06041 {
06042 if (! error_state)
06043 {
06044 if (x_normrendertransform.set (val, true))
06045 {
06046 mark_modified ();
06047 }
06048 }
06049 }
06050
06051 void set_x_rendertransform (const octave_value& val)
06052 {
06053 if (! error_state)
06054 {
06055 if (x_rendertransform.set (val, true))
06056 {
06057 mark_modified ();
06058 }
06059 }
06060 }
06061
06062 void set_xmtick (const octave_value& val)
06063 {
06064 if (! error_state)
06065 {
06066 if (xmtick.set (val, true))
06067 {
06068 mark_modified ();
06069 }
06070 }
06071 }
06072
06073 void set_ymtick (const octave_value& val)
06074 {
06075 if (! error_state)
06076 {
06077 if (ymtick.set (val, true))
06078 {
06079 mark_modified ();
06080 }
06081 }
06082 }
06083
06084 void set_zmtick (const octave_value& val)
06085 {
06086 if (! error_state)
06087 {
06088 if (zmtick.set (val, true))
06089 {
06090 mark_modified ();
06091 }
06092 }
06093 }
06094
06095
06096 protected:
06097 void init (void);
06098
06099 private:
06100 void update_xscale (void) { sx = get_xscale (); }
06101 void update_yscale (void) { sy = get_yscale (); }
06102 void update_zscale (void) { sz = get_zscale (); }
06103
06104 void update_view (void) { update_camera (); update_axes_layout (); }
06105 void update_dataaspectratio (void) { update_transform (); }
06106 void update_dataaspectratiomode (void) { update_transform (); }
06107 void update_plotboxaspectratio (void) { update_transform (); }
06108 void update_plotboxaspectratiomode (void) { update_transform (); }
06109
06110 void update_layer (void) { update_axes_layout (); }
06111 void update_yaxislocation (void) { update_axes_layout (); }
06112 void update_xaxislocation (void) { update_axes_layout (); }
06113
06114 void update_xdir (void) { update_camera (); update_axes_layout (); }
06115 void update_ydir (void) { update_camera (); update_axes_layout (); }
06116 void update_zdir (void) { update_camera (); update_axes_layout (); }
06117
06118 void update_ticklengths (void);
06119 void update_tickdir (void) { update_ticklengths (); }
06120 void update_tickdirmode (void) { update_ticklengths (); }
06121
06122 void update_xtick (void)
06123 {
06124 if (xticklabelmode.is ("auto"))
06125 calc_ticklabels (xtick, xticklabel, xscale.is ("log"));
06126 }
06127 void update_ytick (void)
06128 {
06129 if (yticklabelmode.is ("auto"))
06130 calc_ticklabels (ytick, yticklabel, yscale.is ("log"));
06131 }
06132 void update_ztick (void)
06133 {
06134 if (zticklabelmode.is ("auto"))
06135 calc_ticklabels (ztick, zticklabel, zscale.is ("log"));
06136 }
06137
06138 void update_xtickmode (void)
06139 {
06140 if (xtickmode.is ("auto"))
06141 {
06142 calc_ticks_and_lims (xlim, xtick, xmtick, xlimmode.is ("auto"), xscale.is ("log"));
06143 update_xtick ();
06144 }
06145 }
06146 void update_ytickmode (void)
06147 {
06148 if (ytickmode.is ("auto"))
06149 {
06150 calc_ticks_and_lims (ylim, ytick, ymtick, ylimmode.is ("auto"), yscale.is ("log"));
06151 update_ytick ();
06152 }
06153 }
06154 void update_ztickmode (void)
06155 {
06156 if (ztickmode.is ("auto"))
06157 {
06158 calc_ticks_and_lims (zlim, ztick, zmtick, zlimmode.is ("auto"), zscale.is ("log"));
06159 update_ztick ();
06160 }
06161 }
06162
06163 void update_xticklabelmode (void)
06164 {
06165 if (xticklabelmode.is ("auto"))
06166 calc_ticklabels (xtick, xticklabel, xscale.is ("log"));
06167 }
06168 void update_yticklabelmode (void)
06169 {
06170 if (yticklabelmode.is ("auto"))
06171 calc_ticklabels (ytick, yticklabel, yscale.is ("log"));
06172 }
06173 void update_zticklabelmode (void)
06174 {
06175 if (zticklabelmode.is ("auto"))
06176 calc_ticklabels (ztick, zticklabel, zscale.is ("log"));
06177 }
06178
06179 void sync_positions (void);
06180 void update_outerposition (void) { sync_positions ();}
06181 void update_position (void) { sync_positions (); }
06182
06183 double calc_tick_sep (double minval, double maxval);
06184 void calc_ticks_and_lims (array_property& lims, array_property& ticks, array_property& mticks,
06185 bool limmode_is_auto, bool is_logscale);
06186 void calc_ticklabels (const array_property& ticks, any_property& labels, bool is_logscale);
06187 Matrix get_ticklabel_extents (const Matrix& ticks,
06188 const string_vector& ticklabels,
06189 const Matrix& limits);
06190
06191 void fix_limits (array_property& lims)
06192 {
06193 if (lims.get ().is_empty ())
06194 return;
06195
06196 Matrix l = lims.get ().matrix_value ();
06197 if (l(0) > l(1))
06198 {
06199 l(0) = 0;
06200 l(1) = 1;
06201 lims = l;
06202 }
06203 else if (l(0) == l(1))
06204 {
06205 l(0) -= 0.5;
06206 l(1) += 0.5;
06207 lims = l;
06208 }
06209 }
06210
06211 public:
06212 Matrix get_axis_limits (double xmin, double xmax, double min_pos, bool logscale);
06213
06214 void update_xlim (bool do_clr_zoom = true)
06215 {
06216 if (xtickmode.is ("auto"))
06217 calc_ticks_and_lims (xlim, xtick, xmtick, xlimmode.is ("auto"), xscale.is ("log"));
06218 if (xticklabelmode.is ("auto"))
06219 calc_ticklabels (xtick, xticklabel, xscale.is ("log"));
06220
06221 fix_limits (xlim);
06222
06223 if (do_clr_zoom)
06224 zoom_stack.clear ();
06225
06226 update_axes_layout ();
06227 }
06228
06229 void update_ylim (bool do_clr_zoom = true)
06230 {
06231 if (ytickmode.is ("auto"))
06232 calc_ticks_and_lims (ylim, ytick, ymtick, ylimmode.is ("auto"), yscale.is ("log"));
06233 if (yticklabelmode.is ("auto"))
06234 calc_ticklabels (ytick, yticklabel, yscale.is ("log"));
06235
06236 fix_limits (ylim);
06237
06238 if (do_clr_zoom)
06239 zoom_stack.clear ();
06240
06241 update_axes_layout ();
06242 }
06243
06244 void update_zlim (void)
06245 {
06246 if (ztickmode.is ("auto"))
06247 calc_ticks_and_lims (zlim, ztick, zmtick, zlimmode.is ("auto"), zscale.is ("log"));
06248 if (zticklabelmode.is ("auto"))
06249 calc_ticklabels (ztick, zticklabel, zscale.is ("log"));
06250
06251 fix_limits (zlim);
06252
06253 zoom_stack.clear ();
06254
06255 update_axes_layout ();
06256 }
06257
06258 };
06259
06260 private:
06261 properties xproperties;
06262
06263 public:
06264 axes (const graphics_handle& mh, const graphics_handle& p)
06265 : base_graphics_object (), xproperties (mh, p), default_properties ()
06266 {
06267 xproperties.override_defaults (*this);
06268 xproperties.update_transform ();
06269 }
06270
06271 ~axes (void) { xproperties.delete_children (); }
06272
06273 void override_defaults (base_graphics_object& obj)
06274 {
06275
06276
06277 xproperties.override_defaults (obj);
06278
06279
06280
06281
06282
06283
06284 obj.set_from_list (default_properties);
06285 }
06286
06287 void set (const caseless_str& name, const octave_value& value)
06288 {
06289 if (name.compare ("default", 7))
06290
06291
06292
06293 default_properties.set (name.substr (7), value);
06294 else
06295 xproperties.set (name, value);
06296 }
06297
06298 void set_defaults (const std::string& mode)
06299 {
06300 remove_all_listeners ();
06301 xproperties.set_defaults (*this, mode);
06302 }
06303
06304 octave_value get (const caseless_str& name) const
06305 {
06306 octave_value retval;
06307
06308
06309 if (name.compare ("default", 7))
06310 retval = get_default (name.substr (7));
06311 else
06312 retval = xproperties.get (name);
06313
06314 return retval;
06315 }
06316
06317 octave_value get_default (const caseless_str& name) const;
06318
06319 octave_value get_defaults (void) const
06320 {
06321 return default_properties.as_struct ("default");
06322 }
06323
06324 base_properties& get_properties (void) { return xproperties; }
06325
06326 const base_properties& get_properties (void) const { return xproperties; }
06327
06328 void update_axis_limits (const std::string& axis_type);
06329
06330 void update_axis_limits (const std::string& axis_type,
06331 const graphics_handle& h);
06332
06333 bool valid_object (void) const { return true; }
06334
06335 void reset_default_properties (void);
06336
06337 private:
06338 property_list default_properties;
06339 };
06340
06341
06342
06343 class OCTINTERP_API line : public base_graphics_object
06344 {
06345 public:
06346 class OCTINTERP_API properties : public base_properties
06347 {
06348 public:
06349
06350
06351
06352
06353
06354 public:
06355 properties (const graphics_handle& mh, const graphics_handle& p);
06356
06357 ~properties (void) { }
06358
06359 void set (const caseless_str& pname, const octave_value& val);
06360
06361 octave_value get (bool all = false) const;
06362
06363 octave_value get (const caseless_str& pname) const;
06364
06365 octave_value get (const std::string& pname) const
06366 {
06367 return get (caseless_str (pname));
06368 }
06369
06370 octave_value get (const char *pname) const
06371 {
06372 return get (caseless_str (pname));
06373 }
06374
06375 property get_property (const caseless_str& pname);
06376
06377 std::string graphics_object_name (void) const { return go_name; }
06378
06379 static property_list::pval_map_type factory_defaults (void);
06380
06381 private:
06382 static std::string go_name;
06383
06384 public:
06385
06386
06387 static std::set<std::string> core_property_names (void);
06388
06389 static bool has_core_property (const caseless_str& pname);
06390
06391 std::set<std::string> all_property_names (void) const;
06392
06393 bool has_property (const caseless_str& pname) const;
06394
06395 private:
06396
06397 row_vector_property xdata;
06398 row_vector_property ydata;
06399 row_vector_property zdata;
06400 string_property xdatasource;
06401 string_property ydatasource;
06402 string_property zdatasource;
06403 color_property color;
06404 radio_property linestyle;
06405 double_property linewidth;
06406 radio_property marker;
06407 color_property markeredgecolor;
06408 color_property markerfacecolor;
06409 double_property markersize;
06410 radio_property interpreter;
06411 string_property displayname;
06412 radio_property erasemode;
06413 row_vector_property xlim;
06414 row_vector_property ylim;
06415 row_vector_property zlim;
06416 bool_property xliminclude;
06417 bool_property yliminclude;
06418 bool_property zliminclude;
06419
06420 public:
06421
06422 enum
06423 {
06424 ID_XDATA = 4000,
06425 ID_YDATA = 4001,
06426 ID_ZDATA = 4002,
06427 ID_XDATASOURCE = 4003,
06428 ID_YDATASOURCE = 4004,
06429 ID_ZDATASOURCE = 4005,
06430 ID_COLOR = 4006,
06431 ID_LINESTYLE = 4007,
06432 ID_LINEWIDTH = 4008,
06433 ID_MARKER = 4009,
06434 ID_MARKEREDGECOLOR = 4010,
06435 ID_MARKERFACECOLOR = 4011,
06436 ID_MARKERSIZE = 4012,
06437 ID_INTERPRETER = 4013,
06438 ID_DISPLAYNAME = 4014,
06439 ID_ERASEMODE = 4015,
06440 ID_XLIM = 4016,
06441 ID_YLIM = 4017,
06442 ID_ZLIM = 4018,
06443 ID_XLIMINCLUDE = 4019,
06444 ID_YLIMINCLUDE = 4020,
06445 ID_ZLIMINCLUDE = 4021
06446 };
06447
06448 octave_value get_xdata (void) const { return xdata.get (); }
06449
06450 octave_value get_ydata (void) const { return ydata.get (); }
06451
06452 octave_value get_zdata (void) const { return zdata.get (); }
06453
06454 std::string get_xdatasource (void) const { return xdatasource.string_value (); }
06455
06456 std::string get_ydatasource (void) const { return ydatasource.string_value (); }
06457
06458 std::string get_zdatasource (void) const { return zdatasource.string_value (); }
06459
06460 bool color_is_rgb (void) const { return color.is_rgb (); }
06461 bool color_is (const std::string& v) const { return color.is (v); }
06462 Matrix get_color_rgb (void) const { return (color.is_rgb () ? color.rgb () : Matrix ()); }
06463 octave_value get_color (void) const { return color.get (); }
06464
06465 bool linestyle_is (const std::string& v) const { return linestyle.is (v); }
06466 std::string get_linestyle (void) const { return linestyle.current_value (); }
06467
06468 double get_linewidth (void) const { return linewidth.double_value (); }
06469
06470 bool marker_is (const std::string& v) const { return marker.is (v); }
06471 std::string get_marker (void) const { return marker.current_value (); }
06472
06473 bool markeredgecolor_is_rgb (void) const { return markeredgecolor.is_rgb (); }
06474 bool markeredgecolor_is (const std::string& v) const { return markeredgecolor.is (v); }
06475 Matrix get_markeredgecolor_rgb (void) const { return (markeredgecolor.is_rgb () ? markeredgecolor.rgb () : Matrix ()); }
06476 octave_value get_markeredgecolor (void) const { return markeredgecolor.get (); }
06477
06478 bool markerfacecolor_is_rgb (void) const { return markerfacecolor.is_rgb (); }
06479 bool markerfacecolor_is (const std::string& v) const { return markerfacecolor.is (v); }
06480 Matrix get_markerfacecolor_rgb (void) const { return (markerfacecolor.is_rgb () ? markerfacecolor.rgb () : Matrix ()); }
06481 octave_value get_markerfacecolor (void) const { return markerfacecolor.get (); }
06482
06483 double get_markersize (void) const { return markersize.double_value (); }
06484
06485 bool interpreter_is (const std::string& v) const { return interpreter.is (v); }
06486 std::string get_interpreter (void) const { return interpreter.current_value (); }
06487
06488 std::string get_displayname (void) const { return displayname.string_value (); }
06489
06490 bool erasemode_is (const std::string& v) const { return erasemode.is (v); }
06491 std::string get_erasemode (void) const { return erasemode.current_value (); }
06492
06493 octave_value get_xlim (void) const { return xlim.get (); }
06494
06495 octave_value get_ylim (void) const { return ylim.get (); }
06496
06497 octave_value get_zlim (void) const { return zlim.get (); }
06498
06499 bool is_xliminclude (void) const { return xliminclude.is_on (); }
06500 std::string get_xliminclude (void) const { return xliminclude.current_value (); }
06501
06502 bool is_yliminclude (void) const { return yliminclude.is_on (); }
06503 std::string get_yliminclude (void) const { return yliminclude.current_value (); }
06504
06505 bool is_zliminclude (void) const { return zliminclude.is_on (); }
06506 std::string get_zliminclude (void) const { return zliminclude.current_value (); }
06507
06508
06509 void set_xdata (const octave_value& val)
06510 {
06511 if (! error_state)
06512 {
06513 if (xdata.set (val, true))
06514 {
06515 update_xdata ();
06516 mark_modified ();
06517 }
06518 }
06519 }
06520
06521 void set_ydata (const octave_value& val)
06522 {
06523 if (! error_state)
06524 {
06525 if (ydata.set (val, true))
06526 {
06527 update_ydata ();
06528 mark_modified ();
06529 }
06530 }
06531 }
06532
06533 void set_zdata (const octave_value& val)
06534 {
06535 if (! error_state)
06536 {
06537 if (zdata.set (val, true))
06538 {
06539 update_zdata ();
06540 mark_modified ();
06541 }
06542 }
06543 }
06544
06545 void set_xdatasource (const octave_value& val)
06546 {
06547 if (! error_state)
06548 {
06549 if (xdatasource.set (val, true))
06550 {
06551 mark_modified ();
06552 }
06553 }
06554 }
06555
06556 void set_ydatasource (const octave_value& val)
06557 {
06558 if (! error_state)
06559 {
06560 if (ydatasource.set (val, true))
06561 {
06562 mark_modified ();
06563 }
06564 }
06565 }
06566
06567 void set_zdatasource (const octave_value& val)
06568 {
06569 if (! error_state)
06570 {
06571 if (zdatasource.set (val, true))
06572 {
06573 mark_modified ();
06574 }
06575 }
06576 }
06577
06578 void set_color (const octave_value& val)
06579 {
06580 if (! error_state)
06581 {
06582 if (color.set (val, true))
06583 {
06584 mark_modified ();
06585 }
06586 }
06587 }
06588
06589 void set_linestyle (const octave_value& val)
06590 {
06591 if (! error_state)
06592 {
06593 if (linestyle.set (val, true))
06594 {
06595 mark_modified ();
06596 }
06597 }
06598 }
06599
06600 void set_linewidth (const octave_value& val)
06601 {
06602 if (! error_state)
06603 {
06604 if (linewidth.set (val, true))
06605 {
06606 mark_modified ();
06607 }
06608 }
06609 }
06610
06611 void set_marker (const octave_value& val)
06612 {
06613 if (! error_state)
06614 {
06615 if (marker.set (val, true))
06616 {
06617 mark_modified ();
06618 }
06619 }
06620 }
06621
06622 void set_markeredgecolor (const octave_value& val)
06623 {
06624 if (! error_state)
06625 {
06626 if (markeredgecolor.set (val, true))
06627 {
06628 mark_modified ();
06629 }
06630 }
06631 }
06632
06633 void set_markerfacecolor (const octave_value& val)
06634 {
06635 if (! error_state)
06636 {
06637 if (markerfacecolor.set (val, true))
06638 {
06639 mark_modified ();
06640 }
06641 }
06642 }
06643
06644 void set_markersize (const octave_value& val)
06645 {
06646 if (! error_state)
06647 {
06648 if (markersize.set (val, true))
06649 {
06650 mark_modified ();
06651 }
06652 }
06653 }
06654
06655 void set_interpreter (const octave_value& val)
06656 {
06657 if (! error_state)
06658 {
06659 if (interpreter.set (val, true))
06660 {
06661 mark_modified ();
06662 }
06663 }
06664 }
06665
06666 void set_displayname (const octave_value& val)
06667 {
06668 if (! error_state)
06669 {
06670 if (displayname.set (val, true))
06671 {
06672 mark_modified ();
06673 }
06674 }
06675 }
06676
06677 void set_erasemode (const octave_value& val)
06678 {
06679 if (! error_state)
06680 {
06681 if (erasemode.set (val, true))
06682 {
06683 mark_modified ();
06684 }
06685 }
06686 }
06687
06688 void set_xlim (const octave_value& val)
06689 {
06690 if (! error_state)
06691 {
06692 if (xlim.set (val, false))
06693 {
06694 update_axis_limits ("xlim");
06695 xlim.run_listeners (POSTSET);
06696 mark_modified ();
06697 }
06698 }
06699 }
06700
06701 void set_ylim (const octave_value& val)
06702 {
06703 if (! error_state)
06704 {
06705 if (ylim.set (val, false))
06706 {
06707 update_axis_limits ("ylim");
06708 ylim.run_listeners (POSTSET);
06709 mark_modified ();
06710 }
06711 }
06712 }
06713
06714 void set_zlim (const octave_value& val)
06715 {
06716 if (! error_state)
06717 {
06718 if (zlim.set (val, false))
06719 {
06720 update_axis_limits ("zlim");
06721 zlim.run_listeners (POSTSET);
06722 mark_modified ();
06723 }
06724 }
06725 }
06726
06727 void set_xliminclude (const octave_value& val)
06728 {
06729 if (! error_state)
06730 {
06731 if (xliminclude.set (val, false))
06732 {
06733 update_axis_limits ("xliminclude");
06734 xliminclude.run_listeners (POSTSET);
06735 mark_modified ();
06736 }
06737 }
06738 }
06739
06740 void set_yliminclude (const octave_value& val)
06741 {
06742 if (! error_state)
06743 {
06744 if (yliminclude.set (val, false))
06745 {
06746 update_axis_limits ("yliminclude");
06747 yliminclude.run_listeners (POSTSET);
06748 mark_modified ();
06749 }
06750 }
06751 }
06752
06753 void set_zliminclude (const octave_value& val)
06754 {
06755 if (! error_state)
06756 {
06757 if (zliminclude.set (val, false))
06758 {
06759 update_axis_limits ("zliminclude");
06760 zliminclude.run_listeners (POSTSET);
06761 mark_modified ();
06762 }
06763 }
06764 }
06765
06766
06767 private:
06768 Matrix compute_xlim (void) const;
06769 Matrix compute_ylim (void) const;
06770
06771 void update_xdata (void) { set_xlim (compute_xlim ()); }
06772
06773 void update_ydata (void) { set_ylim (compute_ylim ()); }
06774
06775 void update_zdata (void)
06776 {
06777 set_zlim (zdata.get_limits ());
06778 set_zliminclude (get_zdata ().numel () > 0);
06779 }
06780 };
06781
06782 private:
06783 properties xproperties;
06784
06785 public:
06786 line (const graphics_handle& mh, const graphics_handle& p)
06787 : base_graphics_object (), xproperties (mh, p)
06788 {
06789 xproperties.override_defaults (*this);
06790 }
06791
06792 ~line (void) { xproperties.delete_children (); }
06793
06794 base_properties& get_properties (void) { return xproperties; }
06795
06796 const base_properties& get_properties (void) const { return xproperties; }
06797
06798 bool valid_object (void) const { return true; }
06799 };
06800
06801
06802
06803 class OCTINTERP_API text : public base_graphics_object
06804 {
06805 public:
06806 class OCTINTERP_API properties : public base_properties
06807 {
06808 public:
06809
06810
06811
06812 public:
06813 properties (const graphics_handle& mh, const graphics_handle& p);
06814
06815 ~properties (void) { }
06816
06817 void set (const caseless_str& pname, const octave_value& val);
06818
06819 octave_value get (bool all = false) const;
06820
06821 octave_value get (const caseless_str& pname) const;
06822
06823 octave_value get (const std::string& pname) const
06824 {
06825 return get (caseless_str (pname));
06826 }
06827
06828 octave_value get (const char *pname) const
06829 {
06830 return get (caseless_str (pname));
06831 }
06832
06833 property get_property (const caseless_str& pname);
06834
06835 std::string graphics_object_name (void) const { return go_name; }
06836
06837 static property_list::pval_map_type factory_defaults (void);
06838
06839 private:
06840 static std::string go_name;
06841
06842 public:
06843
06844
06845 static std::set<std::string> core_property_names (void);
06846
06847 static bool has_core_property (const caseless_str& pname);
06848
06849 std::set<std::string> all_property_names (void) const;
06850
06851 bool has_property (const caseless_str& pname) const;
06852
06853 private:
06854
06855 string_property string;
06856 radio_property units;
06857 array_property position;
06858 double_property rotation;
06859 radio_property horizontalalignment;
06860 color_property color;
06861 string_property fontname;
06862 double_property fontsize;
06863 radio_property fontangle;
06864 radio_property fontweight;
06865 radio_property interpreter;
06866 color_property backgroundcolor;
06867 string_property displayname;
06868 color_property edgecolor;
06869 radio_property erasemode;
06870 bool_property editing;
06871 radio_property fontunits;
06872 radio_property linestyle;
06873 double_property linewidth;
06874 double_property margin;
06875 radio_property verticalalignment;
06876 array_property extent;
06877 row_vector_property xlim;
06878 row_vector_property ylim;
06879 row_vector_property zlim;
06880 bool_property xliminclude;
06881 bool_property yliminclude;
06882 bool_property zliminclude;
06883 radio_property positionmode;
06884 radio_property rotationmode;
06885 radio_property horizontalalignmentmode;
06886 radio_property verticalalignmentmode;
06887 radio_property autopos_tag;
06888
06889 public:
06890
06891 enum
06892 {
06893 ID_STRING = 5000,
06894 ID_UNITS = 5001,
06895 ID_POSITION = 5002,
06896 ID_ROTATION = 5003,
06897 ID_HORIZONTALALIGNMENT = 5004,
06898 ID_COLOR = 5005,
06899 ID_FONTNAME = 5006,
06900 ID_FONTSIZE = 5007,
06901 ID_FONTANGLE = 5008,
06902 ID_FONTWEIGHT = 5009,
06903 ID_INTERPRETER = 5010,
06904 ID_BACKGROUNDCOLOR = 5011,
06905 ID_DISPLAYNAME = 5012,
06906 ID_EDGECOLOR = 5013,
06907 ID_ERASEMODE = 5014,
06908 ID_EDITING = 5015,
06909 ID_FONTUNITS = 5016,
06910 ID_LINESTYLE = 5017,
06911 ID_LINEWIDTH = 5018,
06912 ID_MARGIN = 5019,
06913 ID_VERTICALALIGNMENT = 5020,
06914 ID_EXTENT = 5021,
06915 ID_XLIM = 5022,
06916 ID_YLIM = 5023,
06917 ID_ZLIM = 5024,
06918 ID_XLIMINCLUDE = 5025,
06919 ID_YLIMINCLUDE = 5026,
06920 ID_ZLIMINCLUDE = 5027,
06921 ID_POSITIONMODE = 5028,
06922 ID_ROTATIONMODE = 5029,
06923 ID_HORIZONTALALIGNMENTMODE = 5030,
06924 ID_VERTICALALIGNMENTMODE = 5031,
06925 ID_AUTOPOS_TAG = 5032
06926 };
06927
06928 std::string get_string (void) const { return string.string_value (); }
06929
06930 bool units_is (const std::string& v) const { return units.is (v); }
06931 std::string get_units (void) const { return units.current_value (); }
06932
06933 octave_value get_position (void) const { return position.get (); }
06934
06935 double get_rotation (void) const { return rotation.double_value (); }
06936
06937 bool horizontalalignment_is (const std::string& v) const { return horizontalalignment.is (v); }
06938 std::string get_horizontalalignment (void) const { return horizontalalignment.current_value (); }
06939
06940 bool color_is_rgb (void) const { return color.is_rgb (); }
06941 bool color_is (const std::string& v) const { return color.is (v); }
06942 Matrix get_color_rgb (void) const { return (color.is_rgb () ? color.rgb () : Matrix ()); }
06943 octave_value get_color (void) const { return color.get (); }
06944
06945 std::string get_fontname (void) const { return fontname.string_value (); }
06946
06947 double get_fontsize (void) const { return fontsize.double_value (); }
06948
06949 bool fontangle_is (const std::string& v) const { return fontangle.is (v); }
06950 std::string get_fontangle (void) const { return fontangle.current_value (); }
06951
06952 bool fontweight_is (const std::string& v) const { return fontweight.is (v); }
06953 std::string get_fontweight (void) const { return fontweight.current_value (); }
06954
06955 bool interpreter_is (const std::string& v) const { return interpreter.is (v); }
06956 std::string get_interpreter (void) const { return interpreter.current_value (); }
06957
06958 bool backgroundcolor_is_rgb (void) const { return backgroundcolor.is_rgb (); }
06959 bool backgroundcolor_is (const std::string& v) const { return backgroundcolor.is (v); }
06960 Matrix get_backgroundcolor_rgb (void) const { return (backgroundcolor.is_rgb () ? backgroundcolor.rgb () : Matrix ()); }
06961 octave_value get_backgroundcolor (void) const { return backgroundcolor.get (); }
06962
06963 std::string get_displayname (void) const { return displayname.string_value (); }
06964
06965 bool edgecolor_is_rgb (void) const { return edgecolor.is_rgb (); }
06966 bool edgecolor_is (const std::string& v) const { return edgecolor.is (v); }
06967 Matrix get_edgecolor_rgb (void) const { return (edgecolor.is_rgb () ? edgecolor.rgb () : Matrix ()); }
06968 octave_value get_edgecolor (void) const { return edgecolor.get (); }
06969
06970 bool erasemode_is (const std::string& v) const { return erasemode.is (v); }
06971 std::string get_erasemode (void) const { return erasemode.current_value (); }
06972
06973 bool is_editing (void) const { return editing.is_on (); }
06974 std::string get_editing (void) const { return editing.current_value (); }
06975
06976 bool fontunits_is (const std::string& v) const { return fontunits.is (v); }
06977 std::string get_fontunits (void) const { return fontunits.current_value (); }
06978
06979 bool linestyle_is (const std::string& v) const { return linestyle.is (v); }
06980 std::string get_linestyle (void) const { return linestyle.current_value (); }
06981
06982 double get_linewidth (void) const { return linewidth.double_value (); }
06983
06984 double get_margin (void) const { return margin.double_value (); }
06985
06986 bool verticalalignment_is (const std::string& v) const { return verticalalignment.is (v); }
06987 std::string get_verticalalignment (void) const { return verticalalignment.current_value (); }
06988
06989 octave_value get_extent (void) const;
06990
06991 octave_value get_xlim (void) const { return xlim.get (); }
06992
06993 octave_value get_ylim (void) const { return ylim.get (); }
06994
06995 octave_value get_zlim (void) const { return zlim.get (); }
06996
06997 bool is_xliminclude (void) const { return xliminclude.is_on (); }
06998 std::string get_xliminclude (void) const { return xliminclude.current_value (); }
06999
07000 bool is_yliminclude (void) const { return yliminclude.is_on (); }
07001 std::string get_yliminclude (void) const { return yliminclude.current_value (); }
07002
07003 bool is_zliminclude (void) const { return zliminclude.is_on (); }
07004 std::string get_zliminclude (void) const { return zliminclude.current_value (); }
07005
07006 bool positionmode_is (const std::string& v) const { return positionmode.is (v); }
07007 std::string get_positionmode (void) const { return positionmode.current_value (); }
07008
07009 bool rotationmode_is (const std::string& v) const { return rotationmode.is (v); }
07010 std::string get_rotationmode (void) const { return rotationmode.current_value (); }
07011
07012 bool horizontalalignmentmode_is (const std::string& v) const { return horizontalalignmentmode.is (v); }
07013 std::string get_horizontalalignmentmode (void) const { return horizontalalignmentmode.current_value (); }
07014
07015 bool verticalalignmentmode_is (const std::string& v) const { return verticalalignmentmode.is (v); }
07016 std::string get_verticalalignmentmode (void) const { return verticalalignmentmode.current_value (); }
07017
07018 bool autopos_tag_is (const std::string& v) const { return autopos_tag.is (v); }
07019 std::string get_autopos_tag (void) const { return autopos_tag.current_value (); }
07020
07021
07022 void set_string (const octave_value& val)
07023 {
07024 if (! error_state)
07025 {
07026 if (string.set (val, true))
07027 {
07028 update_string ();
07029 mark_modified ();
07030 }
07031 }
07032 }
07033
07034 void set_units (const octave_value& val)
07035 {
07036 if (! error_state)
07037 {
07038 if (units.set (val, true))
07039 {
07040 update_units ();
07041 mark_modified ();
07042 }
07043 }
07044 }
07045
07046 void set_position (const octave_value& val)
07047 {
07048 if (! error_state)
07049 {
07050 if (position.set (val, false))
07051 {
07052 set_positionmode ("manual");
07053 update_position ();
07054 position.run_listeners (POSTSET);
07055 mark_modified ();
07056 }
07057 else
07058 set_positionmode ("manual");
07059 }
07060 }
07061
07062 void set_rotation (const octave_value& val)
07063 {
07064 if (! error_state)
07065 {
07066 if (rotation.set (val, false))
07067 {
07068 set_rotationmode ("manual");
07069 update_rotation ();
07070 rotation.run_listeners (POSTSET);
07071 mark_modified ();
07072 }
07073 else
07074 set_rotationmode ("manual");
07075 }
07076 }
07077
07078 void set_horizontalalignment (const octave_value& val)
07079 {
07080 if (! error_state)
07081 {
07082 if (horizontalalignment.set (val, false))
07083 {
07084 set_horizontalalignmentmode ("manual");
07085 update_horizontalalignment ();
07086 horizontalalignment.run_listeners (POSTSET);
07087 mark_modified ();
07088 }
07089 else
07090 set_horizontalalignmentmode ("manual");
07091 }
07092 }
07093
07094 void set_color (const octave_value& val)
07095 {
07096 if (! error_state)
07097 {
07098 if (color.set (val, true))
07099 {
07100 mark_modified ();
07101 }
07102 }
07103 }
07104
07105 void set_fontname (const octave_value& val)
07106 {
07107 if (! error_state)
07108 {
07109 if (fontname.set (val, true))
07110 {
07111 update_fontname ();
07112 mark_modified ();
07113 }
07114 }
07115 }
07116
07117 void set_fontsize (const octave_value& val)
07118 {
07119 if (! error_state)
07120 {
07121 if (fontsize.set (val, true))
07122 {
07123 update_fontsize ();
07124 mark_modified ();
07125 }
07126 }
07127 }
07128
07129 void set_fontangle (const octave_value& val)
07130 {
07131 if (! error_state)
07132 {
07133 if (fontangle.set (val, true))
07134 {
07135 update_fontangle ();
07136 mark_modified ();
07137 }
07138 }
07139 }
07140
07141 void set_fontweight (const octave_value& val)
07142 {
07143 if (! error_state)
07144 {
07145 if (fontweight.set (val, true))
07146 {
07147 update_fontweight ();
07148 mark_modified ();
07149 }
07150 }
07151 }
07152
07153 void set_interpreter (const octave_value& val)
07154 {
07155 if (! error_state)
07156 {
07157 if (interpreter.set (val, true))
07158 {
07159 update_interpreter ();
07160 mark_modified ();
07161 }
07162 }
07163 }
07164
07165 void set_backgroundcolor (const octave_value& val)
07166 {
07167 if (! error_state)
07168 {
07169 if (backgroundcolor.set (val, true))
07170 {
07171 mark_modified ();
07172 }
07173 }
07174 }
07175
07176 void set_displayname (const octave_value& val)
07177 {
07178 if (! error_state)
07179 {
07180 if (displayname.set (val, true))
07181 {
07182 mark_modified ();
07183 }
07184 }
07185 }
07186
07187 void set_edgecolor (const octave_value& val)
07188 {
07189 if (! error_state)
07190 {
07191 if (edgecolor.set (val, true))
07192 {
07193 mark_modified ();
07194 }
07195 }
07196 }
07197
07198 void set_erasemode (const octave_value& val)
07199 {
07200 if (! error_state)
07201 {
07202 if (erasemode.set (val, true))
07203 {
07204 mark_modified ();
07205 }
07206 }
07207 }
07208
07209 void set_editing (const octave_value& val)
07210 {
07211 if (! error_state)
07212 {
07213 if (editing.set (val, true))
07214 {
07215 mark_modified ();
07216 }
07217 }
07218 }
07219
07220 void set_fontunits (const octave_value& val)
07221 {
07222 if (! error_state)
07223 {
07224 if (fontunits.set (val, true))
07225 {
07226 mark_modified ();
07227 }
07228 }
07229 }
07230
07231 void set_linestyle (const octave_value& val)
07232 {
07233 if (! error_state)
07234 {
07235 if (linestyle.set (val, true))
07236 {
07237 mark_modified ();
07238 }
07239 }
07240 }
07241
07242 void set_linewidth (const octave_value& val)
07243 {
07244 if (! error_state)
07245 {
07246 if (linewidth.set (val, true))
07247 {
07248 mark_modified ();
07249 }
07250 }
07251 }
07252
07253 void set_margin (const octave_value& val)
07254 {
07255 if (! error_state)
07256 {
07257 if (margin.set (val, true))
07258 {
07259 mark_modified ();
07260 }
07261 }
07262 }
07263
07264 void set_verticalalignment (const octave_value& val)
07265 {
07266 if (! error_state)
07267 {
07268 if (verticalalignment.set (val, false))
07269 {
07270 set_verticalalignmentmode ("manual");
07271 update_verticalalignment ();
07272 verticalalignment.run_listeners (POSTSET);
07273 mark_modified ();
07274 }
07275 else
07276 set_verticalalignmentmode ("manual");
07277 }
07278 }
07279
07280 void set_extent (const octave_value& val)
07281 {
07282 if (! error_state)
07283 {
07284 if (extent.set (val, true))
07285 {
07286 mark_modified ();
07287 }
07288 }
07289 }
07290
07291 void set_xlim (const octave_value& val)
07292 {
07293 if (! error_state)
07294 {
07295 if (xlim.set (val, false))
07296 {
07297 update_axis_limits ("xlim");
07298 xlim.run_listeners (POSTSET);
07299 mark_modified ();
07300 }
07301 }
07302 }
07303
07304 void set_ylim (const octave_value& val)
07305 {
07306 if (! error_state)
07307 {
07308 if (ylim.set (val, false))
07309 {
07310 update_axis_limits ("ylim");
07311 ylim.run_listeners (POSTSET);
07312 mark_modified ();
07313 }
07314 }
07315 }
07316
07317 void set_zlim (const octave_value& val)
07318 {
07319 if (! error_state)
07320 {
07321 if (zlim.set (val, false))
07322 {
07323 update_axis_limits ("zlim");
07324 zlim.run_listeners (POSTSET);
07325 mark_modified ();
07326 }
07327 }
07328 }
07329
07330 void set_xliminclude (const octave_value& val)
07331 {
07332 if (! error_state)
07333 {
07334 if (xliminclude.set (val, false))
07335 {
07336 update_axis_limits ("xliminclude");
07337 xliminclude.run_listeners (POSTSET);
07338 mark_modified ();
07339 }
07340 }
07341 }
07342
07343 void set_yliminclude (const octave_value& val)
07344 {
07345 if (! error_state)
07346 {
07347 if (yliminclude.set (val, false))
07348 {
07349 update_axis_limits ("yliminclude");
07350 yliminclude.run_listeners (POSTSET);
07351 mark_modified ();
07352 }
07353 }
07354 }
07355
07356 void set_zliminclude (const octave_value& val)
07357 {
07358 if (! error_state)
07359 {
07360 if (zliminclude.set (val, false))
07361 {
07362 update_axis_limits ("zliminclude");
07363 zliminclude.run_listeners (POSTSET);
07364 mark_modified ();
07365 }
07366 }
07367 }
07368
07369 void set_positionmode (const octave_value& val)
07370 {
07371 if (! error_state)
07372 {
07373 if (positionmode.set (val, true))
07374 {
07375 update_positionmode ();
07376 mark_modified ();
07377 }
07378 }
07379 }
07380
07381 void set_rotationmode (const octave_value& val)
07382 {
07383 if (! error_state)
07384 {
07385 if (rotationmode.set (val, true))
07386 {
07387 update_rotationmode ();
07388 mark_modified ();
07389 }
07390 }
07391 }
07392
07393 void set_horizontalalignmentmode (const octave_value& val)
07394 {
07395 if (! error_state)
07396 {
07397 if (horizontalalignmentmode.set (val, true))
07398 {
07399 update_horizontalalignmentmode ();
07400 mark_modified ();
07401 }
07402 }
07403 }
07404
07405 void set_verticalalignmentmode (const octave_value& val)
07406 {
07407 if (! error_state)
07408 {
07409 if (verticalalignmentmode.set (val, true))
07410 {
07411 update_verticalalignmentmode ();
07412 mark_modified ();
07413 }
07414 }
07415 }
07416
07417 void set_autopos_tag (const octave_value& val)
07418 {
07419 if (! error_state)
07420 {
07421 if (autopos_tag.set (val, true))
07422 {
07423 mark_modified ();
07424 }
07425 }
07426 }
07427
07428
07429 Matrix get_data_position (void) const;
07430 Matrix get_extent_matrix (void) const;
07431 const uint8NDArray& get_pixels (void) const { return pixels; }
07432 #if HAVE_FREETYPE
07433
07434 ft_render renderer;
07435 #endif
07436
07437 protected:
07438 void init (void)
07439 {
07440 position.add_constraint (dim_vector (1, 2));
07441 position.add_constraint (dim_vector (1, 3));
07442 cached_units = get_units ();
07443 }
07444
07445 private:
07446 void update_position (void)
07447 {
07448 Matrix pos = get_data_position ();
07449 Matrix lim;
07450
07451 lim = Matrix (1, 3, pos(0));
07452 lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2));
07453 set_xlim (lim);
07454
07455 lim = Matrix (1, 3, pos(1));
07456 lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2));
07457 set_ylim (lim);
07458
07459 if (pos.numel () == 3)
07460 {
07461 lim = Matrix (1, 3, pos(2));
07462 lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2));
07463 set_zliminclude ("on");
07464 set_zlim (lim);
07465 }
07466 else
07467 set_zliminclude ("off");
07468 }
07469
07470 void update_text_extent (void);
07471
07472 void request_autopos (void);
07473 void update_positionmode (void) { request_autopos (); }
07474 void update_rotationmode (void) { request_autopos (); }
07475 void update_horizontalalignmentmode (void) { request_autopos (); }
07476 void update_verticalalignmentmode (void) { request_autopos (); }
07477
07478 void update_string (void) { update_text_extent (); request_autopos ();}
07479 void update_rotation (void) { update_text_extent (); }
07480 void update_fontname (void) { update_text_extent (); }
07481 void update_fontsize (void) { update_text_extent (); }
07482 void update_fontangle (void) { update_text_extent (); }
07483 void update_fontweight (void) { update_text_extent (); }
07484 void update_interpreter (void) { update_text_extent (); }
07485 void update_horizontalalignment (void) { update_text_extent (); }
07486 void update_verticalalignment (void) { update_text_extent (); }
07487
07488 void update_units (void);
07489
07490 private:
07491 std::string cached_units;
07492 uint8NDArray pixels;
07493 };
07494
07495 private:
07496 properties xproperties;
07497
07498 public:
07499 text (const graphics_handle& mh, const graphics_handle& p)
07500 : base_graphics_object (), xproperties (mh, p)
07501 {
07502 xproperties.override_defaults (*this);
07503 }
07504
07505 ~text (void) { xproperties.delete_children (); }
07506
07507 base_properties& get_properties (void) { return xproperties; }
07508
07509 const base_properties& get_properties (void) const { return xproperties; }
07510
07511 bool valid_object (void) const { return true; }
07512 };
07513
07514
07515
07516 class OCTINTERP_API image : public base_graphics_object
07517 {
07518 public:
07519 class OCTINTERP_API properties : public base_properties
07520 {
07521 public:
07522 bool is_climinclude (void) const
07523 { return (climinclude.is_on () && cdatamapping.is ("scaled")); }
07524 std::string get_climinclude (void) const
07525 { return climinclude.current_value (); }
07526
07527 octave_value get_color_data (void) const;
07528
07529
07530
07531
07532 public:
07533 properties (const graphics_handle& mh, const graphics_handle& p);
07534
07535 ~properties (void) { }
07536
07537 void set (const caseless_str& pname, const octave_value& val);
07538
07539 octave_value get (bool all = false) const;
07540
07541 octave_value get (const caseless_str& pname) const;
07542
07543 octave_value get (const std::string& pname) const
07544 {
07545 return get (caseless_str (pname));
07546 }
07547
07548 octave_value get (const char *pname) const
07549 {
07550 return get (caseless_str (pname));
07551 }
07552
07553 property get_property (const caseless_str& pname);
07554
07555 std::string graphics_object_name (void) const { return go_name; }
07556
07557 static property_list::pval_map_type factory_defaults (void);
07558
07559 private:
07560 static std::string go_name;
07561
07562 public:
07563
07564
07565 static std::set<std::string> core_property_names (void);
07566
07567 static bool has_core_property (const caseless_str& pname);
07568
07569 std::set<std::string> all_property_names (void) const;
07570
07571 bool has_property (const caseless_str& pname) const;
07572
07573 private:
07574
07575 row_vector_property xdata;
07576 row_vector_property ydata;
07577 array_property cdata;
07578 radio_property cdatamapping;
07579 row_vector_property xlim;
07580 row_vector_property ylim;
07581 row_vector_property clim;
07582 bool_property xliminclude;
07583 bool_property yliminclude;
07584 bool_property climinclude;
07585
07586 public:
07587
07588 enum
07589 {
07590 ID_XDATA = 6000,
07591 ID_YDATA = 6001,
07592 ID_CDATA = 6002,
07593 ID_CDATAMAPPING = 6003,
07594 ID_XLIM = 6004,
07595 ID_YLIM = 6005,
07596 ID_CLIM = 6006,
07597 ID_XLIMINCLUDE = 6007,
07598 ID_YLIMINCLUDE = 6008,
07599 ID_CLIMINCLUDE = 6009
07600 };
07601
07602 octave_value get_xdata (void) const { return xdata.get (); }
07603
07604 octave_value get_ydata (void) const { return ydata.get (); }
07605
07606 octave_value get_cdata (void) const { return cdata.get (); }
07607
07608 bool cdatamapping_is (const std::string& v) const { return cdatamapping.is (v); }
07609 std::string get_cdatamapping (void) const { return cdatamapping.current_value (); }
07610
07611 octave_value get_xlim (void) const { return xlim.get (); }
07612
07613 octave_value get_ylim (void) const { return ylim.get (); }
07614
07615 octave_value get_clim (void) const { return clim.get (); }
07616
07617 bool is_xliminclude (void) const { return xliminclude.is_on (); }
07618 std::string get_xliminclude (void) const { return xliminclude.current_value (); }
07619
07620 bool is_yliminclude (void) const { return yliminclude.is_on (); }
07621 std::string get_yliminclude (void) const { return yliminclude.current_value (); }
07622
07623
07624 void set_xdata (const octave_value& val)
07625 {
07626 if (! error_state)
07627 {
07628 if (xdata.set (val, true))
07629 {
07630 update_xdata ();
07631 mark_modified ();
07632 }
07633 }
07634 }
07635
07636 void set_ydata (const octave_value& val)
07637 {
07638 if (! error_state)
07639 {
07640 if (ydata.set (val, true))
07641 {
07642 update_ydata ();
07643 mark_modified ();
07644 }
07645 }
07646 }
07647
07648 void set_cdata (const octave_value& val)
07649 {
07650 if (! error_state)
07651 {
07652 if (cdata.set (val, true))
07653 {
07654 update_cdata ();
07655 mark_modified ();
07656 }
07657 }
07658 }
07659
07660 void set_cdatamapping (const octave_value& val)
07661 {
07662 if (! error_state)
07663 {
07664 if (cdatamapping.set (val, false))
07665 {
07666 update_axis_limits ("cdatamapping");
07667 cdatamapping.run_listeners (POSTSET);
07668 mark_modified ();
07669 }
07670 }
07671 }
07672
07673 void set_xlim (const octave_value& val)
07674 {
07675 if (! error_state)
07676 {
07677 if (xlim.set (val, false))
07678 {
07679 update_axis_limits ("xlim");
07680 xlim.run_listeners (POSTSET);
07681 mark_modified ();
07682 }
07683 }
07684 }
07685
07686 void set_ylim (const octave_value& val)
07687 {
07688 if (! error_state)
07689 {
07690 if (ylim.set (val, false))
07691 {
07692 update_axis_limits ("ylim");
07693 ylim.run_listeners (POSTSET);
07694 mark_modified ();
07695 }
07696 }
07697 }
07698
07699 void set_clim (const octave_value& val)
07700 {
07701 if (! error_state)
07702 {
07703 if (clim.set (val, false))
07704 {
07705 update_axis_limits ("clim");
07706 clim.run_listeners (POSTSET);
07707 mark_modified ();
07708 }
07709 }
07710 }
07711
07712 void set_xliminclude (const octave_value& val)
07713 {
07714 if (! error_state)
07715 {
07716 if (xliminclude.set (val, false))
07717 {
07718 update_axis_limits ("xliminclude");
07719 xliminclude.run_listeners (POSTSET);
07720 mark_modified ();
07721 }
07722 }
07723 }
07724
07725 void set_yliminclude (const octave_value& val)
07726 {
07727 if (! error_state)
07728 {
07729 if (yliminclude.set (val, false))
07730 {
07731 update_axis_limits ("yliminclude");
07732 yliminclude.run_listeners (POSTSET);
07733 mark_modified ();
07734 }
07735 }
07736 }
07737
07738 void set_climinclude (const octave_value& val)
07739 {
07740 if (! error_state)
07741 {
07742 if (climinclude.set (val, false))
07743 {
07744 update_axis_limits ("climinclude");
07745 climinclude.run_listeners (POSTSET);
07746 mark_modified ();
07747 }
07748 }
07749 }
07750
07751
07752 protected:
07753 void init (void)
07754 {
07755 xdata.add_constraint (2);
07756 ydata.add_constraint (2);
07757 cdata.add_constraint ("double");
07758 cdata.add_constraint ("single");
07759 cdata.add_constraint ("logical");
07760 cdata.add_constraint ("uint8");
07761 cdata.add_constraint ("uint16");
07762 cdata.add_constraint ("int16");
07763 cdata.add_constraint (dim_vector (-1, -1));
07764 cdata.add_constraint (dim_vector (-1, -1, 3));
07765 }
07766
07767 private:
07768 void update_xdata (void)
07769 {
07770 Matrix limits = xdata.get_limits ();
07771 float dp = pixel_xsize ();
07772
07773 limits(0) = limits(0) - dp;
07774 limits(1) = limits(1) + dp;
07775 set_xlim (limits);
07776 }
07777
07778 void update_ydata (void)
07779 {
07780 Matrix limits = ydata.get_limits ();
07781 float dp = pixel_ysize ();
07782
07783 limits(0) = limits(0) - dp;
07784 limits(1) = limits(1) + dp;
07785 set_ylim (limits);
07786 }
07787
07788 void update_cdata (void)
07789 {
07790 if (cdatamapping_is ("scaled"))
07791 set_clim (cdata.get_limits ());
07792 else
07793 clim = cdata.get_limits ();
07794 }
07795
07796 float pixel_size (octave_idx_type dim, const Matrix limits)
07797 {
07798 octave_idx_type l = dim - 1;
07799 float dp;
07800
07801 if (l > 0 && limits(0) != limits(1))
07802 dp = (limits(1) - limits(0))/(2*l);
07803 else
07804 {
07805 if (limits(1) == limits(2))
07806 dp = 0.5;
07807 else
07808 dp = (limits(1) - limits(0))/2;
07809 }
07810 return dp;
07811 }
07812
07813 public:
07814 float pixel_xsize (void)
07815 {
07816 return pixel_size ((get_cdata ().dims ())(1), xdata.get_limits ());
07817 }
07818
07819 float pixel_ysize (void)
07820 {
07821 return pixel_size ((get_cdata ().dims ())(0), ydata.get_limits ());
07822 }
07823 };
07824
07825 private:
07826 properties xproperties;
07827
07828 public:
07829 image (const graphics_handle& mh, const graphics_handle& p)
07830 : base_graphics_object (), xproperties (mh, p)
07831 {
07832 xproperties.override_defaults (*this);
07833 }
07834
07835 ~image (void) { xproperties.delete_children (); }
07836
07837 base_properties& get_properties (void) { return xproperties; }
07838
07839 const base_properties& get_properties (void) const { return xproperties; }
07840
07841 bool valid_object (void) const { return true; }
07842 };
07843
07844
07845
07846 class OCTINTERP_API patch : public base_graphics_object
07847 {
07848 public:
07849 class OCTINTERP_API properties : public base_properties
07850 {
07851 public:
07852 octave_value get_color_data (void) const;
07853
07854 bool is_climinclude (void) const
07855 { return (climinclude.is_on () && cdatamapping.is ("scaled")); }
07856 std::string get_climinclude (void) const
07857 { return climinclude.current_value (); }
07858
07859 bool is_aliminclude (void) const
07860 { return (aliminclude.is_on () && alphadatamapping.is ("scaled")); }
07861 std::string get_aliminclude (void) const
07862 { return aliminclude.current_value (); }
07863
07864
07865
07866
07867 public:
07868 properties (const graphics_handle& mh, const graphics_handle& p);
07869
07870 ~properties (void) { }
07871
07872 void set (const caseless_str& pname, const octave_value& val);
07873
07874 octave_value get (bool all = false) const;
07875
07876 octave_value get (const caseless_str& pname) const;
07877
07878 octave_value get (const std::string& pname) const
07879 {
07880 return get (caseless_str (pname));
07881 }
07882
07883 octave_value get (const char *pname) const
07884 {
07885 return get (caseless_str (pname));
07886 }
07887
07888 property get_property (const caseless_str& pname);
07889
07890 std::string graphics_object_name (void) const { return go_name; }
07891
07892 static property_list::pval_map_type factory_defaults (void);
07893
07894 private:
07895 static std::string go_name;
07896
07897 public:
07898
07899
07900 static std::set<std::string> core_property_names (void);
07901
07902 static bool has_core_property (const caseless_str& pname);
07903
07904 std::set<std::string> all_property_names (void) const;
07905
07906 bool has_property (const caseless_str& pname) const;
07907
07908 private:
07909
07910 array_property xdata;
07911 array_property ydata;
07912 array_property zdata;
07913 array_property cdata;
07914 radio_property cdatamapping;
07915 array_property faces;
07916 array_property facevertexalphadata;
07917 array_property facevertexcdata;
07918 array_property vertices;
07919 array_property vertexnormals;
07920 radio_property normalmode;
07921 color_property facecolor;
07922 double_radio_property facealpha;
07923 radio_property facelighting;
07924 color_property edgecolor;
07925 double_radio_property edgealpha;
07926 radio_property edgelighting;
07927 radio_property backfacelighting;
07928 double_property ambientstrength;
07929 double_property diffusestrength;
07930 double_property specularstrength;
07931 double_property specularexponent;
07932 double_property specularcolorreflectance;
07933 radio_property erasemode;
07934 radio_property linestyle;
07935 double_property linewidth;
07936 radio_property marker;
07937 color_property markeredgecolor;
07938 color_property markerfacecolor;
07939 double_property markersize;
07940 radio_property interpreter;
07941 string_property displayname;
07942 radio_property alphadatamapping;
07943 row_vector_property xlim;
07944 row_vector_property ylim;
07945 row_vector_property zlim;
07946 row_vector_property clim;
07947 row_vector_property alim;
07948 bool_property xliminclude;
07949 bool_property yliminclude;
07950 bool_property zliminclude;
07951 bool_property climinclude;
07952 bool_property aliminclude;
07953
07954 public:
07955
07956 enum
07957 {
07958 ID_XDATA = 7000,
07959 ID_YDATA = 7001,
07960 ID_ZDATA = 7002,
07961 ID_CDATA = 7003,
07962 ID_CDATAMAPPING = 7004,
07963 ID_FACES = 7005,
07964 ID_FACEVERTEXALPHADATA = 7006,
07965 ID_FACEVERTEXCDATA = 7007,
07966 ID_VERTICES = 7008,
07967 ID_VERTEXNORMALS = 7009,
07968 ID_NORMALMODE = 7010,
07969 ID_FACECOLOR = 7011,
07970 ID_FACEALPHA = 7012,
07971 ID_FACELIGHTING = 7013,
07972 ID_EDGECOLOR = 7014,
07973 ID_EDGEALPHA = 7015,
07974 ID_EDGELIGHTING = 7016,
07975 ID_BACKFACELIGHTING = 7017,
07976 ID_AMBIENTSTRENGTH = 7018,
07977 ID_DIFFUSESTRENGTH = 7019,
07978 ID_SPECULARSTRENGTH = 7020,
07979 ID_SPECULAREXPONENT = 7021,
07980 ID_SPECULARCOLORREFLECTANCE = 7022,
07981 ID_ERASEMODE = 7023,
07982 ID_LINESTYLE = 7024,
07983 ID_LINEWIDTH = 7025,
07984 ID_MARKER = 7026,
07985 ID_MARKEREDGECOLOR = 7027,
07986 ID_MARKERFACECOLOR = 7028,
07987 ID_MARKERSIZE = 7029,
07988 ID_INTERPRETER = 7030,
07989 ID_DISPLAYNAME = 7031,
07990 ID_ALPHADATAMAPPING = 7032,
07991 ID_XLIM = 7033,
07992 ID_YLIM = 7034,
07993 ID_ZLIM = 7035,
07994 ID_CLIM = 7036,
07995 ID_ALIM = 7037,
07996 ID_XLIMINCLUDE = 7038,
07997 ID_YLIMINCLUDE = 7039,
07998 ID_ZLIMINCLUDE = 7040,
07999 ID_CLIMINCLUDE = 7041,
08000 ID_ALIMINCLUDE = 7042
08001 };
08002
08003 octave_value get_xdata (void) const { return xdata.get (); }
08004
08005 octave_value get_ydata (void) const { return ydata.get (); }
08006
08007 octave_value get_zdata (void) const { return zdata.get (); }
08008
08009 octave_value get_cdata (void) const { return cdata.get (); }
08010
08011 bool cdatamapping_is (const std::string& v) const { return cdatamapping.is (v); }
08012 std::string get_cdatamapping (void) const { return cdatamapping.current_value (); }
08013
08014 octave_value get_faces (void) const { return faces.get (); }
08015
08016 octave_value get_facevertexalphadata (void) const { return facevertexalphadata.get (); }
08017
08018 octave_value get_facevertexcdata (void) const { return facevertexcdata.get (); }
08019
08020 octave_value get_vertices (void) const { return vertices.get (); }
08021
08022 octave_value get_vertexnormals (void) const { return vertexnormals.get (); }
08023
08024 bool normalmode_is (const std::string& v) const { return normalmode.is (v); }
08025 std::string get_normalmode (void) const { return normalmode.current_value (); }
08026
08027 bool facecolor_is_rgb (void) const { return facecolor.is_rgb (); }
08028 bool facecolor_is (const std::string& v) const { return facecolor.is (v); }
08029 Matrix get_facecolor_rgb (void) const { return (facecolor.is_rgb () ? facecolor.rgb () : Matrix ()); }
08030 octave_value get_facecolor (void) const { return facecolor.get (); }
08031
08032 bool facealpha_is_double (void) const { return facealpha.is_double (); }
08033 bool facealpha_is (const std::string& v) const { return facealpha.is (v); }
08034 double get_facealpha_double (void) const { return (facealpha.is_double () ? facealpha.double_value () : 0); }
08035 octave_value get_facealpha (void) const { return facealpha.get (); }
08036
08037 bool facelighting_is (const std::string& v) const { return facelighting.is (v); }
08038 std::string get_facelighting (void) const { return facelighting.current_value (); }
08039
08040 bool edgecolor_is_rgb (void) const { return edgecolor.is_rgb (); }
08041 bool edgecolor_is (const std::string& v) const { return edgecolor.is (v); }
08042 Matrix get_edgecolor_rgb (void) const { return (edgecolor.is_rgb () ? edgecolor.rgb () : Matrix ()); }
08043 octave_value get_edgecolor (void) const { return edgecolor.get (); }
08044
08045 bool edgealpha_is_double (void) const { return edgealpha.is_double (); }
08046 bool edgealpha_is (const std::string& v) const { return edgealpha.is (v); }
08047 double get_edgealpha_double (void) const { return (edgealpha.is_double () ? edgealpha.double_value () : 0); }
08048 octave_value get_edgealpha (void) const { return edgealpha.get (); }
08049
08050 bool edgelighting_is (const std::string& v) const { return edgelighting.is (v); }
08051 std::string get_edgelighting (void) const { return edgelighting.current_value (); }
08052
08053 bool backfacelighting_is (const std::string& v) const { return backfacelighting.is (v); }
08054 std::string get_backfacelighting (void) const { return backfacelighting.current_value (); }
08055
08056 double get_ambientstrength (void) const { return ambientstrength.double_value (); }
08057
08058 double get_diffusestrength (void) const { return diffusestrength.double_value (); }
08059
08060 double get_specularstrength (void) const { return specularstrength.double_value (); }
08061
08062 double get_specularexponent (void) const { return specularexponent.double_value (); }
08063
08064 double get_specularcolorreflectance (void) const { return specularcolorreflectance.double_value (); }
08065
08066 bool erasemode_is (const std::string& v) const { return erasemode.is (v); }
08067 std::string get_erasemode (void) const { return erasemode.current_value (); }
08068
08069 bool linestyle_is (const std::string& v) const { return linestyle.is (v); }
08070 std::string get_linestyle (void) const { return linestyle.current_value (); }
08071
08072 double get_linewidth (void) const { return linewidth.double_value (); }
08073
08074 bool marker_is (const std::string& v) const { return marker.is (v); }
08075 std::string get_marker (void) const { return marker.current_value (); }
08076
08077 bool markeredgecolor_is_rgb (void) const { return markeredgecolor.is_rgb (); }
08078 bool markeredgecolor_is (const std::string& v) const { return markeredgecolor.is (v); }
08079 Matrix get_markeredgecolor_rgb (void) const { return (markeredgecolor.is_rgb () ? markeredgecolor.rgb () : Matrix ()); }
08080 octave_value get_markeredgecolor (void) const { return markeredgecolor.get (); }
08081
08082 bool markerfacecolor_is_rgb (void) const { return markerfacecolor.is_rgb (); }
08083 bool markerfacecolor_is (const std::string& v) const { return markerfacecolor.is (v); }
08084 Matrix get_markerfacecolor_rgb (void) const { return (markerfacecolor.is_rgb () ? markerfacecolor.rgb () : Matrix ()); }
08085 octave_value get_markerfacecolor (void) const { return markerfacecolor.get (); }
08086
08087 double get_markersize (void) const { return markersize.double_value (); }
08088
08089 bool interpreter_is (const std::string& v) const { return interpreter.is (v); }
08090 std::string get_interpreter (void) const { return interpreter.current_value (); }
08091
08092 std::string get_displayname (void) const { return displayname.string_value (); }
08093
08094 bool alphadatamapping_is (const std::string& v) const { return alphadatamapping.is (v); }
08095 std::string get_alphadatamapping (void) const { return alphadatamapping.current_value (); }
08096
08097 octave_value get_xlim (void) const { return xlim.get (); }
08098
08099 octave_value get_ylim (void) const { return ylim.get (); }
08100
08101 octave_value get_zlim (void) const { return zlim.get (); }
08102
08103 octave_value get_clim (void) const { return clim.get (); }
08104
08105 octave_value get_alim (void) const { return alim.get (); }
08106
08107 bool is_xliminclude (void) const { return xliminclude.is_on (); }
08108 std::string get_xliminclude (void) const { return xliminclude.current_value (); }
08109
08110 bool is_yliminclude (void) const { return yliminclude.is_on (); }
08111 std::string get_yliminclude (void) const { return yliminclude.current_value (); }
08112
08113 bool is_zliminclude (void) const { return zliminclude.is_on (); }
08114 std::string get_zliminclude (void) const { return zliminclude.current_value (); }
08115
08116
08117 void set_xdata (const octave_value& val)
08118 {
08119 if (! error_state)
08120 {
08121 if (xdata.set (val, true))
08122 {
08123 update_xdata ();
08124 mark_modified ();
08125 }
08126 }
08127 }
08128
08129 void set_ydata (const octave_value& val)
08130 {
08131 if (! error_state)
08132 {
08133 if (ydata.set (val, true))
08134 {
08135 update_ydata ();
08136 mark_modified ();
08137 }
08138 }
08139 }
08140
08141 void set_zdata (const octave_value& val)
08142 {
08143 if (! error_state)
08144 {
08145 if (zdata.set (val, true))
08146 {
08147 update_zdata ();
08148 mark_modified ();
08149 }
08150 }
08151 }
08152
08153 void set_cdata (const octave_value& val)
08154 {
08155 if (! error_state)
08156 {
08157 if (cdata.set (val, true))
08158 {
08159 update_cdata ();
08160 mark_modified ();
08161 }
08162 }
08163 }
08164
08165 void set_cdatamapping (const octave_value& val)
08166 {
08167 if (! error_state)
08168 {
08169 if (cdatamapping.set (val, false))
08170 {
08171 update_axis_limits ("cdatamapping");
08172 cdatamapping.run_listeners (POSTSET);
08173 mark_modified ();
08174 }
08175 }
08176 }
08177
08178 void set_faces (const octave_value& val)
08179 {
08180 if (! error_state)
08181 {
08182 if (faces.set (val, true))
08183 {
08184 mark_modified ();
08185 }
08186 }
08187 }
08188
08189 void set_facevertexalphadata (const octave_value& val)
08190 {
08191 if (! error_state)
08192 {
08193 if (facevertexalphadata.set (val, true))
08194 {
08195 mark_modified ();
08196 }
08197 }
08198 }
08199
08200 void set_facevertexcdata (const octave_value& val)
08201 {
08202 if (! error_state)
08203 {
08204 if (facevertexcdata.set (val, true))
08205 {
08206 mark_modified ();
08207 }
08208 }
08209 }
08210
08211 void set_vertices (const octave_value& val)
08212 {
08213 if (! error_state)
08214 {
08215 if (vertices.set (val, true))
08216 {
08217 mark_modified ();
08218 }
08219 }
08220 }
08221
08222 void set_vertexnormals (const octave_value& val)
08223 {
08224 if (! error_state)
08225 {
08226 if (vertexnormals.set (val, true))
08227 {
08228 mark_modified ();
08229 }
08230 }
08231 }
08232
08233 void set_normalmode (const octave_value& val)
08234 {
08235 if (! error_state)
08236 {
08237 if (normalmode.set (val, true))
08238 {
08239 mark_modified ();
08240 }
08241 }
08242 }
08243
08244 void set_facecolor (const octave_value& val)
08245 {
08246 if (! error_state)
08247 {
08248 if (facecolor.set (val, true))
08249 {
08250 mark_modified ();
08251 }
08252 }
08253 }
08254
08255 void set_facealpha (const octave_value& val)
08256 {
08257 if (! error_state)
08258 {
08259 if (facealpha.set (val, true))
08260 {
08261 mark_modified ();
08262 }
08263 }
08264 }
08265
08266 void set_facelighting (const octave_value& val)
08267 {
08268 if (! error_state)
08269 {
08270 if (facelighting.set (val, true))
08271 {
08272 mark_modified ();
08273 }
08274 }
08275 }
08276
08277 void set_edgecolor (const octave_value& val)
08278 {
08279 if (! error_state)
08280 {
08281 if (edgecolor.set (val, true))
08282 {
08283 mark_modified ();
08284 }
08285 }
08286 }
08287
08288 void set_edgealpha (const octave_value& val)
08289 {
08290 if (! error_state)
08291 {
08292 if (edgealpha.set (val, true))
08293 {
08294 mark_modified ();
08295 }
08296 }
08297 }
08298
08299 void set_edgelighting (const octave_value& val)
08300 {
08301 if (! error_state)
08302 {
08303 if (edgelighting.set (val, true))
08304 {
08305 mark_modified ();
08306 }
08307 }
08308 }
08309
08310 void set_backfacelighting (const octave_value& val)
08311 {
08312 if (! error_state)
08313 {
08314 if (backfacelighting.set (val, true))
08315 {
08316 mark_modified ();
08317 }
08318 }
08319 }
08320
08321 void set_ambientstrength (const octave_value& val)
08322 {
08323 if (! error_state)
08324 {
08325 if (ambientstrength.set (val, true))
08326 {
08327 mark_modified ();
08328 }
08329 }
08330 }
08331
08332 void set_diffusestrength (const octave_value& val)
08333 {
08334 if (! error_state)
08335 {
08336 if (diffusestrength.set (val, true))
08337 {
08338 mark_modified ();
08339 }
08340 }
08341 }
08342
08343 void set_specularstrength (const octave_value& val)
08344 {
08345 if (! error_state)
08346 {
08347 if (specularstrength.set (val, true))
08348 {
08349 mark_modified ();
08350 }
08351 }
08352 }
08353
08354 void set_specularexponent (const octave_value& val)
08355 {
08356 if (! error_state)
08357 {
08358 if (specularexponent.set (val, true))
08359 {
08360 mark_modified ();
08361 }
08362 }
08363 }
08364
08365 void set_specularcolorreflectance (const octave_value& val)
08366 {
08367 if (! error_state)
08368 {
08369 if (specularcolorreflectance.set (val, true))
08370 {
08371 mark_modified ();
08372 }
08373 }
08374 }
08375
08376 void set_erasemode (const octave_value& val)
08377 {
08378 if (! error_state)
08379 {
08380 if (erasemode.set (val, true))
08381 {
08382 mark_modified ();
08383 }
08384 }
08385 }
08386
08387 void set_linestyle (const octave_value& val)
08388 {
08389 if (! error_state)
08390 {
08391 if (linestyle.set (val, true))
08392 {
08393 mark_modified ();
08394 }
08395 }
08396 }
08397
08398 void set_linewidth (const octave_value& val)
08399 {
08400 if (! error_state)
08401 {
08402 if (linewidth.set (val, true))
08403 {
08404 mark_modified ();
08405 }
08406 }
08407 }
08408
08409 void set_marker (const octave_value& val)
08410 {
08411 if (! error_state)
08412 {
08413 if (marker.set (val, true))
08414 {
08415 mark_modified ();
08416 }
08417 }
08418 }
08419
08420 void set_markeredgecolor (const octave_value& val)
08421 {
08422 if (! error_state)
08423 {
08424 if (markeredgecolor.set (val, true))
08425 {
08426 mark_modified ();
08427 }
08428 }
08429 }
08430
08431 void set_markerfacecolor (const octave_value& val)
08432 {
08433 if (! error_state)
08434 {
08435 if (markerfacecolor.set (val, true))
08436 {
08437 mark_modified ();
08438 }
08439 }
08440 }
08441
08442 void set_markersize (const octave_value& val)
08443 {
08444 if (! error_state)
08445 {
08446 if (markersize.set (val, true))
08447 {
08448 mark_modified ();
08449 }
08450 }
08451 }
08452
08453 void set_interpreter (const octave_value& val)
08454 {
08455 if (! error_state)
08456 {
08457 if (interpreter.set (val, true))
08458 {
08459 mark_modified ();
08460 }
08461 }
08462 }
08463
08464 void set_displayname (const octave_value& val)
08465 {
08466 if (! error_state)
08467 {
08468 if (displayname.set (val, true))
08469 {
08470 mark_modified ();
08471 }
08472 }
08473 }
08474
08475 void set_alphadatamapping (const octave_value& val)
08476 {
08477 if (! error_state)
08478 {
08479 if (alphadatamapping.set (val, false))
08480 {
08481 update_axis_limits ("alphadatamapping");
08482 alphadatamapping.run_listeners (POSTSET);
08483 mark_modified ();
08484 }
08485 }
08486 }
08487
08488 void set_xlim (const octave_value& val)
08489 {
08490 if (! error_state)
08491 {
08492 if (xlim.set (val, false))
08493 {
08494 update_axis_limits ("xlim");
08495 xlim.run_listeners (POSTSET);
08496 mark_modified ();
08497 }
08498 }
08499 }
08500
08501 void set_ylim (const octave_value& val)
08502 {
08503 if (! error_state)
08504 {
08505 if (ylim.set (val, false))
08506 {
08507 update_axis_limits ("ylim");
08508 ylim.run_listeners (POSTSET);
08509 mark_modified ();
08510 }
08511 }
08512 }
08513
08514 void set_zlim (const octave_value& val)
08515 {
08516 if (! error_state)
08517 {
08518 if (zlim.set (val, false))
08519 {
08520 update_axis_limits ("zlim");
08521 zlim.run_listeners (POSTSET);
08522 mark_modified ();
08523 }
08524 }
08525 }
08526
08527 void set_clim (const octave_value& val)
08528 {
08529 if (! error_state)
08530 {
08531 if (clim.set (val, false))
08532 {
08533 update_axis_limits ("clim");
08534 clim.run_listeners (POSTSET);
08535 mark_modified ();
08536 }
08537 }
08538 }
08539
08540 void set_alim (const octave_value& val)
08541 {
08542 if (! error_state)
08543 {
08544 if (alim.set (val, false))
08545 {
08546 update_axis_limits ("alim");
08547 alim.run_listeners (POSTSET);
08548 mark_modified ();
08549 }
08550 }
08551 }
08552
08553 void set_xliminclude (const octave_value& val)
08554 {
08555 if (! error_state)
08556 {
08557 if (xliminclude.set (val, false))
08558 {
08559 update_axis_limits ("xliminclude");
08560 xliminclude.run_listeners (POSTSET);
08561 mark_modified ();
08562 }
08563 }
08564 }
08565
08566 void set_yliminclude (const octave_value& val)
08567 {
08568 if (! error_state)
08569 {
08570 if (yliminclude.set (val, false))
08571 {
08572 update_axis_limits ("yliminclude");
08573 yliminclude.run_listeners (POSTSET);
08574 mark_modified ();
08575 }
08576 }
08577 }
08578
08579 void set_zliminclude (const octave_value& val)
08580 {
08581 if (! error_state)
08582 {
08583 if (zliminclude.set (val, false))
08584 {
08585 update_axis_limits ("zliminclude");
08586 zliminclude.run_listeners (POSTSET);
08587 mark_modified ();
08588 }
08589 }
08590 }
08591
08592 void set_climinclude (const octave_value& val)
08593 {
08594 if (! error_state)
08595 {
08596 if (climinclude.set (val, false))
08597 {
08598 update_axis_limits ("climinclude");
08599 climinclude.run_listeners (POSTSET);
08600 mark_modified ();
08601 }
08602 }
08603 }
08604
08605 void set_aliminclude (const octave_value& val)
08606 {
08607 if (! error_state)
08608 {
08609 if (aliminclude.set (val, false))
08610 {
08611 update_axis_limits ("aliminclude");
08612 aliminclude.run_listeners (POSTSET);
08613 mark_modified ();
08614 }
08615 }
08616 }
08617
08618
08619 protected:
08620 void init (void)
08621 {
08622 xdata.add_constraint (dim_vector (-1, -1));
08623 ydata.add_constraint (dim_vector (-1, -1));
08624 zdata.add_constraint (dim_vector (-1, -1));
08625 vertices.add_constraint (dim_vector (-1, 2));
08626 vertices.add_constraint (dim_vector (-1, 3));
08627 cdata.add_constraint (dim_vector (-1, -1));
08628 cdata.add_constraint (dim_vector (-1, -1, 3));
08629 facevertexcdata.add_constraint (dim_vector (-1, 1));
08630 facevertexcdata.add_constraint (dim_vector (-1, 3));
08631 facevertexalphadata.add_constraint (dim_vector (-1, 1));
08632 }
08633
08634 private:
08635 void update_xdata (void) { set_xlim (xdata.get_limits ()); }
08636 void update_ydata (void) { set_ylim (ydata.get_limits ()); }
08637 void update_zdata (void) { set_zlim (zdata.get_limits ()); }
08638
08639 void update_cdata (void)
08640 {
08641 if (cdatamapping_is ("scaled"))
08642 set_clim (cdata.get_limits ());
08643 else
08644 clim = cdata.get_limits ();
08645 }
08646 };
08647
08648 private:
08649 properties xproperties;
08650
08651 public:
08652 patch (const graphics_handle& mh, const graphics_handle& p)
08653 : base_graphics_object (), xproperties (mh, p)
08654 {
08655 xproperties.override_defaults (*this);
08656 }
08657
08658 ~patch (void) { xproperties.delete_children (); }
08659
08660 base_properties& get_properties (void) { return xproperties; }
08661
08662 const base_properties& get_properties (void) const { return xproperties; }
08663
08664 bool valid_object (void) const { return true; }
08665 };
08666
08667
08668
08669 class OCTINTERP_API surface : public base_graphics_object
08670 {
08671 public:
08672 class OCTINTERP_API properties : public base_properties
08673 {
08674 public:
08675 octave_value get_color_data (void) const;
08676
08677 bool is_climinclude (void) const
08678 { return (climinclude.is_on () && cdatamapping.is ("scaled")); }
08679 std::string get_climinclude (void) const
08680 { return climinclude.current_value (); }
08681
08682 bool is_aliminclude (void) const
08683 { return (aliminclude.is_on () && alphadatamapping.is ("scaled")); }
08684 std::string get_aliminclude (void) const
08685 { return aliminclude.current_value (); }
08686
08687
08688
08689
08690 public:
08691 properties (const graphics_handle& mh, const graphics_handle& p);
08692
08693 ~properties (void) { }
08694
08695 void set (const caseless_str& pname, const octave_value& val);
08696
08697 octave_value get (bool all = false) const;
08698
08699 octave_value get (const caseless_str& pname) const;
08700
08701 octave_value get (const std::string& pname) const
08702 {
08703 return get (caseless_str (pname));
08704 }
08705
08706 octave_value get (const char *pname) const
08707 {
08708 return get (caseless_str (pname));
08709 }
08710
08711 property get_property (const caseless_str& pname);
08712
08713 std::string graphics_object_name (void) const { return go_name; }
08714
08715 static property_list::pval_map_type factory_defaults (void);
08716
08717 private:
08718 static std::string go_name;
08719
08720 public:
08721
08722
08723 static std::set<std::string> core_property_names (void);
08724
08725 static bool has_core_property (const caseless_str& pname);
08726
08727 std::set<std::string> all_property_names (void) const;
08728
08729 bool has_property (const caseless_str& pname) const;
08730
08731 private:
08732
08733 array_property xdata;
08734 array_property ydata;
08735 array_property zdata;
08736 array_property cdata;
08737 radio_property cdatamapping;
08738 string_property xdatasource;
08739 string_property ydatasource;
08740 string_property zdatasource;
08741 string_property cdatasource;
08742 color_property facecolor;
08743 double_radio_property facealpha;
08744 color_property edgecolor;
08745 radio_property linestyle;
08746 double_property linewidth;
08747 radio_property marker;
08748 color_property markeredgecolor;
08749 color_property markerfacecolor;
08750 double_property markersize;
08751 radio_property interpreter;
08752 string_property displayname;
08753 array_property alphadata;
08754 radio_property alphadatamapping;
08755 double_property ambientstrength;
08756 radio_property backfacelighting;
08757 double_property diffusestrength;
08758 double_radio_property edgealpha;
08759 radio_property edgelighting;
08760 radio_property erasemode;
08761 radio_property facelighting;
08762 radio_property meshstyle;
08763 radio_property normalmode;
08764 double_property specularcolorreflectance;
08765 double_property specularexponent;
08766 double_property specularstrength;
08767 array_property vertexnormals;
08768 row_vector_property xlim;
08769 row_vector_property ylim;
08770 row_vector_property zlim;
08771 row_vector_property clim;
08772 row_vector_property alim;
08773 bool_property xliminclude;
08774 bool_property yliminclude;
08775 bool_property zliminclude;
08776 bool_property climinclude;
08777 bool_property aliminclude;
08778
08779 public:
08780
08781 enum
08782 {
08783 ID_XDATA = 8000,
08784 ID_YDATA = 8001,
08785 ID_ZDATA = 8002,
08786 ID_CDATA = 8003,
08787 ID_CDATAMAPPING = 8004,
08788 ID_XDATASOURCE = 8005,
08789 ID_YDATASOURCE = 8006,
08790 ID_ZDATASOURCE = 8007,
08791 ID_CDATASOURCE = 8008,
08792 ID_FACECOLOR = 8009,
08793 ID_FACEALPHA = 8010,
08794 ID_EDGECOLOR = 8011,
08795 ID_LINESTYLE = 8012,
08796 ID_LINEWIDTH = 8013,
08797 ID_MARKER = 8014,
08798 ID_MARKEREDGECOLOR = 8015,
08799 ID_MARKERFACECOLOR = 8016,
08800 ID_MARKERSIZE = 8017,
08801 ID_INTERPRETER = 8018,
08802 ID_DISPLAYNAME = 8019,
08803 ID_ALPHADATA = 8020,
08804 ID_ALPHADATAMAPPING = 8021,
08805 ID_AMBIENTSTRENGTH = 8022,
08806 ID_BACKFACELIGHTING = 8023,
08807 ID_DIFFUSESTRENGTH = 8024,
08808 ID_EDGEALPHA = 8025,
08809 ID_EDGELIGHTING = 8026,
08810 ID_ERASEMODE = 8027,
08811 ID_FACELIGHTING = 8028,
08812 ID_MESHSTYLE = 8029,
08813 ID_NORMALMODE = 8030,
08814 ID_SPECULARCOLORREFLECTANCE = 8031,
08815 ID_SPECULAREXPONENT = 8032,
08816 ID_SPECULARSTRENGTH = 8033,
08817 ID_VERTEXNORMALS = 8034,
08818 ID_XLIM = 8035,
08819 ID_YLIM = 8036,
08820 ID_ZLIM = 8037,
08821 ID_CLIM = 8038,
08822 ID_ALIM = 8039,
08823 ID_XLIMINCLUDE = 8040,
08824 ID_YLIMINCLUDE = 8041,
08825 ID_ZLIMINCLUDE = 8042,
08826 ID_CLIMINCLUDE = 8043,
08827 ID_ALIMINCLUDE = 8044
08828 };
08829
08830 octave_value get_xdata (void) const { return xdata.get (); }
08831
08832 octave_value get_ydata (void) const { return ydata.get (); }
08833
08834 octave_value get_zdata (void) const { return zdata.get (); }
08835
08836 octave_value get_cdata (void) const { return cdata.get (); }
08837
08838 bool cdatamapping_is (const std::string& v) const { return cdatamapping.is (v); }
08839 std::string get_cdatamapping (void) const { return cdatamapping.current_value (); }
08840
08841 std::string get_xdatasource (void) const { return xdatasource.string_value (); }
08842
08843 std::string get_ydatasource (void) const { return ydatasource.string_value (); }
08844
08845 std::string get_zdatasource (void) const { return zdatasource.string_value (); }
08846
08847 std::string get_cdatasource (void) const { return cdatasource.string_value (); }
08848
08849 bool facecolor_is_rgb (void) const { return facecolor.is_rgb (); }
08850 bool facecolor_is (const std::string& v) const { return facecolor.is (v); }
08851 Matrix get_facecolor_rgb (void) const { return (facecolor.is_rgb () ? facecolor.rgb () : Matrix ()); }
08852 octave_value get_facecolor (void) const { return facecolor.get (); }
08853
08854 bool facealpha_is_double (void) const { return facealpha.is_double (); }
08855 bool facealpha_is (const std::string& v) const { return facealpha.is (v); }
08856 double get_facealpha_double (void) const { return (facealpha.is_double () ? facealpha.double_value () : 0); }
08857 octave_value get_facealpha (void) const { return facealpha.get (); }
08858
08859 bool edgecolor_is_rgb (void) const { return edgecolor.is_rgb (); }
08860 bool edgecolor_is (const std::string& v) const { return edgecolor.is (v); }
08861 Matrix get_edgecolor_rgb (void) const { return (edgecolor.is_rgb () ? edgecolor.rgb () : Matrix ()); }
08862 octave_value get_edgecolor (void) const { return edgecolor.get (); }
08863
08864 bool linestyle_is (const std::string& v) const { return linestyle.is (v); }
08865 std::string get_linestyle (void) const { return linestyle.current_value (); }
08866
08867 double get_linewidth (void) const { return linewidth.double_value (); }
08868
08869 bool marker_is (const std::string& v) const { return marker.is (v); }
08870 std::string get_marker (void) const { return marker.current_value (); }
08871
08872 bool markeredgecolor_is_rgb (void) const { return markeredgecolor.is_rgb (); }
08873 bool markeredgecolor_is (const std::string& v) const { return markeredgecolor.is (v); }
08874 Matrix get_markeredgecolor_rgb (void) const { return (markeredgecolor.is_rgb () ? markeredgecolor.rgb () : Matrix ()); }
08875 octave_value get_markeredgecolor (void) const { return markeredgecolor.get (); }
08876
08877 bool markerfacecolor_is_rgb (void) const { return markerfacecolor.is_rgb (); }
08878 bool markerfacecolor_is (const std::string& v) const { return markerfacecolor.is (v); }
08879 Matrix get_markerfacecolor_rgb (void) const { return (markerfacecolor.is_rgb () ? markerfacecolor.rgb () : Matrix ()); }
08880 octave_value get_markerfacecolor (void) const { return markerfacecolor.get (); }
08881
08882 double get_markersize (void) const { return markersize.double_value (); }
08883
08884 bool interpreter_is (const std::string& v) const { return interpreter.is (v); }
08885 std::string get_interpreter (void) const { return interpreter.current_value (); }
08886
08887 std::string get_displayname (void) const { return displayname.string_value (); }
08888
08889 octave_value get_alphadata (void) const { return alphadata.get (); }
08890
08891 bool alphadatamapping_is (const std::string& v) const { return alphadatamapping.is (v); }
08892 std::string get_alphadatamapping (void) const { return alphadatamapping.current_value (); }
08893
08894 double get_ambientstrength (void) const { return ambientstrength.double_value (); }
08895
08896 bool backfacelighting_is (const std::string& v) const { return backfacelighting.is (v); }
08897 std::string get_backfacelighting (void) const { return backfacelighting.current_value (); }
08898
08899 double get_diffusestrength (void) const { return diffusestrength.double_value (); }
08900
08901 bool edgealpha_is_double (void) const { return edgealpha.is_double (); }
08902 bool edgealpha_is (const std::string& v) const { return edgealpha.is (v); }
08903 double get_edgealpha_double (void) const { return (edgealpha.is_double () ? edgealpha.double_value () : 0); }
08904 octave_value get_edgealpha (void) const { return edgealpha.get (); }
08905
08906 bool edgelighting_is (const std::string& v) const { return edgelighting.is (v); }
08907 std::string get_edgelighting (void) const { return edgelighting.current_value (); }
08908
08909 bool erasemode_is (const std::string& v) const { return erasemode.is (v); }
08910 std::string get_erasemode (void) const { return erasemode.current_value (); }
08911
08912 bool facelighting_is (const std::string& v) const { return facelighting.is (v); }
08913 std::string get_facelighting (void) const { return facelighting.current_value (); }
08914
08915 bool meshstyle_is (const std::string& v) const { return meshstyle.is (v); }
08916 std::string get_meshstyle (void) const { return meshstyle.current_value (); }
08917
08918 bool normalmode_is (const std::string& v) const { return normalmode.is (v); }
08919 std::string get_normalmode (void) const { return normalmode.current_value (); }
08920
08921 double get_specularcolorreflectance (void) const { return specularcolorreflectance.double_value (); }
08922
08923 double get_specularexponent (void) const { return specularexponent.double_value (); }
08924
08925 double get_specularstrength (void) const { return specularstrength.double_value (); }
08926
08927 octave_value get_vertexnormals (void) const { return vertexnormals.get (); }
08928
08929 octave_value get_xlim (void) const { return xlim.get (); }
08930
08931 octave_value get_ylim (void) const { return ylim.get (); }
08932
08933 octave_value get_zlim (void) const { return zlim.get (); }
08934
08935 octave_value get_clim (void) const { return clim.get (); }
08936
08937 octave_value get_alim (void) const { return alim.get (); }
08938
08939 bool is_xliminclude (void) const { return xliminclude.is_on (); }
08940 std::string get_xliminclude (void) const { return xliminclude.current_value (); }
08941
08942 bool is_yliminclude (void) const { return yliminclude.is_on (); }
08943 std::string get_yliminclude (void) const { return yliminclude.current_value (); }
08944
08945 bool is_zliminclude (void) const { return zliminclude.is_on (); }
08946 std::string get_zliminclude (void) const { return zliminclude.current_value (); }
08947
08948
08949 void set_xdata (const octave_value& val)
08950 {
08951 if (! error_state)
08952 {
08953 if (xdata.set (val, true))
08954 {
08955 update_xdata ();
08956 mark_modified ();
08957 }
08958 }
08959 }
08960
08961 void set_ydata (const octave_value& val)
08962 {
08963 if (! error_state)
08964 {
08965 if (ydata.set (val, true))
08966 {
08967 update_ydata ();
08968 mark_modified ();
08969 }
08970 }
08971 }
08972
08973 void set_zdata (const octave_value& val)
08974 {
08975 if (! error_state)
08976 {
08977 if (zdata.set (val, true))
08978 {
08979 update_zdata ();
08980 mark_modified ();
08981 }
08982 }
08983 }
08984
08985 void set_cdata (const octave_value& val)
08986 {
08987 if (! error_state)
08988 {
08989 if (cdata.set (val, true))
08990 {
08991 update_cdata ();
08992 mark_modified ();
08993 }
08994 }
08995 }
08996
08997 void set_cdatamapping (const octave_value& val)
08998 {
08999 if (! error_state)
09000 {
09001 if (cdatamapping.set (val, false))
09002 {
09003 update_axis_limits ("cdatamapping");
09004 cdatamapping.run_listeners (POSTSET);
09005 mark_modified ();
09006 }
09007 }
09008 }
09009
09010 void set_xdatasource (const octave_value& val)
09011 {
09012 if (! error_state)
09013 {
09014 if (xdatasource.set (val, true))
09015 {
09016 mark_modified ();
09017 }
09018 }
09019 }
09020
09021 void set_ydatasource (const octave_value& val)
09022 {
09023 if (! error_state)
09024 {
09025 if (ydatasource.set (val, true))
09026 {
09027 mark_modified ();
09028 }
09029 }
09030 }
09031
09032 void set_zdatasource (const octave_value& val)
09033 {
09034 if (! error_state)
09035 {
09036 if (zdatasource.set (val, true))
09037 {
09038 mark_modified ();
09039 }
09040 }
09041 }
09042
09043 void set_cdatasource (const octave_value& val)
09044 {
09045 if (! error_state)
09046 {
09047 if (cdatasource.set (val, true))
09048 {
09049 mark_modified ();
09050 }
09051 }
09052 }
09053
09054 void set_facecolor (const octave_value& val)
09055 {
09056 if (! error_state)
09057 {
09058 if (facecolor.set (val, true))
09059 {
09060 mark_modified ();
09061 }
09062 }
09063 }
09064
09065 void set_facealpha (const octave_value& val)
09066 {
09067 if (! error_state)
09068 {
09069 if (facealpha.set (val, true))
09070 {
09071 mark_modified ();
09072 }
09073 }
09074 }
09075
09076 void set_edgecolor (const octave_value& val)
09077 {
09078 if (! error_state)
09079 {
09080 if (edgecolor.set (val, true))
09081 {
09082 mark_modified ();
09083 }
09084 }
09085 }
09086
09087 void set_linestyle (const octave_value& val)
09088 {
09089 if (! error_state)
09090 {
09091 if (linestyle.set (val, true))
09092 {
09093 mark_modified ();
09094 }
09095 }
09096 }
09097
09098 void set_linewidth (const octave_value& val)
09099 {
09100 if (! error_state)
09101 {
09102 if (linewidth.set (val, true))
09103 {
09104 mark_modified ();
09105 }
09106 }
09107 }
09108
09109 void set_marker (const octave_value& val)
09110 {
09111 if (! error_state)
09112 {
09113 if (marker.set (val, true))
09114 {
09115 mark_modified ();
09116 }
09117 }
09118 }
09119
09120 void set_markeredgecolor (const octave_value& val)
09121 {
09122 if (! error_state)
09123 {
09124 if (markeredgecolor.set (val, true))
09125 {
09126 mark_modified ();
09127 }
09128 }
09129 }
09130
09131 void set_markerfacecolor (const octave_value& val)
09132 {
09133 if (! error_state)
09134 {
09135 if (markerfacecolor.set (val, true))
09136 {
09137 mark_modified ();
09138 }
09139 }
09140 }
09141
09142 void set_markersize (const octave_value& val)
09143 {
09144 if (! error_state)
09145 {
09146 if (markersize.set (val, true))
09147 {
09148 mark_modified ();
09149 }
09150 }
09151 }
09152
09153 void set_interpreter (const octave_value& val)
09154 {
09155 if (! error_state)
09156 {
09157 if (interpreter.set (val, true))
09158 {
09159 mark_modified ();
09160 }
09161 }
09162 }
09163
09164 void set_displayname (const octave_value& val)
09165 {
09166 if (! error_state)
09167 {
09168 if (displayname.set (val, true))
09169 {
09170 mark_modified ();
09171 }
09172 }
09173 }
09174
09175 void set_alphadata (const octave_value& val)
09176 {
09177 if (! error_state)
09178 {
09179 if (alphadata.set (val, true))
09180 {
09181 update_alphadata ();
09182 mark_modified ();
09183 }
09184 }
09185 }
09186
09187 void set_alphadatamapping (const octave_value& val)
09188 {
09189 if (! error_state)
09190 {
09191 if (alphadatamapping.set (val, false))
09192 {
09193 update_axis_limits ("alphadatamapping");
09194 alphadatamapping.run_listeners (POSTSET);
09195 mark_modified ();
09196 }
09197 }
09198 }
09199
09200 void set_ambientstrength (const octave_value& val)
09201 {
09202 if (! error_state)
09203 {
09204 if (ambientstrength.set (val, true))
09205 {
09206 mark_modified ();
09207 }
09208 }
09209 }
09210
09211 void set_backfacelighting (const octave_value& val)
09212 {
09213 if (! error_state)
09214 {
09215 if (backfacelighting.set (val, true))
09216 {
09217 mark_modified ();
09218 }
09219 }
09220 }
09221
09222 void set_diffusestrength (const octave_value& val)
09223 {
09224 if (! error_state)
09225 {
09226 if (diffusestrength.set (val, true))
09227 {
09228 mark_modified ();
09229 }
09230 }
09231 }
09232
09233 void set_edgealpha (const octave_value& val)
09234 {
09235 if (! error_state)
09236 {
09237 if (edgealpha.set (val, true))
09238 {
09239 mark_modified ();
09240 }
09241 }
09242 }
09243
09244 void set_edgelighting (const octave_value& val)
09245 {
09246 if (! error_state)
09247 {
09248 if (edgelighting.set (val, true))
09249 {
09250 mark_modified ();
09251 }
09252 }
09253 }
09254
09255 void set_erasemode (const octave_value& val)
09256 {
09257 if (! error_state)
09258 {
09259 if (erasemode.set (val, true))
09260 {
09261 mark_modified ();
09262 }
09263 }
09264 }
09265
09266 void set_facelighting (const octave_value& val)
09267 {
09268 if (! error_state)
09269 {
09270 if (facelighting.set (val, true))
09271 {
09272 mark_modified ();
09273 }
09274 }
09275 }
09276
09277 void set_meshstyle (const octave_value& val)
09278 {
09279 if (! error_state)
09280 {
09281 if (meshstyle.set (val, true))
09282 {
09283 mark_modified ();
09284 }
09285 }
09286 }
09287
09288 void set_normalmode (const octave_value& val)
09289 {
09290 if (! error_state)
09291 {
09292 if (normalmode.set (val, true))
09293 {
09294 update_normalmode ();
09295 mark_modified ();
09296 }
09297 }
09298 }
09299
09300 void set_specularcolorreflectance (const octave_value& val)
09301 {
09302 if (! error_state)
09303 {
09304 if (specularcolorreflectance.set (val, true))
09305 {
09306 mark_modified ();
09307 }
09308 }
09309 }
09310
09311 void set_specularexponent (const octave_value& val)
09312 {
09313 if (! error_state)
09314 {
09315 if (specularexponent.set (val, true))
09316 {
09317 mark_modified ();
09318 }
09319 }
09320 }
09321
09322 void set_specularstrength (const octave_value& val)
09323 {
09324 if (! error_state)
09325 {
09326 if (specularstrength.set (val, true))
09327 {
09328 mark_modified ();
09329 }
09330 }
09331 }
09332
09333 void set_vertexnormals (const octave_value& val)
09334 {
09335 if (! error_state)
09336 {
09337 if (vertexnormals.set (val, true))
09338 {
09339 update_vertexnormals ();
09340 mark_modified ();
09341 }
09342 }
09343 }
09344
09345 void set_xlim (const octave_value& val)
09346 {
09347 if (! error_state)
09348 {
09349 if (xlim.set (val, false))
09350 {
09351 update_axis_limits ("xlim");
09352 xlim.run_listeners (POSTSET);
09353 mark_modified ();
09354 }
09355 }
09356 }
09357
09358 void set_ylim (const octave_value& val)
09359 {
09360 if (! error_state)
09361 {
09362 if (ylim.set (val, false))
09363 {
09364 update_axis_limits ("ylim");
09365 ylim.run_listeners (POSTSET);
09366 mark_modified ();
09367 }
09368 }
09369 }
09370
09371 void set_zlim (const octave_value& val)
09372 {
09373 if (! error_state)
09374 {
09375 if (zlim.set (val, false))
09376 {
09377 update_axis_limits ("zlim");
09378 zlim.run_listeners (POSTSET);
09379 mark_modified ();
09380 }
09381 }
09382 }
09383
09384 void set_clim (const octave_value& val)
09385 {
09386 if (! error_state)
09387 {
09388 if (clim.set (val, false))
09389 {
09390 update_axis_limits ("clim");
09391 clim.run_listeners (POSTSET);
09392 mark_modified ();
09393 }
09394 }
09395 }
09396
09397 void set_alim (const octave_value& val)
09398 {
09399 if (! error_state)
09400 {
09401 if (alim.set (val, false))
09402 {
09403 update_axis_limits ("alim");
09404 alim.run_listeners (POSTSET);
09405 mark_modified ();
09406 }
09407 }
09408 }
09409
09410 void set_xliminclude (const octave_value& val)
09411 {
09412 if (! error_state)
09413 {
09414 if (xliminclude.set (val, false))
09415 {
09416 update_axis_limits ("xliminclude");
09417 xliminclude.run_listeners (POSTSET);
09418 mark_modified ();
09419 }
09420 }
09421 }
09422
09423 void set_yliminclude (const octave_value& val)
09424 {
09425 if (! error_state)
09426 {
09427 if (yliminclude.set (val, false))
09428 {
09429 update_axis_limits ("yliminclude");
09430 yliminclude.run_listeners (POSTSET);
09431 mark_modified ();
09432 }
09433 }
09434 }
09435
09436 void set_zliminclude (const octave_value& val)
09437 {
09438 if (! error_state)
09439 {
09440 if (zliminclude.set (val, false))
09441 {
09442 update_axis_limits ("zliminclude");
09443 zliminclude.run_listeners (POSTSET);
09444 mark_modified ();
09445 }
09446 }
09447 }
09448
09449 void set_climinclude (const octave_value& val)
09450 {
09451 if (! error_state)
09452 {
09453 if (climinclude.set (val, false))
09454 {
09455 update_axis_limits ("climinclude");
09456 climinclude.run_listeners (POSTSET);
09457 mark_modified ();
09458 }
09459 }
09460 }
09461
09462 void set_aliminclude (const octave_value& val)
09463 {
09464 if (! error_state)
09465 {
09466 if (aliminclude.set (val, false))
09467 {
09468 update_axis_limits ("aliminclude");
09469 aliminclude.run_listeners (POSTSET);
09470 mark_modified ();
09471 }
09472 }
09473 }
09474
09475
09476 protected:
09477 void init (void)
09478 {
09479 xdata.add_constraint (dim_vector (-1, -1));
09480 ydata.add_constraint (dim_vector (-1, -1));
09481 zdata.add_constraint (dim_vector (-1, -1));
09482 alphadata.add_constraint ("single");
09483 alphadata.add_constraint ("double");
09484 alphadata.add_constraint ("uint8");
09485 alphadata.add_constraint (dim_vector (-1, -1));
09486 vertexnormals.add_constraint (dim_vector (-1, -1, 3));
09487 cdata.add_constraint ("single");
09488 cdata.add_constraint ("double");
09489 cdata.add_constraint ("uint8");
09490 cdata.add_constraint (dim_vector (-1, -1));
09491 cdata.add_constraint (dim_vector (-1, -1, 3));
09492 }
09493
09494 private:
09495 void update_normals (void);
09496
09497 void update_xdata (void)
09498 {
09499 update_normals ();
09500 set_xlim (xdata.get_limits ());
09501 }
09502
09503 void update_ydata (void)
09504 {
09505 update_normals ();
09506 set_ylim (ydata.get_limits ());
09507 }
09508
09509 void update_zdata (void)
09510 {
09511 update_normals ();
09512 set_zlim (zdata.get_limits ());
09513 }
09514
09515 void update_cdata (void)
09516 {
09517 if (cdatamapping_is ("scaled"))
09518 set_clim (cdata.get_limits ());
09519 else
09520 clim = cdata.get_limits ();
09521 }
09522
09523 void update_alphadata (void)
09524 {
09525 if (alphadatamapping_is ("scaled"))
09526 set_alim (alphadata.get_limits ());
09527 else
09528 alim = alphadata.get_limits ();
09529 }
09530
09531 void update_normalmode (void)
09532 { update_normals (); }
09533
09534 void update_vertexnormals (void)
09535 { set_normalmode ("manual"); }
09536 };
09537
09538 private:
09539 properties xproperties;
09540
09541 public:
09542 surface (const graphics_handle& mh, const graphics_handle& p)
09543 : base_graphics_object (), xproperties (mh, p)
09544 {
09545 xproperties.override_defaults (*this);
09546 }
09547
09548 ~surface (void) { xproperties.delete_children (); }
09549
09550 base_properties& get_properties (void) { return xproperties; }
09551
09552 const base_properties& get_properties (void) const { return xproperties; }
09553
09554 bool valid_object (void) const { return true; }
09555 };
09556
09557
09558
09559 class OCTINTERP_API hggroup : public base_graphics_object
09560 {
09561 public:
09562 class OCTINTERP_API properties : public base_properties
09563 {
09564 public:
09565 void remove_child (const graphics_handle& h)
09566 {
09567 base_properties::remove_child (h);
09568 update_limits ();
09569 }
09570
09571 void adopt (const graphics_handle& h)
09572 {
09573
09574 base_properties::adopt (h);
09575 update_limits (h);
09576 }
09577
09578
09579
09580
09581 public:
09582 properties (const graphics_handle& mh, const graphics_handle& p);
09583
09584 ~properties (void) { }
09585
09586 void set (const caseless_str& pname, const octave_value& val);
09587
09588 octave_value get (bool all = false) const;
09589
09590 octave_value get (const caseless_str& pname) const;
09591
09592 octave_value get (const std::string& pname) const
09593 {
09594 return get (caseless_str (pname));
09595 }
09596
09597 octave_value get (const char *pname) const
09598 {
09599 return get (caseless_str (pname));
09600 }
09601
09602 property get_property (const caseless_str& pname);
09603
09604 std::string graphics_object_name (void) const { return go_name; }
09605
09606 static property_list::pval_map_type factory_defaults (void);
09607
09608 private:
09609 static std::string go_name;
09610
09611 public:
09612
09613
09614 static std::set<std::string> core_property_names (void);
09615
09616 static bool has_core_property (const caseless_str& pname);
09617
09618 std::set<std::string> all_property_names (void) const;
09619
09620 bool has_property (const caseless_str& pname) const;
09621
09622 private:
09623
09624 row_vector_property xlim;
09625 row_vector_property ylim;
09626 row_vector_property zlim;
09627 row_vector_property clim;
09628 row_vector_property alim;
09629 bool_property xliminclude;
09630 bool_property yliminclude;
09631 bool_property zliminclude;
09632 bool_property climinclude;
09633 bool_property aliminclude;
09634
09635 public:
09636
09637 enum
09638 {
09639 ID_XLIM = 9000,
09640 ID_YLIM = 9001,
09641 ID_ZLIM = 9002,
09642 ID_CLIM = 9003,
09643 ID_ALIM = 9004,
09644 ID_XLIMINCLUDE = 9005,
09645 ID_YLIMINCLUDE = 9006,
09646 ID_ZLIMINCLUDE = 9007,
09647 ID_CLIMINCLUDE = 9008,
09648 ID_ALIMINCLUDE = 9009
09649 };
09650
09651 octave_value get_xlim (void) const { return xlim.get (); }
09652
09653 octave_value get_ylim (void) const { return ylim.get (); }
09654
09655 octave_value get_zlim (void) const { return zlim.get (); }
09656
09657 octave_value get_clim (void) const { return clim.get (); }
09658
09659 octave_value get_alim (void) const { return alim.get (); }
09660
09661 bool is_xliminclude (void) const { return xliminclude.is_on (); }
09662 std::string get_xliminclude (void) const { return xliminclude.current_value (); }
09663
09664 bool is_yliminclude (void) const { return yliminclude.is_on (); }
09665 std::string get_yliminclude (void) const { return yliminclude.current_value (); }
09666
09667 bool is_zliminclude (void) const { return zliminclude.is_on (); }
09668 std::string get_zliminclude (void) const { return zliminclude.current_value (); }
09669
09670 bool is_climinclude (void) const { return climinclude.is_on (); }
09671 std::string get_climinclude (void) const { return climinclude.current_value (); }
09672
09673 bool is_aliminclude (void) const { return aliminclude.is_on (); }
09674 std::string get_aliminclude (void) const { return aliminclude.current_value (); }
09675
09676
09677 void set_xlim (const octave_value& val)
09678 {
09679 if (! error_state)
09680 {
09681 if (xlim.set (val, true))
09682 {
09683 mark_modified ();
09684 }
09685 }
09686 }
09687
09688 void set_ylim (const octave_value& val)
09689 {
09690 if (! error_state)
09691 {
09692 if (ylim.set (val, true))
09693 {
09694 mark_modified ();
09695 }
09696 }
09697 }
09698
09699 void set_zlim (const octave_value& val)
09700 {
09701 if (! error_state)
09702 {
09703 if (zlim.set (val, true))
09704 {
09705 mark_modified ();
09706 }
09707 }
09708 }
09709
09710 void set_clim (const octave_value& val)
09711 {
09712 if (! error_state)
09713 {
09714 if (clim.set (val, true))
09715 {
09716 mark_modified ();
09717 }
09718 }
09719 }
09720
09721 void set_alim (const octave_value& val)
09722 {
09723 if (! error_state)
09724 {
09725 if (alim.set (val, true))
09726 {
09727 mark_modified ();
09728 }
09729 }
09730 }
09731
09732 void set_xliminclude (const octave_value& val)
09733 {
09734 if (! error_state)
09735 {
09736 if (xliminclude.set (val, true))
09737 {
09738 mark_modified ();
09739 }
09740 }
09741 }
09742
09743 void set_yliminclude (const octave_value& val)
09744 {
09745 if (! error_state)
09746 {
09747 if (yliminclude.set (val, true))
09748 {
09749 mark_modified ();
09750 }
09751 }
09752 }
09753
09754 void set_zliminclude (const octave_value& val)
09755 {
09756 if (! error_state)
09757 {
09758 if (zliminclude.set (val, true))
09759 {
09760 mark_modified ();
09761 }
09762 }
09763 }
09764
09765 void set_climinclude (const octave_value& val)
09766 {
09767 if (! error_state)
09768 {
09769 if (climinclude.set (val, true))
09770 {
09771 mark_modified ();
09772 }
09773 }
09774 }
09775
09776 void set_aliminclude (const octave_value& val)
09777 {
09778 if (! error_state)
09779 {
09780 if (aliminclude.set (val, true))
09781 {
09782 mark_modified ();
09783 }
09784 }
09785 }
09786
09787
09788 private:
09789 void update_limits (void) const;
09790
09791 void update_limits (const graphics_handle& h) const;
09792
09793 protected:
09794 void init (void)
09795 { }
09796
09797 };
09798
09799 private:
09800 properties xproperties;
09801
09802 public:
09803 hggroup (const graphics_handle& mh, const graphics_handle& p)
09804 : base_graphics_object (), xproperties (mh, p)
09805 {
09806 xproperties.override_defaults (*this);
09807 }
09808
09809 ~hggroup (void) { xproperties.delete_children (); }
09810
09811 base_properties& get_properties (void) { return xproperties; }
09812
09813 const base_properties& get_properties (void) const { return xproperties; }
09814
09815 bool valid_object (void) const { return true; }
09816
09817 void update_axis_limits (const std::string& axis_type);
09818
09819 void update_axis_limits (const std::string& axis_type,
09820 const graphics_handle& h);
09821
09822 };
09823
09824
09825
09826 class OCTINTERP_API uimenu : public base_graphics_object
09827 {
09828 public:
09829 class OCTINTERP_API properties : public base_properties
09830 {
09831 public:
09832 void remove_child (const graphics_handle& h)
09833 {
09834 base_properties::remove_child (h);
09835 }
09836
09837 void adopt (const graphics_handle& h)
09838 {
09839 base_properties::adopt (h);
09840 }
09841
09842
09843
09844
09845 public:
09846 properties (const graphics_handle& mh, const graphics_handle& p);
09847
09848 ~properties (void) { }
09849
09850 void set (const caseless_str& pname, const octave_value& val);
09851
09852 octave_value get (bool all = false) const;
09853
09854 octave_value get (const caseless_str& pname) const;
09855
09856 octave_value get (const std::string& pname) const
09857 {
09858 return get (caseless_str (pname));
09859 }
09860
09861 octave_value get (const char *pname) const
09862 {
09863 return get (caseless_str (pname));
09864 }
09865
09866 property get_property (const caseless_str& pname);
09867
09868 std::string graphics_object_name (void) const { return go_name; }
09869
09870 static property_list::pval_map_type factory_defaults (void);
09871
09872 private:
09873 static std::string go_name;
09874
09875 public:
09876
09877
09878 static std::set<std::string> core_property_names (void);
09879
09880 static bool has_core_property (const caseless_str& pname);
09881
09882 std::set<std::string> all_property_names (void) const;
09883
09884 bool has_property (const caseless_str& pname) const;
09885
09886 private:
09887
09888 string_property accelerator;
09889 callback_property callback;
09890 bool_property checked;
09891 bool_property enable;
09892 color_property foregroundcolor;
09893 string_property label;
09894 double_property position;
09895 bool_property separator;
09896 string_property fltk_label;
09897
09898 public:
09899
09900 enum
09901 {
09902 ID_ACCELERATOR = 10000,
09903 ID_CALLBACK = 10001,
09904 ID_CHECKED = 10002,
09905 ID_ENABLE = 10003,
09906 ID_FOREGROUNDCOLOR = 10004,
09907 ID_LABEL = 10005,
09908 ID_POSITION = 10006,
09909 ID_SEPARATOR = 10007,
09910 ID_FLTK_LABEL = 10008
09911 };
09912
09913 std::string get_accelerator (void) const { return accelerator.string_value (); }
09914
09915 void execute_callback (const octave_value& data = octave_value ()) const { callback.execute (data); }
09916 octave_value get_callback (void) const { return callback.get (); }
09917
09918 bool is_checked (void) const { return checked.is_on (); }
09919 std::string get_checked (void) const { return checked.current_value (); }
09920
09921 bool is_enable (void) const { return enable.is_on (); }
09922 std::string get_enable (void) const { return enable.current_value (); }
09923
09924 bool foregroundcolor_is_rgb (void) const { return foregroundcolor.is_rgb (); }
09925 bool foregroundcolor_is (const std::string& v) const { return foregroundcolor.is (v); }
09926 Matrix get_foregroundcolor_rgb (void) const { return (foregroundcolor.is_rgb () ? foregroundcolor.rgb () : Matrix ()); }
09927 octave_value get_foregroundcolor (void) const { return foregroundcolor.get (); }
09928
09929 std::string get_label (void) const { return label.string_value (); }
09930
09931 double get_position (void) const { return position.double_value (); }
09932
09933 bool is_separator (void) const { return separator.is_on (); }
09934 std::string get_separator (void) const { return separator.current_value (); }
09935
09936 std::string get_fltk_label (void) const { return fltk_label.string_value (); }
09937
09938
09939 void set_accelerator (const octave_value& val)
09940 {
09941 if (! error_state)
09942 {
09943 if (accelerator.set (val, true))
09944 {
09945 mark_modified ();
09946 }
09947 }
09948 }
09949
09950 void set_callback (const octave_value& val)
09951 {
09952 if (! error_state)
09953 {
09954 if (callback.set (val, true))
09955 {
09956 mark_modified ();
09957 }
09958 }
09959 }
09960
09961 void set_checked (const octave_value& val)
09962 {
09963 if (! error_state)
09964 {
09965 if (checked.set (val, true))
09966 {
09967 mark_modified ();
09968 }
09969 }
09970 }
09971
09972 void set_enable (const octave_value& val)
09973 {
09974 if (! error_state)
09975 {
09976 if (enable.set (val, true))
09977 {
09978 mark_modified ();
09979 }
09980 }
09981 }
09982
09983 void set_foregroundcolor (const octave_value& val)
09984 {
09985 if (! error_state)
09986 {
09987 if (foregroundcolor.set (val, true))
09988 {
09989 mark_modified ();
09990 }
09991 }
09992 }
09993
09994 void set_label (const octave_value& val)
09995 {
09996 if (! error_state)
09997 {
09998 if (label.set (val, true))
09999 {
10000 mark_modified ();
10001 }
10002 }
10003 }
10004
10005 void set_position (const octave_value& val)
10006 {
10007 if (! error_state)
10008 {
10009 if (position.set (val, true))
10010 {
10011 mark_modified ();
10012 }
10013 }
10014 }
10015
10016 void set_separator (const octave_value& val)
10017 {
10018 if (! error_state)
10019 {
10020 if (separator.set (val, true))
10021 {
10022 mark_modified ();
10023 }
10024 }
10025 }
10026
10027 void set_fltk_label (const octave_value& val)
10028 {
10029 if (! error_state)
10030 {
10031 if (fltk_label.set (val, true))
10032 {
10033 mark_modified ();
10034 }
10035 }
10036 }
10037
10038
10039 protected:
10040 void init (void)
10041 { }
10042 };
10043
10044 private:
10045 properties xproperties;
10046
10047 public:
10048 uimenu (const graphics_handle& mh, const graphics_handle& p)
10049 : base_graphics_object (), xproperties (mh, p)
10050 {
10051 xproperties.override_defaults (*this);
10052 }
10053
10054 ~uimenu (void) { xproperties.delete_children (); }
10055
10056 base_properties& get_properties (void) { return xproperties; }
10057
10058 const base_properties& get_properties (void) const { return xproperties; }
10059
10060 bool valid_object (void) const { return true; }
10061
10062 };
10063
10064
10065
10066 octave_value
10067 get_property_from_handle (double handle, const std::string &property,
10068 const std::string &func);
10069 bool
10070 set_property_in_handle (double handle, const std::string &property,
10071 const octave_value &arg, const std::string &func);
10072
10073
10074
10075 class graphics_event;
10076
10077 class
10078 base_graphics_event
10079 {
10080 public:
10081 friend class graphics_event;
10082
10083 base_graphics_event (void) : count (1) { }
10084
10085 virtual ~base_graphics_event (void) { }
10086
10087 virtual void execute (void) = 0;
10088
10089 private:
10090 int count;
10091 };
10092
10093 class
10094 graphics_event
10095 {
10096 public:
10097 typedef void (*event_fcn) (void*);
10098
10099 graphics_event (void) : rep (0) { }
10100
10101 graphics_event (const graphics_event& e) : rep (e.rep)
10102 {
10103 rep->count++;
10104 }
10105
10106 ~graphics_event (void)
10107 {
10108 if (rep && --rep->count == 0)
10109 delete rep;
10110 }
10111
10112 graphics_event& operator = (const graphics_event& e)
10113 {
10114 if (rep != e.rep)
10115 {
10116 if (rep && --rep->count == 0)
10117 delete rep;
10118
10119 rep = e.rep;
10120 if (rep)
10121 rep->count++;
10122 }
10123
10124 return *this;
10125 }
10126
10127 void execute (void)
10128 { if (rep) rep->execute (); }
10129
10130 bool ok (void) const
10131 { return (rep != 0); }
10132
10133 static graphics_event
10134 create_callback_event (const graphics_handle& h,
10135 const std::string& name,
10136 const octave_value& data = Matrix ());
10137
10138 static graphics_event
10139 create_function_event (event_fcn fcn, void *data = 0);
10140
10141 static graphics_event
10142 create_set_event (const graphics_handle& h,
10143 const std::string& name,
10144 const octave_value& value);
10145 private:
10146 base_graphics_event *rep;
10147 };
10148
10149 class OCTINTERP_API gh_manager
10150 {
10151 protected:
10152
10153 gh_manager (void);
10154
10155 public:
10156
10157 static bool instance_ok (void)
10158 {
10159 bool retval = true;
10160
10161 if (! instance)
10162 instance = new gh_manager ();
10163
10164 if (! instance)
10165 {
10166 ::error ("unable to create gh_manager!");
10167
10168 retval = false;
10169 }
10170
10171 return retval;
10172 }
10173
10174 static void free (const graphics_handle& h)
10175 {
10176 if (instance_ok ())
10177 instance->do_free (h);
10178 }
10179
10180 static graphics_handle lookup (double val)
10181 {
10182 return instance_ok () ? instance->do_lookup (val) : graphics_handle ();
10183 }
10184
10185 static graphics_handle lookup (const octave_value& val)
10186 {
10187 return val.is_real_scalar ()
10188 ? lookup (val.double_value ()) : graphics_handle ();
10189 }
10190
10191 static graphics_object get_object (double val)
10192 {
10193 return get_object (lookup (val));
10194 }
10195
10196 static graphics_object get_object (const graphics_handle& h)
10197 {
10198 return instance_ok () ? instance->do_get_object (h) : graphics_object ();
10199 }
10200
10201 static graphics_handle
10202 make_graphics_handle (const std::string& go_name,
10203 const graphics_handle& parent, bool do_createfcn = true)
10204 {
10205 return instance_ok ()
10206 ? instance->do_make_graphics_handle (go_name, parent, do_createfcn)
10207 : graphics_handle ();
10208 }
10209
10210 static graphics_handle make_figure_handle (double val)
10211 {
10212 return instance_ok ()
10213 ? instance->do_make_figure_handle (val) : graphics_handle ();
10214 }
10215
10216 static void push_figure (const graphics_handle& h)
10217 {
10218 if (instance_ok ())
10219 instance->do_push_figure (h);
10220 }
10221
10222 static void pop_figure (const graphics_handle& h)
10223 {
10224 if (instance_ok ())
10225 instance->do_pop_figure (h);
10226 }
10227
10228 static graphics_handle current_figure (void)
10229 {
10230 return instance_ok ()
10231 ? instance->do_current_figure () : graphics_handle ();
10232 }
10233
10234 static Matrix handle_list (void)
10235 {
10236 return instance_ok () ? instance->do_handle_list () : Matrix ();
10237 }
10238
10239 static void lock (void)
10240 {
10241 if (instance_ok ())
10242 instance->do_lock ();
10243 }
10244
10245 static void unlock (void)
10246 {
10247 if (instance_ok ())
10248 instance->do_unlock ();
10249 }
10250
10251 static Matrix figure_handle_list (void)
10252 {
10253 return instance_ok () ? instance->do_figure_handle_list () : Matrix ();
10254 }
10255
10256 static void execute_callback (const graphics_handle& h,
10257 const std::string& name,
10258 const octave_value& data = Matrix ())
10259 {
10260 graphics_object go = get_object (h);
10261
10262 if (go.valid_object ())
10263 {
10264 octave_value cb = go.get (name);
10265
10266 if (! error_state)
10267 execute_callback (h, cb, data);
10268 }
10269 }
10270
10271 static void execute_callback (const graphics_handle& h,
10272 const octave_value& cb,
10273 const octave_value& data = Matrix ())
10274 {
10275 if (instance_ok ())
10276 instance->do_execute_callback (h, cb, data);
10277 }
10278
10279 static void post_callback (const graphics_handle& h,
10280 const std::string& name,
10281 const octave_value& data = Matrix ())
10282 {
10283 if (instance_ok ())
10284 instance->do_post_callback (h, name, data);
10285 }
10286
10287 static void post_function (graphics_event::event_fcn fcn, void* data = 0)
10288 {
10289 if (instance_ok ())
10290 instance->do_post_function (fcn, data);
10291 }
10292
10293 static void post_set (const graphics_handle& h,
10294 const std::string& name,
10295 const octave_value& value)
10296 {
10297 if (instance_ok ())
10298 instance->do_post_set (h, name, value);
10299 }
10300
10301 static int process_events (void)
10302 {
10303 return (instance_ok () ? instance->do_process_events () : 0);
10304 }
10305
10306 static int flush_events (void)
10307 {
10308 return (instance_ok () ? instance->do_process_events (true) : 0);
10309 }
10310
10311 static bool is_handle_visible (const graphics_handle& h)
10312 {
10313 bool retval = false;
10314
10315 graphics_object go = get_object (h);
10316
10317 if (go.valid_object ())
10318 retval = go.is_handle_visible ();
10319
10320 return retval;
10321 }
10322
10323 public:
10324 class autolock
10325 {
10326 public:
10327 autolock (void) { lock (); }
10328
10329 ~autolock (void) { unlock (); }
10330
10331 private:
10332
10333
10334 autolock (const autolock&);
10335 autolock& operator = (const autolock&);
10336 };
10337
10338 private:
10339
10340 static gh_manager *instance;
10341
10342 typedef std::map<graphics_handle, graphics_object>::iterator iterator;
10343 typedef std::map<graphics_handle, graphics_object>::const_iterator const_iterator;
10344
10345 typedef std::set<graphics_handle>::iterator free_list_iterator;
10346 typedef std::set<graphics_handle>::const_iterator const_free_list_iterator;
10347
10348 typedef std::list<graphics_handle>::iterator figure_list_iterator;
10349 typedef std::list<graphics_handle>::const_iterator const_figure_list_iterator;
10350
10351
10352 std::map<graphics_handle, graphics_object> handle_map;
10353
10354
10355 std::set<graphics_handle> handle_free_list;
10356
10357
10358 double next_handle;
10359
10360
10361
10362 std::list<graphics_handle> figure_list;
10363
10364
10365 octave_mutex graphics_lock;
10366
10367
10368 std::list<graphics_event> event_queue;
10369
10370
10371 std::list<graphics_object> callback_objects;
10372
10373 graphics_handle get_handle (const std::string& go_name);
10374
10375 void do_free (const graphics_handle& h);
10376
10377 graphics_handle do_lookup (double val)
10378 {
10379 iterator p = (xisnan (val) ? handle_map.end () : handle_map.find (val));
10380
10381 return (p != handle_map.end ()) ? p->first : graphics_handle ();
10382 }
10383
10384 graphics_object do_get_object (const graphics_handle& h)
10385 {
10386 iterator p = (h.ok () ? handle_map.find (h) : handle_map.end ());
10387
10388 return (p != handle_map.end ()) ? p->second : graphics_object ();
10389 }
10390
10391 graphics_handle do_make_graphics_handle (const std::string& go_name,
10392 const graphics_handle& p, bool do_createfcn);
10393
10394 graphics_handle do_make_figure_handle (double val);
10395
10396 Matrix do_handle_list (void)
10397 {
10398 Matrix retval (1, handle_map.size ());
10399 octave_idx_type i = 0;
10400 for (const_iterator p = handle_map.begin (); p != handle_map.end (); p++)
10401 {
10402 graphics_handle h = p->first;
10403 retval(i++) = h.value ();
10404 }
10405 return retval;
10406 }
10407
10408 Matrix do_figure_handle_list (void)
10409 {
10410 Matrix retval (1, figure_list.size ());
10411 octave_idx_type i = 0;
10412 for (const_figure_list_iterator p = figure_list.begin ();
10413 p != figure_list.end ();
10414 p++)
10415 {
10416 graphics_handle h = *p;
10417 retval(i++) = h.value ();
10418 }
10419 return retval;
10420 }
10421
10422 void do_push_figure (const graphics_handle& h);
10423
10424 void do_pop_figure (const graphics_handle& h);
10425
10426 graphics_handle do_current_figure (void) const
10427 {
10428 return figure_list.empty () ? graphics_handle () : figure_list.front ();
10429 }
10430
10431 void do_lock (void) { graphics_lock.lock (); }
10432
10433 void do_unlock (void) { graphics_lock.unlock (); }
10434
10435 void do_execute_callback (const graphics_handle& h, const octave_value& cb,
10436 const octave_value& data);
10437
10438 void do_post_callback (const graphics_handle& h, const std::string name,
10439 const octave_value& data);
10440
10441 void do_post_function (graphics_event::event_fcn fcn, void* fcn_data);
10442
10443 void do_post_set (const graphics_handle& h, const std::string name,
10444 const octave_value& value);
10445
10446 int do_process_events (bool force = false);
10447
10448 static void restore_gcbo (void)
10449 {
10450 if (instance_ok ())
10451 instance->do_restore_gcbo ();
10452 }
10453
10454 void do_restore_gcbo (void);
10455
10456 void do_post_event (const graphics_event& e);
10457 };
10458
10459 void get_children_limits (double& min_val, double& max_val, double& min_pos,
10460 const Matrix& kids, char limit_type);
10461
10462 OCTINTERP_API int calc_dimensions (const graphics_object& gh);
10463
10464
10465 OCTINTERP_API graphics_handle gcf (void);
10466
10467
10468 OCTINTERP_API graphics_handle gca (void);
10469
10470 #endif