def samplesChanged(self): self.normalizedAperture = aperture.getCircularAperture(self.apertureSamplesGroup.value()) self.apertureChanged()
def __init__(self, pluginManager, illuminationDisplay, frameGrabber, parent=None): QtGui.QWidget.__init__(self, parent) self.inputQueue = None self.pluginManager = pluginManager self.illuminationDisplay = illuminationDisplay self.frameGrabber = frameGrabber # Make sure that optics properties are initialized with reasonable defaults. self.settings = Settings() self.settings['optics'].refreshWithDefault('pitch',125.0) self.settings['optics'].refreshWithDefault('flen',2500.0) self.settings['optics'].refreshWithDefault('mag',40.0) self.settings['optics'].refreshWithDefault('abbe',True) self.settings['optics'].refreshWithDefault('na',0.95) self.settings['optics'].refreshWithDefault('medium',1.0) self.settings['optics'].refreshWithDefault('focus',0.0) self.settings['optics'].refreshWithDefault('perspective',0.0) self.settings['optics'].refreshWithDefault('aperture',0.5) self.focusDirections='\nMoving z in the positive direction (dragging/pressing right) brings the virtual focal plane closer to the objective.' self.focusGroup = gui_utils.TwinInfiniteSliderWidget(5.0, 0.5, 10, label='Focus (z)', suffix='um', digits=4, eps=1e-6, directions=self.focusDirections) self.connect(self.focusGroup, QtCore.SIGNAL('valueChanged()'), self.rayTransferChanged) # NOT DISPLAYED self.perspectiveGroup = gui_utils.SliderWidget(gui_utils.LinearMap(-1.0,1.0), gui_utils.FloatDisplay(3), 0.0, 'Perspective') self.connect(self.perspectiveGroup, QtCore.SIGNAL('valueChanged()'), self.rayTransferChanged) self.apertureTypeGroup = QtGui.QGroupBox('Aperture diameter', self) self.pinholeType = QtGui.QRadioButton('&Pinhole') self.variableType = QtGui.QRadioButton('&Custom') self.fullType = QtGui.QRadioButton('&Full') self.connect(self.pinholeType, QtCore.SIGNAL('clicked()'), self.apertureChanged) self.connect(self.variableType, QtCore.SIGNAL('clicked()'), self.apertureChanged) self.connect(self.fullType, QtCore.SIGNAL('clicked()'), self.apertureChanged) self.apertureTypeLayout = QtGui.QGridLayout(self.apertureTypeGroup) self.apertureTypeLayout.addWidget(self.pinholeType, 0, 0) self.apertureTypeLayout.addWidget(self.variableType, 0, 1) self.apertureTypeLayout.addWidget(self.fullType, 0, 2) self.apertureTypeGroup.setLayout(self.apertureTypeLayout) self.apertureGroup = gui_utils.SliderWidget(gui_utils.LinearMap(0.0,1.0), gui_utils.PercentDisplay(1), 0.5, 'Custom effective aperture', suffix='%', steps=1000) self.connect(self.apertureGroup, QtCore.SIGNAL('valueChanged()'), self.apertureChanged) self.pinholeType.click() self.apertureSamplesGroup = gui_utils.SliderWidget(gui_utils.LinearIntMap(1,APWIDTH*APWIDTH), (int,str), int(APWIDTH*APWIDTH/2), 'Number of aperture samples for non-pinhole rendering', steps=APWIDTH*APWIDTH) self.normalizedAperture = aperture.getCircularAperture(self.apertureSamplesGroup.value()) self.connect(self.apertureSamplesGroup, QtCore.SIGNAL('valueChanged()'), self.samplesChanged) self.buttonGroup = QtGui.QGroupBox('', self) self.centerButton = QtGui.QPushButton('&Reset pan') self.centerButton.setToolTip('Recenter the panning') self.resetFocusButton = QtGui.QPushButton('Reset &focus') self.resetFocusButton.setToolTip('Set the focus back to 0.0') self.buttonLayout = QtGui.QGridLayout(self.buttonGroup) self.buttonLayout.addWidget(self.centerButton,0,0) self.buttonLayout.addWidget(self.resetFocusButton,0,1) self.buttonLayout.setColumnStretch(2,1) self.buttonLayout.setRowStretch(1,1) self.buttonGroup.setLayout(self.buttonLayout) self.recipeGroup = QtGui.QGroupBox('Optics Recipe', self) self.pitchSelector = gui_utils.CustomOptionSelectorWidget('Microlens Array Pitch:', [('62.5um', 62.5), ('125um', 125.0), ('250um', 250.0)], 'Custom', float, self) self.pitchSelector.setValue(self.settings['optics'].pitch) self.flenSelector = gui_utils.CustomOptionSelectorWidget('Microlens Focal Length:', [('1600um', 1600.0), ('2500um', 2500.0), ('3750um', 3750.0)], 'Custom', float, self) self.flenSelector.setValue(self.settings['optics'].flen) self.magSelector = gui_utils.CustomOptionSelectorWidget('Objective Magnification:', [('10X',10.0), ('20X',20.0), ('40X',40.0), ('60X',60.0), ('63X',63.0), ('100X',100.0)], 'Custom', float, self) self.magSelector.setValue(self.settings['optics'].mag) self.abbeSelector = QtGui.QGridLayout() self.abbeCheckBox = QtGui.QCheckBox('Paraxial approximation', self) self.abbeCheckBox.setChecked(not self.settings['optics'].abbe) self.abbeSelector.addWidget(self.abbeCheckBox, 0, 1) self.abbeSelector.setColumnStretch(0,1) self.naSelector = gui_utils.CustomOptionSelectorWidget('Objective NA:', [('0.45',0.45), ('0.8',0.8), ('0.95',0.95), ('1.0',1.0), ('1.3',1.3)], 'Custom', float, self) self.naSelector.setValue(self.settings['optics'].na) (minLabel,maxLabel) = self.apertureGroup.rangeLabels(defaults=True) self.apertureGroup.setRangeLabels(None, maxLabel+'(%g NA)' % self.settings['optics'].na) self.mediumSelector = gui_utils.CustomOptionSelectorWidget('Medium Refractive Index:', [('Dry (air)',1.0), ('Water',1.333), ('Oil',1.5), ], 'Custom', float, self) self.mediumSelector.setValue(self.settings['optics'].medium) self.recipeLayout = QtGui.QGridLayout(self.recipeGroup) num_items = 0 self.recipeLayout.addWidget(self.pitchSelector,num_items,0) self.connect(self.pitchSelector, QtCore.SIGNAL('valueChanged()'), self.recipeChanged) num_items += 1 self.recipeLayout.addWidget(self.flenSelector,num_items,0) self.connect(self.flenSelector, QtCore.SIGNAL('valueChanged()'), self.recipeChanged) num_items += 1 self.recipeLayout.addWidget(self.magSelector,num_items,0) self.connect(self.magSelector, QtCore.SIGNAL('valueChanged()'), self.recipeChanged) num_items += 1 self.recipeLayout.addLayout(self.abbeSelector,num_items,0) self.connect(self.abbeCheckBox, QtCore.SIGNAL('stateChanged(int)'), self.recipeChanged) num_items += 1 self.recipeLayout.addWidget(self.naSelector,num_items,0) self.connect(self.naSelector, QtCore.SIGNAL('valueChanged()'), self.recipeChanged) self.connect(self.naSelector, QtCore.SIGNAL('valueChanged()'), self.naChanged) num_items += 1 self.recipeLayout.addWidget(self.mediumSelector,num_items,0) self.connect(self.mediumSelector, QtCore.SIGNAL('valueChanged()'), self.recipeChanged) num_items += 1 self.recipeButtons = QtGui.QGridLayout() self.recipeNote = QtGui.QLabel('') if self.settings['optics'].na >= self.settings['optics'].medium: self.recipeNote.setText('<font color="red">Error: NA >= medium index</font>') self.loadRecipeButton = QtGui.QPushButton('Load') self.saveRecipeButton = QtGui.QPushButton('Save') self.recipeButtons.addWidget(self.recipeNote, 0, 0) self.recipeButtons.addWidget(self.loadRecipeButton, 0, 1) self.recipeButtons.addWidget(self.saveRecipeButton, 0, 2) self.recipeButtons.setColumnStretch(0,1) self.recipeLayout.addLayout(self.recipeButtons,num_items,0) num_items += 1 self.recipeLayout.setColumnStretch(1,1) self.recipeLayout.setRowStretch(num_items,1) self.recipeGroup.setLayout(self.recipeLayout) # ----------------------- CALIBRATION GROUP ------------------------- self.calibrationOptionsGroup = QtGui.QGroupBox('Calibration', self) self.calibrationOptionsLayout = QtGui.QGridLayout(self.calibrationOptionsGroup) self.calibrateImagingButton = QtGui.QPushButton('Calibrate Imaging') self.calibrateImagingButton.setToolTip('Calibrate the Imaging Path') self.calibrateIlluminationButton = QtGui.QPushButton('Calibrate Illumination') self.calibrateIlluminationButton.setToolTip('Calibrate the Illumination Path') self.calibrationOptionsLayout.addWidget(self.calibrateImagingButton,0,0) self.calibrationOptionsLayout.addWidget(self.calibrateIlluminationButton,0,1) self.calibrationOptionsLayout.setColumnStretch(2,1) self.calibrationOptionsLayout.setRowStretch(1,1) self.calibrationOptionsGroup.setLayout(self.calibrationOptionsLayout) # ----------------------- OVERALL PANEL LAYOUT ------------------------- self.settingsLayout = QtGui.QGridLayout(self) self.settingsLayout.addWidget(self.focusGroup,0,0) self.settingsLayout.addWidget(self.perspectiveGroup,1,0) self.settingsLayout.addWidget(self.apertureTypeGroup,2,0) self.settingsLayout.addWidget(self.apertureGroup,3,0) self.settingsLayout.addWidget(self.apertureSamplesGroup,4,0) self.settingsLayout.addWidget(self.buttonGroup,5,0) self.settingsLayout.addWidget(self.recipeGroup,6,0) self.settingsLayout.addWidget(self.calibrationOptionsGroup,7,0) if not ENABLE_PERSPECTIVE: self.perspectiveGroup.setVisible(False) self.settingsLayout.setRowStretch(7,1) self.setLayout(self.settingsLayout) # self.connect(self.centerButton, # ??????? # QtCore.SIGNAL('clicked()'), # self.displayWindow.setUV) self.connect(self.resetFocusButton, QtCore.SIGNAL('clicked()'), self.resetFocus) self.connect(self.loadRecipeButton, QtCore.SIGNAL('clicked()'), self.loadRecipe) self.connect(self.saveRecipeButton, QtCore.SIGNAL('clicked()'), self.saveRecipe) self.connect(self.calibrateImagingButton, QtCore.SIGNAL('clicked(bool)'), self.calibrateImaging) self.connect(self.calibrateIlluminationButton, QtCore.SIGNAL('clicked(bool)'), self.calibrateIllumination)