Skip to content

Commit

Permalink
Functional
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Agüero <[email protected]>
  • Loading branch information
caguero committed Mar 5, 2024
1 parent 932d144 commit 26b3b1a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
4 changes: 2 additions & 2 deletions resource/bar.ui
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ p, li { white-space: pre-wrap; }
<string>%f%</string>
</property>
</widget> -->
<widget class="QLabel" name="value_label">
<!-- <widget class="QLabel" name="value_label">
<property name="geometry">
<rect>
<x>25</x>
Expand All @@ -276,7 +276,7 @@ p, li { white-space: pre-wrap; }
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget> -->

<widget class="Line" name="line_2">
<property name="geometry">
Expand Down
35 changes: 13 additions & 22 deletions src/rqt_gauges/bar_gauge.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QProgressBar, QWidget
from PyQt5.QtCore import pyqtSignal, Qt
from PyQt5.QtWidgets import QLabel, QProgressBar, QWidget


class BarGauge(QWidget):

updateValueSignal = pyqtSignal(float)

def __init__(self, node):
def __init__(self, parent):
# Constructor method of the class, initializes all the variables needed to create
# the gauge.

super().__init__()
super().__init__(parent)

# Progress bar
self.bar_gauge = QProgressBar(self)
self.bar_gauge.setGeometry(110, 126, 51, 301)
self.bar = QProgressBar(parent)
self.bar.setGeometry(110, 126, 51, 301)
self.bar.setOrientation(Qt.Vertical)

self.valueLabel = QLabel(parent)
self.valueLabel.setGeometry(25, 425, 221, 61)

self.minValue = 0.0
self.maxValue = 1.0
self.maxValue = 100.0
self.raw_value = self.minValue
self.value = self.minValue

self.show()

def updateValue(self, value: float):
print('UpdateValue()', value)
# Updates the value that the gauge is indicating.
# Args:
# value: Value to update the gauge with.
self.raw_value = value
value = max(value, self.minValue)
value = min(value, self.maxValue)
self.value = value
self.bar_gauge.setValue(int(self.value * 100))
# self.value_label.setText(str(self.raw_value))
self.update()
self.bar.setValue(int(self.value))
self.valueLabel.setText(str(self.raw_value))

def setMinValue(self, min_value):
# Modifies the minimum value of the gauge
Expand All @@ -47,8 +47,6 @@ def setMinValue(self, min_value):
else:
self.minValue = min_value

self.update()

def setMaxValue(self, max_value):
# Modifies the maximum value of the gauge
# Args:
Expand All @@ -59,10 +57,3 @@ def setMaxValue(self, max_value):
self.maxValue = self.minValue + 1
else:
self.maxValue = max_value

self.update()

def paintEvent(self, event):
print('paintEvent()', self.value, ' ', self.raw_value)
self.bar_gauge.setValue(int(self.value * 100))
# self.value_label.setText(str(self.raw_value))
2 changes: 0 additions & 2 deletions src/rqt_gauges/dial_gauge.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,6 @@ def resizeEvent(self, event):
self.rescale_method()

def paintEvent(self, event):
print('paintEvent()')

self.draw_outer_circle()
# Colored pie area
if self.enable_filled_Polygon:
Expand Down

0 comments on commit 26b3b1a

Please sign in to comment.