[changeset] - improve clf() compatibility

classic Classic list List threaded Threaded
24 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[changeset] - improve clf() compatibility

bpabbott
Administrator
I sought to apply the new vectorized version of delete(), but  
discovered that clf() was limited in its compatibility with Matlab, so  
I addressed much of that as well.

To be fully compatible with Matlab, the defaults for the figure must  
be available, so that "clf reset" is able to restore the figure's  
properties to their default values (with the exception of "Position"  
and "Units").

Ben



changeset-clf.txt (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

Michael Goffioul
On Fri, Oct 10, 2008 at 2:18 AM, Ben Abbott <[hidden email]> wrote:
> I sought to apply the new vectorized version of delete(), but discovered
> that clf() was limited in its compatibility with Matlab, so I addressed much
> of that as well.
>
> To be fully compatible with Matlab, the defaults for the figure must be
> available, so that "clf reset" is able to restore the figure's properties to
> their default values (with the exception of "Position" and "Units").

What's missing here is probably "reset" function.

Michael.
Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

bpabbott
Administrator

On Oct 10, 2008, at 7:29 AM, Michael Goffioul wrote:

> On Fri, Oct 10, 2008 at 2:18 AM, Ben Abbott <[hidden email]> wrote:
>> I sought to apply the new vectorized version of delete(), but  
>> discovered
>> that clf() was limited in its compatibility with Matlab, so I  
>> addressed much
>> of that as well.
>>
>> To be fully compatible with Matlab, the defaults for the figure  
>> must be
>> available, so that "clf reset" is able to restore the figure's  
>> properties to
>> their default values (with the exception of "Position" and "Units").
>
> What's missing here is probably "reset" function.
>
> Michael.


Agreed.

If I had a method available to inquire as to what the defaults were,  
that would be easy enough to impement. Do you imply that I am already  
able to determine the default property values?

Ben





Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

Michael Goffioul
On Fri, Oct 10, 2008 at 1:46 PM, Ben Abbott <[hidden email]> wrote:

>> What's missing here is probably "reset" function.
>>
>> Michael.
>
>
> Agreed.
>
> If I had a method available to inquire as to what the defaults were, that
> would be easy enough to impement. Do you imply that I am already able to
> determine the default property values?

get(0, 'defaultfigurecolor') for instance

However, implementing this in m-code will probably be rather inefficient.
I guess a C++ implementation (maybe with some autogenerated code)
would be better suited.

Michael.
Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

bpabbott
Administrator

On Oct 10, 2008, at 7:54 AM, Michael Goffioul wrote:

> On Fri, Oct 10, 2008 at 1:46 PM, Ben Abbott <[hidden email]> wrote:
>>> What's missing here is probably "reset" function.
>>>
>>> Michael.
>>
>>
>> Agreed.
>>
>> If I had a method available to inquire as to what the defaults  
>> were, that
>> would be easy enough to impement. Do you imply that I am already  
>> able to
>> determine the default property values?
>
> get(0, 'defaultfigurecolor') for instance
>
> However, implementing this in m-code will probably be rather  
> inefficient.
> I guess a C++ implementation (maybe with some autogenerated code)
> would be better suited.
>
> Michael.

ok, that does work in Matlab, but not in Octave's 3.1.51+ branch. Does  
this functionality exist somewhere else?

Ben

Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

John W. Eaton-6
On 10-Oct-2008, Ben Abbott wrote:

|
| On Oct 10, 2008, at 7:54 AM, Michael Goffioul wrote:
|
| > On Fri, Oct 10, 2008 at 1:46 PM, Ben Abbott <[hidden email]> wrote:
| >>> What's missing here is probably "reset" function.
| >>>
| >>> Michael.
| >>
| >>
| >> Agreed.
| >>
| >> If I had a method available to inquire as to what the defaults  
| >> were, that
| >> would be easy enough to impement. Do you imply that I am already  
| >> able to
| >> determine the default property values?
| >
| > get(0, 'defaultfigurecolor') for instance
| >
| > However, implementing this in m-code will probably be rather  
| > inefficient.
| > I guess a C++ implementation (maybe with some autogenerated code)
| > would be better suited.
| >
| > Michael.
|
| ok, that does work in Matlab, but not in Octave's 3.1.51+ branch. Does  
| this functionality exist somewhere else?

However, setting default properties does work.  For example

  figure (1);
  get (1, "color")
    ==> [1, 1, 1]

  close ("all");

  set (0, "defaultfigurecolor", [0.1, 0.2, 0.3]);
  figure (1);
  get (1, "color")
    ==> [0.1, 0.2, 0.3]


I think getting defaults is just not completely implemented yet.  Some
things do work.  For example, I see

  set (0, "defaultfigurecolor", [0.1, 0.2, 0.3]);
  get (0, "default")
  ans =
  {
    defaultfigurecolor =

       0.20000   0.20000   0.20000

  }

  get (0, "defaultfigurecolor")
  ans =

     0.20000   0.20000   0.20000


but as you noted, this fails when the default has not been explicitly
set.  I guess that's just something that still needs to be done.

jwe
Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

bpabbott
Administrator
In reply to this post by bpabbott
On Friday, October 10, 2008, at 01:31PM, "John W. Eaton" <[hidden email]> wrote:

>On 10-Oct-2008, Ben Abbott wrote:
>
>|
>| On Oct 10, 2008, at 7:54 AM, Michael Goffioul wrote:
>|
>| > On Fri, Oct 10, 2008 at 1:46 PM, Ben Abbott <[hidden email]> wrote:
>| >>> What's missing here is probably "reset" function.
>| >>>
>| >>> Michael.
>| >>
>| >>
>| >> Agreed.
>| >>
>| >> If I had a method available to inquire as to what the defaults  
>| >> were, that
>| >> would be easy enough to impement. Do you imply that I am already  
>| >> able to
>| >> determine the default property values?
>| >
>| > get(0, 'defaultfigurecolor') for instance
>| >
>| > However, implementing this in m-code will probably be rather  
>| > inefficient.
>| > I guess a C++ implementation (maybe with some autogenerated code)
>| > would be better suited.
>| >
>| > Michael.
>|
>| ok, that does work in Matlab, but not in Octave's 3.1.51+ branch. Does  
>| this functionality exist somewhere else?
>
>However, setting default properties does work.  For example
>
>  figure (1);
>  get (1, "color")
>    ==> [1, 1, 1]
>
>  close ("all");
>
>  set (0, "defaultfigurecolor", [0.1, 0.2, 0.3]);
>  figure (1);
>  get (1, "color")
>    ==> [0.1, 0.2, 0.3]
>
>
>I think getting defaults is just not completely implemented yet.  Some
>things do work.  For example, I see
>
>  set (0, "defaultfigurecolor", [0.1, 0.2, 0.3]);
>  get (0, "default")
>  ans =
>  {
>    defaultfigurecolor =
>
>       0.20000   0.20000   0.20000
>
>  }
>
>  get (0, "defaultfigurecolor")
>  ans =
>
>     0.20000   0.20000   0.20000
>
>
>but as you noted, this fails when the default has not been explicitly
>set.  I guess that's just something that still needs to be done.
>
>jwe

heck, it appears all of the defaults could be handled by the functions that create them. Is that what should be done, or should the defaults be handled at a lower level.

Ben
Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

bpabbott
Administrator

On Oct 10, 2008, at 1:49 PM, Ben Abbott wrote:

> On Friday, October 10, 2008, at 01:31PM, "John W. Eaton" <[hidden email]
> > wrote:
>> On 10-Oct-2008, Ben Abbott wrote:
>>
>> |
>> | On Oct 10, 2008, at 7:54 AM, Michael Goffioul wrote:
>> |
>> | > On Fri, Oct 10, 2008 at 1:46 PM, Ben Abbott <[hidden email]>  
>> wrote:
>> | >>> What's missing here is probably "reset" function.
>> | >>>
>> | >>> Michael.
>> | >>
>> | >>
>> | >> Agreed.
>> | >>
>> | >> If I had a method available to inquire as to what the defaults
>> | >> were, that
>> | >> would be easy enough to impement. Do you imply that I am already
>> | >> able to
>> | >> determine the default property values?
>> | >
>> | > get(0, 'defaultfigurecolor') for instance
>> | >
>> | > However, implementing this in m-code will probably be rather
>> | > inefficient.
>> | > I guess a C++ implementation (maybe with some autogenerated code)
>> | > would be better suited.
>> | >
>> | > Michael.
>> |
>> | ok, that does work in Matlab, but not in Octave's 3.1.51+ branch.  
>> Does
>> | this functionality exist somewhere else?
>>
>> However, setting default properties does work.  For example
>>
>> figure (1);
>> get (1, "color")
>>   ==> [1, 1, 1]
>>
>> close ("all");
>>
>> set (0, "defaultfigurecolor", [0.1, 0.2, 0.3]);
>> figure (1);
>> get (1, "color")
>>   ==> [0.1, 0.2, 0.3]
>>
>>
>> I think getting defaults is just not completely implemented yet.  
>> Some
>> things do work.  For example, I see
>>
>> set (0, "defaultfigurecolor", [0.1, 0.2, 0.3]);
>> get (0, "default")
>> ans =
>> {
>>   defaultfigurecolor =
>>
>>      0.20000   0.20000   0.20000
>>
>> }
>>
>> get (0, "defaultfigurecolor")
>> ans =
>>
>>    0.20000   0.20000   0.20000
>>
>>
>> but as you noted, this fails when the default has not been explicitly
>> set.  I guess that's just something that still needs to be done.
>>
>> jwe
>
> heck, it appears all of the defaults could be handled by the  
> functions that create them. Is that what should be done, or should  
> the defaults be handled at a lower level.
>
> Ben
My inference regarding access to default property values was wrong.  
What is needed it a reset() function (likely built-in). I've requested  
such on another thread.

Additionally, when writing the changeset I submitted, I confused the  
"visible" property to be an indicator of handle visibility, rather  
than the object's visibility.

If I understand the visibility of handles correctly, allchild(h)  
returns all children, including those with hidden handles, and  
get(h,"children") returns the children with visible handles. Please  
correct me if I'm wrong.

If it is permissible to accept a changeset for clf() without the  
capability to reset the default propery values, please commit this  
one. Note that while I've included a call to reset(), it is not used  
unless requested.

Ben




changeset-clf.patch (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

John W. Eaton-6
On 20-Oct-2008, Ben Abbott wrote:

|
| On Oct 10, 2008, at 1:49 PM, Ben Abbott wrote:
|
| > On Friday, October 10, 2008, at 01:31PM, "John W. Eaton" <[hidden email]
| > > wrote:
| >> On 10-Oct-2008, Ben Abbott wrote:
| >>
| >> |
| >> | On Oct 10, 2008, at 7:54 AM, Michael Goffioul wrote:
| >> |
| >> | > On Fri, Oct 10, 2008 at 1:46 PM, Ben Abbott <[hidden email]>  
| >> wrote:
| >> | >>> What's missing here is probably "reset" function.
| >> | >>>
| >> | >>> Michael.
| >> | >>
| >> | >>
| >> | >> Agreed.
| >> | >>
| >> | >> If I had a method available to inquire as to what the defaults
| >> | >> were, that
| >> | >> would be easy enough to impement. Do you imply that I am already
| >> | >> able to
| >> | >> determine the default property values?
| >> | >
| >> | > get(0, 'defaultfigurecolor') for instance
| >> | >
| >> | > However, implementing this in m-code will probably be rather
| >> | > inefficient.
| >> | > I guess a C++ implementation (maybe with some autogenerated code)
| >> | > would be better suited.
| >> | >
| >> | > Michael.
| >> |
| >> | ok, that does work in Matlab, but not in Octave's 3.1.51+ branch.  
| >> Does
| >> | this functionality exist somewhere else?
| >>
| >> However, setting default properties does work.  For example
| >>
| >> figure (1);
| >> get (1, "color")
| >>   ==> [1, 1, 1]
| >>
| >> close ("all");
| >>
| >> set (0, "defaultfigurecolor", [0.1, 0.2, 0.3]);
| >> figure (1);
| >> get (1, "color")
| >>   ==> [0.1, 0.2, 0.3]
| >>
| >>
| >> I think getting defaults is just not completely implemented yet.  
| >> Some
| >> things do work.  For example, I see
| >>
| >> set (0, "defaultfigurecolor", [0.1, 0.2, 0.3]);
| >> get (0, "default")
| >> ans =
| >> {
| >>   defaultfigurecolor =
| >>
| >>      0.20000   0.20000   0.20000
| >>
| >> }
| >>
| >> get (0, "defaultfigurecolor")
| >> ans =
| >>
| >>    0.20000   0.20000   0.20000
| >>
| >>
| >> but as you noted, this fails when the default has not been explicitly
| >> set.  I guess that's just something that still needs to be done.
| >>
| >> jwe
| >
| > heck, it appears all of the defaults could be handled by the  
| > functions that create them. Is that what should be done, or should  
| > the defaults be handled at a lower level.
| >
| > Ben
|
| My inference regarding access to default property values was wrong.  
| What is needed it a reset() function (likely built-in). I've requested  
| such on another thread.
|
| Additionally, when writing the changeset I submitted, I confused the  
| "visible" property to be an indicator of handle visibility, rather  
| than the object's visibility.
|
| If I understand the visibility of handles correctly, allchild(h)  
| returns all children, including those with hidden handles, and  
| get(h,"children") returns the children with visible handles. Please  
| correct me if I'm wrong.
|
| If it is permissible to accept a changeset for clf() without the  
| capability to reset the default propery values, please commit this  
| one. Note that while I've included a call to reset(), it is not used  
| unless requested.

Before we apply this change, I think we need to fix the title, xlabel,
ylabel, and zlabel properties to be hidden children of the axes
object.  My best guess at how to do that is below, but it does not
quite work.  I don't have any more time to work on this problem, but I
thought I would post the diffs anyway to give anyone else who wants to
work on this a starting point.

jwe



diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,4 +1,23 @@
 2008-10-20  John W. Eaton  <[hidden email]>
+
+ * graphics.h.in (gh_manager::is_handle_visible): New function.
+ (axes::properites): Move title property after label properties.
+ (graphics_object::is_handle_visible): New function.
+ (base_properties::is_handle_visible): New function.
+ (base_properties): Mark children property with G.
+ * graphics.cc (base_property::get_children): New function.  Only
+ return handles that are visible.
+ (axes::properties::delete_text_child): Set handlevisibility to
+ "off" for newly created object and add it to the list of children.
+ (axes::properties::set_defaults): Don't explicitly delete xlabel,
+ ylabel, zlabel, and title handles.  Don't explicitly set children
+ to empty matrix.
+ (axes::properties::remove_child): Don't explicitly delete xlabel,
+ ylabel, zlabel, and title handles.
+ (axes::properties::remove_child): Always call remove_child on handle.
+ (axes::properties::init): Move here from graphics.h.in.  Set
+ handlevisibility to "off" for xlabel, ylabel, zlabel, and title
+ and add them to the list of children.
 
  * genprops.awk: Allow whitespace between BEGIN_PROPERTIES and
  opening paren.  Accept optional second argument for graphics
diff --git a/src/graphics.cc b/src/graphics.cc
--- a/src/graphics.cc
+++ b/src/graphics.cc
@@ -2133,6 +2133,54 @@
 
 // ---------------------------------------------------------------------
 
+void
+axes::properties::init (void)
+{
+  position.add_constraint (dim_vector (1, 4));
+  position.add_constraint (dim_vector (0, 0));
+  outerposition.add_constraint (dim_vector (1, 4));
+  colororder.add_constraint (dim_vector (-1, 3));
+  dataaspectratio.add_constraint (dim_vector (1, 3));
+  plotboxaspectratio.add_constraint (dim_vector (1, 3));
+  xlim.add_constraint (2);
+  ylim.add_constraint (2);
+  zlim.add_constraint (2);
+  clim.add_constraint (2);
+  alim.add_constraint (2);
+  xtick.add_constraint (dim_vector (1, -1));
+  ytick.add_constraint (dim_vector (1, -1));
+  ztick.add_constraint (dim_vector (1, -1));
+  Matrix vw (1, 2, 0);
+  vw(1) = 90;
+  view = vw;
+  view.add_constraint (dim_vector (1, 2));
+  cameraposition.add_constraint (dim_vector (1, 3));
+  Matrix upv (1, 3, 0.0);
+  upv(2) = 1.0;
+  cameraupvector = upv;
+  cameraupvector.add_constraint (dim_vector (1, 3));
+  currentpoint.add_constraint (dim_vector (2, 3));
+  ticklength.add_constraint (dim_vector (1, 2));
+  tightinset.add_constraint (dim_vector (1, 4));
+
+  x_zlim.resize (1, 2);
+  sx = "linear";
+  sy = "linear";
+  sz = "linear";
+
+  xset (xlabel.handle_value (), "handlevisibility", "off");
+  xset (ylabel.handle_value (), "handlevisibility", "off");
+  xset (zlabel.handle_value (), "handlevisibility", "off");
+
+  xset (title.handle_value (), "handlevisibility", "off");
+
+  adopt (xlabel.handle_value ());
+  adopt (ylabel.handle_value ());
+  adopt (zlabel.handle_value ());
+
+  adopt (title.handle_value ());
+}
+
 void
 axes::properties::sync_positions (void)
 {
@@ -2219,8 +2267,6 @@
 axes::properties::set_defaults (base_graphics_object& obj,
  const std::string& mode)
 {
-  delete_text_child (title);
-
   box = "on";
   key = "off";
   keybox = "off";
@@ -2244,10 +2290,6 @@
   ylimmode = "auto";
   zlimmode = "auto";
   climmode = "auto";
-
-  delete_text_child (xlabel);
-  delete_text_child (ylabel);
-  delete_text_child (zlabel);
 
   xgrid = "off";
   ygrid = "off";
@@ -2331,8 +2373,6 @@
 
   delete_children ();
 
-  children = Matrix ();
-
   update_transform ();
 
   override_defaults (obj);
@@ -2352,7 +2392,13 @@
     }
 
   if (! is_beingdeleted ())
-    hp = gh_manager::make_graphics_handle ("text", __myhandle__);
+    {
+      hp = gh_manager::make_graphics_handle ("text", __myhandle__);
+
+      xset (hp.handle_value (), "handlevisibility", "off");
+
+      adopt (hp.handle_value ());
+    }
 }
 
 void
@@ -2366,20 +2412,42 @@
     delete_text_child (ylabel);
   else if (zlabel.handle_value ().ok () && h == zlabel.handle_value ())
     delete_text_child (zlabel);
-  else
-    base_properties::remove_child (h);
+
+  base_properties::remove_child (h);
 }
 
 void
 axes::properties::delete_children (void)
 {
   base_properties::delete_children ();
-
-  delete_text_child (title);
-
-  delete_text_child (xlabel);
-  delete_text_child (ylabel);
-  delete_text_child (zlabel);
+}
+
+Matrix
+base_properties::get_children (void) const
+{
+  Matrix retval = children;
+  
+  graphics_object go = gh_manager::get_object (0);
+
+  root_figure::properties& props =
+      dynamic_cast<root_figure::properties&> (go.get_properties ());
+
+  if (! props.is_showhiddenhandles ())
+    {
+      octave_idx_type k = 0;
+
+      for (octave_idx_type i = 0; i < children.numel (); i++)
+ {
+  graphics_handle kid = children (i);
+
+  if (gh_manager::is_handle_visible (kid))
+    retval(k++) = children(i);
+ }
+
+      retval.resize (k, 1);
+    }
+
+  return retval;;
 }
 
 inline Matrix
diff --git a/src/graphics.h.in b/src/graphics.h.in
--- a/src/graphics.h.in
+++ b/src/graphics.h.in
@@ -1669,6 +1669,11 @@
   virtual bool is_zliminclude (void) const { return false; }
   virtual bool is_climinclude (void) const { return false; }
   virtual bool is_aliminclude (void) const { return false; }
+
+  bool is_handle_visible (void) const
+  {
+    return ! handlevisibility.is ("off");
+  }
 
 protected:
   void set_dynamic (const caseless_str&, const octave_value&);
@@ -1685,7 +1690,7 @@
     radio_property busyaction , "{queue}|cancel"
     callback_property buttondownfcn , Matrix ()
     // FIXME: use a property class for children
-    Matrix children fs , Matrix ()
+    Matrix children Gfs , Matrix ()
     bool_property clipping , "on"
     callback_property createfcn , Matrix ()
     callback_property deletefcn , Matrix ()
@@ -2070,6 +2075,9 @@
   
   bool is_aliminclude (void) const
   { return get_properties ().is_aliminclude (); }
+
+  bool is_handle_visible (void) const
+  { return get_properties ().is_handle_visible (); }
   
   graphics_backend get_backend (void) const { return rep->get_backend (); }
 
@@ -2543,7 +2551,6 @@
 
     BEGIN_PROPERTIES (axes)
       array_property position u , default_axes_position ()
-      handle_property title SOf , gh_manager::make_graphics_handle ("text", __myhandle__)
       bool_property box , "on"
       bool_property key , "off"
       bool_property keybox , "off"
@@ -2565,6 +2572,7 @@
       handle_property xlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__)
       handle_property ylabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__)
       handle_property zlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__)
