PolyLineRIO: getArrayRegion

398 views
Skip to first unread message

Tobias Schöls

unread,
Jun 25, 2013, 9:37:25 AM6/25/13
to pyqt...@googlegroups.com
Hey everybody,

After creating a PolyLineROI.getArrayRegion() works just fine, but PolyLine.getArrayRegion() returns the worng array after a translation or scaling, which is the unscaled and untranslated array.
Is there a good solution to fix this? 

At the moment, I ended up overwriting getArrayRegion() and getLocalHandlePositions() and run into some trouble with it.

Here is some more that I came a cross, while using PolyLineROI:

To get the size and position of a PolyLineROI I use:

import pyqtgraph as pg
freeform = pg.PolyLineROI([[000, 100], [050, 150], [200, 100], [200, 400], [100, 100], [000, 400]])
Size = pg.Point(freeform.boundingRect().size())
Pos = pg.Point(freeform.boundingRect().topLeft())

#  freeform.pos() returns pg.Point(0, 0)
#  freeform.size() returns pg.Point(1,1)

to get the position and size of the bounding Rectangle for other ROIs this works like this:

rect = pg.RectROI([000, 100], [200, 300])
Size = rect.size()
Pos = rect.pos()

Why is this realized like this? Wouldn't it be reasonable to eigther:
1. overwrite PolyLineROI.size() and PolyLineROI.pos()  (check below)
or
2. to set PolyLineROI.state['pos'] and PolyLine.state['size'] to the values of the bounding rectangle and use relative positions (between 0.0 and 1.0) for the handles' postions

for the sake of consitency?

I would prefer the second solution. Wouldn't that solve the upper issue too?

Thanks for your help!

Regards,

Tobi

Luke Campagnola

unread,
Jun 25, 2013, 11:22:18 AM6/25/13
to pyqt...@googlegroups.com
On Tue, Jun 25, 2013 at 9:37 AM, Tobias Schöls <tobias....@gmail.com> wrote:
After creating a PolyLineROI.getArrayRegion() works just fine, but PolyLine.getArrayRegion() returns the worng array after a translation or scaling, which is the unscaled and untranslated array.
Is there a good solution to fix this? 

Hi Tobias,
I am unable to reproduce this. If I run examples/ROIExamples.py from an interactive prompt and execute the following lines:

>>> rois[-1].translate(10,0)
>>> rois[-1].scale(2,2)

.. then everything still appears to be working correctly. (This should affect the blue triangle in the top-left quadrant)
Can you send an example to describe your problem?
 
To get the size and position of a PolyLineROI I use:

import pyqtgraph as pg
freeform = pg.PolyLineROI([[000, 100], [050, 150], [200, 100], [200, 400], [100, 100], [000, 400]])
Size = pg.Point(freeform.boundingRect().size())
Pos = pg.Point(freeform.boundingRect().topLeft())

#  freeform.pos() returns pg.Point(0, 0)
#  freeform.size() returns pg.Point(1,1)

to get the position and size of the bounding Rectangle for other ROIs this works like this:

rect = pg.RectROI([000, 100], [200, 300])
Size = rect.size()
Pos = rect.pos()

Why is this realized like this? Wouldn't it be reasonable to eigther:
1. overwrite PolyLineROI.size() and PolyLineROI.pos()  (check below)
or
2. to set PolyLineROI.state['pos'] and PolyLine.state['size'] to the values of the bounding rectangle and use relative positions (between 0.0 and 1.0) for the handles' postions for the sake of consitency?

The reason for this behavior is somewhat historical and certainly not intuitive. Basically, PloyLineROI grew out of the usual rectangular ROIs by using freely-moving handles, which have no real relationship to the rectangular part of the ROI. This obviously does not make much sense and should be changed. Reorganizing ROIs is currently on my to-do list, but ROIs are complex and tricky to get right--often seemingly natural changes have unintended consequences (which just means that it will take a lot of testing to make these changes, and I won't be able to get to it for probably a couple of months). 

I would be interested to see what you come up with--everybody seems to use the ROIs a little differently.


Luke


 
Reply all
Reply to author
Forward
0 new messages