Sun 22 Nov 2015 01:59:40 AM UTC, comment #2:
Afterwards, I got a workaround, where I can grab all hidden handle indices, set them visible, turn off the ShowHiddenHandles flag, reorder the children, then set those handles back to being hidden.
Thus, I can replace this:
kk_h = get(gca,'children');
set(gca,'children',[kk_h(2);kk_h(3:length(kk_h));kk_h(1)]);
with:
kk_h = get(gca,'children');
kk_inv = strcmp('off', get(kk_h, 'HandleVisibility'));
set(kk_h(kk_inv), 'HandleVisibility', 'on');
tmp_show=get(0, 'ShowHiddenHandles');
set(0, 'ShowHiddenHandles', 'off');
set(gca,'children',[kk_h(2);kk_h(3:length(kk_h));kk_h(1)]);
set(kk_h(kk_inv), 'HandleVisibility', 'off');
set(0, 'ShowHiddenHandles', tmp_show);
And then the first handle will be set even below those invisible ones.
|
Sat 21 Nov 2015 11:37:03 PM UTC, original submission:
There's a particular weird behavior from using set() with the 'ShowHiddenHandles' option:
graphics_toolkit('gnuplot');
flag = logical(1);
patch([0,0,1,1],[0,1,1,0], 'r');
patch([0,0,2,2],[0,0.5,0.5,0], 'b');
kk = get(gca,'children')
if flag,
show=get(0, 'ShowHiddenHandles');
set(0, 'ShowHiddenHandles', 'on');
end;
kk_h = get(gca,'children')
set(gca,'children',[kk_h(2);kk_h(3:length(kk_h));kk_h(1)]);
kk_h = get(gca,'children')
if flag,
set(0, 'ShowHiddenHandles', show);
end
kk = get(gca,'children')
Using the above code to test, one will notice that if 'ShowHiddenHandles' is set to 'on', setting gca's children will actually double the number of children instead of replacing it, where the new permutation is inserted before the old one. This does not occur when 'ShowHiddenHandles' is set to 'off'.
The intended behavior is that the red patch should now be covering over the blue patch instead of the other way around. While this does not affect fltk as much due to still drawing the final red patch after the final blue patch, gnuplot will have problems due to only caring about the first copy of the draw. Either way, the behavior is incorrect (also according to Matlab) because the number of gca's children should remain constant unless a new handle is created.
|