-
Notifications
You must be signed in to change notification settings - Fork 10
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
Dashboard gauge item #215
Dashboard gauge item #215
Conversation
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.
Haven't reviewed the code yet, but I'm not seeing the same thing as you. Here's what I see after resizing:
Not sure what's going on but maybe you can take a look?
Reviewed 1 of 2 files at r1, all commit messages.
Reviewable status: 1 of 2 files reviewed, all discussions resolved (waiting on @BluCodeGH and @KavinSatheeskumar)
I just realized I think the problem is with the stroke colour - since you are on dark mode, it is drawing everything in white. I will update it to draw in black, but I don't know how to actually use dark mode to test it - my system settings don't seem to affect it |
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.
That fixed it!
Couple things:
- I think the text label should be a bit bigger
- Same with the tick numbers
- The big numeric readout should be rounded to about 6 digits total so the actual value can be seen and not 30 decimals flying by lol
- The default also seems a bit too small, maybe 250x250 or 300x300?
Reviewable status: 1 of 2 files reviewed, all discussions resolved (waiting on @BluCodeGH and @KavinSatheeskumar)
|
@BluCodeGH or @KavinSatheeskumar if you have time, would appreciate a review since you're the code owners |
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.
Nice! Can we move the label down a bit for better spacing?
Also, I think I crashed it by entering a decimal max value, can support for that be added?
Reviewed 1 of 1 files at r8, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @BluCodeGH, @KavinSatheeskumar, and @patrick-gu)
sinks/dashboard/items/gauge_item.py
line 35 at r8 (raw file):
self.min_value: int = 0 self.max_value: int = 10
Decimal support please! E.g. if the data is only between 0 and 0.5
sinks/dashboard/items/gauge_item.py
line 68 at r8 (raw file):
self.widget.update() def on_label_change(self, param, value):
Would it be easier to have all these ..._change
methods just be one thing that grab the new value for every field?
sinks/dashboard/items/gauge_item.py
line 85 at r8 (raw file):
width = self.width() height = self.height() if width < 100 or height < 100:
Why these restrictions on the size?
sinks/dashboard/items/gauge_item.py
line 96 at r8 (raw file):
# Tick marks and text
Extra blank line not needed
sinks/dashboard/items/gauge_item.py
line 111 at r8 (raw file):
# Invalid conditions if max_value < min_value:
This check should be in the ..._change
method and it should reject the invalid value (replace it with whatever the previous value was)
sinks/dashboard/items/gauge_item.py
line 189 at r8 (raw file):
painter.setFont(font) painter.drawText(0, height - side / 8, width, side / 8, Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignTop, label)
Newline please
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.
For the label, I believe there's some padding around the box which will cut off text if it's too low, especially if you have something like a "y". So having more space would come at the cost of making the circle smaller.
Decimal support has been added.
Reviewable status: 1 of 2 files reviewed, 6 unresolved discussions (waiting on @BluCodeGH, @Darth-Raazi, and @KavinSatheeskumar)
sinks/dashboard/items/gauge_item.py
line 35 at r8 (raw file):
Previously, Darth-Raazi (Ozayr Raazi) wrote…
Decimal support please! E.g. if the data is only between 0 and 0.5
Added. It was only integers before because floating point error is weird, but it should work OK now.
sinks/dashboard/items/gauge_item.py
line 68 at r8 (raw file):
Previously, Darth-Raazi (Ozayr Raazi) wrote…
Would it be easier to have all these
..._change
methods just be one thing that grab the new value for every field?
This is what is done in plot_dash_item.py
. Don't want to have too much abstraction
sinks/dashboard/items/gauge_item.py
line 85 at r8 (raw file):
Previously, Darth-Raazi (Ozayr Raazi) wrote…
Why these restrictions on the size?
The thickness of the lines and needle don't scale with the size, which makes it look really goofy when you make it small. I could make them also dynamically scale like the text, which I think would allow it to scale arbitrarily and look the same at any size. If this is important, I can change it. Just didn't account for too many cases to begin with because I was thinking about our typical use cases.
sinks/dashboard/items/gauge_item.py
line 96 at r8 (raw file):
Previously, Darth-Raazi (Ozayr Raazi) wrote…
Extra blank line not needed
Done.
sinks/dashboard/items/gauge_item.py
line 111 at r8 (raw file):
Previously, Darth-Raazi (Ozayr Raazi) wrote…
This check should be in the
..._change
method and it should reject the invalid value (replace it with whatever the previous value was)
I'm not sure how I could go about doing this. pyqtgraph
does have setLimits
but I can't find any documentation on where this is applicable to a simple parameter, if at all.
https://pyqtgraph.readthedocs.io/en/latest/api_reference/parametertree/parameter.html#pyqtgraph.parametertree.Parameter.setLimits
https://pyqtgraph.readthedocs.io/en/latest/api_reference/parametertree/parametertypes.html#pyqtgraph.parametertree.parameterTypes.SimpleParameter
sinks/dashboard/items/gauge_item.py
line 189 at r8 (raw file):
Previously, Darth-Raazi (Ozayr Raazi) wrote…
Newline please
Done.
I had to do a bit of rounding because numbers like 0.1 cannot be represented exactly in floats. I round them and convert to Python's exact decimals before working with them. There are certainly cases where this will not work perfectly, but I think this is fine for any reasonable use case. |
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.
Decimals are working great. For the label, can we make the widget not square then? Default size could be 200x250 or 250x300.
Also, deleting the widget causes this error:
Reviewed 1 of 1 files at r9, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @BluCodeGH, @KavinSatheeskumar, and @patrick-gu)
sinks/dashboard/items/gauge_item.py
line 68 at r8 (raw file):
Previously, patrick-gu (Patrick Gu) wrote…
This is what is done in
plot_dash_item.py
. Don't want to have too much abstraction
Ah makes sense
sinks/dashboard/items/gauge_item.py
line 85 at r8 (raw file):
Previously, patrick-gu (Patrick Gu) wrote…
The thickness of the lines and needle don't scale with the size, which makes it look really goofy when you make it small. I could make them also dynamically scale like the text, which I think would allow it to scale arbitrarily and look the same at any size. If this is important, I can change it. Just didn't account for too many cases to begin with because I was thinking about our typical use cases.
This is fine for now, but let's create an issue to address this in the future
sinks/dashboard/items/gauge_item.py
line 111 at r8 (raw file):
Previously, patrick-gu (Patrick Gu) wrote…
I'm not sure how I could go about doing this.
pyqtgraph
does havesetLimits
but I can't find any documentation on where this is applicable to a simple parameter, if at all.https://pyqtgraph.readthedocs.io/en/latest/api_reference/parametertree/parameter.html#pyqtgraph.parametertree.Parameter.setLimits
https://pyqtgraph.readthedocs.io/en/latest/api_reference/parametertree/parametertypes.html#pyqtgraph.parametertree.parameterTypes.SimpleParameter
What about just checking self.max_value < self.min_value
in the change method and not updating the widget if that's true? Could also save the previous value and then restore it
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.
Updated default size and fixed the error (good catch, I didn't even notice it)
Reviewable status: 1 of 2 files reviewed, 3 unresolved discussions (waiting on @BluCodeGH, @Darth-Raazi, and @KavinSatheeskumar)
sinks/dashboard/items/gauge_item.py
line 68 at r8 (raw file):
Previously, Darth-Raazi (Ozayr Raazi) wrote…
Ah makes sense
Done.
sinks/dashboard/items/gauge_item.py
line 85 at r8 (raw file):
Previously, Darth-Raazi (Ozayr Raazi) wrote…
This is fine for now, but let's create an issue to address this in the future
Done, see #218
sinks/dashboard/items/gauge_item.py
line 111 at r8 (raw file):
Previously, Darth-Raazi (Ozayr Raazi) wrote…
What about just checking
self.max_value < self.min_value
in the change method and not updating the widget if that's true? Could also save the previous value and then restore it
Done. It now goes back to whatever value it was before. Implementation was indeed quite straightforward.
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.
Great work!
Reviewable status: 1 of 2 files reviewed, all discussions resolved (waiting on @BluCodeGH and @KavinSatheeskumar)
Description
This implements a simple gauge using PyQt. Custom QPainter code is used to render the gauge. The value, ticks, and bounds on the gauge are configurable. Data is fetched similar to in the plot item.
This PR closes #198.
Developer Testing
Here's what I did to test my changes:
python -m omnibus
,python ./sources/parsley/main.py --fake
,python ./sinks/dashboard/main.py
ACTUATOR_INJ/SENSOR_ANALOG/SENSOR_BATTERY_VOLT/value
Reviewer Testing
Here's what you should do to quickly validate my changes:
This change is