Beispiel #1
0
    def __init__(self, session, tool_name, *, title=None):
        ToolInstance.__init__(self, session, tool_name)

        from chimerax.ui import MainToolWindow
        tw = MainToolWindow(self)
        if title is not None:
            tw.title = title
        self.tool_window = tw
        parent = tw.ui_area

        from matplotlib import figure
        self.figure = f = figure.Figure(dpi=100, figsize=(2, 2))

        from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as Canvas
        self.canvas = c = Canvas(f)
        parent.setMinimumHeight(
            1
        )  # Matplotlib gives divide by zero error when plot resized to 0 height.
        c.setParent(parent)

        from PyQt5.QtWidgets import QHBoxLayout
        layout = QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(c)
        parent.setLayout(layout)
        tw.manage(placement="side")

        self.axes = axes = f.gca()

        self._pan = None  # Pan/zoom mouse control
Beispiel #2
0
    def __init__(self, session, tool_name):
        ToolInstance.__init__(self, session, tool_name)
        # 'display_name' defaults to class name with spaces inserted
        # between lower-then-upper-case characters (therefore "Tool UI"
        # in this case), so only override if different name desired
        self.display_name = "ChimeraX Python Shell"
        from chimerax.ui import MainToolWindow
        self.tool_window = MainToolWindow(self)
        parent = self.tool_window.ui_area
        # UI content code
        from ipykernel.ipkernel import IPythonKernel
        save_ns = IPythonKernel.user_ns
        IPythonKernel.user_ns = {'session': session}
        from qtconsole.inprocess import QtInProcessKernelManager
        kernel_manager = QtInProcessKernelManager()
        kernel_manager.start_kernel()
        kernel_client = kernel_manager.client()
        kernel_client.start_channels()

        from qtconsole.rich_jupyter_widget import RichJupyterWidget
        self.shell = RichJupyterWidget(parent)
        def_banner = self.shell.banner
        self.shell.banner = "{}\nCurrent ChimeraX session available as 'session'.\n\n".format(
            def_banner)
        self.shell.kernel_manager = kernel_manager
        self.shell.kernel_client = kernel_client
        IPythonKernel.user_ns = save_ns

        from PyQt5.QtWidgets import QHBoxLayout
        layout = QHBoxLayout()
        layout.addWidget(self.shell)
        layout.setStretchFactor(self.shell, 1)
        parent.setLayout(layout)
        self.tool_window.manage(placement=None)
Beispiel #3
0
    def __init__(self, session, tool_name):
        ToolInstance.__init__(self, session, tool_name)
        from chimerax.ui import MainToolWindow
        self.tool_window = tw = MainToolWindow(self)
        parent = tw.ui_area
        from PyQt5.QtWidgets import QVBoxLayout, QDialogButtonBox
        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        parent.setLayout(layout)
        from .gui import HBondsGUI
        self.gui = HBondsGUI(session, show_model_restrict=False)
        layout.addWidget(self.gui)

        from PyQt5.QtWidgets import QDialogButtonBox as qbbox
        bbox = qbbox(qbbox.Ok | qbbox.Apply | qbbox.Close | qbbox.Help)
        bbox.accepted.connect(self.run_hbonds)
        bbox.button(qbbox.Apply).clicked.connect(self.run_hbonds)
        bbox.accepted.connect(
            self.delete)  # slots executed in the order they are connected
        bbox.rejected.connect(self.delete)
        from chimerax.core.commands import run
        bbox.helpRequested.connect(
            lambda run=run, ses=session: run(ses, "help " + self.help))
        layout.addWidget(bbox)

        tw.manage(placement=None)
Beispiel #4
0
    def __init__(self, session):
        ToolInstance.__init__(self, session, "Bogus Toolshed-demo Tool")

        self.display_name = "Open Models"
        from chimerax.ui import MainToolWindow
        self.tool_window = MainToolWindow(self, size=self.SIZE)
        parent = self.tool_window.ui_area
        # UI content code
        from wx import html2
        import wx
        self.webview = html2.WebView.New(parent, wx.ID_ANY, size=self.SIZE)
        self.webview.Bind(html2.EVT_WEBVIEW_NAVIGATING,
                          self._on_navigating,
                          id=self.webview.GetId())
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.webview, 1, wx.EXPAND)
        parent.SetSizerAndFit(sizer)
        self.tool_window.manage(placement="side")
        # Add triggers for model addition/removal
        from chimerax.core.models import ADD_MODELS, REMOVE_MODELS
        self._handlers = [
            session.triggers.add_handler(ADD_MODELS, self._make_page),
            session.triggers.add_handler(REMOVE_MODELS, self._make_page)
        ]
        self._make_page()