+      handle_property title SOf , gh_manager::make_graphics_handle ("text", __myhandle__)
       bool_property xgrid , "off"
       bool_property ygrid , "off"
       bool_property zgrid , "off"
@@ -2643,40 +2651,7 @@
    END_PROPERTIES
 
   protected:
-    void init (void)
-      {
-        position.add_constraint (dim_vector (1, 4));
- position.add_constraint (dim_vector (0, 0));
-        outerposition.add_constraint (dim_vector (1, 4));
-        colororder.add_constraint (dim_vector (-1, 3));
-        dataaspectratio.add_constraint (dim_vector (1, 3));
-        plotboxaspectratio.add_constraint (dim_vector (1, 3));
- xlim.add_constraint (2);
- ylim.add_constraint (2);
- zlim.add_constraint (2);
- clim.add_constraint (2);
- alim.add_constraint (2);
-        xtick.add_constraint (dim_vector (1, -1));
-        ytick.add_constraint (dim_vector (1, -1));
-        ztick.add_constraint (dim_vector (1, -1));
-        Matrix vw (1, 2, 0);
-        vw(1) = 90;
-        view = vw;
-        view.add_constraint (dim_vector (1, 2));
- cameraposition.add_constraint (dim_vector (1, 3));
- Matrix upv (1, 3, 0.0);
- upv(2) = 1.0;
- cameraupvector = upv;
- cameraupvector.add_constraint (dim_vector (1, 3));
- currentpoint.add_constraint (dim_vector (2, 3));
- ticklength.add_constraint (dim_vector (1, 2));
- tightinset.add_constraint (dim_vector (1, 4));
-
- x_zlim.resize (1, 2);
- sx = "linear";
- sy = "linear";
- sz = "linear";
-      }
+    void init (void);
 
   private:
     void update_xscale (void) { sx = get_xscale (); }
