Mercurial > hg > octave-lyh
changeset 6432:5bec61ae1576
[project @ 2007-03-23 02:19:10 by jwe]
author | jwe |
---|---|
date | Fri, 23 Mar 2007 02:19:11 +0000 |
parents | ff87ad14403f |
children | 71c052b5ce47 |
files | scripts/ChangeLog scripts/plot/drawnow.m src/ChangeLog src/graphics.cc |
diffstat | 4 files changed, 174 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,5 +1,8 @@ 2007-03-22 John W. Eaton <jwe@octave.org> + * plot/drawnow.m: Check and optionally, set, the __modified__ + property of each figure. + * plot/__go_draw_axes__.m: If no real data, plot a point at Inf, Inf to show axes. From Daniel J Sebald <daniel.sebald@ieee.org>.
--- a/scripts/plot/drawnow.m +++ b/scripts/plot/drawnow.m @@ -46,16 +46,20 @@ for h = __go_figure_handles__ () if (! (isnan (h) || h == 0)) f = get (h); - plot_stream = f.__plot_stream__; - figure_is_visible = strcmp (f.visible, "on"); - if (figure_is_visible) - if (isempty (plot_stream)) - plot_stream = open_gnuplot_stream (h); + if (f.__modified__) + plot_stream = f.__plot_stream__; + figure_is_visible = strcmp (f.visible, "on"); + if (figure_is_visible) + if (isempty (plot_stream)) + plot_stream = open_gnuplot_stream (h); + endif + __go_draw_figure__ (f, plot_stream); + elseif (! isempty (plot_stream)) + pclose (plot_stream); + set (h, "__plot_stream__", []); endif - __go_draw_figure__ (f, plot_stream); - elseif (! isempty (plot_stream)) - pclose (plot_stream); - set (h, "__plot_stream__", []); + "setting" + set (h, "__modified__", false); endif __request_drawnow__ (false); endif
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,6 +1,29 @@ 2007-03-22 John W. Eaton <jwe@octave.org> - * src/parse.y (Fautoload): Use warning_with_id. + * graphics.cc (base_graphics_object::mark_modified): + New virtual function. + (base_properties::__modified__): New data member. + (base_properties::base_properties): Initialize it. + (graphics_object::mark_modified, base_properties::mark_modified, + root_figure::mark_modified, figure::mark_modified, + axes::mark_modified, line::mark_modified, text::mark_modified, + image::mark_modified, surface::mark_modified, + root_figure::root_figure_properties::mark_modified, + figure::figure_properties::mark_modified, + axes::axes_properties::mark_modified, + line::line_properties::mark_modified, + text::text_properties::mark_modified, + image::image_properties::mark_modified, + surface::surface_properties::mark_modified): New functions. + (figure::figure_properties::set, figure::figure_properties::get, + axes::axes_properties::set, axes::axes_properties::get, + line::line_properties::set, line::line_properties::get, + text::text_properties::set, text::text_properties::get, + image::image_properties::set, image::image_properties::get, + surface::surface_properties::set, surface::surface_properties::get): + Handle __modified__ property. + + * parse.y (Fautoload): Use warning_with_id. 2007-03-21 John W. Eaton <jwe@octave.org>
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -396,6 +396,11 @@ virtual ~base_graphics_object (void) { } + virtual void mark_modified (void) + { + error ("base_graphics_object::mark_modified: invalid graphics object"); + } + virtual void override_defaults (base_graphics_object&) { error ("base_graphics_object::override_defaults: invalid graphics object"); @@ -518,6 +523,8 @@ delete rep; } + void mark_modified (void) { rep->mark_modified (); } + void override_defaults (base_graphics_object& obj) { rep->override_defaults (obj); @@ -1001,12 +1008,20 @@ base_properties (const std::string& t = "unknown", const graphics_handle& mh = octave_NaN, const graphics_handle& p = octave_NaN) - : type (t), __myhandle__ (mh), parent (p), children () { } + : type (t), __modified__ (true), __myhandle__ (mh), parent (p), + children () { } virtual ~base_properties (void) { } virtual std::string graphics_object_name (void) const = 0; + void mark_modified (void) + { + __modified__ = true; + graphics_object parent_obj = gh_manager::get_object (parent); + parent_obj.mark_modified (); + } + void override_defaults (base_graphics_object& obj) { graphics_object parent_obj = gh_manager::get_object (parent); @@ -1119,6 +1134,7 @@ protected: std::string type; + bool __modified__; graphics_handle __myhandle__; graphics_handle parent; Matrix children; @@ -1212,6 +1228,8 @@ std::string type (void) const { return properties.graphics_object_name (); } + void mark_modified (void) { } + void override_defaults (base_graphics_object& obj) { // Now override with our defaults. If the default_properties @@ -1333,8 +1351,15 @@ void set (const property_name& name, const octave_value& val) { + bool modified = true; + if (name.compare ("children")) children = maybe_set_children (children, val); + else if (name.compare ("__modified__")) + { + __modified__ = val.bool_value (); + modified = false; + } else if (name.compare ("__plot_stream__")) __plot_stream__ = val; else if (name.compare ("nextplot")) @@ -1367,7 +1392,13 @@ else if (name.compare ("paperorientation")) paperorientation = val; else - warning ("set: invalid property `%s'", name.c_str ()); + { + modified = false; + warning ("set: invalid property `%s'", name.c_str ()); + } + + if (modified) + mark_modified (); } octave_value get (void) const @@ -1377,6 +1408,7 @@ m.assign ("type", type); m.assign ("parent", parent); m.assign ("children", children); + m.assign ("__modified__", __modified__); m.assign ("__plot_stream__", __plot_stream__); m.assign ("nextplot", nextplot); m.assign ("closerequestfcn", closerequestfcn); @@ -1398,6 +1430,8 @@ retval = parent; else if (name.compare ("children")) retval = children; + else if (name.compare ("__modified__")) + retval = __modified__; else if (name.compare ("__plot_stream__")) retval = __plot_stream__; else if (name.compare ("nextplot")) @@ -1443,7 +1477,7 @@ property_list::pval_map_type m; m["nextplot"] = "replace"; - // m["closerequestfcn"] = make_fcn_handle ("closereq"); + // m["closerequestfcn"] = make_fcn_handle ("closereq"); m["colormap"] = colormap_property (); m["visible"] = "on"; m["paperorientation"] = "portrait"; @@ -1480,6 +1514,8 @@ std::string type (void) const { return properties.graphics_object_name (); } + void mark_modified (void) { properties.mark_modified (); } + void override_defaults (base_graphics_object& obj) { // Allow parent (root figure) to override first (properties knows how @@ -1638,10 +1674,17 @@ void set (const property_name& name, const octave_value& val) { + bool modified = true; + if (name.compare ("parent")) set_parent (val); else if (name.compare ("children")) children = maybe_set_children (children, val); + else if (name.compare ("__modified__")) + { + __modified__ = val.bool_value (); + modified = false; + } else if (name.compare ("position")) position = val; else if (name.compare ("title")) @@ -1801,7 +1844,13 @@ else if (name.compare ("outerposition")) outerposition = val; else - warning ("set: invalid property `%s'", name.c_str ()); + { + modified = false; + warning ("set: invalid property `%s'", name.c_str ()); + } + + if (modified) + mark_modified (); } void set_defaults (base_graphics_object& obj, const std::string& mode) @@ -1895,6 +1944,7 @@ m.assign ("type", type); m.assign ("parent", parent); m.assign ("children", children); + m.assign ("__modified__", __modified__); m.assign ("position", position); m.assign ("title", title); m.assign ("box", box); @@ -1953,6 +2003,8 @@ retval = parent; else if (name.compare ("children")) retval = children; + else if (name.compare ("__modified__")) + retval = __modified__; else if (name.compare ("position")) retval = position; else if (name.compare ("title")) @@ -2229,6 +2281,8 @@ std::string type (void) const { return properties.graphics_object_name (); } + void mark_modified (void) { properties.mark_modified (); } + void override_defaults (base_graphics_object& obj) { // Allow parent (figure) to override first (properties knows how @@ -2357,10 +2411,17 @@ void set (const property_name& name, const octave_value& val) { + bool modified = true; + if (name.compare ("parent")) set_parent (val); else if (name.compare ("children")) children = maybe_set_children (children, val); + else if (name.compare ("__modified__")) + { + __modified__ = val.bool_value (); + modified = false; + } else if (name.compare ("xdata")) xdata = val; else if (name.compare ("ydata")) @@ -2388,7 +2449,13 @@ else if (name.compare ("keylabel")) keylabel = val; else - warning ("set: invalid property `%s'", name.c_str ()); + { + modified = false; + warning ("set: invalid property `%s'", name.c_str ()); + } + + if (modified) + mark_modified (); } octave_value get (void) const @@ -2398,6 +2465,7 @@ m.assign ("type", type); m.assign ("parent", parent); m.assign ("children", children); + m.assign ("__modified__", __modified__); m.assign ("xdata", xdata); m.assign ("ydata", ydata); m.assign ("zdata", zdata); @@ -2425,6 +2493,8 @@ retval = parent; else if (name.compare ("children")) retval = children; + else if (name.compare ("__modified__")) + retval = __modified__; else if (name.compare ("xdata")) retval = xdata; else if (name.compare ("ydata")) @@ -2511,6 +2581,8 @@ std::string type (void) const { return properties.graphics_object_name (); } + void mark_modified (void) { properties.mark_modified (); } + void override_defaults (base_graphics_object& obj) { // Allow parent (figure) to override first (properties knows how @@ -2571,10 +2643,17 @@ void set (const property_name& name, const octave_value& val) { + bool modified = true; + if (name.compare ("parent")) set_parent (val); else if (name.compare ("children")) children = maybe_set_children (children, val); + else if (name.compare ("__modified__")) + { + __modified__ = val.bool_value (); + modified = false; + } else if (name.compare ("string")) string = val; else if (name.compare ("units")) @@ -2584,7 +2663,13 @@ else if (name.compare ("horizontalalignment")) horizontalalignment = val; else - warning ("set: invalid property `%s'", name.c_str ()); + { + modified = false; + warning ("set: invalid property `%s'", name.c_str ()); + } + + if (modified) + mark_modified (); } octave_value get (void) const @@ -2594,6 +2679,7 @@ m.assign ("type", type); m.assign ("parent", parent); m.assign ("children", children); + m.assign ("__modified__", __modified__); m.assign ("string", string); m.assign ("units", units); m.assign ("position", position); @@ -2612,6 +2698,8 @@ retval = parent; else if (name.compare ("children")) retval = children; + else if (name.compare ("__modified__")) + retval = __modified__; else if (name.compare ("string")) retval = string; else if (name.compare ("units")) @@ -2662,6 +2750,8 @@ std::string type (void) const { return properties.graphics_object_name (); } + void mark_modified (void) { properties.mark_modified (); } + void override_defaults (base_graphics_object& obj) { // Allow parent (figure) to override first (properties knows how @@ -2721,10 +2811,17 @@ void set (const property_name& name, const octave_value& val) { + bool modified = true; + if (name.compare ("parent")) set_parent (val); else if (name.compare ("children")) children = maybe_set_children (children, val); + else if (name.compare ("__modified__")) + { + __modified__ = val.bool_value (); + modified = false; + } else if (name.compare ("cdata")) cdata = val; else if (name.compare ("xdata")) @@ -2732,7 +2829,13 @@ else if (name.compare ("ydata")) ydata = val; else - warning ("set: invalid property `%s'", name.c_str ()); + { + modified = false; + warning ("set: invalid property `%s'", name.c_str ()); + } + + if (modified) + mark_modified (); } octave_value get (void) const @@ -2742,6 +2845,7 @@ m.assign ("type", type); m.assign ("parent", parent); m.assign ("children", children); + m.assign ("__modified__", __modified__); m.assign ("cdata", cdata); m.assign ("xdata", xdata); m.assign ("ydata", ydata); @@ -2759,6 +2863,8 @@ retval = parent; else if (name.compare ("children")) retval = children; + else if (name.compare ("__modified__")) + retval = __modified__; else if (name.compare ("cdata")) retval = cdata; else if (name.compare ("xdata")) @@ -2805,6 +2911,8 @@ std::string type (void) const { return properties.graphics_object_name (); } + void mark_modified (void) { properties.mark_modified (); } + void override_defaults (base_graphics_object& obj) { // Allow parent (figure) to override first (properties knows how @@ -2865,10 +2973,17 @@ void set (const property_name& name, const octave_value& val) { + bool modified = true; + if (name.compare ("parent")) set_parent (val); else if (name.compare ("children")) children = maybe_set_children (children, val); + else if (name.compare ("__modified__")) + { + __modified__ = val.bool_value (); + modified = false; + } else if (name.compare ("xdata")) xdata = val; else if (name.compare ("ydata")) @@ -2878,7 +2993,13 @@ else if (name.compare ("keylabel")) keylabel = val; else - warning ("set: invalid property `%s'", name.c_str ()); + { + modified = false; + warning ("set: invalid property `%s'", name.c_str ()); + } + + if (modified) + mark_modified (); } octave_value get (void) const @@ -2888,6 +3009,7 @@ m.assign ("type", type); m.assign ("parent", parent); m.assign ("children", children); + m.assign ("__modified__", __modified__); m.assign ("xdata", xdata); m.assign ("ydata", ydata); m.assign ("zdata", zdata); @@ -2906,6 +3028,8 @@ retval = parent; else if (name.compare ("children")) retval = children; + else if (name.compare ("__modified__")) + retval = __modified__; else if (name.compare ("xdata")) retval = xdata; else if (name.compare ("ydata")) @@ -2956,6 +3080,8 @@ std::string type (void) const { return properties.graphics_object_name (); } + void mark_modified (void) { properties.mark_modified (); } + void override_defaults (base_graphics_object& obj) { // Allow parent (figure) to override first (properties knows how