Beispiel #5
0
 def delete(self):
     ses = self.session
     ses.triggers.remove_handler(self._model_display_change_handler)
     sm = self._sphere_model
     if sm and not sm.deleted:
         ses.models.close([sm])
     self._sphere_model = None
     ToolInstance.delete(self)
Beispiel #6
0
    def delete(self):

        mmh = self._model_move_handler
        if mmh:
            self.session.triggers.remove_handler(mmh)
            self._model_move_handler = None

        ToolInstance.delete(self)
Beispiel #7
0
 def restore_snapshot(cls, session, data):
     bp = ButtonPanel(session, data['title'])
     ToolInstance.set_state_from_snapshot(bp, session, data["super"])
     bp.set_grid_size(data['rows'], data['columns'])
     bp.set_fill_order(data['fill_order'])
     for r, c, name, command in data['buttons']:
         bp.add_button(name, command, row=r, column=c)
     return bp
Beispiel #8
0
    def __init__(self, session, tool_name, models=None, attr_names=None):
        """ if 'models' is None, then we are being restored from a session and
            set_state_from_snapshot will be called later.
        """

        ToolInstance.__init__(self, session, tool_name)
        if models is None:
            return
        self._finalize_init(session, models, attr_names)
Beispiel #9
0
    def __init__(self, session, tool_name, alignment=None):
        """ if 'alignment' is None, then we are being restored from a session and
            _finalize_init will be called later.
        """

        ToolInstance.__init__(self, session, tool_name)
        if alignment is None:
            return
        self._finalize_init(alignment)
Beispiel #10
0
 def delete(self):
     self.region_browser.destroy()
     self.seq_canvas.destroy()
     self.alignment.detach_viewer(self)
     for seq in self.alignment.seqs:
         seq.triggers.remove_handler(self._seq_rename_handlers[seq])
     from chimerax.atomic import get_triggers
     get_triggers().remove_handler(self._atomic_changes_handler)
     ToolInstance.delete(self)
Beispiel #11
0
 def __init__(self, session, tool_name):
     ToolInstance.__init__(self, session, tool_name)
     # FIXME: display_name' defaults to class name with spaces inserted
     # between lower-then-upper-case characters (therefore "Tool UI"
     # in this case), so only override if different name desired
     self.display_name = "custom name for running tool"
     from chimerax.core.ui.gui import MainToolWindow
     self.tool_window = MainToolWindow(self)
     self.tool_window.manage(placement="side")
     parent = self.tool_window.ui_area
Beispiel #12
0
    def __init__(self, session, tool_name):
        ToolInstance.__init__(self, session, tool_name)

        from chimerax.ui import MainToolWindow
        self.tool_window = MainToolWindow(self, close_destroys=False)
        parent = self.tool_window.ui_area

        from chimerax.ui.file_history import FileHistory
        fh = FileHistory(session, parent, size_hint=(575, 200))
        self.tool_window.manage(placement="side")
Beispiel #13
0
    def __init__(self, session, tool_name):
        ToolInstance.__init__(self, session, tool_name)
        self._icon_size = 40
        self._icons_per_row = 13
        self.tool_window = None

        from .shortcuts import keyboard_shortcuts
        self.keyboard_shortcuts = keyboard_shortcuts(session)

        parent = session.ui.main_window
        self.buttons = self.create_toolbar(parent)
Beispiel #14
0
    def __init__(self, session, tool_name):
        ToolInstance.__init__(self, session, tool_name)

        self.mouse_modes = mm = session.ui.mouse_modes
        self.button_to_bind = 'right'
        self._icon_size = 40
        self._icons_per_row = 13
        self.tool_window = None

        self.modes = ordered_modes(mm.modes, mode_order)
        parent = session.ui.main_window
        self.buttons = self.create_toolbar(parent)
