LinearRegionItem resizing

315 views
Skip to first unread message

Scott Crawford

unread,
Jul 8, 2014, 11:13:22 PM7/8/14
to pyqt...@googlegroups.com
Hi Luke, and group,

I have two plots - a top and bottom - and a LinesrRegionItem in the bottom plot used to control the top view extents.

The top plot instantiates an object that extends LinearRegionItem (MyLinearRegionItem)

- The MyLinearRegionItem takes the top plot as an __init__ param so it can
A) set the plot's RangeChange signal handler, which is then hooked to a custom updateRegion method.
The updateRegion method just calls the parent self.setRegion.
B) The MyLinearRegionItem's sigRangeChanged is connected to a local method that explicitly calls the top plot's setXRange method.

- The actual MyLinearRegionItem graphic item is added to the bottom plot.

My issue is that when I resize the linear region, the top plot refresh does not work properly under specific conditions.
The graphic items in the top plot move, but one row of pixels in each graphic item does not get erased. The same is true for an infinite line that streaks across the view. But, if I then move the LinearRegionItem, instead of resizing it, the top view will reset to a good state.

Curiously, if I do not first interact with the top plot, then the issue does not surface.
As soon as I move the top plot view in any way, the refresh problem immediately surfaces as soon I resize the linear bar in the bottom plot.

My pyqtgraph app is displaying realtime data as multiple instances of a class that subclasses pg.GraphicsObject. It is these graphics that are streaking one pixel or so at the top as I resize the bottom linear region item. The infinite line is copied 5 to 10 times, also.

Could someone please recommend a course of action to address this?

Thanks!

Luke Campagnola

unread,
Jul 9, 2014, 7:23:48 AM7/9/14
to pyqt...@googlegroups.com
These custom graphics items are likely the source of the problem. Leftover artifacts are almost always a result of incorrectly handling boundaries around a graphics item. Here are the rules:

* QGraphicsItem.boundingRect() must return a rectangle (defined in the local coordinate system of the item) that fully encloses the contents of the item. Any graphics drawn outside this rectangle may become an artifact.
* If the bounding rect of a QGraphicsItem changes, you must call QGraphicsItem.prepareGeometryChange() to let Qt know this has happened.

It is also possible that there are similar problems with pyqtgraph's items. If you think your items are written correctly, post some example code and I'll see what needs to be fixed.

Luke

Scott Crawford

unread,
Jul 9, 2014, 10:35:32 AM7/9/14
to pyqt...@googlegroups.com
Hi Luke,

Thanks for the response.  I'm fairly certain that this is not an issue with my custom graphic bounds.

Again, the problem only occurs after I manually resize the top plot.

There are two more observables....
- if I resize the bottom plot's linear region item _very slowly_ there are no screen artifacts
- also, when I reset the top plot's y-axis to auto, the problem goes away

I think if I can fix the y-axis to auto, I'd have a workaround.

Thanks for the help.
--scott



Luke Campagnola

unread,
Jul 9, 2014, 10:58:25 AM7/9/14
to pyqt...@googlegroups.com
On Wed, Jul 9, 2014 at 10:35 AM, Scott Crawford <robo...@gmail.com> wrote:
Hi Luke,

Thanks for the response.  I'm fairly certain that this is not an issue with my custom graphic bounds.

Again, the problem only occurs after I manually resize the top plot.

There are two more observables....
- if I resize the bottom plot's linear region item _very slowly_ there are no screen artifacts
- also, when I reset the top plot's y-axis to auto, the problem goes away

This all sounds consistent with a bounding rect issue to me. If you can post an example, I would be happy to look.

Scott Crawford

unread,
Jul 9, 2014, 12:32:02 PM7/9/14
to pyqt...@googlegroups.com
frame_plot.py
frame_plot_region.py
gfp_graphic.py

Scott Crawford

unread,
Jul 9, 2014, 12:33:30 PM7/9/14
to pyqt...@googlegroups.com
Luke,

My issue is probably in the frame_plot.py addFrameData method. 

I really appreciate the help.

--scott

Scott Crawford

unread,
Jul 9, 2014, 2:29:33 PM7/9/14
to pyqt...@googlegroups.com
and the problem goes away when I comment-out the TextItem placed next to each GraphicsObject

--scott

Scott Crawford

unread,
Jul 10, 2014, 7:47:40 PM7/10/14
to pyqt...@googlegroups.com
My issue has been side stepped.

I changed the design to present an HTML formatted table of information when the user clicks the mouse on the screen, using a single TextItem. 
A subsequent mouse click outside the main view removes the TextItem.  

In fact, I was able to create three tables of detailed information with varying colors using a single TextItem - a really nice feature!

Thanks,
--scott c.
Reply all
Reply to author
Forward
0 new messages