Discussion:
Bug in guiqwt and proposition of a fix
Vincent Le Saux
2013-01-29 15:32:45 UTC
Permalink
Hi all,

I noticed a strange behaviour dealing with the addition and suppression of
items in the itemlist. Let's highlight it with a simple example. Execute
the "image_plot_tools" example from the guiqwt examples (I'm using the
lastest version of python(x,y) so I have the guiqwt 2.2.1-1 version). Add
for example five annotated rectangles to the image and rename them (1 for
the first zone you added, 2 for the second and so on). Suppress the
rectangle number "3". Add a new annotated rectangle. The new rectangle is
put at the location of the former rectangle "3" we have just suppressed.
Then rename this new rectangle "3" for example. Select the rectangles 2 and
4 and suppress them. Try to add a new item. It is just impossible and I
think I've found the reason why. The guilt function is, I
guess, "add_item_with_z_offset" located in the "baseplot.py" file in the
guiqwt repertory. For reminder, this function is:

def add_item_with_z_offset(self, item, zoffset):
"""
Add a plot *item* instance within a specified z range, over *zmin*
"""
zlist = sorted([_it.z() for _it in self.items
if _it.z() >= zoffset]+[zoffset-1])
dzlist = np.argwhere(np.diff(zlist) > 1)
if len(dzlist) == 0:
z = max(zlist)+1
else:
z = zlist[dzlist]+1
self.add_item(item, z=z)


I think the problem comes from the variable "z". To fix the problem, I
propose the following modification of this function:
def add_item_with_z_offset(self, item, zoffset):
"""
Add a plot *item* instance within a specified z range, over *zmin*
"""
zlist = sorted([_it.z() for _it in self.items
if _it.z() >= zoffset]+[zoffset-1])
dzlist = np.argwhere(np.diff(zlist) > 1)
z = max(zlist)+1
self.add_item(item, z=z)

In that way, the new items are always located at the end of the itemlist.
If we now do the same as before, everything works fine.

Pierre, what do you think? If this is completely stupid, let me know (may
be this slight modification would bring new problems, but I've not met any
problems yet).

Regards,

Vincent
--
You received this message because you are subscribed to the Google Groups "guidata/guiqwt" group.
To unsubscribe from this group and stop receiving emails from it, send an email to guidata_guiqwt+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Loading...