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}')
|
||||
self.peaktable.blockSignals(False)
|
||||
it_pts.blockSignals(True)
|
||||
it_pts.setRegion(pos)
|
||||
it_pts.setRegion(pos, use_log=True)
|
||||
it_pts.blockSignals(False)
|
||||
undo = False
|
||||
|
||||
|
@ -376,6 +376,8 @@ class RegionItem(LinearRegionItem):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.mode = kwargs.pop('mode', 'half')
|
||||
|
||||
print(args, kwargs)
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.logmode = False
|
||||
@ -422,6 +424,15 @@ class RegionItem(LinearRegionItem):
|
||||
else:
|
||||
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):
|
||||
# overwrite to draw correct rect in logmode
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user