@@ -3653,6 +3628,18 @@
     return (instance_ok () ?  instance->do_process_events (true) : 0);
   }
 
+  static bool is_handle_visible (const graphics_handle& h)
+  {
+    bool retval = false;
+
+    graphics_object go = get_object (h);
+
+    if (go.valid_object ())
+      retval = go.is_handle_visible ();
+
+    return retval;
+  }
+
 public:
   class autolock
   {
Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

bpabbott
Administrator

On Oct 20, 2008, at 11:07 PM, John W. Eaton wrote:

> On 20-Oct-2008, Ben Abbott wrote:
>
> |
> | On Oct 10, 2008, at 1:49 PM, Ben Abbott wrote:
> |
> | > On Friday, October 10, 2008, at 01:31PM, "John W. Eaton" <[hidden email]
> | > > wrote:
> | >> On 10-Oct-2008, Ben Abbott wrote:
> | >>
> | >> |
> | >> | On Oct 10, 2008, at 7:54 AM, Michael Goffioul wrote:
> | >> |
> | >> | > On Fri, Oct 10, 2008 at 1:46 PM, Ben Abbott  
> <[hidden email]>
> | >> wrote:
> | >> | >>> What's missing here is probably "reset" function.
> | >> | >>>
> | >> | >>> Michael.
> | >> | >>
> | >> | >>
> | >> | >> Agreed.
> | >> | >>
> | >> | >> If I had a method available to inquire as to what the  
> defaults
> | >> | >> were, that
> | >> | >> would be easy enough to impement. Do you imply that I am  
> already
> | >> | >> able to
> | >> | >> determine the default property values?
> | >> | >
> | >> | > get(0, 'defaultfigurecolor') for instance
> | >> | >
> | >> | > However, implementing this in m-code will probably be rather
> | >> | > inefficient.
> | >> | > I guess a C++ implementation (maybe with some autogenerated  
> code)
> | >> | > would be better suited.
> | >> | >
> | >> | > Michael.
> | >> |
> | >> | ok, that does work in Matlab, but not in Octave's 3.1.51+  
> branch.
> | >> Does
> | >> | this functionality exist somewhere else?
> | >>
> | >> However, setting default properties does work.  For example
> | >>
> | >> figure (1);
> | >> get (1, "color")
> | >>   ==> [1, 1, 1]
> | >>
> | >> close ("all");
> | >>
> | >> set (0, "defaultfigurecolor", [0.1, 0.2, 0.3]);
> | >> figure (1);
> | >> get (1, "color")
> | >>   ==> [0.1, 0.2, 0.3]
> | >>
> | >>
> | >> I think getting defaults is just not completely implemented yet.
> | >> Some
> | >> things do work.  For example, I see
> | >>
> | >> set (0, "defaultfigurecolor", [0.1, 0.2, 0.3]);
> | >> get (0, "default")
> | >> ans =
> | >> {
> | >>   defaultfigurecolor =
> | >>
> | >>      0.20000   0.20000   0.20000
> | >>
> | >> }
> | >>
> | >> get (0, "defaultfigurecolor")
> | >> ans =
> | >>
> | >>    0.20000   0.20000   0.20000
> | >>
> | >>
> | >> but as you noted, this fails when the default has not been  
> explicitly
> | >> set.  I guess that's just something that still needs to be done.
> | >>
> | >> jwe
> | >
> | > heck, it appears all of the defaults could be handled by the
> | > functions that create them. Is that what should be done, or should
> | > the defaults be handled at a lower level.
> | >
> | > Ben
> |
> | My inference regarding access to default property values was wrong.
> | What is needed it a reset() function (likely built-in). I've  
> requested
> | such on another thread.
> |
> | Additionally, when writing the changeset I submitted, I confused the
> | "visible" property to be an indicator of handle visibility, rather
> | than the object's visibility.
> |
> | If I understand the visibility of handles correctly, allchild(h)
> | returns all children, including those with hidden handles, and
> | get(h,"children") returns the children with visible handles. Please
> | correct me if I'm wrong.
> |
> | If it is permissible to accept a changeset for clf() without the
> | capability to reset the default propery values, please commit this
> | one. Note that while I've included a call to reset(), it is not used
> | unless requested.
>
> Before we apply this change, I think we need to fix the title, xlabel,
> ylabel, and zlabel properties to be hidden children of the axes
> object.  My best guess at how to do that is below, but it does not
> quite work.  I don't have any more time to work on this problem, but I
> thought I would post the diffs anyway to give anyone else who wants to
> work on this a starting point.
>
> jwe
>

Do I infer correctly that the x/y/zlabels are not presently hidden via  
set(hlabel,'HandleVisibility','off')?

... but by some alternative means?

Ben
Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

David Bateman-3
In reply to this post by John W. Eaton-6
John W. Eaton wrote:
> Before we apply this change, I think we need to fix the title, xlabel,
> ylabel, and zlabel properties to be hidden children of the axes
> object.  My best guess at how to do that is below, but it does not
> quite work.  I don't have any more time to work on this problem, but I
> thought I would post the diffs anyway to give anyone else who wants to
> work on this a starting point.
>
> jwe
>  
There are also other issues related to hidden children such as the
"BaseLine" of stem series, etc that cause issues with the "legend"
function as they aren't currently invisible.. So yes, I'd also like to
see this issue addressed. Could you give more information about what
exactly doesn't work with your patch?

Regards
David


--
David Bateman                                [hidden email]
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax)

