Skip to content

reverse coordinates when drawing on row-major images#2085

Merged
j9ac9k merged 1 commit intopyqtgraph:masterfrom
outofculture:draw-on-the-columns
Nov 14, 2021
Merged

reverse coordinates when drawing on row-major images#2085
j9ac9k merged 1 commit intopyqtgraph:masterfrom
outofculture:draw-on-the-columns

Conversation

@outofculture
Copy link
Copy Markdown
Contributor

This addresses #2071


def drawAt(self, pos, ev=None):
pos = [int(pos.x()), int(pos.y())]
if self.axisOrder == "col-major":
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change looks fine to me, but do you know if there is a situation where it would be preferable to do

point  = pos.toPoint()
[point.x(), point.y()]

Or the better way of phrasing that question is is there a situation where QPointF -> QPoint conversion is what we would want instead of int(QPointF.x()) ?

clearly this has worked well for us in the library, so not requesting a change, just something that crossed my mind when I looked at this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooo, interesting. The documentation at https://doc.qt.io/qt-5/qpointf.html#toPoint says it would round the values, whereas int is going to floor them. Rounding is better, but investigating, I also found problems. To be continued...

@outofculture
Copy link
Copy Markdown
Contributor Author

This also fixes #784

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Nov 14, 2021

Thanks @outofculture Love it when the "simple" fix does the trick.

@j9ac9k j9ac9k merged commit 26e8740 into pyqtgraph:master Nov 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected behavior with drawKernel + row-major image item ImageItem.drawAt() method ignores "axisOrder" config option

2 participants