diff --git a/src/erlab/interactive/imagetool/controls.py b/src/erlab/interactive/imagetool/controls.py index f0df5bd1..17a4480f 100644 --- a/src/erlab/interactive/imagetool/controls.py +++ b/src/erlab/interactive/imagetool/controls.py @@ -445,6 +445,7 @@ def update_content(self) -> None: self.spin_val[i].setRange(*self.array_slicer.lims[i]) self.spin_val[i].setSingleStep(self.array_slicer.incs[i]) self.spin_val[i].setValue(self.slicer_area.get_current_value(i)) + self.spin_val[i].setDecimals(self.array_slicer.get_significant(i)) self.label_dim[i].blockSignals(False) self.spin_idx[i].blockSignals(False) diff --git a/src/erlab/interactive/imagetool/slicer.py b/src/erlab/interactive/imagetool/slicer.py index 99b16d48..69a4866e 100644 --- a/src/erlab/interactive/imagetool/slicer.py +++ b/src/erlab/interactive/imagetool/slicer.py @@ -369,6 +369,11 @@ def values_of_dim(self, dim: Hashable) -> npt.NDArray[np.float32]: """ return self._obj._coords[dim]._data.array._data # type: ignore[union-attr] + def get_significant(self, axis: int) -> int: + """Return the number of significant digits for a given axis.""" + step = self.incs[axis] + return int(np.clip(np.ceil(-np.log10(abs(step)) + 1), 0, None)) + def add_cursor(self, like_cursor: int = -1, update: bool = True) -> None: self._bins.append(list(self.get_bins(like_cursor))) new_ind = self.get_indices(like_cursor)