Beispiel #15
0
    def __init__(self, session, tool_name):

        self._requested_halt = False
        self._model_move_handler = None
        self._last_relative_position = None

        self.max_steps = 2000
        self.ijk_step_size_min = 0.01
        self.ijk_step_size_max = 0.5
        self._last_status_time = 0
        self._status_interval = 0.5  # seconds

        ToolInstance.__init__(self, session, tool_name)

        from chimerax.ui import MainToolWindow
        tw = MainToolWindow(self)
        self.tool_window = tw
        parent = tw.ui_area

        from PyQt5.QtWidgets import QVBoxLayout, QLabel
        layout = QVBoxLayout(parent)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        parent.setLayout(layout)

        # Make menus to choose molecule and map for fitting
        mf = self._create_mol_map_menu(parent)
        layout.addWidget(mf)

        # Report correlation
        from chimerax.ui.widgets import EntriesRow
        cr = EntriesRow(
            parent, 'Correlation', 0.0, 'Average map value', 0.0,
            ('Update',
             lambda *args, self=self: self._update_metric_values(log=True)))
        self._corr_label, self._ave_label = cl, al = cr.values
        cl.value = al.value = None  # Make fields blank

        # Options panel
        options = self._create_options_gui(parent)
        layout.addWidget(options)

        # Fit, Undo, Redo buttons
        bf = self._create_action_buttons(parent)
        layout.addWidget(bf)

        # Status line
        self._status_label = sl = QLabel(parent)
        layout.addWidget(sl)

        layout.addStretch(1)  # Extra space at end

        tw.manage(placement="side")
Beispiel #16
0
    def __init__(self, session, tool_name):
        ToolInstance.__init__(self, session, tool_name)
        from chimerax.ui import MainToolWindow
        self.tool_window = MainToolWindow(self)
        parent = self.tool_window.ui_area

        # UI content code
        from PyQt5.QtCore import Qt
        from PyQt5.QtWidgets import QLabel, QHBoxLayout, QVBoxLayout, QCheckBox, QStackedWidget
        self.view = v = View(session.models.scene_root_model, window_size=(0, 0))
        v.initialize_rendering(session.main_view.render.opengl_context)
        # TODO: from chimerax.graphics.camera import OrthographicCamera
        v.camera = OrthoCamera()
        if self.display_name.startswith('Top'):
            side = SideViewCanvas.TOP_SIDE
        else:
            side = SideViewCanvas.RIGHT_SIDE
        self.opengl_canvas = SideViewCanvas(parent, v, session, self, side=side)
        clip = QLabel(parent)
        clip.setText("clip:")
        self.clip_near = QCheckBox(parent)
        self.clip_near.setText("near")
        self.clip_near.down = False
        # TODO: parent.Bind(wx.EVT_CHECKBOX, self.on_near, self.clip_near)
        self.clip_near.clicked.connect(self.on_near)
        self.clip_far = QCheckBox(parent)
        self.clip_far.setText("far")
        self.clip_far.down = False
        # TODO: parent.Bind(wx.EVT_CHECKBOX, self.on_far, self.clip_far)
        self.clip_far.clicked.connect(self.on_far)

        button_layout = QHBoxLayout()
        button_layout.addWidget(clip, alignment=Qt.AlignCenter)
        button_layout.addWidget(self.clip_near)
        button_layout.addWidget(self.clip_far)
        button_layout.addStretch(1)

        class graphics_area(QStackedWidget):

            def sizeHint(self):  # noqa
                from PyQt5.QtCore import QSize
                return QSize(200, 200)

        layout = QVBoxLayout()
        ga = graphics_area(parent)
        ga.addWidget(self.opengl_canvas.widget)
        layout.addWidget(ga, 1)
        layout.addLayout(button_layout)
        parent.setLayout(layout)
        self.tool_window.manage(placement="side")
Beispiel #17
0
 def take_snapshot(self, session, flags):
     data = {
         'ToolInstance': ToolInstance.take_snapshot(self, session, flags),
         'models': self.models,
         'attr_names': self.attr_names,
         'scores_fetched': self.scores_fetched
     }
     return data
Beispiel #18
0
 def take_snapshot(self, session, flags):
     data = {
         'ToolInstance': ToolInstance.take_snapshot(self, session, flags),
         'alignment': self.alignment,
         'region browser': self.region_browser.save_state(),
         'seq canvas': self.seq_canvas.save_state()
     }
     return data
Beispiel #19
0
    def __init__(self, session, title):
        ToolInstance.__init__(self, session, title)

        self.title = title
        self._rows = None
        self._columns = None
        self._next_row_col = (1, 1)
        self._fill_order = 'rows'
        self._buttons = {}  # Map (row,column) -> QPushButton

        from chimerax.ui import MainToolWindow
        tw = MainToolWindow(self)
        self.tool_window = tw
        from PyQt5.QtWidgets import QGridLayout
        self._layout = layout = QGridLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        tw.ui_area.setLayout(layout)
        tw.manage(placement="side")
