bugGNU Octave - Bugs: bug #39813, rectangle(..., 'Parent', hg) not...

 
 

bug #39813: rectangle(..., 'Parent', hg) not working for group objects

Submitter:  Muhali <muhali>
Submitted:  Mon 19 Aug 2013 09:04:13 AM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  rik5
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 22 Oct 2013 07:30:52 PM UTC, comment #8: 

Thanks for testing.  I think this issue is settled.

Rik <rik5>
Group administrator
Tue 22 Oct 2013 06:39:47 PM UTC, comment #7: 

For your test: only "ishandle (li0)" returns false.

The rule I could draw is:
 - if hgsave is an axes: children are deleted, brothers preserved
 - else: all the ancestor axes' children are deleted except the oldest (gran)parent of hgsave with all its descendance (including hgsave's (gran)uncles and brothers).

See the result of the following test


hf = figure (1234), clf;
li = [];
hg = [];
hax = axes (); hold on;
levels = 6;

for ii = 1:levels
  if ii == 1
    hg(ii) = hggroup ();
    li(ii) = line (1:10, 1:10);
  else
    hg(ii) = hggroup ('parent', hg(ii-1));
    li(ii) = line (1:10, 1:10, 'parent', hg(ii-1));
  end
end

uncles = li(1:end-1);
brother = hg(end);
hold off;
newplot (li(end))
ishandle(uncles)
ishandle(brother)

### result

ans =

     0     1     1     1     1


ans =

     1


This is also what we currently obtain in octave with the most recent changesets you pushed.

Pantxo Diribarne <pantxo>
Group Member
Tue 22 Oct 2013 03:51:02 PM UTC, comment #6: 

Pantxo,

I applied your patch for newplot and _plt_get_axis__arg_.  To get everything to work I had to modify the strategy a bit.  _plt_get_axis_arg_ now always returns a valid axis handle in the first position, and any other handles, such as an hggroup handle, come afterwards.  This keeps existing routines working.  newplot() was modified to accept a vector of handles instead of just a single handle.  I also copied the code that searches for handles to save from the "replace" case to the "replacechildren" case as well since that seemed reasonable.  Finally, with those changes in place I was able to fix this bug.  The three changesets are <http://hg.savannah.gnu.org/hgweb/octave/rev/ed9a21a90221>, <http://hg.savannah.gnu.org/hgweb/octave/rev/1ab8e21d9cfc>, <http://hg.savannah.gnu.org/hgweb/octave/rev/f0bc865db55f>.

Final question, did you test the save handle code in newplot against Matlab?  The current code saves uncles, as well as parents, along the tree from the toplevel figure down to a saved handle.  It seems more reasonable, although perhaps harder to code, to save only the direct path from figure down to saved handle.

Using the test code from newplot that you wrote:


hf = figure;
hax = axes ();
hold on;
hg1 = hggroup ();
hg2 = hggroup ("parent", hg1);
li0 = line (1:10, 1:10);
li1 = line (1:10, -1:-1:-10, "parent", hg1);
li2 = line (1:10, sin (1:10), "parent", hg2);
hold off;
newplot (hg2);


Does li1 exist at this point [ishandle (li1)] since it is an uncle to hg2?  Or does the Matlab newplot keep only hf->hax->hg1->hg2.  And does Matlab newplot preserve the children of the saved handle [ishandle (li2)] or just the actual named handle li2 and its parents?


Rik <rik5>
Group administrator
Wed 09 Oct 2013 01:47:52 PM UTC, comment #5: 

Pantxo, I think your analysis is correct.  I need to think a bit about the problem before committing your patch.

Rik <rik5>
Group administrator
Mon 23 Sep 2013 05:57:13 PM UTC, comment #4: 

As an implementation example, attached is a patch:
 - newplot is modified to accept and preserve any kind of input handle
 - _get_axis_args_ is modified to return the parent handle when one is specified in prop/val pairs. The new behavior is contradictory with the function name, which maybe confusing.

Tests in scripts/plot still pass.




(file #29204)

Pantxo Diribarne <pantxo>
Group Member
Sun 22 Sep 2013 06:06:37 PM UTC, comment #3: 

I think the problem lies in the use of "newplot" : when the axes "nextplot" property has value "replace" (which is the case by default), all the axes children including the hggroup are deleted. The following code works well for me: 


hg = hggroup;
set (gca, "nextplot", "add")
rectangle ('Position', [0.05, 0.05, 0.9, 0.9], 'Curvature', [0.5, 0.5], 'Parent', hg);


The newplot function should probably be called with the parent handle as hsave argument (whether an axes or a hggroup).  A way to achieve this could be to have plt_get_axis_arg return an additionnal argument HPAR (parent handle).



 


Pantxo Diribarne <pantxo>
Group Member
Mon 09 Sep 2013 11:56:09 PM UTC, comment #2: 

The problem, not quite sure how to resolve it, is with _plt_get_axis_arg_ which is grabbing the parent/handle property and interpreting it to mean the axis handle of hg.

Rik <rik5>
Group administrator
Tue 20 Aug 2013 10:29:01 AM UTC, comment #1: 

The obvious reason is the double use of 'parent' in l. 151


  h = patch ("xdata", x(:), "ydata", y(:), "facecolor", fc, "edgecolor", ec, ...
             "parent", hg, varargin{:});


Muhali <muhali>
Mon 19 Aug 2013 09:04:13 AM UTC, original submission:  

Defining a group object as a 'Parent' to the rectangle function does not work, e.g.


hg = hggroup;
rectangle ('Position', [0.05, 0.05, 0.9, 0.9], 'Curvature', [0.5, 0.5], 'Parent', hg);


This may be related to this bug.

Muhali <muhali>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #29204:  newplot_get_plt.diff added by pantxo (3KiB - text/x-patch)

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by muhali (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-10-22 rik5 StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2013-10-17 rik5 StatusConfirmed In Progress
        Assigned toNone rik5
    2013-10-09 rik5 Dependencies- Depends on bugs #40214
    2013-09-23 pantxo Attached File- Added newplot_get_plt.diff, #29204
    2013-09-09 rik5 StatusNeed Info Confirmed
    2013-09-09 rik5 StatusNone Need Info
    2013-09-04 mtmiller CategoryNone Plotting
        Item GroupNone Incorrect Result

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code