Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROI: Provide feature for snapSize (x,y) #2485

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dgoeries
Copy link
Contributor

@dgoeries dgoeries commented Oct 11, 2022

This is the next PR after #2476

We now allow to declare the snapSize of the ROI as sequence of length 2 to have individual snapping for x and y dimension.

I extended the previously implemented tests. By doing so, I realized that flooring will provide a better snapping than rounding.


## snap
if self.scaleSnap or (modifiers & QtCore.Qt.KeyboardModifier.ControlModifier):
lp1[0] = round(lp1[0] / self.scaleSnapSize) * self.scaleSnapSize
lp1[1] = round(lp1[1] / self.scaleSnapSize) * self.scaleSnapSize
lp1[0] = np.floor(lp1[0] / self._scaleSnapSize[0]) * self._scaleSnapSize[0]

Check failure

Code scanning / CodeQL

Potentially uninitialized local variable

Local variable 'lp1' may be used before it is initialized.
@j9ac9k
Copy link
Member

j9ac9k commented Oct 13, 2022

CI says no due to codescan issue from before, but as the diff involves a line it already had an issue with, it's returning an error. I'll let @outofculture decide on merging.

Thanks for the PR @dgoeries !

@ixjlyons
Copy link
Member

Maybe this was discussed elsewhere already, but could we avoid the deprecation by accepting either a single scalar or a sequence? It's a minor convenience if you don't care about independent x/y, but no breaking change. I suppose setting roi.scaleSnap = 2 and getting back roi.scaleSnap == (2, 2) might be a little awkward and could break stuff anyway.

@dgoeries
Copy link
Contributor Author

@ixjlyons Yes, we can also provide both ways for an amount of time. Looking forward for @outofculture opinion ...

@pyqtgraph pyqtgraph deleted a comment from dgoeries Oct 26, 2022
@outofculture
Copy link
Contributor

So sorry for the long delay on this. This feature is a great addition.

Yes, absolutely, this will need to have a deprecation cycle if we don't also build in the ability to use the old interface. I think it's reasonable to do both, though. All the old tests (thanks again for those) will need to be copied to ensure that old behavior continues, too. Are you able to put this change together? If not, I can try to take it on.

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.

None yet

4 participants