Beispiel #20
0
    def __init__(self, session, tool_name):
        ToolInstance.__init__(self, session, tool_name)

        self.minimize_steps = 10
        self.edge_thickness = 0.1  # Edge diameter as fraction of edge length.

        self.display_name = 'Cage Builder'

        from chimerax.ui import MainToolWindow
        tw = MainToolWindow(self)
        self.tool_window = tw
        parent = tw.ui_area

        from PyQt5.QtWidgets import QHBoxLayout, QLabel, QPushButton, QLineEdit
        layout = QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        cp = QLabel('Create polygon')
        layout.addWidget(cp)
        b5 = QPushButton('5')
        b5.clicked.connect(lambda e: self.attach_polygons(5))
        layout.addWidget(b5)
        b6 = QPushButton('6')
        b6.clicked.connect(lambda e: self.attach_polygons(6))
        layout.addWidget(b6)
        mn = QPushButton('Minimize')
        mn.clicked.connect(self.minimize_cb)
        layout.addWidget(mn)
        ell = QLabel(' Edge length')
        layout.addWidget(ell)
        self.edge_length = el = QLineEdit('50')
        el.setMaximumWidth(30)
        layout.addWidget(el)
        dp = QPushButton('Delete')
        dp.clicked.connect(self.delete_polygon_cb)
        layout.addWidget(dp)
        layout.addStretch(1)  # Extra space at end of button row.
        parent.setLayout(layout)

        tw.manage(placement="side")
Beispiel #21
0
  def __init__(self, session, tool_name):

    ToolInstance.__init__(self, session, tool_name)

    from chimerax.ui import MainToolWindow
    tw = MainToolWindow(self)
    self.tool_window = tw
    parent = tw.ui_area

    from PyQt5.QtWidgets import QVBoxLayout, QLabel
    layout = QVBoxLayout(parent)
    layout.setContentsMargins(0,0,0,0)
    layout.setSpacing(0)
    parent.setLayout(layout)

    # Heading
    heading = QLabel('Placement of data array in x,y,z coordinate space:', parent)
    layout.addWidget(heading)
    
    # Make menus to choose molecule and map for fitting
    mf = self._create_map_menu(parent)
    layout.addWidget(mf)

    # GUI for origin, step, angles, axis settings.
    options = self._create_parameters_gui(parent)
    layout.addWidget(options)

    # Apply button
#    bf = self._create_action_buttons(parent)
#    layout.addWidget(bf)
  
    # Status line
    self._status_label = sl = QLabel(parent)
    layout.addWidget(sl)
        
    layout.addStretch(1)    # Extra space at end

    self._update_gui_values()

    tw.manage(placement="side")
Beispiel #22
0
    def __init__(self, session, tool_name):
        ToolInstance.__init__(self, session, tool_name)
        self.display_name = "Show Chain Sequence"
        self.settings = SequencesSettings(session, "ChainSequences")

        from chimerax.ui import MainToolWindow
        self.tool_window = tw = MainToolWindow(self)
        parent = tw.ui_area

        from PyQt5.QtWidgets import QVBoxLayout, QCheckBox
        layout = QVBoxLayout()
        parent.setLayout(layout)
        from chimerax.atomic.widgets import ChainListWidget
        self.chain_list = ChainListWidget(session, group_identical=self.settings.grouping,
            autoselect="first")
        self.chain_list.value_changed.connect(self._update_show_button)
        layout.addWidget(self.chain_list, stretch=1)

        self.grouping_button = QCheckBox("Group identical sequences")
        self.grouping_button.setChecked(self.settings.grouping)
        self.grouping_button.stateChanged.connect(self._grouping_change)
        layout.addWidget(self.grouping_button)

        from PyQt5.QtWidgets import QDialogButtonBox as qbbox
        bbox = qbbox()
        self._show_button = bbox.addButton("Show", qbbox.AcceptRole)
        bbox.addButton(qbbox.Cancel)
        #bbox.addButton(qbbox.Help)
        bbox.accepted.connect(self.show_seqs)
        bbox.accepted.connect(self.delete) # slots executed in the order they are connected
        bbox.rejected.connect(self.delete)
        from chimerax.core.commands import run
        bbox.helpRequested.connect(lambda run=run, ses=session: run(ses, "help " + self.help))
        layout.addWidget(bbox)

        self._update_show_button()

        tw.manage(placement=None)