The information contained in this communication has been classified as:

[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary

Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

John W. Eaton-6
On 21-Oct-2008, David Bateman wrote:

| There are also other issues related to hidden children such as the
| "BaseLine" of stem series, etc that cause issues with the "legend"
| function as they aren't currently invisible.. So yes, I'd also like to
| see this issue addressed. Could you give more information about what
| exactly doesn't work with your patch?

This appears to work properly:

  octave:1> get (gca (), "children")
  ans = [](0x1)
  octave:2> h = allchild (gca ())
  h =

    -5.4293
    -4.2588
    -3.3136
    -2.2985

  octave:3> get (h, "type")
  ans =

  {
    [1,1] = text
    [1,2] = text
    [1,3] = text
    [1,4] = text
  }

But the first example from "rundemos plot" fails with the following
error:

  /home/jwe/src/octave/scripts/plot/axis.m example 1: failed
  get: invalid handle (= -3.2606)
  error: get: invalid handle (= -2.92254)
  error: called from:
  error:   /home/jwe/src/octave/scripts/plot/__go_draw_axes__.m at line 77, column 9
  error:   /home/jwe/src/octave/scripts/plot/__go_draw_figure__.m at line 56, column 8
  error:   /home/jwe/src/octave/scripts/plot/gnuplot_drawnow.m at line 68, column 5
  error: input: reading user-input failed!
  error:   /home/jwe/src/octave/scripts/testfun/demo.m at line 111, column 7
  error:   /home/jwe/src/octave/scripts/testfun/rundemos.m at line 65, column 2
  error:   /home/jwe/src/octave/scripts/testfun/rundemos.m at line 52, column 5

I'll try to take a look at this now.

jwe
Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

John W. Eaton-6
In reply to this post by bpabbott
On 21-Oct-2008, Ben Abbott wrote:

| Do I infer correctly that the x/y/zlabels are not presently hidden via  
| set(hlabel,'HandleVisibility','off')?
|
| ... but by some alternative means?

Yes, the handlevisibility property is not set to off and you don't see
them in the list of children because tehy are never added to the array
of children.  When I first wrote the code for the axes object, I
didn't understand that these handles were stored in two places
(children plus {x,y,z}label and title) and that they were usually
hidden in the children property.

jwe
Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

John W. Eaton-6
In reply to this post by David Bateman-3
On 21-Oct-2008, David Bateman wrote:

| John W. Eaton wrote:
| > Before we apply this change, I think we need to fix the title, xlabel,
| > ylabel, and zlabel properties to be hidden children of the axes
| > object.  My best guess at how to do that is below, but it does not
| > quite work.  I don't have any more time to work on this problem, but I
| > thought I would post the diffs anyway to give anyone else who wants to
| > work on this a starting point.
| >
| > jwe
| >  
| There are also other issues related to hidden children such as the
| "BaseLine" of stem series, etc that cause issues with the "legend"
| function as they aren't currently invisible.. So yes, I'd also like to
| see this issue addressed. Could you give more information about what
| exactly doesn't work with your patch?

This version seems to work better.

I still see some strange behavior.


* Try

    demo plotyy
    demo quiver3

  Both of these demos seem to work OK if run separately in fresh Octave
  sessions, but plotyy seems to be leaving some state that causes
  quiver3 to fail with

  octave:2> demo quiver3
  quiver3 example 1:
   [x,y]=meshgrid (-1:0.1:1);
   z=sin(2*pi*sqrt(x.^2+y.^2));
   theta=2*pi*sqrt(x.^2+y.^2)+pi/2;
   quiver3(x,y,z,sin(theta),cos(theta),ones(size(z)));
   hold on;
   mesh(x,y,z);
   hold off;

  quiver3 example 1: failed
  get: invalid handle (= -1.22961)Press <enter> to continue:
  quiver3 example 2:
   [x, y, z] = peaks (25);
   surf (x, y, z);
   hold on;
   [u, v, w] = surfnorm (x, y, z / 10);
   h = quiver3 (x, y, z, u, v, w);
   set (h, "maxheadsize", 0.33);

  quiver3 example 2: failed
  get: invalid handle (= -1.22961)error: get: invalid handle (= -14.6238)
  error: called from:
  error:   /home/jwe/src/octave/scripts/plot/__go_draw_axes__.m at line 60, column 9
  error:   /home/jwe/src/octave/scripts/plot/__go_draw_figure__.m at line 58, column 8
  error:   /home/jwe/src/octave/scripts/plot/gnuplot_drawnow.m at line 66, column 5



* Try

    demo quiver3
    demo ribbon

  Both of these seem to work OK if run separately in fresh Octave
  sessions, but quiver3 seems to be leaving some state that causes
  ribbon to do the wrong thing.  Maybe this is a hold problem?  I
  haven't looked at it yet.



* The refreshdata demo does not seem to be working correctly for me.
  I'm seeing

    octave:1> demo refreshdata
    refreshdata example 1:
     x = 0:0.1:10;
     y = sin (x);
     plot (x, y, "ydatasource", "y");
     for i = 1 : 100
       pause(0.1)
       y = sin (x + 0.1 * i);
       refreshdata();
     endfor

    refreshdata example 1: failed
    `y' undefined near line 0 column 1octave:2>

jwe
Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

John W. Eaton-6
[With the changeset this time...]

On 21-Oct-2008, David Bateman wrote:

| John W. Eaton wrote:
| > Before we apply this change, I think we need to fix the title, xlabel,
| > ylabel, and zlabel properties to be hidden children of the axes
| > object.  My best guess at how to do that is below, but it does not
| > quite work.  I don't have any more time to work on this problem, but I
| > thought I would post the diffs anyway to give anyone else who wants to
| > work on this a starting point.
| >
| > jwe
| >  
| There are also other issues related to hidden children such as the
| "BaseLine" of stem series, etc that cause issues with the "legend"
| function as they aren't currently invisible.. So yes, I'd also like to
| see this issue addressed. Could you give more information about what
| exactly doesn't work with your patch?

This version seems to work better.

I still see some strange behavior.


* Try

    demo plotyy
    demo quiver3

  Both of these demos seem to work OK if run separately in fresh Octave
  sessions, but plotyy seems to be leaving some state that causes
  quiver3 to fail with

  octave:2> demo quiver3
  quiver3 example 1:
   [x,y]=meshgrid (-1:0.1:1);
   z=sin(2*pi*sqrt(x.^2+y.^2));
   theta=2*pi*sqrt(x.^2+y.^2)+pi/2;
   quiver3(x,y,z,sin(theta),cos(theta),ones(size(z)));
   hold on;
   mesh(x,y,z);
   hold off;

  quiver3 example 1: failed
  get: invalid handle (= -1.22961)Press <enter> to continue:
  quiver3 example 2:
   [x, y, z] = peaks (25);
   surf (x, y, z);
   hold on;
   [u, v, w] = surfnorm (x, y, z / 10);
   h = quiver3 (x, y, z, u, v, w);
   set (h, "maxheadsize", 0.33);

  quiver3 example 2: failed
  get: invalid handle (= -1.22961)error: get: invalid handle (= -14.6238)
  error: called from:
  error:   /home/jwe/src/octave/scripts/plot/__go_draw_axes__.m at line 60, column 9
  error:   /home/jwe/src/octave/scripts/plot/__go_draw_figure__.m at line 58, column 8
  error:   /home/jwe/src/octave/scripts/plot/gnuplot_drawnow.m at line 66, column 5



* Try

    demo quiver3
    demo ribbon

  Both of these seem to work OK if run separately in fresh Octave
  sessions, but quiver3 seems to be leaving some state that causes
  ribbon to do the wrong thing.  Maybe this is a hold problem?  I
  haven't looked at it yet.



* The refreshdata demo does not seem to be working correctly for me.
  I'm seeing

    octave:1> demo refreshdata
    refreshdata example 1:
     x = 0:0.1:10;
     y = sin (x);
     plot (x, y, "ydatasource", "y");
     for i = 1 : 100
       pause(0.1)
       y = sin (x + 0.1 * i);
       refreshdata();
     endfor

    refreshdata example 1: failed
    `y' undefined near line 0 column 1octave:2>

jwe



# HG changeset patch
# User John W. Eaton <[hidden email]>
# Date 1224612385 14400
# Node ID 1f429086565cd3e38e0db01a3be97126cfed4c63
# Parent  08bb643966858d025204676799c2f8d7d75f1f84
[mq]: hidden-children

diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,12 @@
+2008-10-21  John W. Eaton  <[hidden email]>
+
+ * plot/gnuplot_drawnow.m: Pass handle to __go_draw_figure__, not
+ struct.  Use get instead of examining struct fields directly.
+ * plot/__go_draw_figure__.m: First arg is now handle, not figure
+ object struct.  Use get instead of examining struct elements
+ directly.  Use allhild instead of looking at children field of
+ figure object struct.
+
 2008-10-20  Ben Abbott <[hidden email]>
 
  * plot/orient.m: Fix syntax error.
diff --git a/scripts/plot/__go_draw_figure__.m b/scripts/plot/__go_draw_figure__.m
--- a/scripts/plot/__go_draw_figure__.m
+++ b/scripts/plot/__go_draw_figure__.m
@@ -20,14 +20,16 @@
 
 ## Author: jwe
 
-function __go_draw_figure__ (f, plot_stream, enhanced, mono)
+function __go_draw_figure__ (h, plot_stream, enhanced, mono)
 
   if (nargin == 4)
-    if (strcmp (f.type, "figure"))
+    htype = get (h, "type");
+    if (strcmp (htype, "figure"))
 
       ## Set figure properties here?
 
-      kids = f.children;
+      ## Get complete list of children.
+      kids = allchild (h);
       nkids = length (kids);
 
       if (nkids > 0)
@@ -64,7 +66,7 @@
       endif
     else
       error ("__go_draw_figure__: expecting figure object, found `%s'",
-     f.type);
+     htype);
     endif
   else
     print_usage ();
