class SettingsWindow(wxtbx.utils.SettingsPanel): def __init__(self, *args, **kwds): wxtbx.utils.SettingsPanel.__init__(self, *args, **kwds) self.Bind(wx.EVT_CHAR, self.OnChar) def OnChar(self, event): self.GetParent().viewer.OnChar(event) def add_controls(self): # d_min control self.d_min_ctrl = floatspin.FloatSpin(parent=self, increment=0.05, digits=2) self.d_min_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.d_min_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "High resolution:") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.d_min_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.d_min_ctrl) self.z_min_ctrl = floatspin.FloatSpin(parent=self, increment=1, digits=0) self.z_min_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.z_min_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Min Z") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.z_min_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.z_min_ctrl) self.z_max_ctrl = floatspin.FloatSpin(parent=self, increment=1, digits=0) self.z_max_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.z_max_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Max Z") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.z_max_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.z_max_ctrl) # Control for spot size (utility depends on n_signal column in reflection # file - will be ignored if not in file self.n_min_ctrl = floatspin.FloatSpin(parent=self, increment=1, digits=0) self.n_min_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.n_min_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Min Pixels") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.n_min_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.n_min_ctrl) self.n_max_ctrl = floatspin.FloatSpin(parent=self, increment=1, digits=0) self.n_max_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.n_max_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Max Pixels") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.n_max_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.n_max_ctrl) # end new control self.partiality_min_ctrl = floatspin.FloatSpin(parent=self, increment=0.01, digits=3, min_val=0, max_val=1) self.partiality_min_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.partiality_min_ctrl.SetBackgroundColour( self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Min partiality") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.partiality_min_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.partiality_min_ctrl) self.partiality_max_ctrl = floatspin.FloatSpin(parent=self, increment=0.01, digits=3, min_val=0, max_val=1) self.partiality_max_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.partiality_max_ctrl.SetBackgroundColour( self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Max partiality") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.partiality_max_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.partiality_max_ctrl) ctrls = self.create_controls(setting="show_rotation_axis", label="Show rotation axis") self.panel_sizer.Add(ctrls[0], 0, wx.ALL, 5) ctrls = self.create_controls(setting="show_beam_vector", label="Show beam vector") self.panel_sizer.Add(ctrls[0], 0, wx.ALL, 5) ctrls = self.create_controls(setting="show_reciprocal_cell", label="Show reciprocal cell") self.panel_sizer.Add(ctrls[0], 0, wx.ALL, 5) self.reverse_phi_ctrl = self.create_controls( setting="reverse_phi", label="Invert rotation axis")[0] self.panel_sizer.Add(self.reverse_phi_ctrl, 0, wx.ALL, 5) self.Bind(wx.EVT_CHECKBOX, self.OnChangeSettings, self.reverse_phi_ctrl) self.crystal_frame_tooltip = wx.ToolTip( "Show the reciprocal lattice(s) in the crystal rather than the laboratory frame" ) self.crystal_frame_ctrl = self.create_controls( setting="crystal_frame", label="Show in crystal frame")[0] self.crystal_frame_ctrl.SetToolTip(self.crystal_frame_tooltip) self.panel_sizer.Add(self.crystal_frame_ctrl, 0, wx.ALL, 5) self.Bind(wx.EVT_CHECKBOX, self.OnChangeSettings, self.crystal_frame_ctrl) self.beam_fast_ctrl = floatspin.FloatSpin(parent=self, increment=0.01, digits=2) self.beam_fast_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.beam_fast_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Beam centre (mm)") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.beam_fast_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.beam_fast_ctrl) self.beam_slow_ctrl = floatspin.FloatSpin(parent=self, increment=0.01, digits=2) self.beam_slow_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.beam_slow_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box.Add(self.beam_slow_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.beam_slow_ctrl) self.marker_size_ctrl = floatspin.FloatSpin(parent=self, increment=1, digits=0, min_val=1) self.marker_size_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.marker_size_ctrl.SetBackgroundColour( self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Marker size:") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.marker_size_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.marker_size_ctrl) self.btn = SegmentedRadioControl(self, style=SEGBTN_HORIZONTAL) self.btn.AddSegment("all") self.btn.AddSegment("indexed") self.btn.AddSegment("unindexed") self.btn.AddSegment("integrated") self.btn.SetSelection(["all", "indexed", "unindexed", "integrated"].index(self.settings.display)) self.Bind(wx.EVT_RADIOBUTTON, self.OnChangeSettings, self.btn) self.GetSizer().Add(self.btn, 0, wx.ALL, 5) self.outlier_btn = SegmentedRadioControl(self, style=SEGBTN_HORIZONTAL) self.outlier_btn.AddSegment("all") self.outlier_btn.AddSegment("inliers") self.outlier_btn.AddSegment("outliers") self.outlier_btn.SetSelection([None, "inliers", "outliers" ].index(self.settings.outlier_display)) self.Bind(wx.EVT_RADIOBUTTON, self.OnChangeSettings, self.outlier_btn) self.GetSizer().Add(self.outlier_btn, 0, wx.ALL, 5) def add_value_widgets(self, sizer): sizer.Add( wx.StaticText(self.panel, -1, "Value:"), 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5, ) self.value_info = wx.TextCtrl(self.panel, -1, size=(80, -1), style=wx.TE_READONLY) sizer.Add(self.value_info, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) def add_experiments_buttons(self): n = flex.max(self.parent.reflections_input["id"]) if n <= 0: self.expt_btn = None return box = wx.BoxSizer(wx.VERTICAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Experiment ids:") box.Add(label, 0, wx.ALL, 5) self.expt_btn = SegmentedToggleControl(self, style=SEGBTN_HORIZONTAL) for i in range(-1, n + 1): self.expt_btn.AddSegment(str(i)) if (self.settings.experiment_ids is not None and i in self.settings.experiment_ids): self.expt_btn.SetValue(i + 1, True) self.expt_btn.Realize() self.Bind(wx.EVT_TOGGLEBUTTON, self.OnChangeSettings, self.expt_btn) box.Add(self.expt_btn, 0, wx.ALL, 5) def OnChangeSettings(self, event): self.settings.d_min = self.d_min_ctrl.GetValue() self.settings.z_min = self.z_min_ctrl.GetValue() self.settings.z_max = self.z_max_ctrl.GetValue() self.settings.n_min = int(self.n_min_ctrl.GetValue()) self.settings.n_max = int(self.n_max_ctrl.GetValue()) self.settings.partiality_min = self.partiality_min_ctrl.GetValue() self.settings.partiality_max = self.partiality_max_ctrl.GetValue() self.settings.beam_centre = ( self.beam_fast_ctrl.GetValue(), self.beam_slow_ctrl.GetValue(), ) self.settings.reverse_phi = self.reverse_phi_ctrl.GetValue() self.settings.crystal_frame = self.crystal_frame_ctrl.GetValue() self.settings.marker_size = self.marker_size_ctrl.GetValue() for i, display in enumerate( ("all", "indexed", "unindexed", "integrated")): if self.btn.values[i]: self.settings.display = display break for i, display in enumerate(("all", "inliers", "outliers")): if self.outlier_btn.values[i]: self.settings.outlier_display = display break if self.expt_btn is not None: expt_ids = [] for i in range(len(self.expt_btn.segments)): if self.expt_btn.GetValue(i): expt_ids.append(i - 1) self.settings.experiment_ids = expt_ids self.parent.update_settings()
def add_controls(self): # d_min control self.d_min_ctrl = floatspin.FloatSpin(parent=self, increment=0.05, digits=2) self.d_min_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.d_min_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "High resolution:") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.d_min_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.d_min_ctrl) self.z_min_ctrl = floatspin.FloatSpin(parent=self, increment=1, digits=0) self.z_min_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.z_min_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Min Z") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.z_min_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.z_min_ctrl) self.z_max_ctrl = floatspin.FloatSpin(parent=self, increment=1, digits=0) self.z_max_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.z_max_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Max Z") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.z_max_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.z_max_ctrl) # Control for spot size (utility depends on n_signal column in reflection # file - will be ignored if not in file self.n_min_ctrl = floatspin.FloatSpin(parent=self, increment=1, digits=0) self.n_min_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.n_min_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Min Pixels") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.n_min_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.n_min_ctrl) self.n_max_ctrl = floatspin.FloatSpin(parent=self, increment=1, digits=0) self.n_max_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.n_max_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Max Pixels") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.n_max_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.n_max_ctrl) # end new control self.partiality_min_ctrl = floatspin.FloatSpin(parent=self, increment=0.01, digits=3, min_val=0, max_val=1) self.partiality_min_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.partiality_min_ctrl.SetBackgroundColour( self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Min partiality") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.partiality_min_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.partiality_min_ctrl) self.partiality_max_ctrl = floatspin.FloatSpin(parent=self, increment=0.01, digits=3, min_val=0, max_val=1) self.partiality_max_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.partiality_max_ctrl.SetBackgroundColour( self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Max partiality") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.partiality_max_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.partiality_max_ctrl) ctrls = self.create_controls(setting="show_rotation_axis", label="Show rotation axis") self.panel_sizer.Add(ctrls[0], 0, wx.ALL, 5) ctrls = self.create_controls(setting="show_beam_vector", label="Show beam vector") self.panel_sizer.Add(ctrls[0], 0, wx.ALL, 5) ctrls = self.create_controls(setting="show_reciprocal_cell", label="Show reciprocal cell") self.panel_sizer.Add(ctrls[0], 0, wx.ALL, 5) self.reverse_phi_ctrl = self.create_controls( setting="reverse_phi", label="Invert rotation axis")[0] self.panel_sizer.Add(self.reverse_phi_ctrl, 0, wx.ALL, 5) self.Bind(wx.EVT_CHECKBOX, self.OnChangeSettings, self.reverse_phi_ctrl) self.crystal_frame_tooltip = wx.ToolTip( "Show the reciprocal lattice(s) in the crystal rather than the laboratory frame" ) self.crystal_frame_ctrl = self.create_controls( setting="crystal_frame", label="Show in crystal frame")[0] self.crystal_frame_ctrl.SetToolTip(self.crystal_frame_tooltip) self.panel_sizer.Add(self.crystal_frame_ctrl, 0, wx.ALL, 5) self.Bind(wx.EVT_CHECKBOX, self.OnChangeSettings, self.crystal_frame_ctrl) self.beam_fast_ctrl = floatspin.FloatSpin(parent=self, increment=0.01, digits=2) self.beam_fast_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.beam_fast_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Beam centre (mm)") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.beam_fast_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.beam_fast_ctrl) self.beam_slow_ctrl = floatspin.FloatSpin(parent=self, increment=0.01, digits=2) self.beam_slow_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.beam_slow_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box.Add(self.beam_slow_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.beam_slow_ctrl) self.marker_size_ctrl = floatspin.FloatSpin(parent=self, increment=1, digits=0, min_val=1) self.marker_size_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.marker_size_ctrl.SetBackgroundColour( self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Marker size:") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.marker_size_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.marker_size_ctrl) self.btn = SegmentedRadioControl(self, style=SEGBTN_HORIZONTAL) self.btn.AddSegment("all") self.btn.AddSegment("indexed") self.btn.AddSegment("unindexed") self.btn.AddSegment("integrated") self.btn.SetSelection(["all", "indexed", "unindexed", "integrated"].index(self.settings.display)) self.Bind(wx.EVT_RADIOBUTTON, self.OnChangeSettings, self.btn) self.GetSizer().Add(self.btn, 0, wx.ALL, 5) self.outlier_btn = SegmentedRadioControl(self, style=SEGBTN_HORIZONTAL) self.outlier_btn.AddSegment("all") self.outlier_btn.AddSegment("inliers") self.outlier_btn.AddSegment("outliers") self.outlier_btn.SetSelection([None, "inliers", "outliers" ].index(self.settings.outlier_display)) self.Bind(wx.EVT_RADIOBUTTON, self.OnChangeSettings, self.outlier_btn) self.GetSizer().Add(self.outlier_btn, 0, wx.ALL, 5)
def add_controls(self): # d_min control from wx.lib.agw import floatspin self.d_min_ctrl = floatspin.FloatSpin(parent=self, increment=0.05, digits=2) self.d_min_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.d_min_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "High resolution:") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.d_min_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.d_min_ctrl) self.z_min_ctrl = floatspin.FloatSpin(parent=self, increment=1, digits=0) self.z_min_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.z_min_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Min Z") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.z_min_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.z_min_ctrl) self.z_max_ctrl = floatspin.FloatSpin(parent=self, increment=1, digits=0) self.z_max_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.z_max_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Max Z") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.z_max_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.z_max_ctrl) self.partiality_min_ctrl = floatspin.FloatSpin(parent=self, increment=0.01, digits=3, min_val=0, max_val=1) self.partiality_min_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.partiality_min_ctrl.SetBackgroundColour( self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Min partiality") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.partiality_min_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.partiality_min_ctrl) self.partiality_max_ctrl = floatspin.FloatSpin(parent=self, increment=0.01, digits=3, min_val=0, max_val=1) self.partiality_max_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.partiality_max_ctrl.SetBackgroundColour( self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Max partiality") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.partiality_max_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.partiality_max_ctrl) ctrls = self.create_controls(setting="show_rotation_axis", label="Show rotation axis") self.panel_sizer.Add(ctrls[0], 0, wx.ALL, 5) ctrls = self.create_controls(setting="show_beam_vector", label="Show beam vector") self.panel_sizer.Add(ctrls[0], 0, wx.ALL, 5) ctrls = self.create_controls(setting="show_reciprocal_cell", label="Show reciprocal cell") self.panel_sizer.Add(ctrls[0], 0, wx.ALL, 5) self.reverse_phi_ctrl = self.create_controls( setting="reverse_phi", label="Invert rotation axis")[0] self.panel_sizer.Add(self.reverse_phi_ctrl, 0, wx.ALL, 5) self.Bind(wx.EVT_CHECKBOX, self.OnChangeSettings, self.reverse_phi_ctrl) self.beam_fast_ctrl = floatspin.FloatSpin(parent=self, increment=0.01, digits=2) self.beam_fast_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.beam_fast_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Beam centre (mm)") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.beam_fast_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.beam_fast_ctrl) self.beam_slow_ctrl = floatspin.FloatSpin(parent=self, increment=0.01, digits=2) self.beam_slow_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.beam_slow_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box.Add(self.beam_slow_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.beam_slow_ctrl) self.marker_size_ctrl = floatspin.FloatSpin(parent=self, increment=1, digits=0, min_val=1) self.marker_size_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2, 9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.marker_size_ctrl.SetBackgroundColour( self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self, -1, "Marker size:") box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) box.Add(self.marker_size_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.marker_size_ctrl) from wxtbx.segmentedctrl import SegmentedRadioControl, SEGBTN_HORIZONTAL self.btn = SegmentedRadioControl(self, style=SEGBTN_HORIZONTAL) self.btn.AddSegment("all") self.btn.AddSegment("indexed") self.btn.AddSegment("unindexed") self.btn.AddSegment("integrated") self.btn.SetSelection(["all", "indexed", "unindexed", "integrated"].index(self.settings.display)) self.Bind(wx.EVT_RADIOBUTTON, self.OnChangeSettings, self.btn) self.GetSizer().Add(self.btn, 0, wx.ALL, 5) self.outlier_btn = SegmentedRadioControl(self, style=SEGBTN_HORIZONTAL) self.outlier_btn.AddSegment("all") self.outlier_btn.AddSegment("inliers") self.outlier_btn.AddSegment("outliers") self.outlier_btn.SetSelection([None, "inliers", "outliers" ].index(self.settings.outlier_display)) self.Bind(wx.EVT_RADIOBUTTON, self.OnChangeSettings, self.outlier_btn) self.GetSizer().Add(self.outlier_btn, 0, wx.ALL, 5)