Beispiel #23
0
    def __init__(self, session, tool_name):
        # Standard template stuff
        ToolInstance.__init__(self, session, tool_name)
        self.display_name = "Toolshed"
        from chimerax.ui import MainToolWindow
        self.tool_window = MainToolWindow(self)
        self.tool_window.manage(placement=None)
        parent = self.tool_window.ui_area

        from PyQt5.QtWidgets import QGridLayout, QTabWidget
        from chimerax.ui.widgets import HtmlView
        layout = QGridLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        self.tab_widget = QTabWidget()
        self.html_view = HtmlView(size_hint=(1000, 600),
                                  download=self._download)
        self.tab_widget.addTab(self.html_view, "Toolshed")
        layout.addWidget(self.tab_widget, 0, 0)
        parent.setLayout(layout)

        from PyQt5.QtCore import QUrl
        self.html_view.setUrl(QUrl(self.url))
        self._pending_downloads = []
Beispiel #24
0
    def __init__(self, session, tool_name):
        ToolInstance.__init__(self, session, tool_name)
        from chimerax.ui import MainToolWindow
        self.tool_window = tw = MainToolWindow(self)
        parent = tw.ui_area
        layout = QVBoxLayout()
        layout.setContentsMargins(0,0,0,0)
        layout.setSpacing(3)
        parent.setLayout(layout)

        session.logger.status("Build Structure is a work in progress, more functions coming soon...",
            color="blue")

        self.category_button = QPushButton()
        layout.addWidget(self.category_button, alignment=Qt.AlignCenter)
        cat_menu = QMenu(parent)
        self.category_button.setMenu(cat_menu)
        cat_menu.triggered.connect(self._cat_menu_cb)

        self.category_areas = QStackedWidget()
        layout.addWidget(self.category_areas)

        self.handlers = []
        self.category_widgets = {}
        for category in ["Start Structure", "Modify Structure"]:
            self.category_widgets[category] = widget = QFrame()
            widget.setLineWidth(2)
            widget.setFrameStyle(QFrame.Panel | QFrame.Sunken)
            getattr(self, "_layout_" + category.lower().replace(' ', '_'))(widget)
            self.category_areas.addWidget(widget)
            cat_menu.addAction(category)
        initial_category = "Start Structure"
        self.category_button.setText(initial_category)
        self.category_areas.setCurrentWidget(self.category_widgets[initial_category])

        tw.manage(placement="side")
Beispiel #25
0
 def take_snapshot(self, session, flags):
     import sys
     data = {
         'ToolInstance':
         ToolInstance.take_snapshot(self, session, flags),
         'mgr':
         self.mgr,
         'res_type':
         self.res_type,
         'lib_display_name':
         session.rotamers.library(self.rot_lib).display_name,
         'table info': (self.table.session_info(),
                        [(col_type, c.title, c.data_fetch, c.display_format)
                         for col_type, c in self.opt_columns.items()])
     }
     return data