diff --git a/scripts/plot/gnuplot_drawnow.m b/scripts/plot/gnuplot_drawnow.m
--- a/scripts/plot/gnuplot_drawnow.m
+++ b/scripts/plot/gnuplot_drawnow.m
@@ -34,16 +34,15 @@
   endif
 
   if (nargin >= 3 && nargin <= 5)
-    f = __get__ (h);
     plot_stream = [];
     fid = [];
     unwind_protect
       [plot_stream, enhanced] = open_gnuplot_stream (1, [], term, file);
-      __go_draw_figure__ (f, plot_stream, enhanced, mono);
+      __go_draw_figure__ (h, plot_stream, enhanced, mono);
       if (nargin == 5)
         fid = fopen (debug_file, "wb");
         enhanced = init_plot_stream (fid, [], term, file);
-        __go_draw_figure__ (f, fid, enhanced, mono);
+        __go_draw_figure__ (h, fid, enhanced, mono);
       endif
     unwind_protect_cleanup
       if (! isempty (plot_stream))
@@ -54,15 +53,14 @@
       endif
     end_unwind_protect
   elseif (nargin == 1)
-    f = __get__ (h);
-    plot_stream = f.__plot_stream__;
+    plot_stream = get (h, "__plot_stream__");
     if (isempty (plot_stream))
       [plot_stream, enhanced] = open_gnuplot_stream (2, h);
       set (h, "__enhanced__", enhanced);
     else
