File: gui_hole.py

package info (click to toggle)
coot 1.1.18%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 219,964 kB
  • sloc: cpp: 495,934; python: 35,043; ansic: 26,143; lisp: 22,768; sh: 13,186; makefile: 2,746; awk: 441; xml: 245; csh: 14
file content (93 lines) | stat: -rw-r--r-- 3,450 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

def hole_ify():
    global start_pos, end_pos
    start_pos = False
    end_pos = False

    def status_bar_pos(position, pos_type):
        s = "Hole %s point set: (%6.2f %6.2f %6.2f)" %(pos_type,
                                                       position[0],
                                                       position[1],
                                                       position[2])
        coot.add_status_bar_text(s)

    window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    vbox = gtk.VBox(False, 0)
    hbox = gtk.VBox(False, 0)
    hbox_pos_buttons = gtk.HBox(False, 0)
    hbox_calc_cancel_buttons = gtk.HBox(False, 0)
    start_button = gtk.Button(label="  Set Start Point  ")
    end_button   = gtk.Button(label="  Set End Point  ")
    h_sep = gtk.HSeparator()
    calculate_button = gtk.Button(label="Calculate")
    cancel_button = gtk.Button(label="Cancel")
    hole_export_entry = gtk.Entry()
    export_text = gtk.Label(label="Export surface dots to File: ")
    export_hbox = gtk.HBox(False, 0)
    combobox = coot_gui.generic_molecule_chooser(hbox, "HOLE-ify molecule: ")

    window.add(vbox)
    hbox_pos_buttons.append(start_button)
    hbox_pos_buttons.append(end_button)
    hbox_calc_cancel_buttons.append(calculate_button)
    hbox_calc_cancel_buttons.append(cancel_button)
    export_hbox.append(export_text)
    export_hbox.append(hole_export_entry)
    vbox.append(hbox)
    vbox.append(hbox_pos_buttons)
    vbox.append(export_hbox)
    vbox.pack_start(h_sep)
    vbox.append(hbox_calc_cancel_buttons)

    hole_export_entry.set_text("hole_surface_dots.dat")

    def start_button_cb(*args):
        global start_pos
        start_pos = coot_utils.rotation_centre()
        print("Start pos set to:", start_pos)
        status_bar_pos(start_pos, "start")
        
    start_button.connect("clicked", start_button_cb)

    def end_button_cb(*args):
        global end_pos
        end_pos = coot_utils.rotation_centre()
        print("End pos set to:", end_pos)
        status_bar_pos(end_pos, "end")
        
    end_button.connect("clicked", end_button_cb)

    def delete_event(*args):
        window.destroy()
        return False
    
    def calculate_button_cb(*args):
        global start_pos, end_pos
        imol = combobox_to_molecule_number(combobox)
        if isinstance(imol, int):
            print(start_pos, end_pos)
            if not isinstance(start_pos, list):
                coot.add_status_bar_text("Start position not set")
            else:
                if not isinstance(end_pos, list):
                    coot.add_status_bar_text("End position not set")
                else:
                    # main?
                    print("hole", imol, start_pos, end_pos)
                    # get this from an entry ideally.
                    export_dots_file_name = hole_export_entry.get_text()
                    colour_map_multiplier = 1
                    colour_map_offset = 0
                    hole_args = [imol] + start_pos + end_pos + \
                                [colour_map_multiplier, colour_map_offset, 1,
                                 True, export_dots_file_name]
                    print("BL DEBUG:: hole_args", hole_args)
                    coot.hole(*hole_args)
                    delete_event()
                    
    calculate_button.connect("clicked", calculate_button_cb)

    cancel_button.connect("clicked", delete_event)

    window.show_all()