Beispiel #26
0
    def __init__(self, session, tool_name):
        ToolInstance.__init__(self, session, tool_name)
        self.display_name = "Models"
        self.settings = ModelPanelSettings(session, "ModelPanel")
        last = self.settings.last_use
        from time import time
        now = self.settings.last_use = time()
        short_titles = last != None and now - last < 777700 # about 3 months

        from chimerax.ui import MainToolWindow
        self.tool_window = tw = MainToolWindow(self, close_destroys=False)
        parent = tw.ui_area
        from PyQt5.QtWidgets import QTreeWidget, QHBoxLayout, QVBoxLayout, QAbstractItemView, \
            QFrame, QPushButton, QSizePolicy
        class SizedTreeWidget(QTreeWidget):
            def sizeHint(self):
                from PyQt5.QtCore import QSize
                # side buttons will keep the vertical size reasonable
                if getattr(self, '_first_size_hint_call', True):
                    self._first_size_hint_call = False
                    width = 0
                else:
                    width = self.header().length()
                return QSize(width, 200)
        self.tree = SizedTreeWidget()
        self.tree.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.tree.keyPressEvent = session.ui.forward_keystroke
        self.tree.expanded.connect(self._ensure_id_width)
        layout = QHBoxLayout()
        layout.setContentsMargins(0,0,0,0)
        layout.setSpacing(0)
        layout.addWidget(self.tree)
        layout.setStretchFactor(self.tree, 1)
        parent.setLayout(layout)
        shown_title = "" if short_titles else "Shown"
        sel_title = "" if short_titles else "Select"
        self.tree.setHeaderLabels(["Name", "ID", " ", shown_title, sel_title])
        from chimerax.ui.icons import get_qt_icon
        self.tree.headerItem().setIcon(3, get_qt_icon("shown"))
        self.tree.headerItem().setToolTip(3, "Shown")
        self.tree.headerItem().setIcon(4, get_qt_icon("select"))
        self.tree.headerItem().setToolTip(4, "Selected")
        self.tree.setColumnWidth(self.NAME_COLUMN, 200)
        self.tree.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.tree.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.tree.setAnimated(True)
        self.tree.setUniformRowHeights(True)
        self.tree.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.tree.itemChanged.connect(self._tree_change_cb)
        buttons_layout = QVBoxLayout()
        layout.addLayout(buttons_layout)
        self._items = []
        for model_func in [close, hide, show, view]:
            button = QPushButton(model_func.__name__.capitalize())
            buttons_layout.addWidget(button)
            button.clicked.connect(lambda chk, self=self, mf=model_func, ses=session:
                mf([self.models[row] for row in [self._items.index(i)
                    for i in self.tree.selectedItems()]] or self.models, ses))
        self.simply_changed_models = set()
        self.check_model_list = True
        self.countdown = 1
        self.self_initiated = False
        from chimerax.core.models import ADD_MODELS, REMOVE_MODELS, \
            MODEL_DISPLAY_CHANGED, MODEL_ID_CHANGED, MODEL_NAME_CHANGED
        from chimerax.core.selection import SELECTION_CHANGED
        session.triggers.add_handler(SELECTION_CHANGED,
            lambda *args: self._initiate_fill_tree(*args, countdown=3))
        session.triggers.add_handler(MODEL_DISPLAY_CHANGED,
            lambda *args: self._initiate_fill_tree(*args, simple_change=True, countdown=(0,3)))
        session.triggers.add_handler(ADD_MODELS,
            lambda *args: self._initiate_fill_tree(*args, always_rebuild=True, countdown=(3,10)))
        session.triggers.add_handler(REMOVE_MODELS,
            lambda *args: self._initiate_fill_tree(*args, always_rebuild=True))
        session.triggers.add_handler(MODEL_ID_CHANGED,
            lambda *args: self._initiate_fill_tree(*args, always_rebuild=True, countdown=3))
        session.triggers.add_handler(MODEL_NAME_CHANGED,
            lambda *args: self._initiate_fill_tree(*args, simple_change=True, countdown=3))
        from chimerax import atomic
        atomic.get_triggers().add_handler("changes", self._changes_cb)
        self._frame_drawn_handler = None
        tw.manage(placement="side")
        tw.shown_changed = self._shown_changed
