Exemplo n.º 1
0
def volume_color(name, ramp='', quiet=1, _guiupdate=True, _self=cmd):
    '''
DESCRIPTION

    Set or get the volume colors.

ARGUMENTS

    name = str: volume object name

    ramp = str, list or empty: named ramp, space delimited string or list
    with (x, color, alpha, ...) or (x, r, g, b, alpha, ...) values. If empty, get
    the current volume colors.

EXAMPLE

    fetch 1a00, map, type=2fofc
    volume vol, map
    volume_color vol, .8 cyan 0. 1. blue .3 2. yellow .3
    '''
    quiet = int(quiet)

    if not ramp:
        return get_volume_color(name, quiet, _self)

    if isinstance(ramp, str) and ramp in namedramps:
        ramp = namedramps[ramp]

    ramplist = ramp_expand(ramp)

    with _self.lockcm:
        r = cmd._cmd.set_volume_ramp(_self._COb, name, ramplist)

    if _guiupdate and name in _volume_windows:
        from pymol import gui
        def func():
            if sys.version_info[0] == 2:
                import Tkinter
            else:
                import tkinter as Tkinter
            try:
                panel = _volume_windows[name].panel
                panel.set_flat(ramplist)
            except (LookupError, Tkinter.TclError):
                pass
        app = gui.get_pmgapp()
        app.execute(func)

    if _guiupdate and name in _volume_windows_qt:
        from pymol import gui
        app = gui.get_pmgapp()
        @app.execute
        def _():
            try:
                panel = _volume_windows_qt[name]
                panel.widget().editor.setColors(ramplist)
            except LookupError:
                pass

    return r
def volume_color(name, ramp='', quiet=1, _guiupdate=True, _self=cmd):
    '''
DESCRIPTION

    Set or get the volume colors.

ARGUMENTS

    name = str: volume object name

    ramp = str, list or empty: named ramp, space delimited string or list
    with (x, color, alpha, ...) or (x, r, g, b, alpha, ...) values. If empty, get
    the current volume colors.

EXAMPLE

    fetch 1a00, map, type=2fofc
    volume vol, map
    volume_color vol, .8 cyan 0. 1. blue .3 2. yellow .3
    '''
    quiet = int(quiet)

    if not ramp:
        return get_volume_color(name, quiet, _self)

    if isinstance(ramp, str) and ramp in namedramps:
        ramp = namedramps[ramp]

    ramplist = ramp_expand(ramp)

    with _self.lockcm:
        r = cmd._cmd.set_volume_ramp(_self._COb, name, ramplist)

    if _guiupdate and name in _volume_windows:
        from pymol import gui

        def func():
            import tkinter as Tkinter
            try:
                panel = _volume_windows[name].panel
                panel.set_flat(ramplist)
            except (LookupError, Tkinter.TclError):
                pass

        app = gui.get_pmgapp()
        app.execute(func)

    if _guiupdate and name in _volume_windows_qt:
        from pymol import gui
        app = gui.get_pmgapp()

        @app.execute
        def _():
            try:
                panel = _volume_windows_qt[name]
                panel.widget().editor.setColors(ramplist)
            except LookupError:
                pass

    return r
Exemplo n.º 3
0
def volume_panel(name, quiet=1, _self=cmd):
    '''
DESCRIPTION

    Open an interactive volume ramp panel

ARGUMENTS

    name = str: name of volume object
    '''
    from pymol import gui
    from pmg_tk import volume
    if sys.version_info[0] == 2:
        import Tkinter
    else:
        import tkinter as Tkinter

    app = gui.get_pmgapp()

    def func():
        try:
            window = _volume_windows[name]
            window.lift()
        except (LookupError, Tkinter.TclError):
            window = Tkinter.Toplevel(app.root)
            window.title('Volume Panel for "%s"' % name)
            window.panel = volume.VolumePanel(window, name, _self=cmd)
            window.panel.pack()
            _volume_windows[name] = window

    app.execute(func)
Exemplo n.º 4
0
def volume_panel(name, quiet=1, _self=cmd):
    '''
DESCRIPTION

    Open an interactive volume ramp panel

ARGUMENTS

    name = str: name of volume object
    '''
    from pymol import gui
    from pmg_tk import volume
    import Tkinter

    app = gui.get_pmgapp()
    def func():
        try:
            window = _volume_windows[name]
            window.lift()
        except (LookupError, Tkinter.TclError):
            window = Tkinter.Toplevel(app.root)
            window.title('Volume Panel for "%s"' % name)
            window.panel = volume.VolumePanel(window, name, _self=cmd)
            window.panel.pack()
            _volume_windows[name] = window
    app.execute(func)
Exemplo n.º 5
0
def volume_panel(name, quiet=1, _self=cmd, _noqt=0):
    '''
DESCRIPTION

    Open an interactive volume ramp panel

ARGUMENTS

    name = str: name of volume object
    '''
    from pymol import gui

    qt_window = not int(_noqt) and gui.get_qtwindow()
    app = gui.get_pmgapp()

    if qt_window:
        from pmg_qt import volume as volume_qt

        @app.execute
        def _():
            try:
                panel = _volume_windows_qt[name]
            except LookupError:
                panel = volume_qt.VolumePanel(qt_window, name, _self=_self)
                _volume_windows_qt[name] = panel
            panel.show()
            panel.raise_()

        return

    # Tk fallback
    from pmg_tk import volume
    if sys.version_info[0] == 2:
        import Tkinter
    else:
        import tkinter as Tkinter

    def func():
        try:
            window = _volume_windows[name]
            window.lift()
        except (LookupError, Tkinter.TclError):
            window = Tkinter.Toplevel(app.root)
            window.title('Volume Panel for "%s"' % name)
            window.panel = volume.VolumePanel(window, name, _self=_self)
            window.panel.pack()
            _volume_windows[name] = window

    app.execute(func)
Exemplo n.º 6
0
def volume_panel(name, quiet=1, _self=cmd, _noqt=0):
    '''
DESCRIPTION

    Open an interactive volume ramp panel

ARGUMENTS

    name = str: name of volume object
    '''
    from pymol import gui

    qt_window = not int(_noqt) and gui.get_qtwindow()
    app = gui.get_pmgapp()

    if qt_window:
        from pmg_qt import volume as volume_qt

        @app.execute
        def _():
            try:
                panel = _volume_windows_qt[name]
            except LookupError:
                panel = volume_qt.VolumePanel(qt_window, name, _self=_self)
                _volume_windows_qt[name] = panel
            panel.show()
            panel.raise_()

        return

    # Tk fallback
    from pmg_tk import volume
    if sys.version_info[0] == 2:
        import Tkinter
    else:
        import tkinter as Tkinter

    def func():
        try:
            window = _volume_windows[name]
            window.lift()
        except (LookupError, Tkinter.TclError):
            window = Tkinter.Toplevel(app.root)
            window.title('Volume Panel for "%s"' % name)
            window.panel = volume.VolumePanel(window, name, _self=_self)
            window.panel.pack()
            _volume_windows[name] = window
    app.execute(func)