Mercurial > hg > octave-avbm
changeset 7848:6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Wed, 27 Feb 2008 21:45:12 +0100 |
parents | 40b16e04172a |
children | 3249f64f69b2 |
files | src/ChangeLog src/genprops.awk src/graphics.cc src/graphics.h.in |
diffstat | 4 files changed, 87 insertions(+), 164 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -27,6 +27,33 @@ 2008-06-04 Michael Goffioul <michael.goffioul@gmail.com> + * genprops.awk (emit_get_data): Remove. + (emit_declarations): Treat row_vector_property as array_property and + remove data_property references. + * graphics.h.in (array_property::array_property(array_property)): Add + copy constructor. + (class data_property): Remove (replaced by array_property). + (class base_graphics_backend, class graphics_backend): Replace + data_property references with array_property. + (line::properties::xdata, line::properties::ydata, + line::properties::zdata, line::properties::ldata, + line::properties::udata, line::properties::xldata, + line::properties::xudata): Turn into row_vector_property. + (image::properties::xdata, image::properties::ydata): Likewise. + (image::properties::init): Add length constraints for xdata and ydata. + (patch::properties::xdata, patch::properties::ydata, + patch::properties::zdata, patch::properties::facevertexalphadata): + Turn into array_property. + (surface::properties::xdata, surface::properties::ydata, + surface::properties::zdata): Likewise. + (patch::properties::init): Add size constraints for xdata, ydata, + zdata and facevertexalphadata. + (surface::properties::init): Add size constraints for xdata, ydata and + zdata. + * graphics.cc (check_limit_vals): Remove override with data_property. + (axes::update_axis_limits): Replace data_property references with + array_property. + * graphics.h.in (root_figure::get_default): Use factory defaults when no explicit default value exists. (figure::properties::set___backend__): Reset __plot_stream__ to empty
--- a/src/genprops.awk +++ b/src/genprops.awk @@ -224,16 +224,6 @@ emit_get_accessor(i, "octave_value", "get"); } -## data_property - -function emit_get_data (i) -{ - emit_get_accessor(i, "NDArray", "array_value"); - - printf (" data_property get_%s_property (void) const { return %s; }\n", - name[i], name[i]); -} - ## array_property function emit_get_array (i) @@ -287,8 +277,6 @@ emit_get_accessor(i, "double", "double_value"); else if (type[i] == "double_radio_property") emit_get_double_radio(i); - else if (type[i] == "data_property") - emit_get_data(i); else if (type[i] == "array_property" \ || type[i] == "row_vector_property") emit_get_array(i);
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -2462,23 +2462,6 @@ return retval; } -// FIXME: Remove in case all data_property are converted into -// array_property -static void -check_limit_vals (double& min_val, double& max_val, double& min_pos, - const data_property& data) -{ - double val = data.min_val (); - if (! (xisinf (val) || xisnan (val)) && val < min_val) - min_val = val; - val = data.max_val (); - if (! (xisinf (val) || xisnan (val)) && val > max_val) - max_val = val; - val = data.min_pos (); - if (! (xisinf (val) || xisnan (val)) && val > 0 && val < min_pos) - min_pos = val; -} - // FIXME: Maybe this should go into array_property class? static void check_limit_vals (double& min_val, double& max_val, double& min_pos, @@ -2702,14 +2685,14 @@ if (obj.isa ("line") || obj.isa ("image") || obj.isa ("patch") || obj.isa ("surface")) { - data_property xdata = obj.get_xdata_property (); + array_property xdata = obj.get_xdata_property (); check_limit_vals (min_val, max_val, min_pos, xdata); if (obj.isa ("line")) { - data_property xldata = obj.get_xldata_property (); - data_property xudata = obj.get_xudata_property (); + array_property xldata = obj.get_xldata_property (); + array_property xudata = obj.get_xudata_property (); check_limit_vals (min_val, max_val, min_pos, xldata); check_limit_vals (min_val, max_val, min_pos, xudata); @@ -2736,14 +2719,14 @@ if (obj.isa ("line") || obj.isa ("image") || obj.isa ("patch") || obj.isa ("surface")) { - data_property ydata = obj.get_ydata_property (); + array_property ydata = obj.get_ydata_property (); check_limit_vals (min_val, max_val, min_pos, ydata); if (obj.isa ("line")) { - data_property ldata = obj.get_ldata_property (); - data_property udata = obj.get_udata_property (); + array_property ldata = obj.get_ldata_property (); + array_property udata = obj.get_udata_property (); check_limit_vals (min_val, max_val, min_pos, ldata); check_limit_vals (min_val, max_val, min_pos, udata); @@ -2768,7 +2751,7 @@ if (obj.isa ("line") || obj.isa ("patch") || obj.isa ("surface")) { - data_property zdata = obj.get_zdata_property (); + array_property zdata = obj.get_zdata_property (); check_limit_vals (min_val, max_val, min_pos, zdata); }
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -803,6 +803,13 @@ get_data_limits (); } + // This copy constructor is only intended to be used + // internally to access min/max values; no need to + // copy constraints. + array_property (const array_property& p) + : base_property (p), data (p.data), + xmin (p.xmin), xmax (p.xmax), xminp (p.xminp) { } + octave_value get (void) const { return data; } void set (const octave_value& v) @@ -909,94 +916,6 @@ // --------------------------------------------------------------------- -class data_property : public base_property -{ -public: - data_property (void) - : base_property ("", graphics_handle ()) { } - - data_property (const std::string& nm, const graphics_handle& h, - const NDArray& m = NDArray ()) - : base_property (nm, h), - data (m), xmin (octave_Inf), xmax (-octave_Inf), xminp (octave_Inf) - { - get_data_limits (); - } - - data_property (const std::string& nm, const graphics_handle& h, - const Matrix& m) - : base_property (nm, h), - data (m), xmin (octave_Inf), xmax (-octave_Inf), xminp (octave_Inf) - { - get_data_limits (); - } - - data_property (const data_property& p) - : base_property (p), data (p.data), - xmin (p.xmin), xmax (p.xmax), xminp (p.xminp) { } - - void set (const octave_value& val) - { - data = val.array_value (); - - get_data_limits (); - } - - octave_value get (void) const { return data; } - - NDArray array_value (void) const { return data; } - - Matrix matrix_value (void) const { return data.matrix_value (); } - - double min_val (void) const { return xmin; } - double max_val (void) const { return xmax; } - double min_pos (void) const { return xminp; } - - data_property& operator = (const octave_value& val) - { - set (val); - return *this; - } - -private: - NDArray data; - double xmin; - double xmax; - double xminp; - - void get_data_limits (void) - { - octave_idx_type nel = data.numel (); - - xmin = xminp = octave_Inf; - xmax = -octave_Inf; - - if (nel > 0) - { - const double *d = data.data (); - - for (octave_idx_type i = 0; i < nel; i++) - { - double val = d[i]; - - if (! (xisinf (val) || xisnan (val))) - { - if (val < xmin) - xmin = val; - - if (val > xmax) - xmax = val; - - if (val > 0 && val < xminp) - xminp = val; - } - } - } - } -}; - -// --------------------------------------------------------------------- - class bool_property : public radio_property { public: @@ -1208,9 +1127,6 @@ const double_property& as_double_property (void) const { return *(dynamic_cast<double_property*> (rep)); } - const data_property& as_data_property (void) const - { return *(dynamic_cast<data_property*> (rep)); } - const bool_property& as_bool_property (void) const { return *(dynamic_cast<bool_property*> (rep)); } @@ -1710,46 +1626,46 @@ // genprops.awk script. // // EMIT_BASE_PROPERTIES_GET_FUNCTIONS - virtual data_property get_xdata_property (void) const + virtual array_property get_xdata_property (void) const { error ("get: invalid property \"xdata\""); - return data_property (); + return array_property (); } - virtual data_property get_ydata_property (void) const + virtual array_property get_ydata_property (void) const { error ("get: invalid property \"ydata\""); - return data_property (); + return array_property (); } - virtual data_property get_zdata_property (void) const + virtual array_property get_zdata_property (void) const { error ("get: invalid property \"zdata\""); - return data_property (); + return array_property (); } - virtual data_property get_ldata_property (void) const + virtual array_property get_ldata_property (void) const { error ("get: invalid property \"ldata\""); - return data_property (); + return array_property (); } - virtual data_property get_udata_property (void) const + virtual array_property get_udata_property (void) const { error ("get: invalid property \"udata\""); - return data_property (); + return array_property (); } - virtual data_property get_xldata_property (void) const + virtual array_property get_xldata_property (void) const { error ("get: invalid property \"xldata\""); - return data_property (); + return array_property (); } - virtual data_property get_xudata_property (void) const + virtual array_property get_xudata_property (void) const { error ("get: invalid property \"xudata\""); - return data_property (); + return array_property (); } virtual array_property get_cdata_property (void) const @@ -2085,43 +2001,43 @@ // genprops.awk script. // // EMIT_GRAPHICS_OBJECT_GET_FUNCTIONS - data_property get_xdata_property (void) const + array_property get_xdata_property (void) const { const base_properties& props = get_properties (); return props.get_xdata_property (); } - data_property get_ydata_property (void) const + array_property get_ydata_property (void) const { const base_properties& props = get_properties (); return props.get_ydata_property (); } - data_property get_zdata_property (void) const + array_property get_zdata_property (void) const { const base_properties& props = get_properties (); return props.get_zdata_property (); } - data_property get_ldata_property (void) const + array_property get_ldata_property (void) const { const base_properties& props = get_properties (); return props.get_ldata_property (); } - data_property get_udata_property (void) const + array_property get_udata_property (void) const { const base_properties& props = get_properties (); return props.get_udata_property (); } - data_property get_xldata_property (void) const + array_property get_xldata_property (void) const { const base_properties& props = get_properties (); return props.get_xldata_property (); } - data_property get_xudata_property (void) const + array_property get_xudata_property (void) const { const base_properties& props = get_properties (); return props.get_xudata_property (); @@ -2851,13 +2767,13 @@ // ldata, udata, xldata, xudata, keylabel, interpreter BEGIN_PROPERTIES(line) - data_property xdata l , default_data () - data_property ydata l , default_data () - data_property zdata l , Matrix () - data_property ldata l , Matrix () - data_property udata l , Matrix () - data_property xldata l , Matrix () - data_property xudata l , Matrix () + row_vector_property xdata l , default_data () + row_vector_property ydata l , default_data () + row_vector_property zdata l , Matrix () + row_vector_property ldata l , Matrix () + row_vector_property udata l , Matrix () + row_vector_property xldata l , Matrix () + row_vector_property xudata l , Matrix () color_property color , color_values (0, 0, 0) radio_property linestyle , "{-}|--|:|-.|none" double_property linewidth , 0.5 @@ -2964,8 +2880,8 @@ // properties declarations. BEGIN_PROPERTIES(image) - data_property xdata l , Matrix () - data_property ydata l , Matrix () + row_vector_property xdata l , Matrix () + row_vector_property ydata l , Matrix () array_property cdata l , Matrix () radio_property cdatamapping a , "{scaled}|direct" END_PROPERTIES @@ -2973,6 +2889,8 @@ protected: void init (void) { + xdata.add_constraint (2); + ydata.add_constraint (2); cdata.add_constraint ("double"); cdata.add_constraint ("uint8"); cdata.add_constraint (dim_vector (-1, -1)); @@ -3013,13 +2931,13 @@ // properties declarations. BEGIN_PROPERTIES(patch) - data_property xdata l , Matrix () - data_property ydata l , Matrix () - data_property zdata l , Matrix () + array_property xdata l , Matrix () + array_property ydata l , Matrix () + array_property zdata l , Matrix () array_property cdata l , Matrix () radio_property cdatamapping , "{scaled}|direct" array_property faces , Matrix () - data_property facevertexalphadata , Matrix () + array_property facevertexalphadata , Matrix () array_property facevertexcdata , Matrix () array_property vertices , Matrix () array_property vertexnormals , Matrix () @@ -3050,12 +2968,16 @@ protected: void init (void) { + xdata.add_constraint (dim_vector (-1, -1)); + ydata.add_constraint (dim_vector (-1, -1)); + zdata.add_constraint (dim_vector (-1, -1)); vertices.add_constraint (dim_vector (-1, 2)); vertices.add_constraint (dim_vector (-1, 3)); cdata.add_constraint (dim_vector (-1, -1)); cdata.add_constraint (dim_vector (-1, -1, 3)); facevertexcdata.add_constraint (dim_vector (-1, 1)); facevertexcdata.add_constraint (dim_vector (-1, 3)); + facevertexalphadata.add_constraint (dim_vector (-1, 1)); } }; @@ -3092,9 +3014,9 @@ // properties declarations. BEGIN_PROPERTIES(surface) - data_property xdata lu , Matrix () - data_property ydata lu , Matrix () - data_property zdata lu , Matrix () + array_property xdata lu , Matrix () + array_property ydata lu , Matrix () + array_property zdata lu , Matrix () array_property cdata l , Matrix () radio_property cdatamapping a , "{scaled}|direct" color_property facecolor , "{flat}|none|interp|texturemap" @@ -3128,6 +3050,9 @@ protected: void init (void) { + xdata.add_constraint (dim_vector (-1, -1)); + ydata.add_constraint (dim_vector (-1, -1)); + zdata.add_constraint (dim_vector (-1, -1)); alphadata.add_constraint ("double"); alphadata.add_constraint ("uint8"); alphadata.add_constraint (dim_vector (-1, -1));