Beispiel #1
0
  def __init__(O, parent, work_params):
    super(main_panel, O).__init__(parent=parent, id=-1)
    O.work_params = work_params

    O.variable_name_by_wx_id = {}
    O.variable_values_by_name = {}
    v_sizer = wx.BoxSizer(orient=wx.VERTICAL)

    def add_detector_pixels():
      h_sizer = wx.BoxSizer(orient=wx.HORIZONTAL)
      label = wx.StaticText(parent=O, id=-1, label="Detector pixels:")
      h_sizer.Add(item=label)
      dp = wx.StaticText(parent=O, id=-1, label="None")
      f = dp.GetFont()
      f.SetWeight(wx.BOLD)
      dp.SetFont(f)
      h_sizer.Add(item=dp, flag=wx.LEFT, border=5)
      v_sizer.AddSpacer(3)
      v_sizer.Add(item=h_sizer)
      return dp

    O.wx_detector_pixels = add_detector_pixels()

    def add_active_wavelengths():
      h_sizer = wx.BoxSizer(orient=wx.HORIZONTAL)
      label = wx.StaticText(parent=O, id=-1, label="Active wavelengths:")
      h_sizer.Add(item=label)
      dp = wx.StaticText(parent=O, id=-1, label="None")
      f = dp.GetFont()
      f.SetWeight(wx.BOLD)
      dp.SetFont(f)
      h_sizer.Add(item=dp, flag=wx.LEFT, border=5)
      v_sizer.AddSpacer(3)
      v_sizer.Add(item=h_sizer)
      return dp

    O.wx_active_wavelengths = add_active_wavelengths()

    def add_slider(variable_name, val_min_max):
      h_sizer = wx.BoxSizer(orient=wx.HORIZONTAL)
      ctrl_id = wx.NewId()
      slider = wx.Slider(
        parent=O,
        id=ctrl_id,
        value=val_min_max[0],
        minValue=val_min_max[1],
        maxValue=val_min_max[2],
        size=(150, -1),
        style=wx.SL_HORIZONTAL|wx.SL_AUTOTICKS|wx.SL_LABELS)
      O.variable_name_by_wx_id[ctrl_id] = variable_name
      O.variable_values_by_name[variable_name] = val_min_max[0]
      slider.Bind(event=wx.EVT_SCROLL, handler=O.OnSliderScroll)
      h_sizer.Add(item=slider)
      label = wx.StaticText(parent=O, id=-1, label=variable_name)
      h_sizer.Add(item=label)
      v_sizer.Add(item=h_sizer)
      v_sizer.AddSpacer(3)

    from libtbx.math_utils import normalize_angle
    xyz = O.work_params.euler_angles_xyz
    for variable_name,value in zip(["rot x", "rot y", "rot z"], xyz):
      add_slider(variable_name, (
        normalize_angle(value, deg=True, zero_centered=True),
        -180,
        180))
    v_sizer.AddSpacer(3)

    def add_fs(min_val, max_val, increment, digits, label, value):
      import wx.lib.agw.floatspin as FS
      ctrl_id = wx.NewId()
      fs = FS.FloatSpin(
        parent=O,
        id=ctrl_id,
        min_val=min_val,
        max_val=max_val,
        increment=increment,
        value=value,
        agwStyle=FS.FS_LEFT)
      O.variable_name_by_wx_id[ctrl_id] = label
      fs.SetFormat("%f")
      fs.SetDigits(digits)
      fs.Bind(event=FS.EVT_FLOATSPIN, handler=O.OnFloatSpin),
      h_sizer = wx.BoxSizer(orient=wx.HORIZONTAL)
      h_sizer.Add(item=fs)
      label = wx.StaticText(parent=O, id=-1, label=label)
      h_sizer.Add(item=label, flag=wx.LEFT, border=5)
      v_sizer.Add(item=h_sizer)
      v_sizer.AddSpacer(3)

    add_fs(
      min_val=0.1,
      max_val=10,
      increment=0.1,
      digits=6,
      label="Wavelength 1",
      value=O.work_params.wavelength)

    add_fs(
      min_val=0.1,
      max_val=10,
      increment=0.1,
      digits=6,
      label="Wavelength 2",
      value=O.work_params.wavelength_2)

    if (O.work_params.d_min is None):
      O.work_params.d_min = O.work_params.wavelength
    add_fs(
      min_val=0.1,
      max_val=10,
      increment=0.1,
      digits=6,
      label="d-min",
      value=O.work_params.d_min)

    add_fs(
      min_val=-1,
      max_val=1,
      increment=0.01,
      digits=6,
      label="Ewald proximity",
      value=O.work_params.ewald_proximity)

    add_fs(
      min_val=1,
      max_val=500,
      increment=50,
      digits=2,
      label="Detector distance",
      value=O.work_params.detector.distance)

    def add_sp(label, value):
      sp = wx.SpinCtrl(parent=O, id=-1, min=1, max=100, initial=value)
      sp.Bind(event=wx.EVT_SPINCTRL, handler=O.OnSpin),
      h_sizer = wx.BoxSizer(orient=wx.HORIZONTAL)
      h_sizer.Add(item=sp)
      label = wx.StaticText(parent=O, id=-1, label=label)
      h_sizer.Add(item=label, flag=wx.LEFT, border=5)
      v_sizer.Add(item=h_sizer)
      v_sizer.AddSpacer(3)

    add_sp(
      label="Point spread",
      value=O.work_params.point_spread)

    add_fs(
      min_val=0,
      max_val=100,
      increment=1,
      digits=1,
      label="Gaussian falloff scale",
      value=O.work_params.gaussian_falloff_scale)

    ucp = O.work_params.unit_cell.parameters()
    for variable_name,value in zip(["a", "b", "c"], ucp[:3]):
      add_slider(variable_name, (
        value,
        min(10, round(value-0.5, 0)),
        max(100, round(value+5, -1))))
    for variable_name,value in zip(["alpha", "beta", "gamma"], ucp[3:]):
      add_slider(variable_name, (
        value,
        min(60, round(value-5, -1)),
        max(105, round(value+5, -1))))

    O.detector_surface = detector_surface(parent=O, work_params=O.work_params)

    topsizer = wx.BoxSizer(orient=wx.HORIZONTAL)
    topsizer.Add(item=O.detector_surface, proportion=1, flag=wx.EXPAND)
    topsizer.Add(item=v_sizer, flag=wx.ALL, border=10)
    O.SetSizer(topsizer)
    topsizer.Layout()
 def dihe(sites):
     return normalize_angle(scitbx.math.dihedral_angle(sites=sites,
                                                       deg=True),
                            deg=True)