-      enhanced = f.__enhanced__;
+      enhanced = get (h, "__enhanced__");
     endif
-    __go_draw_figure__ (f, plot_stream (1), enhanced, mono);
+    __go_draw_figure__ (h, plot_stream (1), enhanced, mono);
     fflush (plot_stream (1));
   else
     print_usage ();
diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,4 +1,27 @@
-2008-10-20  John W. Eaton  <[hidden email]>
+2008-10-21  John W. Eaton  <[hidden email]>
+
+ * graphics.h.in (gh_manager::is_handle_visible): New function.
+ (axes::properites): Move title property after label properties.
+ (graphics_object::is_handle_visible): New function.
+ (base_properties::is_handle_visible): New function.
+ (base_properties): Mark children property with G.
+ * graphics.cc (axes::properties::set_text_child): New function.
+ (axes::properties::set_title, axes::properties::set_xlabel,
+ axes::properties::set_ylabel, axes::properties::set_zlabel): Use it.
+ (base_property::get_children): New function.  Only
+ return handles that are visible.
+ (axes::properties::delete_text_child): Set handlevisibility to
+ "off" for newly created object and add it to the list of children.
+ Call base_properties::remove_child on previous handle value.
+ (axes::properties::set_defaults): Don't explicitly delete xlabel,
+ ylabel, zlabel, and title handles.  Reinitialize them after
+ deleting children.
+ (axes::properties::remove_child): Don't explicitly delete xlabel,
+ ylabel, zlabel, and title handles.
+ (axes::properties::init): Move here from graphics.h.in.  Set
+ handlevisibility to "off" for xlabel, ylabel, zlabel, and title
+ and add them to the list of children.
+ (axes::properties::delete_children): Delete.
 
  * genprops.awk: Allow whitespace between BEGIN_PROPERTIES and
  opening paren.  Accept optional second argument for graphics
diff --git a/src/graphics.cc b/src/graphics.cc
--- a/src/graphics.cc
+++ b/src/graphics.cc
@@ -2133,6 +2133,54 @@
 
 // ---------------------------------------------------------------------
 
+void
+axes::properties::init (void)
+{
+  position.add_constraint (dim_vector (1, 4));
+  position.add_constraint (dim_vector (0, 0));
+  outerposition.add_constraint (dim_vector (1, 4));
+  colororder.add_constraint (dim_vector (-1, 3));
+  dataaspectratio.add_constraint (dim_vector (1, 3));
+  plotboxaspectratio.add_constraint (dim_vector (1, 3));
+  xlim.add_constraint (2);
+  ylim.add_constraint (2);
+  zlim.add_constraint (2);
+  clim.add_constraint (2);
+  alim.add_constraint (2);
+  xtick.add_constraint (dim_vector (1, -1));
+  ytick.add_constraint (dim_vector (1, -1));
+  ztick.add_constraint (dim_vector (1, -1));
+  Matrix vw (1, 2, 0);
+  vw(1) = 90;
+  view = vw;
+  view.add_constraint (dim_vector (1, 2));
+  cameraposition.add_constraint (dim_vector (1, 3));
+  Matrix upv (1, 3, 0.0);
+  upv(2) = 1.0;
+  cameraupvector = upv;
+  cameraupvector.add_constraint (dim_vector (1, 3));
+  currentpoint.add_constraint (dim_vector (2, 3));
+  ticklength.add_constraint (dim_vector (1, 2));
+  tightinset.add_constraint (dim_vector (1, 4));
+
+  x_zlim.resize (1, 2);
+  sx = "linear";
+  sy = "linear";
+  sz = "linear";
+
+  xset (xlabel.handle_value (), "handlevisibility", "off");
+  xset (ylabel.handle_value (), "handlevisibility", "off");
+  xset (zlabel.handle_value (), "handlevisibility", "off");
+
+  xset (title.handle_value (), "handlevisibility", "off");
+
+  adopt (xlabel.handle_value ());
+  adopt (ylabel.handle_value ());
+  adopt (zlabel.handle_value ());
+
+  adopt (title.handle_value ());
+}
+
 void
 axes::properties::sync_positions (void)
 {
@@ -2168,59 +2216,54 @@
 }
 
 void
+axes::properties::set_text_child (handle_property& hp,
+  const std::string& who,
+  const octave_value& v)
+{
+  graphics_handle val = ::reparent (v, "set", who, __myhandle__, false);
+
+  if (! error_state)
+    {
+      xset (val, "handlevisibility", "off");
+
+      gh_manager::free (hp.handle_value ());
+
+      base_properties::remove_child (hp.handle_value ());
+
+      hp = val;
+
+      adopt (hp.handle_value ());
+    }
+}
+
+void
+axes::properties::set_xlabel (const octave_value& v)
+{
+  set_text_child (xlabel, "xlabel", v);
+}
+
+void
+axes::properties::set_ylabel (const octave_value& v)
+{
+  set_text_child (ylabel, "ylabel", v);
+}
+
+void
+axes::properties::set_zlabel (const octave_value& v)
+{
+  set_text_child (zlabel, "zlabel", v);
+}
+
+void
 axes::properties::set_title (const octave_value& v)
 {
-  graphics_handle val = ::reparent (v, "set", "title", __myhandle__, false);
-
-  if (! error_state)
-    {
-      gh_manager::free (title.handle_value ());
-      title = val;
-    }
-}
-
-void
-axes::properties::set_xlabel (const octave_value& v)
-{
-  graphics_handle val = ::reparent (v, "set", "xlabel", __myhandle__, false);
-
-  if (! error_state)
-    {
-      gh_manager::free (xlabel.handle_value ());
-      xlabel = val;
-    }
-}
-
-void
-axes::properties::set_ylabel (const octave_value& v)
-{
-  graphics_handle val = ::reparent (v, "set", "ylabel", __myhandle__, false);
-
-  if (! error_state)
-    {
-      gh_manager::free (ylabel.handle_value ());
-      ylabel = val;
-    }
-}
-
-void
-axes::properties::set_zlabel (const octave_value& v)
-{
-  graphics_handle val = ::reparent (v, "set", "zlabel", __myhandle__, false);
-
-  if (! error_state)
-    {
-      gh_manager::free (zlabel.handle_value ());
-      zlabel = val;
-    }
+  set_text_child (title, "title", v);
 }
 
 void
 axes::properties::set_defaults (base_graphics_object& obj,
  const std::string& mode)
 {
-  delete_text_child (title);
-
   box = "on";
   key = "off";
   keybox = "off";
@@ -2244,10 +2287,6 @@
   ylimmode = "auto";
   zlimmode = "auto";
   climmode = "auto";
-
-  delete_text_child (xlabel);
-  delete_text_child (ylabel);
-  delete_text_child (zlabel);
 
   xgrid = "off";
   ygrid = "off";
@@ -2328,10 +2367,27 @@
       activepositionproperty = "outerposition";
     }
 
-
   delete_children ();
 
   children = Matrix ();
