Exemple #1
0
    def fillInUI(self, parent):

        self.requested_halt = False
        self.xform_handler = None
        self.last_relative_xform = None

        t = parent.winfo_toplevel()
        self.toplevel_widget = t
        t.withdraw()

        parent.columnconfigure(0, weight=1)
        row = 0

        import Tkinter
        from CGLtk import Hybrid
        from VolumeViewer import Volume_Menu

        ff = Tkinter.Frame(parent)
        ff.grid(row=row, column=0, sticky='w')
        row = row + 1

        from chimera.widgets import ModelOptionMenu
        om = ModelOptionMenu(ff,
                             labelpos='w',
                             label_text='Fit ',
                             listFunc=fit_object_models,
                             sortFunc=compare_fit_objects,
                             command=self.object_chosen_cb)
        om.grid(row=0, column=0, sticky='w')
        self.object_menu = om

        fm = Volume_Menu(ff, ' in map ')
        fm.frame.grid(row=0, column=1, sticky='w')
        self.map_menu = fm

        gf = Tkinter.Frame(parent)
        gf.grid(row=row, column=0, sticky='w')
        row += 1

        cl = Tkinter.Label(gf, text='Correlation')
        cl.grid(row=0, column=0, sticky='w')
        cv = Tkinter.Label(gf,
                           width=6,
                           anchor='w',
                           relief=Tkinter.SUNKEN,
                           borderwidth=2)
        cv.grid(row=0, column=1, padx=5, sticky='w')
        self.corr_label = cv
        al = Tkinter.Label(gf, text='Average map value')
        al.grid(row=0, column=2, sticky='w')
        av = Tkinter.Label(gf,
                           width=6,
                           anchor='w',
                           relief=Tkinter.SUNKEN,
                           borderwidth=2)
        av.grid(row=0, column=3, padx=5, sticky='w')
        self.ave_label = av
        ub = Tkinter.Button(gf, text='Update', command=self.update_metric_cb)
        ub.grid(row=0, column=4, sticky='w')

        op = Hybrid.Popup_Panel(parent)
        opf = op.frame
        opf.grid(row=row, column=0, sticky='news')
        opf.grid_remove()
        opf.columnconfigure(0, weight=1)
        self.options_panel = op.panel_shown_variable
        row += 1
        orow = 0

        cb = op.make_close_button(opf)
        cb.grid(row=orow, column=1, sticky='e')

        ru = Hybrid.Checkbutton(opf, 'Real-time correlation / average update',
                                False)
        ru.button.grid(row=orow, column=0, sticky='w')
        orow += 1
        self.realtime_update = ru.variable
        ru.callback(self.realtime_cb)

        sm = Hybrid.Checkbutton_Entries(
            opf, False, 'Use map simulated from atoms, resolution ', (4, ''))
        sm.frame.grid(row=orow, column=0, sticky='nw')
        orow += 1
        self.simulate_map, self.map_resolution = sm.variables
        self.simulate_map.add_callback(self.simulate_map_cb)
        sm.entries[0].bind('<KeyPress-Return>', self.simulate_resolution_cb)

        dt = Hybrid.Checkbutton(
            opf, 'Use only data above contour level from first map', True)
        dt.button.grid(row=orow, column=0, sticky='w')
        orow += 1
        dt.button['state'] = 'disabled'
        self.limit_data = dt
        self.above_threshold = dt.variable

        opt = Hybrid.Radiobutton_Row(opf, 'Optimize ',
                                     ('overlap', 'correlation'))
        opt.frame.grid(row=orow, column=0, sticky='w')
        orow += 1
        self.optimize = opt.variable
        self.opt_widget = opt

        cam = Hybrid.Checkbutton(
            opf, 'Correlation calculated about mean data value', False)
        cam.button.grid(row=orow, column=0, sticky='w')
        orow += 1
        cam.button['state'] = 'disabled'
        self.cam_widget = cam
        self.corr_about_mean = cam.variable

        al = Hybrid.Checkbutton_Row(opf, 'Allow ', ('rotation', 'shift'))
        al.frame.grid(row=orow, column=0, sticky='w')
        orow += 1
        ar, ash = [c.variable for c in al.checkbuttons]
        ar.set(True)
        ash.set(True)
        self.allow_rotation = ar
        self.allow_shift = ash

        mm = Hybrid.Checkbutton(opf, 'Move whole molecules', True)
        mm.button.grid(row=orow, column=0, sticky='w')
        orow += 1
        self.move_whole_molecules = mm.variable
        self.mwm_button = mm.button

        #
        # Specify a label width so dialog is not resized for long messages.
        #
        msg = Tkinter.Label(parent, width=40, anchor='w', justify='left')
        msg.grid(row=row, column=0, sticky='ew')
        row = row + 1
        self.message_label = msg

        self.halt_button = self.buttonWidgets['Halt']
        self.allow_halt(False)

        self.update_gray_out()
        self.activate_undo_redo()
