Skip to content

Commit 51772d3

Browse files
committed
Updatign comments
1 parent 04e48d1 commit 51772d3

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

RawRefinery/application/LogarithmicSlider.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,32 @@ class LogarithmicSlider(QSlider):
1212
def __init__(self, min_val, max_val, parent=None):
1313
super().__init__(parent)
1414
self.setOrientation(Qt.Horizontal)
15-
# Use a large integer scale for better precision in the linear range
1615
self._scale = 1000
1716
self.setMinimum(0)
1817
self.setMaximum(self._scale)
1918

2019
self._min_val = min_val
2120
self._max_val = max_val
22-
23-
# Connect the internal integer value change to a custom handler
2421
self.valueChanged.connect(self._on_internal_value_changed)
2522

26-
self.setNaturalValue(min_val) # Set initial value
23+
self.setNaturalValue(min_val)
2724

2825
def get_natural_value(self):
29-
# Convert the internal linear integer value to the logarithmic float value
3026
log_min = math.log10(self._min_val)
3127
log_max = math.log10(self._max_val)
32-
33-
# Calculate the log value corresponding to the slider's integer position
28+
3429
log_value = log_min + (self.value() / self._scale) * (log_max - log_min)
35-
36-
# Convert back from log to the natural value
3730
natural_value = math.pow(10, log_value)
31+
3832
return float(natural_value)
3933

4034
def _on_internal_value_changed(self, value):
41-
# Convert the internal linear integer value to the logarithmic float value
4235
log_min = math.log10(self._min_val)
4336
log_max = math.log10(self._max_val)
4437

45-
# Calculate the log value corresponding to the slider's integer position
4638
log_value = log_min + (value / self._scale) * (log_max - log_min)
47-
48-
# Convert back from log to the natural value
4939
natural_value = math.pow(10, log_value)
5040

51-
# Emit the custom signal with the natural (float) value
5241
self.naturalValueChanged.emit(natural_value)
5342

5443
def setNaturalValue(self, value):

0 commit comments

Comments
 (0)