forked from IPKM/nmreval
setRegion of RegionItem with option to account for log mode
This commit is contained in:
parent
3321d85203
commit
3149a3f958
@ -177,7 +177,7 @@ class PointSelectWidget(QtWidgets.QWidget, Ui_Form):
|
|||||||
it.setText(f'{pos[0]:.5g} - {pos[1]:.5g}')
|
it.setText(f'{pos[0]:.5g} - {pos[1]:.5g}')
|
||||||
self.peaktable.blockSignals(False)
|
self.peaktable.blockSignals(False)
|
||||||
it_pts.blockSignals(True)
|
it_pts.blockSignals(True)
|
||||||
it_pts.setRegion(pos)
|
it_pts.setRegion(pos, use_log=True)
|
||||||
it_pts.blockSignals(False)
|
it_pts.blockSignals(False)
|
||||||
undo = False
|
undo = False
|
||||||
|
|
||||||
|
@ -376,6 +376,8 @@ class RegionItem(LinearRegionItem):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.mode = kwargs.pop('mode', 'half')
|
self.mode = kwargs.pop('mode', 'half')
|
||||||
|
|
||||||
|
print(args, kwargs)
|
||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
self.logmode = False
|
self.logmode = False
|
||||||
@ -422,6 +424,15 @@ class RegionItem(LinearRegionItem):
|
|||||||
else:
|
else:
|
||||||
return region
|
return region
|
||||||
|
|
||||||
|
def setRegion(self, region, use_log=False):
|
||||||
|
if self.logmode and use_log:
|
||||||
|
region = np.log10(region[0]), np.log10(region[1])
|
||||||
|
|
||||||
|
if not np.all(np.isfinite(region)):
|
||||||
|
raise ValueError(f'Invalid region limits ({region[0]}, {region[1]})')
|
||||||
|
else:
|
||||||
|
super().setRegion(region)
|
||||||
|
|
||||||
def boundingRect(self):
|
def boundingRect(self):
|
||||||
# overwrite to draw correct rect in logmode
|
# overwrite to draw correct rect in logmode
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user