Beispiel #3
0
    def __init__(O, parent, work_params):
        super(main_panel, O).__init__(parent=parent, id=-1)
        O.work_params = work_params

        O.variable_name_by_wx_id = {}
        O.variable_values_by_name = {}
        v_sizer = wx.BoxSizer(orient=wx.VERTICAL)

        def add_detector_pixels():
            h_sizer = wx.BoxSizer(orient=wx.HORIZONTAL)
            label = wx.StaticText(parent=O, id=-1, label="Detector pixels:")
            h_sizer.Add(item=label)
            dp = wx.StaticText(parent=O, id=-1, label="None")
            f = dp.GetFont()
            f.SetWeight(wx.BOLD)
            dp.SetFont(f)
            h_sizer.Add(item=dp, flag=wx.LEFT, border=5)
            v_sizer.AddSpacer(3)
            v_sizer.Add(item=h_sizer)
            return dp

        O.wx_detector_pixels = add_detector_pixels()

        def add_active_wavelengths():
            h_sizer = wx.BoxSizer(orient=wx.HORIZONTAL)
            label = wx.StaticText(parent=O, id=-1, label="Active wavelengths:")
            h_sizer.Add(item=label)
            dp = wx.StaticText(parent=O, id=-1, label="None")
            f = dp.GetFont()
            f.SetWeight(wx.BOLD)
            dp.SetFont(f)
            h_sizer.Add(item=dp, flag=wx.LEFT, border=5)
            v_sizer.AddSpacer(3)
            v_sizer.Add(item=h_sizer)
            return dp

        O.wx_active_wavelengths = add_active_wavelengths()

        def add_slider(variable_name, val_min_max):
            h_sizer = wx.BoxSizer(orient=wx.HORIZONTAL)
            ctrl_id = wx.NewId()
            slider = wx.Slider(parent=O,
                               id=ctrl_id,
                               value=val_min_max[0],
                               minValue=val_min_max[1],
                               maxValue=val_min_max[2],
                               size=(150, -1),
                               style=wx.SL_HORIZONTAL | wx.SL_AUTOTICKS
                               | wx.SL_LABELS)
            O.variable_name_by_wx_id[ctrl_id] = variable_name
            O.variable_values_by_name[variable_name] = val_min_max[0]
            slider.Bind(event=wx.EVT_SCROLL, handler=O.OnSliderScroll)
            h_sizer.Add(item=slider)
            label = wx.StaticText(parent=O, id=-1, label=variable_name)
            h_sizer.Add(item=label)
            v_sizer.Add(item=h_sizer)
            v_sizer.AddSpacer(3)

        from libtbx.math_utils import normalize_angle
        xyz = O.work_params.euler_angles_xyz
        for variable_name, value in zip(["rot x", "rot y", "rot z"], xyz):
            add_slider(variable_name, (normalize_angle(
                value, deg=True, zero_centered=True), -180, 180))
        v_sizer.AddSpacer(3)

        def add_fs(min_val, max_val, increment, digits, label, value):
            import wx.lib.agw.floatspin as FS
            ctrl_id = wx.NewId()
            fs = FS.FloatSpin(parent=O,
                              id=ctrl_id,
                              min_val=min_val,
                              max_val=max_val,
                              increment=increment,
                              value=value,
                              agwStyle=FS.FS_LEFT)
            O.variable_name_by_wx_id[ctrl_id] = label
            fs.SetFormat("%f")
            fs.SetDigits(digits)
            fs.Bind(event=FS.EVT_FLOATSPIN, handler=O.OnFloatSpin),
            h_sizer = wx.BoxSizer(orient=wx.HORIZONTAL)
            h_sizer.Add(item=fs)
            label = wx.StaticText(parent=O, id=-1, label=label)
            h_sizer.Add(item=label, flag=wx.LEFT, border=5)
            v_sizer.Add(item=h_sizer)
            v_sizer.AddSpacer(3)

        add_fs(min_val=0.1,
               max_val=10,
               increment=0.1,
               digits=6,
               label="Wavelength 1",
               value=O.work_params.wavelength)

        add_fs(min_val=0.1,
               max_val=10,
               increment=0.1,
               digits=6,
               label="Wavelength 2",
               value=O.work_params.wavelength_2)

        if (O.work_params.d_min is None):
            O.work_params.d_min = O.work_params.wavelength
        add_fs(min_val=0.1,
               max_val=10,
               increment=0.1,
               digits=6,
               label="d-min",
               value=O.work_params.d_min)

        add_fs(min_val=-1,
               max_val=1,
               increment=0.01,
               digits=6,
               label="Ewald proximity",
               value=O.work_params.ewald_proximity)

        add_fs(min_val=1,
               max_val=500,
               increment=50,
               digits=2,
               label="Detector distance",
               value=O.work_params.detector.distance)

        def add_sp(label, value):
            sp = wx.SpinCtrl(parent=O, id=-1, min=1, max=100, initial=value)
            sp.Bind(event=wx.EVT_SPINCTRL, handler=O.OnSpin),
            h_sizer = wx.BoxSizer(orient=wx.HORIZONTAL)
            h_sizer.Add(item=sp)
            label = wx.StaticText(parent=O, id=-1, label=label)
            h_sizer.Add(item=label, flag=wx.LEFT, border=5)
            v_sizer.Add(item=h_sizer)
            v_sizer.AddSpacer(3)

        add_sp(label="Point spread", value=O.work_params.point_spread)

        add_fs(min_val=0,
               max_val=100,
               increment=1,
               digits=1,
               label="Gaussian falloff scale",
               value=O.work_params.gaussian_falloff_scale)

        ucp = O.work_params.unit_cell.parameters()
        for variable_name, value in zip(["a", "b", "c"], ucp[:3]):
            add_slider(variable_name, (value, min(10, round(
                value - 0.5, 0)), max(100, round(value + 5, -1))))
        for variable_name, value in zip(["alpha", "beta", "gamma"], ucp[3:]):
            add_slider(variable_name, (value, min(60, round(
                value - 5, -1)), max(105, round(value + 5, -1))))

        O.detector_surface = detector_surface(parent=O,
                                              work_params=O.work_params)

        topsizer = wx.BoxSizer(orient=wx.HORIZONTAL)
        topsizer.Add(item=O.detector_surface, proportion=1, flag=wx.EXPAND)
        topsizer.Add(item=v_sizer, flag=wx.ALL, border=10)
        O.SetSizer(topsizer)
        topsizer.Layout()
 def dihe(sites):
   return normalize_angle(
     scitbx.math.dihedral_angle(sites=sites, deg=True),
     deg=True)