octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need help for little math problem


From: John W. Eaton
Subject: Re: Need help for little math problem
Date: Thu, 22 Sep 2011 11:35:30 -0400

On 22-Sep-2011, Michael Goffioul wrote:

| On Thu, Sep 22, 2011 at 12:26 PM, Olaf Till <address@hidden> wrote:
| > No help with the math problem, but maybe 2 possibilities to solve this
| > differently:
| >
| > 1. Round or reject user input for M and m if M deviates too far from a
| > multiple of m (I guess in most useful cases M should be a multiple of
| > m anyway),
| >
| > or
| >
| > 2. Do the mapping only in direction double -> integer, i.e. map the
| > current value from double to integer (by some rounding as hinted by
| > you), but preserve both the double and the integer to which it
| > maps. If a new integer value comes back from the widget (I don't know
| > how), check if it has changed with respect to the old integer
| > value. If not, keep the preserved current double value. If yes, change
| > the preserved current double value by a multiple of M (or up to max or
| > min).
| >
| > Was just an idea ...
| 
| Thanks for the input. I'll read it in details later, but it looks like you're
| assuming that value changes in the integer scale are only by M, which
| is not the case. Just for completeness, I have to map the floating-point
| scale (uicontrol::min, uicontrol::max, uicontrol::sliderstep), to a Qt
| QAbstractSlider (http://doc.qt.nokia.com/stable/qabstractslider.html),
| that is: minimum, maximum, singleStep, pageStep, and "unity".

What about using 0 for minimun, std::numeric_limits<int>::max() for
maximum, and the compute singleStep as

  round (uicontrol::sliderstep / (uicontrol::max - uicontrol:min) * maximum)

?  Wouldn't that give you the best resolution?  I suppose you could
set pageStep to be something like min (singleStep, 5 to 10% of range) so
that a slider has a maximum of 10 to 20 "pages" and a page is never
less than a "singleStep".

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]