Skip to content

Commit

Permalink
fixes for setting microscope calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
newville committed Sep 30, 2019
1 parent f7acb89 commit 76e8a5a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
18 changes: 8 additions & 10 deletions epicsapps/microscope/calibrationframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,14 @@ def txt(label, size=-1):

def onCalibSelection(self, event=None, **kws):
name = self.calname.GetValue()
try:
if name not in self.calibrations:
x, y = self.calib_x.GetValue(), self.calib_y.GetValue()
self.calibrations[name] = [float(x), float(y)]
else:
calib = self.calibrations[name]
self.calib_x.SetValue(calib[0])
self.calib_y.SetValue(calib[1])
except AttributeError:
pass
# print(" On Calib selection ", name)
if name not in self.calibrations:
x, y = self.calib_x.GetValue(), self.calib_y.GetValue()
self.calibrations[name] = [float(x), float(y)]
else:
calib = self.calibrations[name]
self.calib_x.SetValue(calib[0])
self.calib_y.SetValue(calib[1])

def onCalibXY(self, event=None, **kws):
try:
Expand Down
15 changes: 13 additions & 2 deletions epicsapps/microscope/microscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,18 @@ def onConfigCalibration(self, evt=None, **kws):
callback=self.onSetCalibration)

def onSetCalibration(self, calibrations, current):

self.calibrations = calibrations
self.calib_current = current

self.config['calibration'] = []
for cname, cval in calibrations.items():
self.config['calibration'].append([cname, "%.4f" % cval[0], "%.4f" % cval[1]])
self.confpanel.calib.Clear()
for cname in calibrations:
self.confpanel.calib.Append(cname)
self.confpanel.calibrations = calibrations
self.confpanel.calib.SetStringSelection(current)
self.get_calibration()
self.onSetOverlays()

Expand Down Expand Up @@ -604,6 +614,7 @@ def get_calibration(self, name=None):
name = self.calib_current
if name in self.calibrations:
self.current_calib = name

cal = self.calibrations[name]
self.cam_calibx = abs(float(cal[0]))
self.cam_caliby = abs(float(cal[0]))
Expand Down Expand Up @@ -889,8 +900,8 @@ def onCaptureVideo(self, event=None):

def onSaveConfig(self, event=None):
fname = FileSave(self, 'Save Configuration File',
wildcard='INI (*.ini)|*.ini|All files (*.*)|*.*',
default_file='SampleStage.ini')
wildcard='Config files (*.yaml)|*.yaml|All files (*.*)|*.*',
default_file='microscope.yaml')
if fname is not None:
self.configfile.save(fname=fname)
self.write_message('Saved Configuration File %s' % fname)
Expand Down

0 comments on commit 76e8a5a

Please sign in to comment.