def initialize(self):
        leginon.gui.wx.Settings.ScrolledDialog.initialize(self)
        sb = wx.StaticBox(self, -1, 'Settings')
        sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)

        sz = wx.GridBagSizer(5, 10)

        label = wx.StaticText(self, -1, 'Mask Run Name:')
        masknames = self.node.getMaskRunNames()
        self.widgets['mask run'] = Choice(self, -1, choices=masknames)
        sz.Add(label, (0, 0), (1, 1))
        sz.Add(self.widgets['mask run'], (0, 1), (1, 1))

        label = wx.StaticText(self, -1, 'Assessor Run Name:')
        self.widgets['run'] = Entry(self, -1)
        sz.Add(label, (1, 1), (1, 1))
        sz.Add(self.widgets['run'], (1, 2), (1, 1))

        self.widgets['continueon'] = wx.CheckBox(self, -1, 'Continue')
        sz.Add(self.widgets['continueon'], (2, 0), (1, 1))

        self.widgets['jump filename'] = Entry(self, -1, chars=12)
        label = wx.StaticText(self, -1, 'Image to Jump to:')
        sz.Add(label, (3, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        sz.Add(self.widgets['jump filename'], (3, 1), (1, 1),
               wx.ALIGN_CENTER | wx.FIXED_MINSIZE)

        sbsz.Add(sz, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        return [
            sbsz,
        ]
    def createNewPlateSelector(self, start_position):
        sb = wx.StaticBox(self, -1, 'New Prep Plate')
        sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)
        szplate = wx.GridBagSizer(5, 5)
        # plate format
        label = wx.StaticText(self, -1, 'Plate Format:')
        szplate.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.cplateformat = wx.Choice(self, -1)
        self.cplateformat.Enable(False)
        szplate.Add(self.cplateformat, (0, 1), (1, 1),
                    wx.ALIGN_CENTER_VERTICAL)
        # plate name
        label = wx.StaticText(self, -1, 'New Plate Name:')
        szplate.Add(label, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.newplate = Entry(self, -1)
        szplate.Add(self.newplate, (1, 1), (1, 1),
                    wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)

        self.savenewplate = wx.Button(self, wx.ID_SAVE)

        szplate.Add(self.savenewplate, (2, 0), (1, 2),
                    wx.ALIGN_CENTER_VERTICAL)

        szplate.AddGrowableCol(1)
        sbsz.Add(szplate, 0, wx.EXPAND | wx.ALL, 5)
        self.szmain.Add(sbsz, start_position, (1, 1),
                        wx.EXPAND | wx.ALL | wx.ALIGN_CENTER_VERTICAL)
class Panel(GridSelectionPanel):
    def setDefaultGridSelection(self):
        self.default_gridlabel = '--New Grid as Below--'

    def addNew(self):
        self.createNewGridEntry((1, 0))

    def enableNew(self, gridlabel):
        # enable entry of new grid
        if gridlabel != self.default_gridlabel:
            self.newgrid.Enable(False)
        else:
            self.newgrid.Enable(True)

    def runNew(self):
        self.onSaveNewGrid(None)

    def createNewGridEntry(self, start_position):
        sb = wx.StaticBox(self, -1, 'New Grid')
        sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)
        szgrid = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, -1, 'New Grid Name:')
        szgrid.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.newgrid = Entry(self, -1)
        szgrid.Add(self.newgrid, (0, 1), (1, 1),
                   wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)

        self.savenewgrid = wx.Button(self, wx.ID_APPLY)

        szgrid.Add(self.savenewgrid, (2, 0), (1, 2), wx.ALIGN_CENTER_VERTICAL)

        szgrid.AddGrowableCol(1)
        sbsz.Add(szgrid, 0, wx.EXPAND | wx.ALL, 5)
        self.szmain.Add(sbsz, start_position, (1, 1),
                        wx.EXPAND | wx.ALL | wx.ALIGN_CENTER_VERTICAL)

    def onNodeInitialized(self):
        super(Panel, self).onNodeInitialized()
        self.Bind(wx.EVT_BUTTON, self.onSaveNewGrid, self.savenewgrid)

    def onSaveNewGrid(self, evt=None):
        choices = self.node.getGridNames()
        newgrid = self.newgrid.Update()
        newgrid = self.newgrid.GetValue()
        if newgrid is None or newgrid == '':
            self.node.onBadEMGridName('No Grid Name')
            return
        elif newgrid in choices:
            self.node.onBadEMGridName('Grid Name Exists')
            return
        else:
            self.node.publishNewEMGrid(newgrid)
        self.refreshGrids()
    def initialize(self):
        leginon.gui.wx.Settings.ScrolledDialog.initialize(self)
        sb = wx.StaticBox(self, -1, 'Settings')
        sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)

        sz = wx.GridBagSizer(5, 10)

        #self.widgets['image directory'] = filebrowse.FileBrowseButton(self, -1)
        presets = self.node.presetsclient.getPresetNames()
        label = wx.StaticText(self, -1, 'Transform From:')
        self.widgets['child preset'] = PresetChoice(self, -1)
        self.widgets['child preset'].setChoices(presets)
        sz.Add(label, (0, 0), (1, 1))
        sz.Add(self.widgets['child preset'], (0, 1), (1, 1),
               wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)

        label = wx.StaticText(self, -1, 'Transform To:')
        self.widgets['ancestor preset'] = PresetChoice(self, -1)
        self.widgets['ancestor preset'].setChoices(presets)
        sz.Add(label, (1, 0), (1, 1))
        sz.Add(self.widgets['ancestor preset'], (1, 1), (1, 1),
               wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)

        self.widgets['jump filename'] = Entry(self, -1, chars=12)
        label = wx.StaticText(self, -1, 'Image to Jump to:')
        sz.Add(label, (2, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        sz.Add(self.widgets['jump filename'], (2, 1), (1, 1),
               wx.ALIGN_CENTER | wx.FIXED_MINSIZE)

        sbsz.Add(sz, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        return [
            sbsz,
        ]
Example #5
0
    def initialize(self):
        leginon.gui.wx.Settings.ScrolledDialog.initialize(self)
        sb = wx.StaticBox(self, -1, 'ACE')
        sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)
        sb = wx.StaticBox(self, -1, 'Images in Database')
        sbszdb = wx.StaticBoxSizer(sb, wx.VERTICAL)

        self.widgets['process'] = wx.CheckBox(self, -1, 'Analyze CTF')
        self.widgets['label'] = Entry(self, -1)

        sz = wx.GridBagSizer(5, 10)
        sz.Add(self.widgets['process'], (1, 0), (1, 1),
               wx.ALIGN_CENTER_VERTICAL)

        sbsz.Add(sz, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        sz = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, -1,
                              'Find images in this session with label:')
        sz.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        sz.Add(self.widgets['label'], (0, 1), (1, 1),
               wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)

        sbszdb.Add(sz, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        return [sbsz, sbszdb]
    def addTiltSettings(self):
        sb = wx.StaticBox(self, -1, 'Tilting')
        sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)

        sizer = wx.GridBagSizer(5, 4)
        bordersize = 3
        self.widgets['use tilts'] = \
          wx.CheckBox(self, -1, 'Acquire each target at different tilt in the list')
        sizer.Add(self.widgets['use tilts'], (0, 0), (1, 4),
                  wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL, bordersize)

        label = wx.StaticText(self, -1,
                              'List of Tilts to Collect (in degrees)')
        sizer.Add(label, (1, 1), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.widgets['tilts'] = Entry(self, -1, chars=15, style=wx.ALIGN_RIGHT)
        sizer.Add(self.widgets['tilts'], (1, 2), (1, 2),
                  wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL, bordersize)

        self.widgets['reset per targetlist'] = \
          wx.CheckBox(self, -1, 'Reset to the first of the tilts for targets from new image')
        sizer.Add(self.widgets['reset per targetlist'], (2, 1), (1, 3),
                  wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL, bordersize)

        sbsz.Add(sizer, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 5)

        return sbsz
    def __init__(self, parent):
        self.node = parent.node

        wx.Dialog.__init__(self, parent, -1, 'Test Reproducibiltiy')

        self.measure = wx.Button(self, -1, 'Run')
        self.Bind(wx.EVT_BUTTON, self.onMeasureButton, self.measure)

        szbutton = wx.GridBagSizer(5, 5)
        szbutton.Add(self.measure, (0, 0), (1, 1), wx.EXPAND)

        sbsz = wx.GridBagSizer(5, 5)

        label = wx.StaticText(self, -1, 'Label:')
        self.labvalue = Entry(self, -1, chars=20, value='test1')
        sbsz.Add(label, (0, 0), (1, 1))
        sbsz.Add(self.labvalue, (0, 1), (1, 1))

        label = wx.StaticText(self, -1, 'Moves:')
        self.movesvalue = IntEntry(self,
                                   -1,
                                   allownone=False,
                                   chars=5,
                                   value='10')
        sbsz.Add(label, (1, 0), (1, 1))
        sbsz.Add(self.movesvalue, (1, 1), (1, 1))

        label = wx.StaticText(self, -1, 'Distance:')
        self.distvalue = FloatEntry(self,
                                    -1,
                                    allownone=False,
                                    chars=5,
                                    value='1e-5')
        sbsz.Add(label, (2, 0), (1, 1))
        sbsz.Add(self.distvalue, (2, 1), (1, 1))

        label = wx.StaticText(self, -1, 'Angle:')
        self.angvalue = FloatEntry(self, -1, allownone=True, chars=5, value='')
        sbsz.Add(label, (3, 0), (1, 1))
        sbsz.Add(self.angvalue, (3, 1), (1, 1))

        self.sizer = wx.GridBagSizer(5, 5)
        self.sizer.Add(sbsz, (0, 0), (1, 1), wx.EXPAND | wx.ALL, 10)
        self.sizer.Add(self.measure, (1, 0), (1, 1),
                       wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.ALL, 10)

        self.SetSizerAndFit(self.sizer)
	def addRCTSettings(self):
		sb = wx.StaticBox(self, -1, 'RCT Options')
		sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)

		sizer = wx.GridBagSizer(5, 4)
		bordersize = 3

		label = wx.StaticText(self, -1, 'List of Tilts to Collect (in degrees)')
		sizer.Add(label, (0, 0), (1, 2), wx.ALIGN_CENTER_VERTICAL)
		self.widgets['tilts'] = Entry(self, -1, chars=15, style=wx.ALIGN_RIGHT)
		sizer.Add(self.widgets['tilts'], (0,2), (1,2), wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, bordersize)

		label = wx.StaticText(self, -1, 'Maximum Tilt Stepsize (in degrees)')
		sizer.Add(label, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		self.widgets['stepsize'] = IntEntry(self, -1, chars=2, value='15')
		sizer.Add(self.widgets['stepsize'], (1,1), (1,1), wx.ALL|wx.ALIGN_CENTER_VERTICAL, bordersize)

		label = wx.StaticText(self, -1, 'Pause Between Steps')
		sizer.Add(label, (1, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		self.widgets['pause'] = FloatEntry(self, -1, chars=2, value='1')
		sizer.Add(self.widgets['pause'], (1,3), (1,1), wx.ALL|wx.ALIGN_CENTER_VERTICAL, bordersize)

		'''
		label = wx.StaticText(self, -1, 'Min Feature Size')
		sizer.Add(label, (2,0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		self.widgets['minsize'] = FloatEntry(self, -1, chars=6, value='0.0')
		#sizer.Add(self.widgets['minsize'], (2,1), (1,1), wx.ALL|wx.ALIGN_CENTER_VERTICAL, bordersize)

		label = wx.StaticText(self, -1, 'Max Feature Size')
		sizer.Add(label, (2, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		self.widgets['maxsize'] = FloatEntry(self, -1, chars=6, value='0.0')
		sizer.Add(self.widgets['maxsize'], (2,3), (1,1), wx.ALL|wx.ALIGN_CENTER_VERTICAL, bordersize)

		label = wx.StaticText(self, -1, 'Median Filter (pixels)')
		sizer.Add(label, (3, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		self.widgets['medfilt'] = IntEntry(self, -1, chars=2, value='0')
		sizer.Add(self.widgets['medfilt'], (3,1), (1,1), wx.ALL|wx.ALIGN_CENTER_VERTICAL, bordersize)
		'''

		label = wx.StaticText(self, -1, 'LowPass Filter (pixels)')
		sizer.Add(label, (3, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		self.widgets['lowfilt'] = IntEntry(self, -1, chars=2, value='0')
		sizer.Add(self.widgets['lowfilt'], (3,3), (1,1), wx.ALL|wx.ALIGN_CENTER_VERTICAL, bordersize)

		label = wx.StaticText(self, -1, 'Drift threshold')
		sizer.Add(label, (4, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		self.widgets['drift threshold'] = FloatEntry(self, -1, chars=6, value='0.0')
		sizer.Add(self.widgets['drift threshold'], (4,1), (1,1), wx.ALL|wx.ALIGN_CENTER_VERTICAL, bordersize)

		label = wx.StaticText(self, -1, 'Drift preset')
		sizer.Add(label, (4, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		presets = self.node.presetsclient.getPresetNames()
		self.widgets['drift preset'] = PresetChoice(self, -1)
		self.widgets['drift preset'].setChoices(presets)
		sizer.Add(self.widgets['drift preset'], (4,3), (1,1), wx.ALL|wx.ALIGN_CENTER_VERTICAL, bordersize)

		sbsz.Add(sizer, 0, wx.ALIGN_CENTER|wx.ALL, 2)

		return sbsz
Example #9
0
	def __init__(self, parent, title='Film'):
		self.parent = parent
		wx.StaticBoxSizer.__init__(self, wx.StaticBox(self.parent, -1, title),
																			wx.VERTICAL)
		self.sz = wx.GridBagSizer(5, 5)
		self.Add(self.sz, 1, wx.EXPAND|wx.ALL, 5)

		parameterorder = [
			'Stock',
			'Exposure number',
			'Exposure type',
			'Automatic exposure time',
			'Manual exposure time',
			'User code',
			'Date Type',
			'Text',
			'Shutter',
			'External shutter',
		]

		self.parameters = {
			'Stock': wx.StaticText(self.parent, -1, ''),
			'Exposure number': IntEntry(self.parent, -1, chars=5, allownone=True),
			'Exposure type': wx.Choice(self.parent, -1),
			'Automatic exposure time': wx.StaticText(self.parent, -1, ''),
			'Manual exposure time': FloatEntry(self.parent, -1, chars=5, allownone=True),
			'User code': Entry(self.parent, -1, chars=3),
			'Date Type': wx.Choice(self.parent, -1),
			'Text': Entry(self.parent, -1, chars=20),
			'Shutter': wx.Choice(self.parent, -1),
			'External shutter': wx.Choice(self.parent, -1),
		}

		row = 0
		for key in parameterorder:
			st = wx.StaticText(self.parent, -1, key + ':')
			self.sz.Add(st, (row, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
			style = wx.ALIGN_CENTER
			if isinstance(self.parameters[key], Entry):
				style |= wx.FIXED_MINSIZE
			self.sz.Add(self.parameters[key], (row, 1), (1, 1), style)
			self.parameters[key].Enable(False)
			self.parameters[key].Enable(False)
			row += 1
		self.sz.AddGrowableCol(1)
    def createNewGridEntry(self, start_position):
        sb = wx.StaticBox(self, -1, 'New Grid')
        sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)
        szgrid = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, -1, 'New Grid Name:')
        szgrid.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.newgrid = Entry(self, -1)
        szgrid.Add(self.newgrid, (0, 1), (1, 1),
                   wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)

        self.savenewgrid = wx.Button(self, wx.ID_APPLY)

        szgrid.Add(self.savenewgrid, (2, 0), (1, 2), wx.ALIGN_CENTER_VERTICAL)

        szgrid.AddGrowableCol(1)
        sbsz.Add(szgrid, 0, wx.EXPAND | wx.ALL, 5)
        self.szmain.Add(sbsz, start_position, (1, 1),
                        wx.EXPAND | wx.ALL | wx.ALIGN_CENTER_VERTICAL)
class ReproTestDialog(wx.Dialog):
    def __init__(self, parent):
        self.node = parent.node

        wx.Dialog.__init__(self, parent, -1, 'Test Reproducibiltiy')

        self.measure = wx.Button(self, -1, 'Run')
        self.Bind(wx.EVT_BUTTON, self.onMeasureButton, self.measure)

        szbutton = wx.GridBagSizer(5, 5)
        szbutton.Add(self.measure, (0, 0), (1, 1), wx.EXPAND)

        sbsz = wx.GridBagSizer(5, 5)

        label = wx.StaticText(self, -1, 'Label:')
        self.labvalue = Entry(self, -1, chars=20, value='test1')
        sbsz.Add(label, (0, 0), (1, 1))
        sbsz.Add(self.labvalue, (0, 1), (1, 1))

        label = wx.StaticText(self, -1, 'Moves:')
        self.movesvalue = IntEntry(self,
                                   -1,
                                   allownone=False,
                                   chars=5,
                                   value='10')
        sbsz.Add(label, (1, 0), (1, 1))
        sbsz.Add(self.movesvalue, (1, 1), (1, 1))

        label = wx.StaticText(self, -1, 'Distance:')
        self.distvalue = FloatEntry(self,
                                    -1,
                                    allownone=False,
                                    chars=5,
                                    value='1e-5')
        sbsz.Add(label, (2, 0), (1, 1))
        sbsz.Add(self.distvalue, (2, 1), (1, 1))

        label = wx.StaticText(self, -1, 'Angle:')
        self.angvalue = FloatEntry(self, -1, allownone=True, chars=5, value='')
        sbsz.Add(label, (3, 0), (1, 1))
        sbsz.Add(self.angvalue, (3, 1), (1, 1))

        self.sizer = wx.GridBagSizer(5, 5)
        self.sizer.Add(sbsz, (0, 0), (1, 1), wx.EXPAND | wx.ALL, 10)
        self.sizer.Add(self.measure, (1, 0), (1, 1),
                       wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.ALL, 10)

        self.SetSizerAndFit(self.sizer)

    def onMeasureButton(self, evt):
        self.Close()
        label = self.labvalue.GetValue()
        moves = self.movesvalue.GetValue()
        distance = self.distvalue.GetValue()
        angle = self.angvalue.GetValue()
        threading.Thread(target=self.node.move_away_move_back,
                         args=(label, moves, distance, angle)).start()
Example #12
0
	def initialize(self):
		sizers = leginon.gui.wx.TargetRepeater.ScrolledSettings.initialize(self)

		sb = wx.StaticBox(self, -1, 'Tilts')
		sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)
		self.widgets['tilts'] = Entry(self, -1, chars=15, style=wx.ALIGN_RIGHT)
		sbsz.Add(self.widgets['tilts'], wx.EXPAND)

		return sizers + [sbsz]
 def createTemplateFilenameEntry(self, sz, start_position):
     # define widget
     self.widgets['template filename'] = Entry(self, -1, chars=20)
     label = wx.StaticText(self, -1, 'Template Filename')
     # add to main
     newrow, newcol = self.addToSizer(sz, label, start_position, (1, 1))
     newrow, newcol = self.addToSizer(sz, self.widgets['template filename'],
                                      (start_position[0], newcol), (1, 2),
                                      wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
     return newrow, newcol
Example #14
0
    def initialize(self):
        leginon.gui.wx.Settings.ScrolledDialog.initialize(self)
        sb = wx.StaticBox(self, -1, 'Settings')
        sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)

        sz = wx.GridBagSizer(5, 10)

        #self.widgets['image directory'] = filebrowse.FileBrowseButton(self, -1)
        #self.widgets['image directory'].SetMinSize((500,50))

        label = wx.StaticText(self, -1, 'Image Directory:')
        self.widgets['image directory'] = Entry(self, -1)
        sz.Add(label, (0, 0), (1, 1))
        sz.Add(self.widgets['image directory'], (0, 1), (1, 1))

        label = wx.StaticText(self, -1, 'Image Format:')
        self.widgets['format'] = leginon.gui.wx.Choice.Choice(
            self, -1, choices=['mrc', 'jpg', 'png'])
        sz.Add(label, (1, 0), (1, 1))
        sz.Add(self.widgets['format'], (1, 1), (1, 1))

        label = wx.StaticText(self, -1, 'Output Filename:')
        self.widgets['outputfile'] = Entry(self, -1)
        sz.Add(label, (2, 0), (1, 1))
        sz.Add(self.widgets['outputfile'], (2, 1), (1, 1))

        label = wx.StaticText(self, -1, 'Run Name:')
        self.widgets['run'] = Entry(self, -1)
        sz.Add(label, (3, 0), (1, 1))
        sz.Add(self.widgets['run'], (3, 1), (1, 1))

        self.widgets['jump filename'] = Entry(self, -1, chars=12)
        label = wx.StaticText(self, -1, 'Image to Jump to:')
        sz.Add(label, (4, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        sz.Add(self.widgets['jump filename'], (4, 1), (1, 1),
               wx.ALIGN_CENTER | wx.FIXED_MINSIZE)

        sbsz.Add(sz, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        return [
            sbsz,
        ]
    def initialize(self):
        leginon.gui.wx.Settings.ScrolledDialog.initialize(self)
        sb = wx.StaticBox(self, -1, 'Settings')
        sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)

        sz = wx.GridBagSizer(5, 10)

        label = wx.StaticText(self, -1, 'Preset Name:')
        self.widgets['preset'] = Entry(self, -1)
        sz.Add(label, (0, 0), (1, 1))
        sz.Add(self.widgets['preset'], (0, 1), (1, 1))

        label = wx.StaticText(self, -1, 'Binning:')
        self.widgets['bin'] = IntEntry(self, -1, min=1, chars=4)
        sz.Add(label, (1, 0), (1, 1))
        sz.Add(self.widgets['bin'], (1, 1), (1, 1))

        label = wx.StaticText(self, -1, 'Mask Run Name:')
        self.widgets['run'] = Entry(self, -1)
        sz.Add(label, (2, 0), (1, 1))
        sz.Add(self.widgets['run'], (2, 1), (1, 1))

        self.widgets['continueon'] = wx.CheckBox(
            self, -1, 'empty-mask-overwrite Not Allowed')
        sz.Add(self.widgets['continueon'], (3, 0), (1, 1))

        label = wx.StaticText(self, -1, 'Mask Run Path:')
        self.widgets['path'] = Entry(self, -1)
        sz.Add(label, (4, 0), (1, 1))
        sz.Add(self.widgets['path'], (4, 1), (1, 1))

        self.widgets['jump filename'] = Entry(self, -1, chars=12)
        label = wx.StaticText(self, -1, 'Image to Jump to:')
        sz.Add(label, (5, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        sz.Add(self.widgets['jump filename'], (5, 1), (1, 1),
               wx.ALIGN_CENTER | wx.FIXED_MINSIZE)

        sbsz.Add(sz, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        return [
            sbsz,
        ]
Example #16
0
    def addBasicTiltSettings(self):
        sb = wx.StaticBox(self, -1, 'Tilt Options')
        sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)

        sizer = wx.GridBagSizer(5, 4)
        bordersize = 3

        label = wx.StaticText(self, -1, 'Activation Interval')
        sizer.Add(label, (0, 0), (1, 2), wx.ALIGN_CENTER_VERTICAL)
        self.widgets['activation interval'] = IntEntry(self,
                                                       -1,
                                                       chars=5,
                                                       style=wx.ALIGN_RIGHT)
        sizer.Add(self.widgets['activation interval'], (0, 2), (1, 2),
                  wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL, bordersize)

        label = wx.StaticText(self, -1,
                              'List of Tilts to Collect (in degrees)')
        sizer.Add(label, (1, 0), (1, 2), wx.ALIGN_CENTER_VERTICAL)
        self.widgets['tilts'] = Entry(self, -1, chars=15, style=wx.ALIGN_RIGHT)
        sizer.Add(self.widgets['tilts'], (1, 2), (1, 2),
                  wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL, bordersize)

        label = wx.StaticText(self, -1, 'Min Feature Size')
        sizer.Add(label, (2, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.widgets['minsize'] = FloatEntry(self, -1, chars=6, value='0.0')
        sizer.Add(self.widgets['minsize'], (2, 1), (1, 1),
                  wx.ALL | wx.ALIGN_CENTER_VERTICAL, bordersize)

        label = wx.StaticText(self, -1, 'Max Feature Size')
        sizer.Add(label, (2, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.widgets['maxsize'] = FloatEntry(self, -1, chars=6, value='0.0')
        sizer.Add(self.widgets['maxsize'], (2, 3), (1, 1),
                  wx.ALL | wx.ALIGN_CENTER_VERTICAL, bordersize)

        label = wx.StaticText(self, -1, 'Median Filter (pixels)')
        sizer.Add(label, (3, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.widgets['medfilt'] = IntEntry(self, -1, chars=2, value='0')
        sizer.Add(self.widgets['medfilt'], (3, 1), (1, 1),
                  wx.ALL | wx.ALIGN_CENTER_VERTICAL, bordersize)

        label = wx.StaticText(self, -1, 'LowPass Filter (pixels)')
        sizer.Add(label, (3, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.widgets['lowfilt'] = FloatEntry(self, -1, chars=2, value='0.0')
        sizer.Add(self.widgets['lowfilt'], (3, 3), (1, 1),
                  wx.ALL | wx.ALIGN_CENTER_VERTICAL, bordersize)

        sbsz.Add(sizer, 0, wx.ALIGN_CENTER | wx.ALL, 2)

        return sbsz
    def __init__(self, *args, **kwargs):
        leginon.gui.wx.Node.Panel.__init__(self, *args, **kwargs)

        self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_SETTINGS,
                             'settings',
                             shortHelpString='Start')
        self.toolbar.AddSeparator()
        self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_PLAY,
                             'play',
                             shortHelpString='Start')
        self.toolbar.AddSeparator()
        self.toolbar.AddTool(leginon.gui.wx.ToolBar.ID_REFRESH,
                             'refresh',
                             shortHelpString='Refresh Grid List')

        self.cgrid = wx.Choice(self, -1)
        self.cgrid.Enable(False)
        szgrid = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, -1, 'Grids in the project')
        szgrid.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        szgrid.Add(self.cgrid, (0, 1), (1, 1), wx.ALIGN_CENTER_VERTICAL)

        label = wx.StaticText(self, -1, 'New Grid Name:')
        szgrid.Add(label, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.newgrid = Entry(self, -1)
        szgrid.Add(self.newgrid, (1, 1), (1, 1),
                   wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
        self.savenewgrid = wx.Button(self, wx.ID_APPLY)
        szgrid.Add(self.savenewgrid, (1, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)

        self.szmain.Add(szgrid, (0, 0), (1, 1), wx.ALIGN_CENTER)
        self.szmain.AddGrowableCol(0)

        self.SetSizer(self.szmain)
        self.SetAutoLayout(True)
        self.SetupScrolling()
    def addBasicRCTSettings(self):
        sb = wx.StaticBox(self, -1, 'RCT Options')
        sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)

        sizer = wx.GridBagSizer(5, 4)
        bordersize = 3

        label = wx.StaticText(self, -1,
                              'List of Tilts to Collect (in degrees)')
        sizer.Add(label, (0, 0), (1, 2), wx.ALIGN_CENTER_VERTICAL)
        self.widgets['tilts'] = Entry(self, -1, chars=15, style=wx.ALIGN_RIGHT)
        sizer.Add(self.widgets['tilts'], (0, 2), (1, 2),
                  wx.ALL | wx.EXPAND | wx.ALIGN_CENTER_VERTICAL, bordersize)

        sbsz.Add(sizer, 0, wx.ALIGN_CENTER | wx.ALL, 2)

        return sbsz
        def initialize(self):
                leginon.gui.wx.Settings.ScrolledDialog.initialize(self)
                sb = wx.StaticBox(self, -1, 'Raptor Settings')
                sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)

                self.widgets['process'] = wx.CheckBox(self, -1,
                                                                                                                                                        'Process images when event received')
                self.widgets['path'] = Entry(self, -1)
                self.widgets['time'] = IntEntry(self, -1)
                self.widgets['binning'] = IntEntry(self, -1)

                sbsz.Add(self.widgets['process'])
                sbsz.Add(self.widgets['path'])
                sbsz.Add(self.widgets['time'])
                sbsz.Add(self.widgets['binning'])

                return [sbsz]
	def addBasicSettings(self):
		sz = wx.GridBagSizer(5, 10)
		# preset
		presets = self.node.presetsclient.getPresetNames()
		self.widgets['preset'] = PresetChoice(self, -1)
		self.widgets['preset'].setChoices(presets)
		label = wx.StaticText(self, -1, 'Preset:')
		sz.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		sz.Add(self.widgets['preset'], (0, 1), (1, 1),
						wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
		# atlas label
		self.widgets['label'] = Entry(self, -1, allowspaces=False)
		label = wx.StaticText(self, -1, 'Label:')
		sz.Add(label, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		sz.Add(self.widgets['label'], (1, 1), (1, 1),
						wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
		# radius
		self.widgets['radius'] = FloatEntry(self, -1, min=0.0, chars=6)
		label = wx.StaticText(self, -1, 'Radius:')
		sz.Add(label, (2, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		#sz.Add(szradius, (2, 1), (1, 1), wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
		sz.Add(self.widgets['radius'], (2, 1), (1, 1),
										wx.ALIGN_CENTER_VERTICAL|wx.FIXED_MINSIZE|wx.ALIGN_RIGHT)
		label = wx.StaticText(self, -1, 'm')
		sz.Add(label, (2, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)

		'''
		# atlas max size
		self.widgets['max size'] = IntEntry(self, -1)
		label = wx.StaticText(self, -1, 'Max size:')
		sz.Add(label, (3, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		sz.Add(self.widgets['max size'], (3, 1), (1, 1),
						wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)

		# atlas max size
		self.widgets['max targets'] = IntEntry(self, -1)
		label = wx.StaticText(self, -1, 'Max targets:')
		sz.Add(label, (4, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		sz.Add(self.widgets['max targets'], (4, 1), (1, 1),
						wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
		'''

		return sz
Example #21
0
    def initialize(self):
        leginon.gui.wx.Settings.ScrolledDialog.initialize(self)
        sb = wx.StaticBox(self, -1, 'FFT')
        sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)
        sb = wx.StaticBox(self, -1, 'Images in Database')
        sbszdb = wx.StaticBoxSizer(sb, wx.VERTICAL)

        self.widgets['process'] = wx.CheckBox(self, -1, 'Calculate FFT')
        self.widgets['save'] = wx.CheckBox(self, -1, 'Save to the database')
        self.widgets['reduced'] = wx.CheckBox(
            self, -1, 'Truncate FFT to center 1024 pixels')
        self.widgets['mask radius'] = FloatEntry(self, -1, min=0.0, chars=6)
        self.widgets['label'] = Entry(self, -1)

        szmaskradius = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, -1, 'Mask radius:')
        szmaskradius.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        szmaskradius.Add(self.widgets['mask radius'], (0, 1), (1, 1),
                         wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, '% of image width')
        szmaskradius.Add(label, (0, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)

        sz = wx.GridBagSizer(5, 10)
        sz.Add(self.widgets['reduced'], (0, 0), (1, 1),
               wx.ALIGN_CENTER_VERTICAL)
        sz.Add(self.widgets['process'], (1, 0), (1, 1),
               wx.ALIGN_CENTER_VERTICAL)
        sz.Add(self.widgets['save'], (2, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        sz.Add(szmaskradius, (3, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)

        sbsz.Add(sz, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        sz = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, -1,
                              'Find images in this session with label:')
        sz.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        sz.Add(self.widgets['label'], (0, 1), (1, 1),
               wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)

        sbszdb.Add(sz, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        return [sbsz, sbszdb]
    def addGonModelerSettings(self):
        sb = wx.StaticBox(self, -1, 'Measurement')
        sbszmeasure = wx.StaticBoxSizer(sb, wx.VERTICAL)
        sb = wx.StaticBox(self, -1, 'Modeling')
        sbszmodel = wx.StaticBoxSizer(sb, wx.VERTICAL)

        self.widgets['measure axis'] = Choice(self, -1, choices=self.node.axes)
        self.widgets['measure points'] = IntEntry(self, -1, min=2, chars=5)
        self.widgets['measure tolerance'] = FloatEntry(self,
                                                       -1,
                                                       min=0.0,
                                                       chars=5)
        self.widgets['measure interval'] = FloatEntry(self, -1, chars=9)
        self.widgets['measure label'] = Entry(self, -1, chars=12)
        self.widgets['model label'] = Entry(self, -1, chars=12)

        self.widgets['model axis'] = Choice(self, -1, choices=self.node.axes)
        self.widgets['model magnification'] = FloatEntry(self, -1, chars=9)
        self.widgets['model terms'] = IntEntry(self, -1, chars=2)
        self.widgets['model mag only'] = wx.CheckBox(
            self, -1, 'Scale and Rotation Adjustment Only')

        szmeasure = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, -1, 'Axis:')
        szmeasure.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        szmeasure.Add(self.widgets['measure axis'], (0, 1), (1, 1),
                      wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
        label = wx.StaticText(self, -1, 'Points:')
        szmeasure.Add(label, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        szmeasure.Add(
            self.widgets['measure points'], (1, 1), (1, 1),
            wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'Tolerance:')
        szmeasure.Add(label, (2, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        szmeasure.Add(
            self.widgets['measure tolerance'], (2, 1), (1, 1),
            wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, '%')
        szmeasure.Add(label, (2, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        label = wx.StaticText(self, -1, 'Interval')
        szmeasure.Add(label, (3, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        szmeasure.Add(
            self.widgets['measure interval'], (3, 1), (1, 1),
            wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'Label')
        szmeasure.Add(label, (4, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        szmeasure.Add(
            self.widgets['measure label'], (4, 1), (1, 1),
            wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
        szmeasure.AddGrowableCol(1)

        sbszmeasure.Add(szmeasure, 1, wx.EXPAND | wx.ALL, 5)

        szmodel = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, -1, 'Label:')
        szmodel.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        szmodel.Add(
            self.widgets['model label'], (0, 1), (1, 1),
            wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'Axis:')
        szmodel.Add(label, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        szmodel.Add(self.widgets['model axis'], (1, 1), (1, 1),
                    wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
        label = wx.StaticText(self, -1, 'Magnification:')
        szmodel.Add(label, (2, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        szmodel.Add(
            self.widgets['model magnification'], (2, 1), (1, 1),
            wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'Terms:')
        szmodel.Add(label, (3, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        szmodel.Add(
            self.widgets['model terms'], (3, 1), (1, 1),
            wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
        szmodel.Add(self.widgets['model mag only'], (4, 0), (1, 2),
                    wx.ALIGN_CENTER)
        szmodel.AddGrowableCol(1)

        sbszmodel.Add(szmodel, 1, wx.EXPAND | wx.ALL, 5)

        return [sbszmeasure, sbszmodel]
Example #23
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)
        sb = wx.StaticBox(self, -1, 'Camera Configuration')
        self.sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)
        self.size = None
        self.binmethod = 'exact'
        self.geometry = None
        self.binnings = {'x': [1, 2, 3, 4, 6, 8], 'y': [1, 2, 3, 4, 6, 8]}
        self.defaultexptime = 1000.0
        self.defaultsaveframes = False
        self.defaultframetime = 200
        self.defaultalignframes = False
        self.defaultalignfilter = 'None'
        self.defaultuseframes = ''
        self.defaultreadoutdelay = 0
        self.common = {}
        self.setfuncs = {
            'exposure time': self._setExposureTime,
            'save frames': self._setSaveFrames,
            'frame time': self._setFrameTime,
            'align frames': self._setAlignFrames,
            'align filter': self._setAlignFilter,
            'use frames': self._setUseFrames,
            'readout delay': self._setReadoutDelay,
        }
        self.getfuncs = {
            'exposure time': self._getExposureTime,
            'save frames': self._getSaveFrames,
            'frame time': self._getFrameTime,
            'align frames': self._getAlignFrames,
            'align filter': self._getAlignFilter,
            'use frames': self._getUseFrames,
            'readout delay': self._getReadoutDelay,
        }

        # geometry
        self.ccommon = wx.Choice(self, -1, choices=['(None)'])
        self.ccommon.SetSelection(0)
        bcustom = wx.Button(self, -1, 'Custom...')

        std = wx.StaticText(self, -1, 'Dimension:')
        self.stdimension = wx.StaticText(self, -1, '')

        sto = wx.StaticText(self, -1, 'Offset:')
        self.stoffset = wx.StaticText(self, -1, '')

        stb = wx.StaticText(self, -1, 'Binning:')
        self.stbinning = wx.StaticText(self, -1, '')

        self.szmain = wx.GridBagSizer(3, 3)

        sz = wx.GridBagSizer(5, 5)
        sz.Add(self.ccommon, (0, 0), (1, 1),
               wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
        sz.Add(bcustom, (0, 1), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        sz.AddGrowableRow(0)
        sz.AddGrowableCol(0)
        sz.AddGrowableCol(1)
        self.szmain.Add(sz, (0, 0), (1, 2), wx.EXPAND)

        self.szmain.Add(std, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.szmain.Add(self.stdimension, (1, 1), (1, 1), wx.ALIGN_CENTER)

        self.szmain.Add(sto, (2, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.szmain.Add(self.stoffset, (2, 1), (1, 1), wx.ALIGN_CENTER)

        self.szmain.Add(stb, (3, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.szmain.Add(self.stbinning, (3, 1), (1, 1), wx.ALIGN_CENTER)

        # exposure time
        stet = wx.StaticText(self, -1, 'Exposure time:')
        self.feexposuretime = FloatEntry(self, -1, min=0.0, chars=7)
        stms = wx.StaticText(self, -1, 'ms')

        self.szmain.Add(stet, (4, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        sz = wx.GridBagSizer(0, 3)
        sz.Add(self.feexposuretime, (0, 0), (1, 1),
               wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        sz.Add(stms, (0, 1), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.szmain.Add(sz, (4, 1), (1, 2), wx.ALIGN_CENTER | wx.EXPAND)

        sb = wx.StaticBox(self, -1, 'Camera with Movie Mode')
        ddsb = wx.StaticBoxSizer(sb, wx.VERTICAL)
        ddsz = wx.GridBagSizer(5, 5)
        # save frames
        self.saveframes = wx.CheckBox(self, -1, 'Save frames')
        ddsz.Add(self.saveframes, (0, 0), (1, 2), wx.ALIGN_CENTER | wx.EXPAND)

        # frame time
        stet = wx.StaticText(self, -1, 'Exposure time per Frame:')
        self.frametime = FloatEntry(self, -1, min=0.01, chars=7)
        stms = wx.StaticText(self, -1, 'ms')

        ddsz.Add(stet, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        ftsz = wx.GridBagSizer(0, 3)
        ftsz.Add(self.frametime, (0, 0), (1, 1),
                 wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        ftsz.Add(stms, (0, 1), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        ddsz.Add(ftsz, (1, 1), (1, 2), wx.ALIGN_CENTER | wx.EXPAND)
        # use raw frames
        label = wx.StaticText(self, -1, 'Frames to use:')
        self.useframes = Entry(self, -1)
        ddsz.Add(label, (2, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        ddsz.Add(self.useframes, (2, 1), (1, 1), wx.ALIGN_CENTER | wx.EXPAND)

        # readout delay
        strd = wx.StaticText(self, -1, 'Readout delay:')
        self.readoutdelay = IntEntry(self, -1, chars=7)
        stms = wx.StaticText(self, -1, 'ms')
        sz = wx.BoxSizer(wx.HORIZONTAL)
        sz.Add(strd)
        sz.Add(self.readoutdelay)
        sz.Add(stms)
        ddsz.Add(sz, (3, 0), (1, 2), wx.ALIGN_CENTER | wx.EXPAND)

        # align frames box
        sb = wx.StaticBox(self, -1, 'Frame-Aligning Camera Only')
        afsb = wx.StaticBoxSizer(sb, wx.VERTICAL)
        afsz = wx.GridBagSizer(3, 3)
        # align frames
        self.alignframes = wx.CheckBox(self, -1, 'Align frames')
        afsz.Add(self.alignframes, (0, 0), (1, 2), wx.ALIGN_CENTER | wx.EXPAND)

        # align frame filter
        label = wx.StaticText(self, -1, 'c-correlation filter:')
        self.alignfilter = wx.Choice(self, -1, choices=self.getAlignFilters())
        self.alignfilter.SetSelection(0)
        afsz.Add(label, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        afsz.Add(self.alignfilter, (1, 1), (1, 1), wx.ALIGN_CENTER | wx.EXPAND)
        afsb.Add(afsz, 0, wx.EXPAND | wx.ALL, 2)

        ddsz.Add(afsb, (4, 0), (3, 2), wx.ALIGN_CENTER | wx.EXPAND)

        ddsb.Add(ddsz, 0, wx.EXPAND | wx.ALL, 2)
        self.szmain.Add(ddsb, (7, 0), (1, 3), wx.ALIGN_CENTER | wx.EXPAND)

        ddsz.AddGrowableCol(1)
        self.szmain.AddGrowableCol(1)
        self.szmain.AddGrowableCol(2)

        self.sbsz.Add(self.szmain, 0, wx.EXPAND | wx.ALL, 2)

        self.SetSizerAndFit(self.sbsz)

        self.Bind(wx.EVT_CHOICE, self.onCommonChoice, self.ccommon)
        self.Bind(wx.EVT_BUTTON, self.onCustomButton, bcustom)
        self.Bind(EVT_ENTRY, self.onExposureTime, self.feexposuretime)
        self.Bind(wx.EVT_CHECKBOX, self.onSaveFrames, self.saveframes)
        self.Bind(EVT_ENTRY, self.onFrameTime, self.frametime)
        self.Bind(EVT_ENTRY, self.onUseFrames, self.useframes)
        self.Bind(EVT_ENTRY, self.onReadoutDelay, self.readoutdelay)
        self.Bind(EVT_SET_CONFIGURATION, self.onSetConfiguration)
Example #24
0
class CameraPanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)
        sb = wx.StaticBox(self, -1, 'Camera Configuration')
        self.sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)
        self.size = None
        self.binmethod = 'exact'
        self.geometry = None
        self.binnings = {'x': [1, 2, 3, 4, 6, 8], 'y': [1, 2, 3, 4, 6, 8]}
        self.defaultexptime = 1000.0
        self.defaultsaveframes = False
        self.defaultframetime = 200
        self.defaultalignframes = False
        self.defaultalignfilter = 'None'
        self.defaultuseframes = ''
        self.defaultreadoutdelay = 0
        self.common = {}
        self.setfuncs = {
            'exposure time': self._setExposureTime,
            'save frames': self._setSaveFrames,
            'frame time': self._setFrameTime,
            'align frames': self._setAlignFrames,
            'align filter': self._setAlignFilter,
            'use frames': self._setUseFrames,
            'readout delay': self._setReadoutDelay,
        }
        self.getfuncs = {
            'exposure time': self._getExposureTime,
            'save frames': self._getSaveFrames,
            'frame time': self._getFrameTime,
            'align frames': self._getAlignFrames,
            'align filter': self._getAlignFilter,
            'use frames': self._getUseFrames,
            'readout delay': self._getReadoutDelay,
        }

        # geometry
        self.ccommon = wx.Choice(self, -1, choices=['(None)'])
        self.ccommon.SetSelection(0)
        bcustom = wx.Button(self, -1, 'Custom...')

        std = wx.StaticText(self, -1, 'Dimension:')
        self.stdimension = wx.StaticText(self, -1, '')

        sto = wx.StaticText(self, -1, 'Offset:')
        self.stoffset = wx.StaticText(self, -1, '')

        stb = wx.StaticText(self, -1, 'Binning:')
        self.stbinning = wx.StaticText(self, -1, '')

        self.szmain = wx.GridBagSizer(3, 3)

        sz = wx.GridBagSizer(5, 5)
        sz.Add(self.ccommon, (0, 0), (1, 1),
               wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
        sz.Add(bcustom, (0, 1), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        sz.AddGrowableRow(0)
        sz.AddGrowableCol(0)
        sz.AddGrowableCol(1)
        self.szmain.Add(sz, (0, 0), (1, 2), wx.EXPAND)

        self.szmain.Add(std, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.szmain.Add(self.stdimension, (1, 1), (1, 1), wx.ALIGN_CENTER)

        self.szmain.Add(sto, (2, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.szmain.Add(self.stoffset, (2, 1), (1, 1), wx.ALIGN_CENTER)

        self.szmain.Add(stb, (3, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.szmain.Add(self.stbinning, (3, 1), (1, 1), wx.ALIGN_CENTER)

        # exposure time
        stet = wx.StaticText(self, -1, 'Exposure time:')
        self.feexposuretime = FloatEntry(self, -1, min=0.0, chars=7)
        stms = wx.StaticText(self, -1, 'ms')

        self.szmain.Add(stet, (4, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        sz = wx.GridBagSizer(0, 3)
        sz.Add(self.feexposuretime, (0, 0), (1, 1),
               wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        sz.Add(stms, (0, 1), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.szmain.Add(sz, (4, 1), (1, 2), wx.ALIGN_CENTER | wx.EXPAND)

        sb = wx.StaticBox(self, -1, 'Camera with Movie Mode')
        ddsb = wx.StaticBoxSizer(sb, wx.VERTICAL)
        ddsz = wx.GridBagSizer(5, 5)
        # save frames
        self.saveframes = wx.CheckBox(self, -1, 'Save frames')
        ddsz.Add(self.saveframes, (0, 0), (1, 2), wx.ALIGN_CENTER | wx.EXPAND)

        # frame time
        stet = wx.StaticText(self, -1, 'Exposure time per Frame:')
        self.frametime = FloatEntry(self, -1, min=0.01, chars=7)
        stms = wx.StaticText(self, -1, 'ms')

        ddsz.Add(stet, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        ftsz = wx.GridBagSizer(0, 3)
        ftsz.Add(self.frametime, (0, 0), (1, 1),
                 wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        ftsz.Add(stms, (0, 1), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        ddsz.Add(ftsz, (1, 1), (1, 2), wx.ALIGN_CENTER | wx.EXPAND)
        # use raw frames
        label = wx.StaticText(self, -1, 'Frames to use:')
        self.useframes = Entry(self, -1)
        ddsz.Add(label, (2, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        ddsz.Add(self.useframes, (2, 1), (1, 1), wx.ALIGN_CENTER | wx.EXPAND)

        # readout delay
        strd = wx.StaticText(self, -1, 'Readout delay:')
        self.readoutdelay = IntEntry(self, -1, chars=7)
        stms = wx.StaticText(self, -1, 'ms')
        sz = wx.BoxSizer(wx.HORIZONTAL)
        sz.Add(strd)
        sz.Add(self.readoutdelay)
        sz.Add(stms)
        ddsz.Add(sz, (3, 0), (1, 2), wx.ALIGN_CENTER | wx.EXPAND)

        # align frames box
        sb = wx.StaticBox(self, -1, 'Frame-Aligning Camera Only')
        afsb = wx.StaticBoxSizer(sb, wx.VERTICAL)
        afsz = wx.GridBagSizer(3, 3)
        # align frames
        self.alignframes = wx.CheckBox(self, -1, 'Align frames')
        afsz.Add(self.alignframes, (0, 0), (1, 2), wx.ALIGN_CENTER | wx.EXPAND)

        # align frame filter
        label = wx.StaticText(self, -1, 'c-correlation filter:')
        self.alignfilter = wx.Choice(self, -1, choices=self.getAlignFilters())
        self.alignfilter.SetSelection(0)
        afsz.Add(label, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        afsz.Add(self.alignfilter, (1, 1), (1, 1), wx.ALIGN_CENTER | wx.EXPAND)
        afsb.Add(afsz, 0, wx.EXPAND | wx.ALL, 2)

        ddsz.Add(afsb, (4, 0), (3, 2), wx.ALIGN_CENTER | wx.EXPAND)

        ddsb.Add(ddsz, 0, wx.EXPAND | wx.ALL, 2)
        self.szmain.Add(ddsb, (7, 0), (1, 3), wx.ALIGN_CENTER | wx.EXPAND)

        ddsz.AddGrowableCol(1)
        self.szmain.AddGrowableCol(1)
        self.szmain.AddGrowableCol(2)

        self.sbsz.Add(self.szmain, 0, wx.EXPAND | wx.ALL, 2)

        self.SetSizerAndFit(self.sbsz)

        self.Bind(wx.EVT_CHOICE, self.onCommonChoice, self.ccommon)
        self.Bind(wx.EVT_BUTTON, self.onCustomButton, bcustom)
        self.Bind(EVT_ENTRY, self.onExposureTime, self.feexposuretime)
        self.Bind(wx.EVT_CHECKBOX, self.onSaveFrames, self.saveframes)
        self.Bind(EVT_ENTRY, self.onFrameTime, self.frametime)
        self.Bind(EVT_ENTRY, self.onUseFrames, self.useframes)
        self.Bind(EVT_ENTRY, self.onReadoutDelay, self.readoutdelay)
        self.Bind(EVT_SET_CONFIGURATION, self.onSetConfiguration)

        #self.Enable(False)

    def setGeometryLimits(self, limitdict):
        if limitdict is None:
            self.setSize(None)
        if 'binnings' in limitdict.keys():
            self.binnings['x'] = limitdict['binnings']
            self.binnings['y'] = limitdict['binnings']
        if 'binmethod' in limitdict.keys():
            self.binmethod = limitdict['binmethod']
        if 'size' in limitdict.keys():
            self.setSize(limitdict['size'])
        else:
            self.setSize(None)

    def setSize(self, size):
        if size is None:
            self.size = None
            self.Freeze()
            self.choices, self.common = None, None
            self.ccommon.Clear()
            self.ccommon.Append('(None)')
            self.szmain.Layout()
            #self.Enable(False)
            self.Thaw()
        else:
            self.size = dict(size)
            self.Freeze()
            self.choices, self.common = self.getCenteredGeometries()
            self.ccommon.Clear()
            self.ccommon.AppendItems(self.choices)
            if self.geometry is None or not self.validateGeometry():
                self.ccommon.SetSelection(len(self.choices) - 1)
                self.setGeometry(
                    self.common[self.ccommon.GetStringSelection()])
            else:
                self.setCommonChoice()
            if self.feexposuretime.GetValue() is None:
                self.feexposuretime.SetValue(self.defaultexptime)
            #self.Enable(True)
            self.szmain.Layout()
            self.Thaw()

    def clear(self):
        if self.size is None:
            return
        self.Freeze()
        self.ccommon.SetSelection(len(self.choices) - 1)
        self.setGeometry(self.common[self.ccommon.GetStringSelection()])
        self.feexposuretime.SetValue(self.defaultexptime)
        self.saveframes.SetValue(self.defaultsaveframes)
        self.frametime.SetValue(self.defaultframetime)
        self.alignframes.SetValue(self.defaultalignframes)
        self.alignfilter.SetValue(self.defaultalignfilter)
        self.useframes.SetValue(self.defaultuseframes)
        self.readoutdelay.SetValue(self.defaultreadoutdelay)
        #self.Enable(False)
        self.Thaw()

    def onConfigurationChanged(self):
        evt = ConfigurationChangedEvent(self.getConfiguration(), self)
        self.GetEventHandler().AddPendingEvent(evt)

    def onExposureTime(self, evt):
        self.onConfigurationChanged()

    def onSaveFrames(self, evt):
        self.onConfigurationChanged()

    def onFrameTime(self, evt):
        self.onConfigurationChanged()

    def onUseFrames(self, evt):
        self.onConfigurationChanged()

    def onReadoutDelay(self, evt):
        self.onConfigurationChanged()

    def setCommonChoice(self):
        for key, geometry in self.common.items():
            flag = True
            for i in ['dimension', 'offset', 'binning']:
                if self.geometry[i] != geometry[i]:
                    flag = False
                    break
            if flag:
                self.ccommon.SetStringSelection(key)
                return
        if self.ccommon.FindString('(Custom)') is wx.NOT_FOUND:
            self.ccommon.Insert('(Custom)', 0)
            self.ccommon.SetSelection(0)

    def _getDimension(self):
        return self.geometry['dimension']

    def _setDimension(self, value):
        self.geometry['dimension'] = value
        self.setCommonChoice()

    def _getOffset(self):
        return self.geometry['offset']

    def _setOffset(self, value):
        self.geometry['offset'] = value
        self.setCommonChoice()

    def _getBinning(self):
        return self.geometry['binning']

    def _setBinning(self, value):
        self.geometry['binning'] = value
        self.setCommonChoice()

    def _getExposureTime(self):
        return self.feexposuretime.GetValue()

    def _setExposureTime(self, value):
        self.feexposuretime.SetValue(value)

    def _getSaveFrames(self):
        return self.saveframes.GetValue()

    def _setSaveFrames(self, value):
        value = bool(value)
        self.saveframes.SetValue(value)

    def _getFrameTime(self):
        return self.frametime.GetValue()

    def _setFrameTime(self, value):
        self.frametime.SetValue(value)

    def _getAlignFrames(self):
        return self.alignframes.GetValue()

    def _setAlignFrames(self, value):
        value = bool(value)
        self.alignframes.SetValue(value)

    def getAlignFilters(self):
        return [
            'None', 'Hanning Window (default)', 'Bandpass Filter (default)',
            'Sobel Filter (default)', 'Combined Filter (default)'
        ]

    def _getAlignFilter(self):
        return self.alignfilter.GetStringSelection()

    def _setAlignFilter(self, value):
        if value:
            value = str(value)
        else:
            value = 'None'
        self.alignfilter.SetStringSelection(value)

    def _getUseFrames(self):
        frames_str = self.useframes.GetValue()
        numbers = re.split('\D+', frames_str)
        numbers = filter(None, numbers)
        if numbers:
            numbers = map(int, numbers)
            numbers = tuple(numbers)
        else:
            numbers = ()
        return numbers

    def _setUseFrames(self, value):
        if value:
            value = str(value)
        else:
            value = ''
        self.useframes.SetValue(value)

    def _getReadoutDelay(self):
        return self.readoutdelay.GetValue()

    def _setReadoutDelay(self, value):
        return self.readoutdelay.SetValue(value)

    def onCommonChoice(self, evt):
        key = evt.GetString()
        if key == '(Custom)' or key.startswith('-'):
            return
        if self.setGeometry(self.common[key]):
            self.onConfigurationChanged()
        n = self.ccommon.FindString('(Custom)')
        if n is not wx.NOT_FOUND:
            self.ccommon.Delete(n)

    def onCustomButton(self, evt):
        dialog = CustomDialog(self, self.getGeometry())
        if dialog.ShowModal() == wx.ID_OK:
            if self.setGeometry(dialog.getGeometry()):
                self.onConfigurationChanged()
            self.setCommonChoice()
        dialog.Destroy()

    def getCenteredGeometry(self, dimension, binning):
        offset = {}
        for axis in ['x', 'y']:
            offset[axis] = int((self.size[axis] / binning - dimension) / 2)

        geometry = {
            'dimension': {
                'x': dimension,
                'y': dimension
            },
            'offset': {
                'x': offset['x'],
                'y': offset['y']
            },
            'binning': {
                'x': binning,
                'y': binning
            }
        }
        return geometry

    def getFullGeometry(self, binning):
        if self.binmethod == 'exact' and ((self.size['x'] % binning) or
                                          (self.size['y'] % binning)):
            return None
        dimx = self.size['x'] / binning
        dimy = self.size['y'] / binning
        geometry = {
            'dimension': {
                'x': dimx,
                'y': dimy
            },
            'offset': {
                'x': 0,
                'y': 0
            },
            'binning': {
                'x': binning,
                'y': binning
            }
        }
        return geometry

    def getCenteredGeometries(self):
        geometries = {}
        keys = []
        show_sections = False
        if self.size['x'] != self.size['y']:
            show_sections = True
            keys.append('--- Full ---')
            for binning in self.binnings['x']:
                dimx = self.size['x'] / binning
                dimy = self.size['y'] / binning
                key = '%d x %d bin %d' % (dimx, dimy, binning)
                geo = self.getFullGeometry(binning)
                if geo is not None:
                    geometries[key] = geo
                    keys.append(key)
        if self.binnings['x'] != self.binnings['y']:
            return geometries
        self.minsize = min(self.size['x'], self.size['y'])
        dimensions = [int(self.minsize / float(b)) for b in self.binnings['x']]

        def good(dim):
            return not bool(numpy.modf(dim)[1] - dim)

        def filtergood(input, mask):
            result = []
            for i, inval in enumerate(input):
                if mask[i]:
                    result.append(inval)
            return result

        if self.binmethod == 'exact':
            mask = [good(dim) for dim in dimensions]
        else:
            mask = [True for dim in dimensions]
        dimensions = filtergood(dimensions, mask)

        def minsize(size):
            return size >= self.minsize / max(self.binnings['x'])

        dimensions = filter(minsize, dimensions)
        dimensions = map((lambda x: primefactor.getAllEvenPrimes(x)[-1]),
                         dimensions)
        binnings = filtergood(self.binnings['x'], mask)
        dimensions.reverse()
        if show_sections:
            keys.append('--- Center ---')
        for d in dimensions:
            for b in self.binnings['x']:
                if d * b <= self.minsize:
                    key = '%d x %d bin %d' % (d, d, b)
                    geometries[key] = self.getCenteredGeometry(d, b)
                    keys.append(key)
                else:
                    break
        return keys, geometries

    def validateGeometry(self, geometry=None):
        if geometry is None:
            geometry = self.geometry
        for a in ['x', 'y']:
            try:
                if geometry['dimension'][a] < 1 or geometry['offset'][a] < 0:
                    return False
                if geometry['binning'][a] not in self.binnings[a]:
                    return False
                size = geometry['dimension'][a] + geometry['offset'][a]
                size *= geometry['binning'][a]
                if size > self.size[a]:
                    return False
            except:
                return False
        return True

    def cmpGeometry(self, geometry):
        if self.geometry == geometry:
            return True
        for g in ['dimension', 'offset', 'binning']:
            try:
                for a in ['x', 'y']:
                    if self.geometry[g][a] != geometry[g][a]:
                        return False
            except (KeyError, TypeError):
                return False
        return True

    def setGeometry(self, geometry):
        if self.cmpGeometry(geometry):
            return False

        if self.size is not None and not self.validateGeometry(geometry):
            raise ValueError

        self._setGeometry(geometry)

        return True

    def getGeometry(self):
        return self.geometry

    def getConfiguration(self):
        g = self.getGeometry()
        if g is None:
            return None
        c = copy.deepcopy(g)
        for key, func in self.getfuncs.items():
            c[key] = func()
        return c

    def _setGeometry(self, geometry):
        if self.geometry is None:
            self.geometry = {}
        else:
            self.geometry = copy.deepcopy(self.geometry)
        self.Freeze()
        for g in ['dimension', 'offset', 'binning']:
            if g not in self.geometry:
                self.geometry[g] = {}
            try:
                self.geometry[g].update(dict(geometry[g]))
                if g == 'offset':
                    label = '(%d, %d)'
                else:
                    #label = '%d × %d'
                    label = '%d x %d'
                label = label % (self.geometry[g]['x'], self.geometry[g]['y'])
                getattr(self, 'st' + g).SetLabel(label)
            except:
                pass
        self.szmain.Layout()
        self.Thaw()
        return True

    def _setConfiguration(self, value):
        for key, func in self.setfuncs.items():
            if key in value:
                func(value[key])
        self._setGeometry(value)
        self.setCommonChoice()

    def setConfiguration(self, value):
        for key, func in self.setfuncs.items():
            if key in value:
                func(value[key])
        self.setGeometry(value)
        if self.size is not None:
            self.setCommonChoice()
        #if not self.IsEnabled():
        #       self.Enable(True)

    def onSetConfiguration(self, evt):
        self.setConfiguration(evt.configuration)
    def addSettings(self):
        presets = self.node.presetsclient.getPresetNames()
        self.widgets['preset'] = PresetChoice(self, -1)
        self.widgets['preset'].setChoices(presets)
        self.widgets['label'] = Entry(self, -1, allowspaces=False)
        self.widgets['radius'] = FloatEntry(self, -1, min=0.0, chars=6)
        self.widgets['max size'] = IntEntry(self, -1, chars=6)
        self.widgets['max targets'] = IntEntry(self, -1, chars=6)
        self.widgets['overlap'] = FloatEntry(self, -1, max=100.0, chars=6)
        self.widgets['mosaic center'] = Choice(
            self, -1, choices=['stage center', 'current position'])
        self.widgets['ignore request'] = wx.CheckBox(
            self, -1, 'Ignore Request to Make Targets from Others')

        #szradius = wx.GridBagSizer(5, 5)
        #szradius.Add(self.widgets['radius'], (0, 0), (1, 1),
        #                                                               wx.ALIGN_CENTER_VERTICAL|wx.FIXED_MINSIZE)
        #label = wx.StaticText(self, -1, 'meters')
        #szradius.Add(label, (0, 1), (1, 1), wx.ALIGN_CENTER_VERTICAL)

        sz = wx.GridBagSizer(5, 10)

        label = wx.StaticText(self, -1, 'Preset:')
        sz.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        sz.Add(self.widgets['preset'], (0, 1), (1, 1),
               wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)

        label = wx.StaticText(self, -1, 'Label:')
        sz.Add(label, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        sz.Add(self.widgets['label'], (1, 1), (1, 1),
               wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)

        label = wx.StaticText(self, -1, 'Radius:')
        sz.Add(label, (2, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        #sz.Add(szradius, (2, 1), (1, 1), wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
        sz.Add(self.widgets['radius'], (2, 1), (1, 1),
               wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE | wx.ALIGN_RIGHT)
        label = wx.StaticText(self, -1, 'm')
        sz.Add(label, (2, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)

        label = wx.StaticText(self, -1, 'Max size:')
        sz.Add(label, (3, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        sz.Add(self.widgets['max size'], (3, 1), (1, 1),
               wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)

        label = wx.StaticText(self, -1, 'Max targets:')
        sz.Add(label, (4, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        sz.Add(self.widgets['max targets'], (4, 1), (1, 1),
               wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)

        label = wx.StaticText(self, -1, 'Overlap:')
        sz.Add(label, (5, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        sz.Add(self.widgets['overlap'], (5, 1), (1, 1),
               wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE | wx.ALIGN_RIGHT)
        label = wx.StaticText(self, -1, '%')
        sz.Add(label, (5, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)

        label = wx.StaticText(self, -1, 'Mosaic Center:')
        sz.Add(label, (6, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        sz.Add(self.widgets['mosaic center'], (6, 1), (1, 1),
               wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE | wx.ALIGN_RIGHT)

        sz.Add(self.widgets['ignore request'], (7, 0), (1, 3),
               wx.ALIGN_CENTER_VERTICAL)

        sz.AddGrowableCol(1)

        return sz
class Panel(leginon.gui.wx.GridEntry.GridSelectionPanel):
    #icon = 'robot'
    def setDefaultGridSelection(self):
        self.default_gridlabel = '--Not-specified--'

    def addNew(self):
        self.createNewGridFromPlate((2, 0))
        self.createNewPlateSelector((4, 0))

    def runNew(self):
        self.node.onBadEMGridName('No Grid')

    def createNewGridFromPlate(self, start_position):
        sb = wx.StaticBox(self, -1, 'New Grid Batch')
        sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)
        szgrid = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, -1, 'Select a Grid Format (r x c:skips):')
        szgrid.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
        self.cgridformat = wx.Choice(self, -1)
        self.cgridformat.Enable(False)
        szgrid.Add(self.cgridformat, (0, 1), (1, 1), wx.ALIGN_CENTER_VERTICAL)

        label = wx.StaticText(self, -1, 'Select a plate in the project')
        szgrid.Add(label, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)

        self.cplate = wx.Choice(self, -1)
        self.cplate.Enable(False)

        szgrid.Add(self.cplate, (1, 1), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.savenewgrid = wx.Button(self, wx.ID_APPLY)

        szgrid.Add(self.savenewgrid, (2, 0), (1, 2), wx.ALIGN_CENTER_VERTICAL)

        szgrid.AddGrowableCol(1)
        sbsz.Add(szgrid, 0, wx.EXPAND | wx.ALL, 5)
        self.szmain.Add(sbsz, start_position, (1, 1),
                        wx.EXPAND | wx.ALL | wx.ALIGN_CENTER_VERTICAL)

    def createNewPlateSelector(self, start_position):
        sb = wx.StaticBox(self, -1, 'New Prep Plate')
        sbsz = wx.StaticBoxSizer(sb, wx.VERTICAL)
        szplate = wx.GridBagSizer(5, 5)
        # plate format
        label = wx.StaticText(self, -1, 'Plate Format:')
        szplate.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.cplateformat = wx.Choice(self, -1)
        self.cplateformat.Enable(False)
        szplate.Add(self.cplateformat, (0, 1), (1, 1),
                    wx.ALIGN_CENTER_VERTICAL)
        # plate name
        label = wx.StaticText(self, -1, 'New Plate Name:')
        szplate.Add(label, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        self.newplate = Entry(self, -1)
        szplate.Add(self.newplate, (1, 1), (1, 1),
                    wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)

        self.savenewplate = wx.Button(self, wx.ID_SAVE)

        szplate.Add(self.savenewplate, (2, 0), (1, 2),
                    wx.ALIGN_CENTER_VERTICAL)

        szplate.AddGrowableCol(1)
        sbsz.Add(szplate, 0, wx.EXPAND | wx.ALL, 5)
        self.szmain.Add(sbsz, start_position, (1, 1),
                        wx.EXPAND | wx.ALL | wx.ALIGN_CENTER_VERTICAL)

    def onNodeInitialized(self):
        super(Panel, self).onNodeInitialized()

        self.Bind(wx.EVT_BUTTON, self.onSaveNewGrids, self.savenewgrid)
        self.Bind(wx.EVT_CHOICE, self.onGridFormatChoice, self.cgridformat)
        self.Bind(wx.EVT_CHOICE, self.onPlateChoice, self.cplate)
        self.Bind(wx.EVT_CHOICE, self.onPlateFormatChoice, self.cplateformat)
        self.Bind(wx.EVT_BUTTON, self.onSaveNewPlate, self.savenewplate)
        self.refreshNewGrids()
        self.refreshPlates()

    def onSaveNewGrids(self, evt=None):
        self.cplate.Update()
        plate = self.cplate.GetStringSelection()
        if plate is None or plate == '':
            self.node.onBadEMGridName('No Plate')
            return
        if plate == '--New Plate as Below--':
            # save the new plate entry and then update the value
            status = self.onSaveNewPlate()
            if status is False:
                return
            plate = self.cplate.GetStringSelection()
        self.cgridformat.Update()
        gformat = self.cgridformat.GetStringSelection()
        if gformat is None or gformat == '':
            self.node.onBadEMGridName('No Grid Format')
            return
        else:
            self.node.publishNewEMGrids(gformat, plate)
        self.refreshGrids()

    def onGridFormatChoice(self, evt=None):
        if evt is None:
            formatlabel = self.cgridformat.GetStringSelection()
        else:
            formatlabel = evt.GetString()
        settings = self.node.getSettings()
        settings['grid format name'] = formatlabel
        self.node.setSettings(settings)
        self.newplate.Enable(False)

    def onPlateFormatChoice(self, evt=None):
        if evt is None:
            formatlabel = self.cplateformat.GetStringSelection()
        else:
            formatlabel = evt.GetString()
        settings = self.node.getSettings()
        settings['plate format name'] = formatlabel
        self.node.setSettings(settings)
        self.newplate.Enable(True)

    def setGridFormatSelection(self, choices):
        if choices:
            self.cgridformat.Clear()
            self.cgridformat.AppendItems(choices)
            if self.node.settings['grid format name']:
                n = self.cgridformat.FindString(
                    self.node.settings['grid format name'])
            else:
                n = wx.NOT_FOUND
            if n == wx.NOT_FOUND:
                self.cgridformat.SetSelection(0)
            else:
                self.cgridformat.SetSelection(n)
            self.cgridformat.Enable(True)
            self.onGridFormatChoice()

    def setPlateFormatSelection(self, choices):
        if choices:
            self.cplateformat.Clear()
            self.cplateformat.AppendItems(choices)
            if self.node.settings['plate format name']:
                n = self.cplateformat.FindString(
                    self.node.settings['plate format name'])
            else:
                n = wx.NOT_FOUND
            if n == wx.NOT_FOUND:
                self.cplateformat.SetSelection(0)
            else:
                self.cplateformat.SetSelection(n)
            self.cplateformat.Enable(True)
            self.onPlateFormatChoice()

    def onSaveNewPlate(self, evt=None):
        choices = self.node.getPlateNames()
        self.newplate.Update()
        newplate = self.newplate.GetValue()
        if newplate is None or newplate == '':
            self.node.onBadPlateName('No Plate Name')
            return False
        elif newplate in choices:
            self.node.onBadPlateName('Plate Name Exists')
            return False
        choices = self.node.getPlateFormats()
        self.cplateformat.Update()
        pformat = self.cplateformat.GetStringSelection()
        if pformat is None or pformat == '':
            self.node.onBadPlateName('No Plate Format')
            return False
        else:
            self.node.publishNewPlate(newplate, pformat)
        self.refreshPlates()

    def onPlateChoice(self, evt=None):
        if evt is None:
            platelabel = self.cplate.GetStringSelection()
        else:
            platelabel = evt.GetString()
        settings = self.node.getSettings()
        settings['plate name'] = platelabel
        self.node.setSettings(settings)
        if platelabel != '--New Plate as Below--':
            self.newplate.Enable(False)
        else:
            self.newplate.Enable(True)

    def setPlateSelection(self, choices):
        if choices:
            self.cplate.Clear()
            self.cplate.AppendItems(choices)
            if self.node.settings['plate name']:
                n = self.cplate.FindString(self.node.settings['plate name'])
            else:
                n = wx.NOT_FOUND
            if n == wx.NOT_FOUND:
                self.cplate.SetSelection(0)
            else:
                self.cplate.SetSelection(n)
            self.cplate.Enable(True)
            self.onPlateChoice()

    def onRefreshGridsButton(self, evt):
        self.refreshGrids()
        self.refreshNewGrids()
        self.refreshPlates()

    def refreshNewGrids(self):
        choices = self.node.getGridFormats()
        self.setGridFormatSelection(choices)

    def refreshPlates(self):
        choices = self.node.getPlateNames()
        choices.insert(0, '--New Plate as Below--')
        self.setPlateSelection(choices)
        choices = self.node.getPlateFormats()
        self.setPlateFormatSelection(choices)
Example #27
0
        def initialize(self):
                leginon.gui.wx.Settings.ScrolledDialog.initialize(self)
                sb = wx.StaticBox(self, -1, 'Stuff')
                sbsz= wx.StaticBoxSizer(sb, wx.VERTICAL)

                sz = wx.GridBagSizer(5, 5)

                self.gobut = wx.Button(self, -1, 'Go')
                sz.Add(self.gobut, (0, 0), (1, 1), wx.ALIGN_CENTER)

                self.testbut = wx.Button(self, -1, 'Test')
                sz.Add(self.testbut, (0, 1), (1, 1), wx.ALIGN_CENTER)

                lab = wx.StaticText(self, -1, 'minsize')
                self.widgets['minsize'] = FloatEntry(self, -1)
                sz.Add(lab, (1,0), (1,1))
                sz.Add(self.widgets['minsize'], (1,1), (1,1))

                lab = wx.StaticText(self, -1, 'maxsize')
                self.widgets['maxsize'] = FloatEntry(self, -1)
                sz.Add(lab, (2,0), (1,1))
                sz.Add(self.widgets['maxsize'], (2,1), (1,1))

                lab = wx.StaticText(self, -1, 'pause')
                self.widgets['pause'] = FloatEntry(self, -1)
                sz.Add(lab, (3,0), (1,1))
                sz.Add(self.widgets['pause'], (3,1), (1,1))

                lab = wx.StaticText(self, -1, 'label')
                self.widgets['label'] = Entry(self, -1)
                sz.Add(lab, (4,0), (1,1))
                sz.Add(self.widgets['label'], (4,1), (1,1))

                lab = wx.StaticText(self, -1, 'threshold')
                self.widgets['threshold'] = FloatEntry(self, -1)
                sz.Add(lab, (5,0), (1,1))
                sz.Add(self.widgets['threshold'], (5,1), (1,1))

                lab = wx.StaticText(self, -1, 'maxcount')
                self.widgets['maxcount'] = IntEntry(self, -1)
                sz.Add(lab, (6,0), (1,1))
                sz.Add(self.widgets['maxcount'], (6,1), (1,1))

                lab = wx.StaticText(self, -1, 'minbright')
                self.widgets['minbright'] = FloatEntry(self, -1)
                sz.Add(lab, (7,0), (1,1))
                sz.Add(self.widgets['minbright'], (7,1), (1,1))

                lab = wx.StaticText(self, -1, 'maxbright')
                self.widgets['maxbright'] = FloatEntry(self, -1)
                sz.Add(lab, (8,0), (1,1))
                sz.Add(self.widgets['maxbright'], (8,1), (1,1))

                lab = wx.StaticText(self, -1, 'cutoffpercent')
                self.widgets['cutoffpercent'] = FloatEntry(self, -1)
                sz.Add(lab, (9,0), (1,1))
                sz.Add(self.widgets['cutoffpercent'], (9,1), (1,1))

                lab = wx.StaticText(self, -1, 'magsteps')
                self.widgets['magsteps'] = IntEntry(self, -1)
                sz.Add(lab, (10,0), (1,1))
                sz.Add(self.widgets['magsteps'], (10,1), (1,1))

                lab = wx.StaticText(self, -1, 'mag1')
                self.widgets['mag1'] = IntEntry(self, -1)
                sz.Add(lab, (11,0), (1,1))
                sz.Add(self.widgets['mag1'], (11,1), (1,1))

                lab = wx.StaticText(self, -1, 'mag2')
                self.widgets['mag2'] = IntEntry(self, -1)
                sz.Add(lab, (12,0), (1,1))
                sz.Add(self.widgets['mag2'], (12,1), (1,1))

                sbsz.Add(sz, 0, wx.EXPAND|wx.ALL, 5)

                self.Bind(wx.EVT_BUTTON, self.onGo, self.gobut)
                self.Bind(wx.EVT_BUTTON, self.onTest, self.testbut)

                return [sbsz,]
Example #28
0
	def addSettings(self):
		sb = wx.StaticBox(self, -1, 'Main Screen')
		sbszscreen = wx.StaticBoxSizer(sb, wx.VERTICAL)
		sb = wx.StaticBox(self, -1, 'Low Dose')
		sbszlowdose = wx.StaticBoxSizer(sb, wx.VERTICAL)
		sb = wx.StaticBox(self, -1, 'Defocus Pair')
		sbszdefocus = wx.StaticBoxSizer(sb, wx.VERTICAL)

		self.instrumentselection = leginon.gui.wx.Instrument.SelectionPanel(self)
		self.panel.setInstrumentSelection(self.instrumentselection)

		self.widgets['camera settings'] = leginon.gui.wx.Camera.CameraPanel(self)
		self.widgets['camera settings'].setGeometryLimits({'size':self.node.instrument.camerasize,'binnings':self.node.instrument.camerabinnings,'binmethod':self.node.instrument.camerabinmethod})
		self.widgets['screen up'] = wx.CheckBox(self, -1, 'Up before acquire')
		self.widgets['screen down'] = wx.CheckBox(self, -1, 'Down after acquired')
		self.widgets['beam blank'] = wx.CheckBox(self, -1, 'Force beam blank after acquired')
		self.widgets['correct image'] = wx.CheckBox(self, -1, 'Correct image')
		self.widgets['save image'] = wx.CheckBox(self, -1,
																							'Save image to the database')
		self.widgets['image label'] = Entry(self, -1, chars=12)
		self.widgets['loop pause time'] = FloatEntry(self, -1, min=0.0, chars=4)
		self.widgets['low dose'] = wx.CheckBox(self, -1, 'Use low dose')
		self.widgets['low dose pause time'] = FloatEntry(self, -1, min=0.0, chars=4)

		szscreen = wx.GridBagSizer(5, 5)
		szscreen.Add(self.widgets['screen up'], (0, 0), (1, 1),
									wx.ALIGN_CENTER_VERTICAL)
		szscreen.Add(self.widgets['screen down'], (1, 0), (1, 1),
									wx.ALIGN_CENTER_VERTICAL)

		sbszscreen.Add(szscreen, 1, wx.EXPAND|wx.ALL, 5)

		szlowdose = wx.GridBagSizer(5, 5)
		szlowdose.Add(self.widgets['low dose'], (0, 0), (1, 1),
									wx.ALIGN_CENTER_VERTICAL)
		szlowdose.Add(self.widgets['beam blank'], (1, 0), (1, 1),
									wx.ALIGN_CENTER_VERTICAL)
		label = wx.StaticText(self, -1, 'Low dose pause')
		szlowdose.Add(label, (2, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		szlowdose.Add(self.widgets['low dose pause time'], (2, 1), (1, 1),
									wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.FIXED_MINSIZE)
		label = wx.StaticText(self, -1, 'seconds')
		szlowdose.Add(label, (2, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		szlowdose.AddGrowableCol(1)

		sbszlowdose.Add(szlowdose, 1, wx.EXPAND|wx.ALL, 5)

		sz = wx.GridBagSizer(5, 5)
		sz.Add(self.instrumentselection, (0, 0), (1, 3), wx.EXPAND)
		sz.Add(self.widgets['camera settings'], (1, 0), (1, 3), wx.EXPAND)
		sz.Add(self.widgets['correct image'], (2, 0), (1, 3),
						wx.ALIGN_CENTER_VERTICAL)
		sz.Add(self.widgets['save image'], (3, 0), (1, 3),
						wx.ALIGN_CENTER_VERTICAL)

		sb2 = wx.GridBagSizer(5,5)
	
		szdefocus= wx.GridBagSizer(5, 5)
		label = wx.StaticText(self, -1,'(leave both unchecked to use current defocus)')
		szdefocus.Add(label, (0,0), (1,2))
		self.widgets['defocus1switch'] = wx.CheckBox(self, -1, 'Defocus 1')
		szdefocus.Add(self.widgets['defocus1switch'], (1,0), (1,1))
		self.widgets['defocus1'] = FloatEntry(self, -1, chars=6)
		szdefocus.Add(self.widgets['defocus1'], (1,1), (1,1))
		self.widgets['defocus2switch'] = wx.CheckBox(self, -1, 'Defocus 2')
		szdefocus.Add(self.widgets['defocus2switch'], (2,0), (1,1))
		self.widgets['defocus2'] = FloatEntry(self, -1, chars=6)
		szdefocus.Add(self.widgets['defocus2'], (2,1), (1,1))
		sbszdefocus.Add(szdefocus, 1, wx.EXPAND|wx.ALL, 5)
		sb2.Add(sbszscreen,(0,0),(1,3), wx.EXPAND)
		sb2.Add(sbszlowdose,(1,0),(1,3), wx.EXPAND)
		sb2.Add(sbszdefocus,(2,0),(1,3), wx.EXPAND)

		label = wx.StaticText(self, -1, 'Loop pause')
		sb2.Add(label, (3, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		sb2.Add(self.widgets['loop pause time'], (3, 1), (1, 1),
						wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.FIXED_MINSIZE)
		label = wx.StaticText(self, -1, 'seconds')
		sb2.Add(label, (3, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		label = wx.StaticText(self, -1, 'Label')
		sb2.Add(label, (4, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
		sb2.Add(self.widgets['image label'], (4, 1), (1, 1),
						wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.FIXED_MINSIZE)
		sb2.AddGrowableCol(1)
		self.widgets['dark'] = wx.CheckBox(self, -1, 'Dark Exposure')
		sb2.Add(self.widgets['dark'], (5,0), (1,1))

		self.widgets['force annotate'] = wx.CheckBox(self, -1, 'Always Annotate Saved Images')
		sb2.Add(self.widgets['force annotate'], (6,0), (1,1))

		self.widgets['reduced params'] = wx.CheckBox(self, -1, 'Reduced EM Parameter Set (for slow TEMs)')
		sb2.Add(self.widgets['reduced params'], (7,0), (1,1))

		sba = wx.GridBagSizer(5,5)
		# put the two sizers in columns
		sba.Add(sz,(0,0),(1,1))
		sba.Add(sb2,(0,1),(1,1))

		return sba
Example #29
0
        def initialize(self):
                leginon.gui.wx.Settings.ScrolledDialog.initialize(self)
                sb = wx.StaticBox(self, -1, 'Low Pass Filter (Phase Correlation)')
                sbszlpf = wx.StaticBoxSizer(sb, wx.VERTICAL)
                sb = wx.StaticBox(self, -1, 'Template Correlation')
                sbsztemplate = wx.StaticBoxSizer(sb, wx.VERTICAL)

                self.widgets['template lpf'] = {}
                self.widgets['template lpf']['sigma'] = FloatEntry(self, -1,
                                                                                                                                                                                                                                min=0.0, chars=4)

                szlpf = wx.GridBagSizer(5, 5)
                label = wx.StaticText(self, -1, 'Sigma:')
                szlpf.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
                szlpf.Add(self.widgets['template lpf']['sigma'], (0, 1), (1, 1),
                                                wx.ALIGN_CENTER_VERTICAL|wx.FIXED_MINSIZE|wx.ALIGN_RIGHT)
                szlpf.AddGrowableCol(1)

                sbszlpf.Add(szlpf, 1, wx.EXPAND|wx.ALL, 5)

                self.widgets['template filename'] = Entry(self, -1, chars=12)
                self.widgets['file diameter'] = IntEntry(self, -1, chars=4)
                self.widgets['template diameter'] = IntEntry(self, -1, chars=4)

                self.widgets['template type'] = Choice(self, -1, choices=self.node.cortypes)

                szcor = wx.GridBagSizer(5, 5)
                label = wx.StaticText(self, -1, 'Use')
                szcor.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
                szcor.Add(self.widgets['template type'], (0, 1), (1, 1),
                                                        wx.ALIGN_CENTER_VERTICAL)
                label = wx.StaticText(self, -1, 'correlation')
                szcor.Add(label, (0, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)

                sztemplate = wx.GridBagSizer(5, 5)
                sztemplate.Add(szcor, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)

                label = wx.StaticText(self, -1, 'Template Filename')
                sztemplate.Add(label, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
                sztemplate.Add(self.widgets['template filename'], (1, 1), (1, 1),
                                                                                wx.ALIGN_CENTER|wx.FIXED_MINSIZE)

                label = wx.StaticText(self, -1, 'Original Template Diameter')
                sztemplate.Add(label, (2, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
                sztemplate.Add(self.widgets['file diameter'], (2, 1), (1, 1),
                                                                                wx.ALIGN_CENTER|wx.FIXED_MINSIZE)

                label = wx.StaticText(self, -1, 'Final Template Diameter')
                sztemplate.Add(label, (3, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
                sztemplate.Add(self.widgets['template diameter'], (3, 1), (1, 1),
                                                                                wx.ALIGN_CENTER|wx.FIXED_MINSIZE)

                sbsztemplate.Add(sztemplate, 1, wx.EXPAND|wx.ALL, 5)

                self.btest = wx.Button(self, -1, 'Test')
                szbutton = wx.GridBagSizer(5, 5)
                szbutton.Add(self.btest, (0, 0), (1, 1),
                                                                        wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
                szbutton.AddGrowableCol(0)

                self.Bind(wx.EVT_BUTTON, self.onTestButton, self.btest)

                return [sbsztemplate, sbszlpf, szbutton]
    def addTomoSettings(self):
        tiltsb = wx.StaticBox(self, -1, 'Tilt')
        tiltsbsz = wx.StaticBoxSizer(tiltsb, wx.VERTICAL)
        equalslopesb = wx.StaticBox(self, -1, 'Cosine Rule Tilting')
        equalslopesbsz = wx.StaticBoxSizer(equalslopesb, wx.VERTICAL)
        expsb = wx.StaticBox(self, -1, 'Exposure')
        expsbsz = wx.StaticBoxSizer(expsb, wx.VERTICAL)
        bcsb = wx.StaticBox(self, -1, 'Before Collection')
        bcsbsz = wx.StaticBoxSizer(bcsb, wx.VERTICAL)
        miscsb = wx.StaticBox(self, -1, 'Misc.')
        miscsbsz = wx.StaticBoxSizer(miscsb, wx.VERTICAL)
        modelb = wx.StaticBox(self, -1, 'Model')
        modelbsz = wx.StaticBoxSizer(modelb, wx.VERTICAL)
        optb = wx.StaticBox(self, -1,
                            'Custom Tilt Axis Model in +/- Directions(d)')
        optbsz = wx.StaticBoxSizer(optb, wx.VERTICAL)

        self.widgets['tilt min'] = FloatEntry(self,
                                              -1,
                                              allownone=False,
                                              chars=7,
                                              value='0.0')
        self.widgets['tilt max'] = FloatEntry(self,
                                              -1,
                                              allownone=False,
                                              chars=7,
                                              value='0.0')
        self.widgets['tilt start'] = FloatEntry(self,
                                                -1,
                                                allownone=False,
                                                chars=7,
                                                value='0.0')
        self.widgets['tilt step'] = FloatEntry(self,
                                               -1,
                                               allownone=False,
                                               chars=7,
                                               value='0.0')
        self.widgets['equally sloped'] = wx.CheckBox(self, -1,
                                                     'Use cosine rule')
        self.widgets['equally sloped n'] = IntEntry(self,
                                                    -1,
                                                    min=1,
                                                    allownone=False,
                                                    chars=5,
                                                    value='30')

        tiltoptsz = wx.GridBagSizer(5, 5)
        tiltsz = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, -1, 'Min.')
        tiltsz.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL | wx.LEFT,
                   10)
        tiltsz.Add(self.widgets['tilt min'], (0, 1), (1, 1),
                   wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'Max.')
        tiltsz.Add(label, (0, 2), (1, 1),
                   wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10)
        tiltsz.Add(self.widgets['tilt max'], (0, 3), (1, 1),
                   wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'Start')
        tiltsz.Add(label, (0, 4), (1, 1),
                   wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10)
        tiltsz.Add(self.widgets['tilt start'], (0, 5), (1, 1),
                   wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'Step')
        tiltsz.Add(label, (0, 6), (1, 1),
                   wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10)
        tiltsz.Add(self.widgets['tilt step'], (0, 7), (1, 1),
                   wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'degree(s)')
        tiltsz.Add(label, (0, 8), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        addonsizer = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, -1,
                              'List of Extra Tilts to Collect (in degrees)')
        addonsizer.Add(label, (0, 0), (1, 2), wx.ALIGN_CENTER_VERTICAL)
        self.widgets['addon tilts'] = Entry(self,
                                            -1,
                                            chars=45,
                                            style=wx.ALIGN_RIGHT | wx.EXPAND)
        addonsizer.Add(self.widgets['addon tilts'], (0, 2), (1, 7), wx.EXPAND)
        addonsizer.AddGrowableCol(2)
        tiltsz.Add(addonsizer, (1, 0), (1, 9), wx.EXPAND)

        tiltoptsz.Add(tiltsz, (1, 0), (2, 9),
                      wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
        equalslopesz = wx.GridBagSizer(0, 5)
        equalslopesz.Add(self.widgets['equally sloped'], (0, 0), (1, 2),
                         wx.ALIGN_LEFT | wx.FIXED_MINSIZE)
        equalslopesz.Add(self.widgets['equally sloped n'], (1, 0), (1, 1),
                         wx.ALIGN_LEFT | wx.FIXED_MINSIZE)
        label = wx.StaticText(
            self, -1, 'Number of tilts in the maximal tilting direction')
        equalslopesz.Add(label, (1, 1), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        equalslopesbsz.Add(equalslopesz, 0, wx.EXPAND)
        tiltoptsz.Add(equalslopesbsz, (0, 9), (3, 2),
                      wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)

        tiltsbsz.Add(tiltoptsz, 0, wx.EXPAND | wx.ALL, 5)

        self.widgets['dose'] = FloatEntry(self,
                                          -1,
                                          min=0.0,
                                          allownone=False,
                                          chars=7,
                                          value='200.0')
        self.widgets['min exposure'] = FloatEntry(self,
                                                  -1,
                                                  min=0.0,
                                                  allownone=False,
                                                  chars=5,
                                                  value='0.25')
        self.widgets['max exposure'] = FloatEntry(self,
                                                  -1,
                                                  min=0.0,
                                                  allownone=False,
                                                  chars=5,
                                                  value='2.0')

        expsz = wx.GridBagSizer(5, 10)
        label = wx.StaticText(self, -1, 'Total dose')
        expsz.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        expsz.Add(self.widgets['dose'], (0, 1), (1, 1),
                  wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'e-/A^2')
        expsz.Add(label, (0, 2), (1, 1),
                  wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'Exposure time')
        expsz.Add(label, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)

        exptsz = wx.GridBagSizer(0, 0)
        label = wx.StaticText(self, -1, 'Min.')
        exptsz.Add(label, (0, 0), (1, 1),
                   wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        exptsz.Add(self.widgets['min exposure'], (0, 1), (1, 1),
                   wx.ALIGN_LEFT | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'Max.')
        exptsz.Add(label, (0, 2), (1, 1),
                   wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        exptsz.Add(self.widgets['max exposure'], (0, 3), (1, 1),
                   wx.ALIGN_LEFT | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'seconds')
        exptsz.Add(label, (0, 4), (1, 1), wx.ALIGN_CENTER_VERTICAL)

        expsz.Add(exptsz, (1, 1), (1, 2),
                  wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)

        expsz.AddGrowableCol(0)
        expsz.AddGrowableRow(0)
        expsz.AddGrowableRow(1)

        expsbsz.Add(expsz, 1, wx.EXPAND | wx.ALL, 5)

        self.widgets['run buffer cycle'] = wx.CheckBox(self, -1,
                                                       'Run buffer cycle')
        self.widgets['align zero loss peak'] = wx.CheckBox(
            self, -1, 'Align zero loss peak')
        self.widgets['measure dose'] = wx.CheckBox(self, -1, 'Measure dose')

        bcsz = wx.GridBagSizer(5, 10)
        bcsz.Add(self.widgets['run buffer cycle'], (0, 0), (1, 1),
                 wx.ALIGN_CENTER_VERTICAL)
        bcsz.Add(self.widgets['align zero loss peak'], (0, 1), (1, 1),
                 wx.ALIGN_CENTER_VERTICAL)
        bcsz.Add(self.widgets['measure dose'], (1, 0), (1, 1),
                 wx.ALIGN_CENTER_VERTICAL)
        bcsbsz.Add(bcsz, 1, wx.ALL | wx.ALIGN_CENTER, 5)

        self.widgets['integer'] = wx.CheckBox(self, -1, 'Scale by')
        self.widgets['intscale'] = FloatEntry(self,
                                              -1,
                                              min=0.0,
                                              allownone=False,
                                              chars=5,
                                              value='10.0')
        self.widgets['mean threshold'] = FloatEntry(self,
                                                    -1,
                                                    min=0.0,
                                                    allownone=False,
                                                    chars=5,
                                                    value='100.0')
        self.widgets['collection threshold'] = FloatEntry(self,
                                                          -1,
                                                          min=0.0,
                                                          allownone=False,
                                                          chars=5,
                                                          value='90.0')
        self.widgets['tilt pause time'] = FloatEntry(self,
                                                     -1,
                                                     min=0.0,
                                                     allownone=False,
                                                     chars=5,
                                                     value='1.0')
        #		self.widgets['measure defocus'] = wx.CheckBox(self, -1, 'Measure defocus')
        self.widgets['use lpf'] = wx.CheckBox(
            self, -1, 'Use lpf in peak finding of tilt image correlation')
        self.widgets['use tilt'] = wx.CheckBox(
            self, -1,
            'Stretch images according to the tilt before correlation')

        #		tapersz = wx.GridBagSizer(5,5)
        #		lab = wx.StaticText(self, -1, 'edge tapered upto')
        #		tapersz.Add(lab, (0,0), (1,1))
        #		tapersz.Add(self.widgets['taper size'], (0,1), (1,1))
        #		lab = wx.StaticText(self, -1, '% image length')
        #		tapersz.Add(lab, (0,2), (1,1))

        intsz = wx.GridBagSizer(5, 5)
        intsz.Add(self.widgets['integer'], (0, 0), (1, 1),
                  wx.ALIGN_CENTER_VERTICAL)
        intsz.Add(self.widgets['intscale'], (0, 1), (1, 1),
                  wx.ALIGN_CENTER_VERTICAL)
        label = wx.StaticText(self, -1, 'to convert to integer')
        intsz.Add(label, (0, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)

        mtsz = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, -1, 'Consider images with less than')
        mtsz.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        mtsz.Add(self.widgets['mean threshold'], (0, 1), (1, 1),
                 wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'counts as obstructed')
        mtsz.Add(label, (0, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)

        ctsz = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, -1,
                              'Abort if first half collected less than')
        ctsz.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        ctsz.Add(self.widgets['collection threshold'], (0, 1), (1, 1),
                 wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, '% of images')
        ctsz.Add(label, (0, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)

        tptsz = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, -1, 'Pause')
        tptsz.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        tptsz.Add(self.widgets['tilt pause time'], (0, 1), (1, 1),
                  wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'seconds before each tilt image.')
        tptsz.Add(label, (0, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)

        miscsz = wx.GridBagSizer(5, 10)
        miscsz.Add(intsz, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        miscsz.Add(mtsz, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        miscsz.Add(ctsz, (2, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        miscsz.Add(tptsz, (3, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        miscsz.Add(self.widgets['use lpf'], (4, 0), (1, 1), wx.ALIGN_CENTER)
        miscsz.Add(self.widgets['use tilt'], (5, 0), (1, 1), wx.ALIGN_CENTER)
        #miscsz.Add(tapersz, (7, 0), (1, 1), wx.ALIGN_CENTER)
        #miscsz.Add(self.widgets['measure defocus'], (5, 0), (1, 1), wx.ALIGN_CENTER)
        miscsbsz.Add(miscsz, 1, wx.ALL | wx.ALIGN_CENTER, 5)

        modelmags = self.getMagChoices()
        self.widgets['model mag'] = wx.Choice(self, -1, choices=modelmags)
        self.widgets['phi'] = FloatEntry(self,
                                         -1,
                                         allownone=False,
                                         chars=4,
                                         value='0.0')
        self.widgets['phi2'] = FloatEntry(self,
                                          -1,
                                          allownone=False,
                                          chars=4,
                                          value='0.0')
        self.widgets['offset'] = FloatEntry(self,
                                            -1,
                                            allownone=False,
                                            chars=6,
                                            value='0.0')
        self.widgets['offset2'] = FloatEntry(self,
                                             -1,
                                             allownone=False,
                                             chars=6,
                                             value='0.0')
        self.widgets['z0'] = FloatEntry(self,
                                        -1,
                                        allownone=False,
                                        chars=6,
                                        value='0.0')
        self.widgets['z02'] = FloatEntry(self,
                                         -1,
                                         allownone=False,
                                         chars=6,
                                         value='0.0')
        self.widgets['z0 error'] = FloatEntry(self,
                                              -1,
                                              min=0.0,
                                              allownone=False,
                                              chars=6,
                                              value='2e-6')
        self.widgets['fixed model'] = wx.CheckBox(
            self, -1, 'Keep the tilt axis parameters fixed')
        self.widgets['use z0'] = wx.CheckBox(
            self, -1, 'Initialize z0 with current model')
        self.widgets['fit data points'] = IntEntry(self,
                                                   -1,
                                                   min=4,
                                                   allownone=False,
                                                   chars=5,
                                                   value='4')

        magsz = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, -1, 'Initialize with the model of')
        magsz.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        magsz.Add(self.widgets['model mag'], (0, 1), (1, 1),
                  wx.ALIGN_CENTER_VERTICAL)

        phisz = wx.GridBagSizer(2, 2)
        phisz.AddGrowableCol(0)
        label = wx.StaticText(self, -1, 'Tilt Axis from Y')
        phisz.Add(label, (0, 0), (2, 1), wx.ALIGN_CENTER_VERTICAL)
        label = wx.StaticText(self, -1, '+d')
        phisz.Add(label, (0, 1), (1, 1),
                  wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
        phisz.Add(self.widgets['phi'], (0, 2), (1, 1),
                  wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, '-d')
        phisz.Add(label, (1, 1), (1, 1),
                  wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
        phisz.Add(self.widgets['phi2'], (1, 2), (1, 1),
                  wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'degs')
        phisz.Add(label, (0, 3), (2, 1), wx.ALIGN_CENTER_VERTICAL)

        offsetsz = wx.GridBagSizer(2, 2)
        label = wx.StaticText(self, -1, 'Offset:')
        offsetsz.Add(label, (0, 0), (2, 1), wx.ALIGN_CENTER_VERTICAL)
        label = wx.StaticText(self, -1, '+d')
        offsetsz.Add(label, (0, 1), (1, 1),
                     wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
        offsetsz.Add(self.widgets['offset'], (0, 2), (1, 1),
                     wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'um')
        offsetsz.Add(label, (0, 3), (2, 1), wx.ALIGN_CENTER_VERTICAL)
        label = wx.StaticText(self, -1, '-d')
        offsetsz.Add(label, (1, 1), (1, 1),
                     wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
        offsetsz.Add(self.widgets['offset2'], (1, 2), (1, 1),
                     wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        z0sz = wx.GridBagSizer(2, 2)
        label = wx.StaticText(self, -1, 'Z0:')
        z0sz.Add(label, (0, 0), (2, 1), wx.ALIGN_CENTER_VERTICAL)
        label = wx.StaticText(self, -1, '+d')
        z0sz.Add(label, (0, 1), (1, 1),
                 wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
        z0sz.Add(self.widgets['z0'], (0, 2), (1, 1),
                 wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'um')
        z0sz.Add(label, (0, 3), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        label = wx.StaticText(self, -1, '-d')
        z0sz.Add(label, (1, 1), (1, 1),
                 wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
        z0sz.Add(self.widgets['z02'], (1, 2), (1, 1),
                 wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'um')
        z0sz.Add(label, (1, 3), (2, 1), wx.ALIGN_CENTER_VERTICAL)

        optsz = wx.GridBagSizer(5, 10)
        optsz.Add(phisz, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        optsz.Add(offsetsz, (0, 1), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        optsz.Add(z0sz, (1, 0), (1, 2), wx.ALIGN_CENTER_VERTICAL)
        optbsz.Add(optsz, 1, wx.ALL | wx.ALIGN_CENTER, 5)
        optsz.AddGrowableCol(0)

        zsz = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, -1, 'Allow')
        zsz.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        zsz.Add(self.widgets['z0 error'], (0, 1), (1, 1),
                wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'um of z0 jump between models')
        zsz.Add(label, (0, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)

        fsz = wx.GridBagSizer(5, 5)
        label = wx.StaticText(self, -1, 'Smooth')
        fsz.Add(label, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        fsz.Add(self.widgets['fit data points'], (0, 1), (1, 1),
                wx.ALIGN_CENTER_VERTICAL | wx.FIXED_MINSIZE)
        label = wx.StaticText(self, -1, 'tilts (>=4) for defocus prediction')
        fsz.Add(label, (0, 2), (1, 1), wx.ALIGN_CENTER_VERTICAL)

        modelsz = wx.GridBagSizer(5, 5)
        modelsz.Add(magsz, (0, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        modelsz.Add(optbsz, (1, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        modelsz.Add(zsz, (2, 0), (1, 1), wx.ALIGN_CENTER_VERTICAL)
        modelsz.Add(self.widgets['fixed model'], (3, 0), (1, 1),
                    wx.ALIGN_CENTER_VERTICAL)
        modelsz.Add(self.widgets['use z0'], (4, 0), (1, 1),
                    wx.ALIGN_CENTER_VERTICAL)
        modelsz.Add(fsz, (5, 0), (1, 1), wx.ALIGN_RIGHT)

        modelbsz.Add(modelsz, 1, wx.ALL | wx.ALIGN_CENTER, 5)
        modelsz.AddGrowableCol(0)

        sz = wx.GridBagSizer(5, 5)
        sz.Add(tiltsbsz, (0, 0), (1, 2), wx.EXPAND)
        sz.Add(expsbsz, (1, 0), (1, 1), wx.EXPAND)
        sz.Add(bcsbsz, (1, 1), (1, 1), wx.EXPAND)
        sz.Add(miscsbsz, (2, 0), (1, 1), wx.EXPAND)
        sz.Add(modelbsz, (2, 1), (1, 1), wx.EXPAND)
        sz.AddGrowableRow(0)
        sz.AddGrowableRow(1)
        sz.AddGrowableRow(2)
        sz.AddGrowableCol(0)
        sz.AddGrowableCol(1)

        self.Bind(wx.EVT_CHECKBOX, self.onFixedModel,
                  self.widgets['fixed model'])
        return sz