-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Fix #5088: Numbers cut off at bottom of Spectrum Analyzer #5098
Fix #5088: Numbers cut off at bottom of Spectrum Analyzer #5098
Conversation
Fixes the problem of numbers that are cut of at the bottom of the Spectrum Analyzer. The changes consist of the following: * Measure the maximum height needed to render the frequency ticks and adjust the bottom of the rectangle where the spectrum is rendered accordingly. * Measure the maximum width needed to render the amplitude ticks and adjust the left and right margin of the rectangle where the spectrum is rendered accordingly. * Adjust the code that renders the cursor text to measure the text that will be rendered so that it can be positioned correctly. Technical changes: * Add the two helper methods renderLogarithmicAmpTics and getAmpTicsToRender. * Make the bottom margin a member.
Rename renderLogarithmicAmpTics to isRenderLogarithmicAmpTics to better indicate that it does not render the amp tics. Add the isRenderLogarithmicFrequencyTics and getFrequencyTicsToRender so that the code is consistent with the amp tics.
Hi @he29-net, thanks for the code review! I have added some of the changes that you have proposed:
I have indeed missed the waterfall view. The problem of the shared scale should be solved by giving the waterfall view its own scale in my opinion. The waterfall view should be an independent widget of its own and its correct functionality should not dependend on that there's a spectrum view above it with a frequency range. At one point we might for example decide that it should be possible to show the waterfall view without the spectrum view. I therefore propose the following solution:
|
Hi @he29-net, the size of the labels is relative. 😃 Here's how the same area looks on my machine: Concerning the rendering of labels on the spectrum I guess pictures are worth a thousand words. 😃 Here's the result of some experimentation:
The labels become a bit harder to read if the stereo option is active: And here's a mono display with a bit less transparency: The advantage of such an approach would be that the spectrum and the waterfall would be of the same size and therefore their frequency ranges would line up again (albeit still implicitly). The only thing that might differ is the width of the transparent areas. |
Hmm.. 🤔 The Qt scaling is really quite a mess. In my case, when I have the QT_FONT_DPI set to 96, everything scales all right, including the track names. Maybe it's as you say -- some fonts are in "pixels", that are by default treated as "logical pixels", so Qt just scales it up based on DPI of the monitor. And some fonts are using a different metric, that gets first scaled using the logical → device-dependent pixel conversion, and then again the metric itself is scaled by the ratio given by QT_FONT_DPI, producing the double-scale bug..
The labels-inside version actually looks much better than I imagined, nice work! It will probably need some refinement, but I really like how it uses all available space. And as you say, it even fixes the width variability, so no objections for taking this route. 👍 The 10 and 20k Hz extremes are probably not much concern overall. The right side is probably more important than the low-end, so hiding the right axis may be beneficial, but there is still the problem of clearly (but not too in-your-face) indicating the left/right channel colors.. Also the numbers in corner look pretty bad and it's not clear to which axis they belong; maybe it would be better to even drop them completely. Given that they require special alignment behavior, it may even make the code less complicated. And cursor behavior should be probably also checked after all the changes. That's currently all the issues I can think of.. |
std::vector<std::pair<float, std::string>> const & getAmpTicsToRender() const; | ||
|
||
bool isRenderLogarithmicFrequencyTics() const; | ||
std::vector<std::pair<int, std::string>> const & getFrequencyTicsToRender() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you use std::pair<int, std::string>
many times, I suggest you make a typedef of it (something like FrequencyAndText
), and the same for std::pair<float, std::string>
.
Also, is there a reason for using std::string instead of QString?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using std::string
would be mainly my doing, I used it everywhere in the code. I never worked with Qt before writing the analyzer and I didn't see any reason to use some weird non-standard data types when the std
library works just fine. The same goes for containers (e.g. std::vector and not QVector). Maybe there is some reason why Qt had to reinvent everything (to the point you could almost call the language Qt++), but to this day the reason eludes me. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In most cases it has the same interface (and more), In this case you have to manually convert it using QString::fromStdString
which is just redundant.
{ | ||
freqTics = &m_linearFreqTics; | ||
} | ||
std::vector<std::pair<int, std::string>> const & freqTics = getFrequencyTicsToRender(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto?
} | ||
float margin = 2; | ||
// Fetch the correct amp ticks with regards to log or linear scaling | ||
std::vector<std::pair<float, std::string>> const & ampTics = getAmpTicsToRender(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason for not using auto
?
Closing this pull request as the problem cannot be reproduced anymore in master (see here). |
Fix for #5088. Fix the problem of numbers that are cut of at the bottom of the Spectrum Analyzer. The changes consist of the following:
Technical changes:
renderLogarithmicAmpTics
andgetAmpTicsToRender
.