octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new snapshot (2.9.10)


From: John W. Eaton
Subject: Re: new snapshot (2.9.10)
Date: Thu, 22 Mar 2007 22:18:56 -0400

On 22-Mar-2007, Daniel J Sebald wrote:

| John W. Eaton wrote:
| > Are there any pending changes that are important enough to prevent
| > making a new snapshot?  If any major problems show up in 2.9.10, we
| > can make another one soon.  I'd like to start trying to stablize
| > things for a 3.0 release.
| > 
| > Comments?
| 
| Is the "figure redraw" as it should be?  Try
| 
| x=1:0.01:10
| figure(1)
| plot(x,sin(x))
| figure(2)
| plot(x,sin(x))
| 
| After switching to figure 2 and plotting, Octave then redraws figure 1 which 
| causes the window for figure 1 to come forward.  There's no reason to redraw 
| figure 1, is there?

I checked in the following patch to attempt to avoid redrawing figures
that have not changed since the last call to drawnow.

Thanks,

jwe


scripts/ChangeLog:

2007-03-22  John W. Eaton  <address@hidden>

        * plot/drawnow.m: Check and optionally, set, the __modified__
        property of each figure.


src/ChangeLog:

2007-03-22  John W. Eaton  <address@hidden>

        * 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.


Index: scripts/plot/drawnow.m
===================================================================
RCS file: /cvs/octave/scripts/plot/drawnow.m,v
retrieving revision 1.11
diff -u -u -r1.11 drawnow.m
--- scripts/plot/drawnow.m      21 Mar 2007 15:57:19 -0000      1.11
+++ scripts/plot/drawnow.m      23 Mar 2007 02:11:01 -0000
@@ -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
Index: src/graphics.cc
===================================================================
RCS file: /cvs/octave/src/graphics.cc,v
retrieving revision 1.3
diff -u -u -r1.3 graphics.cc
--- src/graphics.cc     21 Mar 2007 15:57:19 -0000      1.3
+++ src/graphics.cc     23 Mar 2007 02:11:01 -0000
@@ -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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]