Beispiel #27
0
    def __init__(self, session, tool_name):
        ToolInstance.__init__(self, session, tool_name)
        self.display_name = "ISOLDE"
        from chimerax.ui.gui import MainToolWindow
        self.tool_window = MainToolWindow(self)
        self.tool_window.manage(placement=None)
        parent = self.tool_window.ui_area
        pp = parent.parent().parent()
        pp.resize(540, 850)

        import os
        basedir = os.path.dirname(os.path.abspath(__file__))
        from PyQt5 import uic
        uifile = os.path.join(basedir, 'ui', 'IsoldeFrame.ui')
        from Qt import QtWidgets, QtGui
        #from . import isoldewidget
        from .resources import resources_rc
        mw = self.mainwin = QtWidgets.QFrame(parent=parent)
        iw = self.iw = uic.loadUi(uifile, mw)
        # iw = self.iw = isoldewidget.Ui_isolde_widget()
        #iw = w.Ui_isolde_widget()
        # iw.setupUi(self.mainwin)

        import os
        icon_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                 'resources/logo_small.png')
        isolde_icon = QtGui.QPixmap(icon_file)
        iw._isolde_icon.setPixmap(isolde_icon)

        layout = QtWidgets.QHBoxLayout()
        layout.addWidget(self.mainwin)
        layout.setStretchFactor(self.mainwin, 1)
        layout.setContentsMargins(1, 1, 1, 3)
        parent.setLayout(layout)
        self.tool_window.manage(placement=None)
        # Should load saved state here

        combo_boxes = (
            iw._tutorials_combo_box,
            iw._master_model_combo_box,
            iw._real_space_map_volume_combo_box,
            iw._sim_basic_xtal_settings_map_combo_box,
            iw._sim_force_field_combo_box,
            iw._sim_platform_combo_box,
            iw._experience_level_combo_box,
            iw._rebuild_sel_res_rot_backrub_map_combo_box,
            iw._validate_rama_case_combo_box,
            iw._validate_rama_sel_combo_box,
        )
        from .ui.util import win_auto_resize_combo_box_hack
        for cb in combo_boxes:
            win_auto_resize_combo_box_hack(cb)

        ###
        # Selection manipulation buttons
        ###

        # Grow selection at N-terminus
        self._sel_grow_n_terminal_buttons = (iw._sel_extend_N_button, )

        # Shrink selection at N-terminus
        self._sel_shrink_n_terminal_buttons = (iw._sel_shrink_N_button, )

        # Shrink selection at C-terminus
        self._sel_shrink_c_terminal_buttons = (iw._sel_shrink_C_button, )

        # Grow selection at C-terminus
        self._sel_grow_c_terminal_buttons = (iw._sel_extend_C_button, )

        # Define intermediate and expert frames
        self._intermediate_frames = [
            iw._sim_platform_frame,
            iw._sim_basic_load_cif_templates_button,
        ]
        self._expert_frames = [
            iw._force_field_selection_frame,
        ]

        # Any other frames/widgets that should be hidden at the start
        self._hidden_at_start = [
            iw._validate_rama_main_frame,
            iw._validate_pep_main_frame,
            iw._validate_rota_main_frame,
            iw._validate_unparameterised_residues_main_frame,
            iw._sim_basic_xtal_init_open_button,
            iw._sim_basic_xtal_init_main_frame,
            iw._sim_basic_xtal_settings_live_recalc_checkbox,
            iw._sim_basic_xtal_map_settings_frame,
            iw._real_space_map_from_volume_frame,
            iw._live_map_control_frame,
            iw._sim_status_indicator,
        ]

        for f in self._hidden_at_start:
            f.hide()

        # Any frames/widgets that should be disabled at the start
        self._disabled_at_start = [
            #iw._sim_basic_xtal_map_settings_frame,
            iw._map_masking_frame,
            iw._rebuild_sel_res_pep_flip_button,
            iw._rebuild_sel_res_cis_trans_flip_button,
            iw._rebuild_cycle_rotamer_frame,
            #iw._rebuild_sel_res_last_rotamer_button,
            #iw._rebuild_sel_res_next_rotamer_button,
            iw._rebuild_sel_res_rot_commit_button,
            iw._rebuild_sel_res_rot_target_button,
            iw._rebuild_sel_res_rot_discard_button,
            iw._rebuild_sel_res_rot_release_button,
            #~ iw._rebuild_pos_restraint_one_atom_frame,
            #iw._rebuild_pin_atom_container,
            iw._rebuild_pin_atom_to_current_pos_button,
            iw._rebuild_pin_atom_to_pivot_button,
            iw._rebuild_pos_restraint_clear_button,
            iw._rebuild_2ry_struct_restr_container,
            iw._rebuild_2ry_struct_restr_clear_button,
            iw._rebuild_register_shift_container,
            iw._rebuild_dist_restraint_container,
            iw._rebuild_dist_restraint_apply_button,
            iw._rebuild_grow_shrink_sel_frame,
            iw._right_mouse_modes_frame,
            iw._live_map_recalc_button,
            iw._live_map_update_sim_button,
        ]
        for f in self._disabled_at_start:
            f.setEnabled(False)

        # Apply custom palettes to intermediate and expert frames
        from . import palettes
        self._pi = palettes.IntermediatePalette()
        self._pe = palettes.ExpertPalette()

        for f in self._intermediate_frames:
            f.setPalette(self._pi.palette)
            f.setAutoFillBackground(True)

        for f in self._expert_frames:
            f.setPalette(self._pe.palette)
            f.setAutoFillBackground(True)

        from . import isolde
        self.isolde = isolde.Isolde(self)