+
+  xlabel = gh_manager::make_graphics_handle ("text", __myhandle__, false);
+  ylabel = gh_manager::make_graphics_handle ("text", __myhandle__, false);
+  zlabel = gh_manager::make_graphics_handle ("text", __myhandle__, false);
+
+  title = gh_manager::make_graphics_handle ("text", __myhandle__, false);
+
+  xset (xlabel.handle_value (), "handlevisibility", "off");
+  xset (ylabel.handle_value (), "handlevisibility", "off");
+  xset (zlabel.handle_value (), "handlevisibility", "off");
+
+  xset (title.handle_value (), "handlevisibility", "off");
+
+  adopt (xlabel.handle_value ());
+  adopt (ylabel.handle_value ());
+  adopt (zlabel.handle_value ());
+
+  adopt (title.handle_value ());
 
   update_transform ();
 
@@ -2349,37 +2405,66 @@
 
       if (go.valid_object ())
  gh_manager::free (h);
-    }
+
+      base_properties::remove_child (h);
+    }
+
+  // FIXME -- is it necessary to check whether the axes object is
+  // being deleted now?  I think this function is only called when an
+  // individual child object is delete and not when the parent axes
+  // object is deleted.
 
   if (! is_beingdeleted ())
-    hp = gh_manager::make_graphics_handle ("text", __myhandle__);
+    {
+      hp = gh_manager::make_graphics_handle ("text", __myhandle__, false);
+
+      xset (hp.handle_value (), "handlevisibility", "off");
+
+      adopt (hp.handle_value ());
+    }
 }
 
 void
 axes::properties::remove_child (const graphics_handle& h)
 {
-  if (title.handle_value ().ok () && h == title.handle_value ())
-    delete_text_child (title);
-  else if (xlabel.handle_value ().ok () && h == xlabel.handle_value ())
+  if (xlabel.handle_value ().ok () && h == xlabel.handle_value ())
     delete_text_child (xlabel);
   else if (ylabel.handle_value ().ok () && h == ylabel.handle_value ())
     delete_text_child (ylabel);
   else if (zlabel.handle_value ().ok () && h == zlabel.handle_value ())
     delete_text_child (zlabel);
+  else if (title.handle_value ().ok () && h == title.handle_value ())
+    delete_text_child (title);
   else
     base_properties::remove_child (h);
 }
 
-void
-axes::properties::delete_children (void)
-{
-  base_properties::delete_children ();
-
-  delete_text_child (title);
-
-  delete_text_child (xlabel);
-  delete_text_child (ylabel);
-  delete_text_child (zlabel);
+Matrix
+base_properties::get_children (void) const
+{
+  Matrix retval = children;
+  
+  graphics_object go = gh_manager::get_object (0);
+
+  root_figure::properties& props =
+      dynamic_cast<root_figure::properties&> (go.get_properties ());
+
+  if (! props.is_showhiddenhandles ())
+    {
+      octave_idx_type k = 0;
+
+      for (octave_idx_type i = 0; i < children.numel (); i++)
+ {
+  graphics_handle kid = children (i);
+
+  if (gh_manager::is_handle_visible (kid))
+    retval(k++) = children(i);
+ }
+
+      retval.resize (k, 1);
+    }
+
+  return retval;;
 }
 
 inline Matrix
diff --git a/src/graphics.h.in b/src/graphics.h.in
--- a/src/graphics.h.in
+++ b/src/graphics.h.in
@@ -1669,6 +1669,11 @@
   virtual bool is_zliminclude (void) const { return false; }
   virtual bool is_climinclude (void) const { return false; }
   virtual bool is_aliminclude (void) const { return false; }
+
+  bool is_handle_visible (void) const
+  {
+    return ! handlevisibility.is ("off");
+  }
 
 protected:
   void set_dynamic (const caseless_str&, const octave_value&);
@@ -1685,7 +1690,7 @@
     radio_property busyaction , "{queue}|cancel"
     callback_property buttondownfcn , Matrix ()
     // FIXME: use a property class for children
-    Matrix children fs , Matrix ()
+    Matrix children Gfs , Matrix ()
     bool_property clipping , "on"
     callback_property createfcn , Matrix ()
     callback_property deletefcn , Matrix ()
@@ -2070,6 +2075,9 @@
   
   bool is_aliminclude (void) const
   { return get_properties ().is_aliminclude (); }
+
+  bool is_handle_visible (void) const
+  { return get_properties ().is_handle_visible (); }
   
   graphics_backend get_backend (void) const { return rep->get_backend (); }
 
@@ -2534,6 +2542,9 @@
     Matrix x_zlim;
     std::list<octave_value> zoom_stack;
 
+    void set_text_child (handle_property& h, const std::string& who,
+ const octave_value& v);
+
     void delete_text_child (handle_property& h);
 
     // See the genprops.awk script for an explanation of the
@@ -2543,7 +2554,6 @@
 
     BEGIN_PROPERTIES (axes)
       array_property position u , default_axes_position ()
-      handle_property title SOf , gh_manager::make_graphics_handle ("text", __myhandle__)
       bool_property box , "on"
       bool_property key , "off"
       bool_property keybox , "off"
@@ -2562,9 +2572,10 @@
       radio_property zlimmode al , "{auto}|manual"
       radio_property climmode al , "{auto}|manual"
       radio_property alimmode    , "{auto}|manual"
-      handle_property xlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__)
-      handle_property ylabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__)
-      handle_property zlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__)
+      handle_property xlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false)
+      handle_property ylabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false)
+      handle_property zlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false)
+      handle_property title SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false)
       bool_property xgrid , "off"
       bool_property ygrid , "off"
       bool_property zgrid , "off"
@@ -2643,40 +2654,7 @@
    END_PROPERTIES
 
   protected:
-    void init (void)
-      {
-        position.add_constraint (dim_vector (1, 4));
- position.add_constraint (dim_vector (0, 0));
-        outerposition.add_constraint (dim_vector (1, 4));
-        colororder.add_constraint (dim_vector (-1, 3));
-        dataaspectratio.add_constraint (dim_vector (1, 3));
-        plotboxaspectratio.add_constraint (dim_vector (1, 3));
- xlim.add_constraint (2);
- ylim.add_constraint (2);
- zlim.add_constraint (2);
- clim.add_constraint (2);
- alim.add_constraint (2);
-        xtick.add_constraint (dim_vector (1, -1));
-        ytick.add_constraint (dim_vector (1, -1));
-        ztick.add_constraint (dim_vector (1, -1));
-        Matrix vw (1, 2, 0);
-        vw(1) = 90;
-        view = vw;
-        view.add_constraint (dim_vector (1, 2));
- cameraposition.add_constraint (dim_vector (1, 3));
- Matrix upv (1, 3, 0.0);
- upv(2) = 1.0;
- cameraupvector = upv;
- cameraupvector.add_constraint (dim_vector (1, 3));
- currentpoint.add_constraint (dim_vector (2, 3));
- ticklength.add_constraint (dim_vector (1, 2));
- tightinset.add_constraint (dim_vector (1, 4));
-
- x_zlim.resize (1, 2);
- sx = "linear";
- sy = "linear";
- sz = "linear";
-      }
+    void init (void);
 
   private:
     void update_xscale (void) { sx = get_xscale (); }
@@ -3653,6 +3631,18 @@
     return (instance_ok () ?  instance->do_process_events (true) : 0);
   }
 
