Skip to content

Add a few ImageView improvements#1828

Merged
outofculture merged 28 commits intopyqtgraph:masterfrom
outofculture:image-improved
Sep 7, 2022
Merged

Add a few ImageView improvements#1828
outofculture merged 28 commits intopyqtgraph:masterfrom
outofculture:image-improved

Conversation

@outofculture
Copy link
Copy Markdown
Contributor

Taking up #396 (thanks, @radjkarl!), this PR does a little more cleanup. Some of the features were incomplete or had bugs. I fixed some of these, omitted others. Here's what happened to everything:

setHistogramLabel looks good and is connected to the example now.

discreteTimeLine, now an init argument, controls snap-to-frame in the timeline. This can now handle non-integer xvals. The example now uses this option. A test now checks this.

nframes handles zero frames now. A test now checks this.

play, keyPressEvent and timeIndex methods are working smoothly. Spacebar now toggles play-through, instead of only starting it. Example now plays.

opts needed additional documentation and scaffolding, and I didn't want to put in the work for what didn't feel particularly impactful.

setHistogramPrintView needed some improvement, but I didn't understand the expected behavior well enough to take it over, so I just removed it. If this is still valuable to someone, a version with a more thoroughly described spec would be an acceptable addition.

@ixjlyons
Copy link
Copy Markdown
Member

@outofculture is this ready for a review or were there still some things you wanted to work on?

@outofculture
Copy link
Copy Markdown
Contributor Author

@ixjlyons argh, no, it's not ready. I was testing things and ran into some problems that didn't have a clear solution, and I haven't come back to it, and now I'll have to start from scratch to figure out what those problems were. I might pare this down again in the process, but I'll put this back on the top of my pyqtgraph stack.

@outofculture outofculture marked this pull request as ready for review September 7, 2022 16:28
@outofculture
Copy link
Copy Markdown
Contributor Author

Okay, I finally got back to this and cleaned it up. The test is saner now, I cleaned up a few more docstrings, and I made sure pause/unpause would restore the previous play speed. This is ready for review.

@ixjlyons ixjlyons self-assigned this Sep 7, 2022
@ixjlyons ixjlyons self-requested a review September 7, 2022 17:30
@ixjlyons ixjlyons removed their assignment Sep 7, 2022
self.currentIndex = ind
self.updateImage()
if self.discreteTimeLine:
with fn.SignalBlock(self.timeLine.sigPositionChanged, self.timeLineChanged):
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.

nice use of SignalBlock probably should use it more in this library!

if not self.hasTimeAxis():
return (0,0)
return 0, 0
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.

nit-pick, but for type-correctness, probably should return 0, 0.0

ind, val = iv.timeIndex(iv.timeLine)
assert ind == count // 2
assert val == 0.5
iv.togglePause()
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.

perhaps we should add a comment here indicating that this call to togglePause should get playback going?

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Sep 7, 2022

Hi @outofculture I did a look-through, looks good to me. I just got nit-picky about the float vs. int return type and requested a comment in the test function, I think this is ready for merging otherwise! Thanks for your work on this!

@outofculture outofculture merged commit 7d956fe into pyqtgraph:master Sep 7, 2022
ntjess pushed a commit to ntjess/pyqtgraph that referenced this pull request Sep 12, 2022
NEW features in ImageView:
 * timeline mouse interactions can be configured as discrete
 * histograms can be given a title
 * pause/unpause maintains playback speed

Also, some style improvements.

Squashed history:

* +corrected wrong .opts key which caused example to crash
+corrected buggy play()

* removes 'pass'

* ignorePlaying replaced with ignoreTimeLine

* no thanks, import star

* use tVals if present; use SignalBlock

* small improvements

* whitespace

* remove discreteTimeLine from opts; remove opts

* space toggles playitude

* show off new features in example

* nframes can be zero; no need to normalize first

* bugs in setHistogramPrintView, so just remove it for now

* docstring the new methods; lint

* INCOMPLETE: test the discrete timeline

* fix ui_template

* numpy-style docstrings

* numpy-style docstrings

* fix test fails: imageItem might be None

* a linspace across 31 points gives the values I expect

* playback should resume at the previous play speed

* style: no property decorators unless necessary

* int, float; comments to track play state

Co-authored-by: Karl Bedrich <karl@bedrich.de>
Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
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.

4 participants