Beispiel #28
0
    def __init__(self, session):
        tool_name = "Help Viewer"
        ToolInstance.__init__(self, session, tool_name)
        self._pending_downloads = []
        from chimerax.ui import MainToolWindow
        self.tool_window = MainToolWindow(self)
        parent = self.tool_window.ui_area

        # UI content code
        from PyQt5.QtWidgets import QToolBar, QVBoxLayout, QAction, QLineEdit, QTabWidget, QShortcut, QStatusBar
        from PyQt5.QtGui import QIcon
        from PyQt5.QtCore import Qt
        shortcuts = (
            (Qt.CTRL + Qt.Key_0, self.page_reset_zoom),
            (Qt.CTRL + Qt.Key_T, lambda: self.create_tab(empty=True)),
            (Qt.CTRL + Qt.Key_W, self.close_current_tab),
            (Qt.CTRL + Qt.Key_Tab, lambda: self.cycle_tab(1)),
            (Qt.CTRL + Qt.SHIFT + Qt.Key_Tab, lambda: self.cycle_tab(-1)),
            (Qt.CTRL + Qt.Key_1, lambda: self.tab_n(0)),
            (Qt.CTRL + Qt.Key_2, lambda: self.tab_n(1)),
            (Qt.CTRL + Qt.Key_3, lambda: self.tab_n(2)),
            (Qt.CTRL + Qt.Key_4, lambda: self.tab_n(3)),
            (Qt.CTRL + Qt.Key_5, lambda: self.tab_n(4)),
            (Qt.CTRL + Qt.Key_6, lambda: self.tab_n(5)),
            (Qt.CTRL + Qt.Key_7, lambda: self.tab_n(6)),
            (Qt.CTRL + Qt.Key_8, lambda: self.tab_n(7)),
            (Qt.CTRL + Qt.Key_9, lambda: self.tab_n(-1)),
        )
        for shortcut, callback in shortcuts:
            sc = QShortcut(shortcut, parent)
            sc.activated.connect(callback)
        self.toolbar = tb = QToolBar()
        # tb.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        layout = QVBoxLayout()
        layout.setContentsMargins(0, 1, 0, 0)
        layout.addWidget(tb)
        parent.setLayout(layout)
        import os.path
        icon_dir = os.path.dirname(__file__)
        # attribute, text, tool tip, callback, shortcut(s), enabled
        buttons = (
            ("back", "Back", "Back to previous page", self.page_back,
             Qt.Key_Back, False),
            ("forward", "Forward", "Next page", self.page_forward,
             Qt.Key_Forward, False),
            ("reload", "Reload", "Reload page", self.page_reload,
             Qt.Key_Reload, True),
            ("new_tab", "New Tab", "New Tab",
             lambda: self.create_tab(empty=True), Qt.Key_Reload, True),
            ("zoom_in", "Zoom in", "Zoom in", self.page_zoom_in,
             [Qt.CTRL + Qt.Key_Plus, Qt.Key_ZoomIn,
              Qt.CTRL + Qt.Key_Equal], True),
            ("zoom_out", "Zoom out", "Zoom out", self.page_zoom_out,
             [Qt.CTRL + Qt.Key_Minus, Qt.Key_ZoomOut], True),
            ("home", "Home", "Home page", self.page_home, Qt.Key_HomePage,
             True),
            (None, None, None, None, None, None),
            ("search", "Search", "Search in page", self.page_search,
             Qt.Key_Search, True),
        )
        for attribute, text, tooltip, callback, shortcut, enabled in buttons:
            if attribute is None:
                tb.addSeparator()
                continue
            icon_path = os.path.join(icon_dir, "%s.svg" % attribute)
            setattr(self, attribute, QAction(QIcon(icon_path), text, tb))
            a = getattr(self, attribute)
            a.setToolTip(tooltip)
            a.triggered.connect(callback)
            if shortcut:
                if isinstance(shortcut, list):
                    a.setShortcuts(shortcut)
                else:
                    a.setShortcut(shortcut)
            a.setEnabled(enabled)
            tb.addAction(a)

        self.url = QLineEdit()
        self.url.setPlaceholderText("url")
        self.url.setClearButtonEnabled(True)
        self.url.returnPressed.connect(self.go_to)
        tb.insertWidget(self.reload, self.url)

        self.search_terms = QLineEdit()
        self.search_terms.setClearButtonEnabled(True)
        self.search_terms.setPlaceholderText("search in page")
        self.search_terms.setMaximumWidth(200)
        self.search_terms.returnPressed.connect(self.page_search)
        tb.addWidget(self.search_terms)

        self.tabs = QTabWidget(parent)
        self.tabs.setTabsClosable(True)
        self.tabs.setUsesScrollButtons(True)
        self.tabs.setTabBarAutoHide(True)
        self.tabs.setDocumentMode(False)
        self.tabs.currentChanged.connect(self.tab_changed)
        self.tabs.tabCloseRequested.connect(self.close_tab)
        layout.addWidget(self.tabs)

        self.status_bar = QStatusBar()
        layout.addWidget(self.status_bar)

        self.tool_window.manage(placement=None)

        self.profile = create_chimerax_profile(
            self.tabs,
            interceptor=self.intercept,
            download=self.download_requested)
Beispiel #29
0
 def delete(self):
     global _singleton
     _singleton = None
     ToolInstance.delete(self)
Beispiel #30
0
 def delete(self):
     self.opengl_canvas.close()
     self.view.delete()
     self.view = None
     ToolInstance.delete(self)