+  static bool is_handle_visible (const graphics_handle& h)
+  {
+    bool retval = false;
+
+    graphics_object go = get_object (h);
+
+    if (go.valid_object ())
+      retval = go.is_handle_visible ();
+
+    return retval;
+  }
+
 public:
   class autolock
   {
Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

John W. Eaton-6
In reply to this post by bpabbott
On 20-Oct-2008, Ben Abbott wrote:

| My inference regarding access to default property values was wrong.  
| What is needed it a reset() function (likely built-in). I've requested  
| such on another thread.
|
| Additionally, when writing the changeset I submitted, I confused the  
| "visible" property to be an indicator of handle visibility, rather  
| than the object's visibility.
|
| If I understand the visibility of handles correctly, allchild(h)  
| returns all children, including those with hidden handles, and  
| get(h,"children") returns the children with visible handles. Please  
| correct me if I'm wrong.
|
| If it is permissible to accept a changeset for clf() without the  
| capability to reset the default propery values, please commit this  
| one. Note that while I've included a call to reset(), it is not used  
| unless requested.

I applied it.  Now someone needs to write the reset function...

Thanks,

jwe
Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

John W. Eaton-6
In reply to this post by John W. Eaton-6
On 21-Oct-2008, John W. Eaton wrote:

| * Try
|
|     demo quiver3
|     demo ribbon
|
|   Both of these seem to work OK if run separately in fresh Octave
|   sessions, but quiver3 seems to be leaving some state that causes
|   ribbon to do the wrong thing.  Maybe this is a hold problem?  I
|   haven't looked at it yet.

OK, this one was trivial.  I applied the following patch.

jwe


# HG changeset patch
# User John W. Eaton <[hidden email]>
# Date 1224618553 14400
# Node ID 873ea2c72f16b4f089d721809b419c3c5cc522bb
# Parent  b12a2975bf7e1b32b25fd8ea9912f346076d90ec
quiver3.m: turn hold off after demo

diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -3,6 +3,8 @@
  * plot/clf.m: Improve Matlab compatibility.
 
 2008-10-21  John W. Eaton  <[hidden email]>
+
+ * plot/quiver3.m: Turn hold off after demo.
 
  * plot/newplot.m: Delete stray debugging code.
 
diff --git a/scripts/plot/quiver3.m b/scripts/plot/quiver3.m
--- a/scripts/plot/quiver3.m
+++ b/scripts/plot/quiver3.m
@@ -100,3 +100,4 @@
 %! [u, v, w] = surfnorm (x, y, z / 10);
 %! h = quiver3 (x, y, z, u, v, w);
 %! set (h, "maxheadsize", 0.33);
+%! hold off;
Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

David Bateman-2
In reply to this post by John W. Eaton-6
John W. Eaton wrote:

> * The refreshdata demo does not seem to be working correctly for me.
>   I'm seeing
>
>     octave:1> demo refreshdata
>     refreshdata example 1:
>      x = 0:0.1:10;
>      y = sin (x);
>      plot (x, y, "ydatasource", "y");
>      for i = 1 : 100
>        pause(0.1)
>        y = sin (x + 0.1 * i);
>        refreshdata();
>      endfor
>
>     refreshdata example 1: failed
>     `y' undefined near line 0 column 1octave:2>


Strange, run from the command line as

x=0:0.1:10;y=sin(x); plot(x,y,"ydatasource","y"); for i = 1:100,
pause(0.1); y = sin(x + 0.1*x); refreshdata(); endfor

it works fine.. Not sure yet what is going on here.

D.
--
David Bateman                                [hidden email]
35 rue Gambetta                              +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE            +33 6 72 01 06 33 (Mob)
Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

David Bateman-3
David Bateman wrote:

> John W. Eaton wrote:
>> * The refreshdata demo does not seem to be working correctly for me.
>>   I'm seeing
>>
>>     octave:1> demo refreshdata
>>     refreshdata example 1:
>>      x = 0:0.1:10;
>>      y = sin (x);
>>      plot (x, y, "ydatasource", "y");
>>      for i = 1 : 100
>>        pause(0.1)
>>        y = sin (x + 0.1 * i);
>>        refreshdata();
>>      endfor
>>
>>     refreshdata example 1: failed
>>     `y' undefined near line 0 column 1octave:2>
>
>
> Strange, run from the command line as
>
> x=0:0.1:10;y=sin(x); plot(x,y,"ydatasource","y"); for i = 1:100,
> pause(0.1); y = sin(x + 0.1*x); refreshdata(); endfor
>
> it works fine.. Not sure yet what is going on here.
>
> D.
Ok, this is in fact obvious.. refreshdata by default evaluates its
arguments in the "base" workspace and in a demo script it needs to do it
in the "caller" workspace.. Patch attached and pushed to Savannah..

D.

--
David Bateman                                [hidden email]
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax)

The information contained in this communication has been classified as:

[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary


# HG changeset patch
# User David Bateman <[hidden email]>
# Date 1224677452 -3600
# Node ID b7d2a51e04c4b5e301e7cfa3e95a218acb4d2c11
# Parent  e364f5be1236491c10c3637ac0ed703b122edb8a
Fix for refreshdata demo

diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,4 +1,7 @@
 2008-10-22  David Bateman  <[hidden email]>
+
+ * plot/refreshdata.m: Modify demo so that "y" is evaluated in the
+ "caller" workspace.
 
  * plot/__errplot__.m: Add errorbar series objects.
  * plot/errbar.m: Add some demos.
diff --git a/scripts/plot/refreshdata.m b/scripts/plot/refreshdata.m
--- a/scripts/plot/refreshdata.m
+++ b/scripts/plot/refreshdata.m
@@ -103,5 +103,5 @@
 %! for i = 1 : 100
 %!   pause(0.1)
 %!   y = sin (x + 0.1 * i);
-%!   refreshdata();
+%!   refreshdata(gcf(), "caller");
 %! endfor
Reply | Threaded
Open this post in threaded view
|

Re: [changeset] - improve clf() compatibility

John W. Eaton-6
On 22-Oct-2008, David Bateman wrote:

| Ok, this is in fact obvious.. refreshdata by default evaluates its
| arguments in the "base" workspace and in a demo script it needs to do it
| in the "caller" workspace.. Patch attached and pushed to Savannah..

Thanks.

OK, now I am only seeing failures for the following sequences of
commands:

  demo plotyy
  demo quiver3
  [...]
  quiver3 example 1: failed
  get: invalid handle (= -1.45621)Press <enter> to continue:
  quiver3 example 2:
   [x, y, z] = peaks (25);
   surf (x, y, z);
   hold on;
   [u, v, w] = surfnorm (x, y, z / 10);
   h = quiver3 (x, y, z, u, v, w);
   set (h, "maxheadsize", 0.33);
   hold off;

  quiver3 example 2: failed
  get: invalid handle (= -1.45621)error: get: invalid handle (= -12.7459)
  error: called from:
  error:   /home/jwe/src/octave/scripts/plot/__go_draw_axes__.m at line 60, column 9
  error:   /home/jwe/src/octave/scripts/plot/__go_draw_figure__.m at line 58, column 8
  error:   /home/jwe/src/octave/scripts/plot/gnuplot_drawnow.m at line 66, column 5

and

  demo scatter3
  demo shading
  [...]
  shading example 1: failed
  axes: expecting argument to be a scalar axes handle

and

  demo stem
  demo stem3
  demo surfnorm
  [...]
  warning: implicit conversion from matrix to real vector
  surfnorm example 1: failed

  Invalid call to any.  Correct usage is:

   -- Built-in Function:  any (X, DIM)


  Additional help for built-in functions and operators is
  available in the on-line version of the manual.  Use the command
  `doc <topic>' to search the manual index.

  Help and information about Octave is also available on the WWW
  at http://www.octave.org and via the [hidden email]
  mailing list.
  error: get: invalid handle (= -9.13597)
  error: called from:
  error:   /home/jwe/src/octave/scripts/plot/__go_draw_axes__.m at line 60, column 9
  error:   /home/jwe/src/octave/scripts/plot/__go_draw_figure__.m at line 58, column 8
  error:   /home/jwe/src/octave/scripts/plot/gnuplot_drawnow.m at line 66, column 5
  error: input: reading user-input failed!
  error:   /home/jwe/src/octave/scripts/testfun/demo.m at line 111, column 7

Oddly,

  demo stem
  demo surfnorm

and

  demo stem3
  demo surfnorm

appear to work correctly.

jwe
12