-
Notifications
You must be signed in to change notification settings - Fork 544
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
Prevent range changing during drag #386
base: master
Are you sure you want to change the base?
Conversation
Fix small range changing during axis drag. This occurs because SetMin uses max value for validating range before it is set by calling SetMax. It is easy to observe with for example the following code const double plot_l = x_axis.PixelsToPlot(plot.PlotRect.Min.x - IO.MouseDelta.x); const double plot_r = x_axis.PixelsToPlot(plot.PlotRect.Max.x - IO.MouseDelta.x); const auto range = x_axis.Range.Size(); x_axis.SetMin(x_axis.IsInverted() ? plot_r : plot_l); x_axis.SetMax(x_axis.IsInverted() ? plot_l : plot_r); IM_ASSERT_USER_ERROR(range == x_axis.Range.Size(), "Range chnaged during drag!");
Hello, anybody here? @epezent |
Hey, thanks for the PR and sorry for the slow response. I was sitting on this one because I was worried it might have cause some unintended side effects. This may seem like a simple change, but it is not and needs to be confirmed not to break several related features (e.g. axis locking, constraining, inversion, etc.). I just tested it and it turns out that it does break things, specifically it breaks the minimum zoom constraint feature, which can be observed in the demo under There may be other side effects as well that I haven't discovered yet. I suspect |
You right, but... If we want prevent scrolling at minimum zoom, then best way to do it - dont process scroll input at minimum zoom. But now its not implemented
really, new |
After looking into this more closely, I'm not convinced it's a real issue. The amount of variation in the range is extremely small, essentially epsilon, and I'm not so sure it's even avoidable. In fact, your fix doesn't actually correct the problem -- I'm curious -- what was the actual problem that prompted you to investigate this? |
I just develop SDR software using your great library... Typical parameters of my x-axis: range constraint about [400000.0, 2000000000.0], zoom constraint [1000, 2400000.0] and range size is 2400000.0 With these values, the effect of changing the range during dragging becomes very noticeable and annoying (its looks like waterfall horizontal scaling during freq retuning by mouse drag). So... I would like fix this problem :)
You right, my bad, I didn't fully test solution. But I think this is due to a rounding error during
So... I need some more time to think about a more complete solution. Or maybe you can suggest solution or some workaround for this. |
I just tried the following with the parameters you provided and don't see anything particularly unusual: if (ImPlot::BeginPlot("My Plot")) {
ImPlot::SetupAxisLimitsConstraints(ImAxis_X1, 400000.0, 2000000000.0);
ImPlot::SetupAxisZoomConstraints(ImAxis_X1, 1000, 2400000.0);
ImPlot::EndPlot();
}
|
Ah, nevermind I'm seeing the issue now. Yea, looks like the range does creep up pretty quickly with these values. This is indeed something we need to fix! Thanks for the clarification. |
Great, thanks! I remove changes from scrolling and selection because I'm not sure if it's needed.
looks good for me. |
Hello @epezent! Any news about this 1-year issue? |
…#386) - Make scrolling not affect the zoom level when near the axis limit constraint - Keep the zoom-out speed constant when one side of the axis is against the limit constraint while the mouse is on the other side
Fix small range changing during axis drag (from left to right).
This occurs because
SetMin
usesRange.Max
value for validating range before it is set by callingSetMax
.It is easy to observe with for example the following code