Exemple #2
0
    def fillInUI(self, parent):

        self.phantom_device = None
        self.cursor_model = None
        self.phantom_handler = None
        self.gradient_force = None
        self.phantom_button_down = 0
        self.last_phantom_transform = None
        self.last_roll = None
        self.key_callback_registered = None
        self.mode = 'cursor'  # 'cursor', 'move models', 'zoom',
        # 'contour level', 'move marker'
        self.command_list_shown = False

        import Tkinter
        from CGLtk import Hybrid

        row = 0

        po = Hybrid.Checkbutton_Row(parent, 'Enable',
                                    ('cursor', 'forces', 'key commands'))
        po.frame.grid(row=row, column=0, sticky='w')
        row = row + 1
        self.phantom_on, self.force_field, self.commands = \
            [c.variable for c in po.checkbuttons]
        self.phantom_on.add_callback(self.settings_changed_cb)
        self.force_field.add_callback(self.settings_changed_cb)
        self.commands.add_callback(self.toggle_commands_cb)

        cf = Tkinter.Frame(parent)
        cf.grid(row=row, column=0, sticky='w')
        row = row + 1

        cs = Hybrid.Option_Menu(cf, 'Cursor shape ', 'cross', 'jack', 'sphere',
                                'volume crosshair')
        cs.frame.grid(row=0, column=0, sticky='nw')
        row = row + 1
        cs.variable.set('jack')
        cs.add_callback(self.settings_changed_cb)
        self.cursor_shape = cs.variable

        from VolumeViewer import active_volume
        v = active_volume()
        if v:
            csize = '%.3g' % (10 * max(v.data.step))
        else:
            csize = '1'
        cs = Hybrid.Entry(cf, ' size ', 5, csize)
        cs.frame.grid(row=0, column=1, sticky='w')
        cs.entry.bind('<KeyPress-Return>', self.settings_changed_cb)
        self.cursor_size = cs.variable

        cl = Tkinter.Label(cf, text=' color ')
        cl.grid(row=0, column=2, sticky='w')

        from CGLtk.color import ColorWell
        cc = ColorWell.ColorWell(cf, callback=self.settings_changed_cb)
        self.cursor_color = cc
        cc.showColor((0, 0.5, 1), doCallback=0)
        cc.grid(row=0, column=3, sticky='w')

        sp = Hybrid.Popup_Panel(parent)
        spf = sp.frame
        spf.grid(row=row, column=0, sticky='news')
        spf.grid_remove()
        spf.columnconfigure(0, weight=1)
        self.settings_panel = sp.panel_shown_variable
        row += 1
        srow = 0

        cb = sp.make_close_button(spf)
        cb.grid(row=srow, column=1, sticky='e')

        pr = Hybrid.Entry(spf, 'Phantom physical range (mm) ', 5, '200')
        pr.frame.grid(row=srow, column=0, sticky='w')
        srow += 1
        pr.entry.bind('<KeyPress-Return>', self.settings_changed_cb)
        self.phantom_range = pr.variable

        mf = Hybrid.Entry(spf, 'Maximum force (lbs) ', 5, '.4')
        mf.frame.grid(row=srow, column=0, sticky='w')
        srow += 1
        mf.entry.bind('<KeyPress-Return>', self.settings_changed_cb)
        self.maximum_force = mf.variable

        af = Hybrid.Checkbutton(spf, 'Auto-adjust force constant', 1)
        af.button.grid(row=srow, column=0, sticky='w')
        srow += 1
        self.auto_adjust_force_constant = af.variable
        self.force_field.add_callback(self.settings_changed_cb)

        fc = Hybrid.Logarithmic_Scale(spf, 'Force constant ', .0001, 100, 1,
                                      '%.2g')
        fc.frame.grid(row=srow, column=0, sticky='ew')
        srow += 1
        fc.set_value(1)
        fc.callback(self.force_constant_changed_cb)
        fc.entry.bind('<KeyPress-Return>', self.force_constant_changed_cb)
        self.force_constant = fc

        vf = Tkinter.Frame(spf)
        vf.grid(row=srow, column=0, sticky='ew')
        srow += 1

        self.label_row(vf, 0, ('', 'x', 'y', 'z'))
        pl = self.label_row(vf, 1, ('Phantom position', '', '', ''))
        self.phantom_position_labels = pl[1:]
        cpl = self.label_row(vf, 2, ('Chimera position', '', '', ''))
        self.chimera_position_labels = cpl[1:]
        vpl = self.label_row(vf, 3, ('Volume position', '', '', ''))
        self.volume_position_labels = vpl[1:]
        vil = self.label_row(vf, 4, ('Volume index', '', '', ''))
        self.volume_index_labels = vil[1:]
        gl = self.label_row(vf, 5, ('Gradient', '', '', ''))
        self.gradient_labels = gl[1:]
        fl = self.label_row(vf, 6, ('Force', '', '', ''))
        self.force_labels = fl[1:]
        dvl = self.label_row(vf, 7, ('Data value', ''))
        self.data_value_label = dvl[1]