Beispiel #1
0
def test_ctf_manager_load():
    transfer_func = TransferFunction()

    with temp_directory() as root_dir:
        manager = CtfManager.from_directory(root_dir)
        manager.add("test", transfer_func)

        del manager
        manager = CtfManager.from_directory(root_dir)
        manager.get("test")
Beispiel #2
0
def test_ctf_manager_load():
    transfer_func = TransferFunction()

    with temp_directory() as root_dir:
        manager = CtfManager.from_directory(root_dir)
        manager.add('test', transfer_func)

        del manager
        manager = CtfManager.from_directory(root_dir)
        manager.get('test')
Beispiel #3
0
def _test_ctf_manager_names(names_to_test):
    transfer_func = TransferFunction()
    with temp_directory() as root_dir:
        manager = CtfManager.from_directory(root_dir)

        for name in names_to_test:
            manager.add(name, transfer_func)

        # Reload and check the names
        manager = CtfManager.from_directory(root_dir)
        for name in manager.names:
            assert name in names_to_test
Beispiel #4
0
def _test_ctf_manager_names(names_to_test):
    transfer_func = TransferFunction()
    with temp_directory() as root_dir:
        manager = CtfManager.from_directory(root_dir)

        for name in names_to_test:
            manager.add(name, transfer_func)

        # Reload and check the names
        manager = CtfManager.from_directory(root_dir)
        for name in manager.names:
            assert name in names_to_test
Beispiel #5
0
def test_ctf_manager_add():
    transfer_func = TransferFunction()

    with temp_directory() as root_dir:
        manager = CtfManager.from_directory(root_dir)
        for i in range(5):
            manager.add(str(i), transfer_func)

        assert len(listdir(root_dir)) == 5
Beispiel #6
0
def test_ctf_manager_add():
    transfer_func = TransferFunction()

    with temp_directory() as root_dir:
        manager = CtfManager.from_directory(root_dir)
        for i in range(5):
            manager.add(str(i), transfer_func)

        assert len(listdir(root_dir)) == 5
Beispiel #7
0
def test_ctf_manager_get():
    transfer_func = TransferFunction()

    with temp_directory() as root_dir:
        manager = CtfManager.from_directory(root_dir)
        manager.add("test", transfer_func)

        ret_func = manager.get("test")
        assert_allclose(ret_func.color.values(), transfer_func.color.values())
        assert_allclose(ret_func.opacity.values(), transfer_func.opacity.values())
Beispiel #8
0
def test_ctf_manager_get():
    transfer_func = TransferFunction()

    with temp_directory() as root_dir:
        manager = CtfManager.from_directory(root_dir)
        manager.add('test', transfer_func)

        ret_func = manager.get('test')
        assert_allclose(ret_func.color.values(), transfer_func.color.values())
        assert_allclose(ret_func.opacity.values(),
                        transfer_func.opacity.values())
Beispiel #9
0
To use: right-click in the window to bring up a context menu. Once you've added
a color or opacity, you can drag them around by just clicking on them. The
colors at the end points are editable, but cannot be removed.

"""

from os.path import join

from traits.etsconfig.api import ETSConfig
ETSConfig.toolkit = 'qt4'

from enaml.qt.qt_application import QtApplication
from ensemble.ctf.api import CtfEditor, CtfManager, get_color
import traits_enaml


if __name__ == "__main__":
    with traits_enaml.imports():
        from ctf_demo_window import CtfDemoWindow

    app = QtApplication()

    ctf_editor = CtfEditor(prompt_color_selection=get_color)
    ctf_manager = CtfManager.from_directory(
        join(ETSConfig.application_data, 'CTF_demo')
    )
    win = CtfDemoWindow(ctf_editor=ctf_editor, ctf_manager=ctf_manager)
    win.show()

    app.start()