예제 #1
0
    def test_menu_creation_include_roles(self):
        """
        Test the constructor() with extra roles.
        """
        params = OCIO.ColorSpaceMenuParameters(config=self.cfg,
                                               includeRoles=True)
        menu = OCIO.ColorSpaceMenuHelper(params)
        self.assertEqual(menu.getNumColorSpaces(), 20)
        self.assertEqual(menu.getName(0), 'raw')
        self.assertEqual(menu.getName(1), 'lin_1')
        # Skip up to roles.
        self.assertEqual(menu.getName(16), 'default')
        self.assertEqual(menu.getName(17), 'reference')
        self.assertEqual(menu.getName(18), 'rendering')
        self.assertEqual(menu.getName(19), 'scene_linear')
        self.assertEqual(menu.getUIName(16), 'default (raw)')
        self.assertEqual(menu.getUIName(17), 'reference (lin_1)')
        self.assertEqual(menu.getUIName(18), 'rendering (lin_1)')
        self.assertEqual(menu.getUIName(19), 'scene_linear (lin_1)')
        hlevels = menu.getHierarchyLevels(16)
        self.assertEqual(len(hlevels), 1)
        self.assertEqual(next(hlevels), 'Roles')

        params = OCIO.ColorSpaceMenuParameters(
            config=self.cfg,
            includeRoles=True,
            appCategories='file-io, working-space')
        menu = OCIO.ColorSpaceMenuHelper(params)
        # [lin_1, lin_2, log_1, in_1, in_2, in_3, lut_input_3, display_lin_1, display_lin_2, display_log_1, default, reference, rendering, scene_linear]
        self.assertEqual(menu.getNumColorSpaces(), 14)
        self.assertEqual(menu.getName(0), 'lin_1')
        self.assertEqual(menu.getName(1), 'lin_2')
        self.assertEqual(menu.getName(2), 'log_1')
        self.assertEqual(menu.getName(3), 'in_1')
        self.assertEqual(menu.getName(4), 'in_2')
        self.assertEqual(menu.getName(5), 'in_3')
        self.assertEqual(menu.getName(6), 'lut_input_3')
        self.assertEqual(menu.getName(7), 'display_lin_1')
        self.assertEqual(menu.getName(8), 'display_lin_2')
        self.assertEqual(menu.getName(9), 'display_log_1')
        self.assertEqual(menu.getName(10), 'default')
        self.assertEqual(menu.getName(11), 'reference')
        self.assertEqual(menu.getName(12), 'rendering')
        self.assertEqual(menu.getName(13), 'scene_linear')
        self.assertEqual(menu.getUIName(10), 'default (raw)')
        self.assertEqual(menu.getUIName(11), 'reference (lin_1)')
        self.assertEqual(menu.getUIName(12), 'rendering (lin_1)')
        self.assertEqual(menu.getUIName(13), 'scene_linear (lin_1)')
예제 #2
0
    def test_menu_creation_single_role(self):
        """
        Test the constructor() with single role.
        """
        params = OCIO.ColorSpaceMenuParameters(config=self.cfg, role='default')
        menu = OCIO.ColorSpaceMenuHelper(params)
        self.assertEqual(menu.getNumColorSpaces(), 1)
        self.assertEqual(menu.getName(0), 'raw')
        self.assertEqual(menu.getUIName(0), 'default (raw)')
        self.assertEqual(menu.getDescription(0), '')
        self.assertEqual(menu.getFamily(0), '')
        hlevels = menu.getHierarchyLevels(0)
        self.assertEqual(len(hlevels), 0)
        # Out of range index.
        self.assertEqual(menu.getName(1), '')
        self.assertEqual(menu.getUIName(1), '')
        self.assertEqual(menu.getDescription(1), '')
        self.assertEqual(menu.getFamily(1), '')
        hlevels = menu.getHierarchyLevels(1)
        self.assertEqual(len(hlevels), 0)

        # Other paramters are ignored if role exist.
        params.setAppCategories('file-io')
        menu = OCIO.ColorSpaceMenuHelper(params)
        self.assertEqual(menu.getNumColorSpaces(), 1)
        params.setAppCategories('unknown')
        menu = OCIO.ColorSpaceMenuHelper(params)
        self.assertEqual(menu.getNumColorSpaces(), 1)
        params.setAppCategories('file-io')
        params.setIncludeRoles()
        menu = OCIO.ColorSpaceMenuHelper(params)
        self.assertEqual(menu.getNumColorSpaces(), 1)

        # Other parameters are used if role does not exist.
        params = OCIO.ColorSpaceMenuParameters(config=self.cfg,
                                               role='non-existing',
                                               appCategories='working-space')
        menu = OCIO.ColorSpaceMenuHelper(params)
        self.assertEqual(menu.getNumColorSpaces(), 7)
예제 #3
0
    def test_menu_creation_catgeories(self):
        """
        Test the constructor() with categories.
        """
        params = OCIO.ColorSpaceMenuParameters(
            config=self.cfg, appCategories='working-space, file-io')
        menu = OCIO.ColorSpaceMenuHelper(params)
        # [lin_1, lin_2, log_1, in_1, in_2, in_3, lut_input_3, display_lin_1, display_lin_2, display_log_1]
        self.assertEqual(menu.getNumColorSpaces(), 10)
        self.assertEqual(menu.getName(0), 'lin_1')
        self.assertEqual(menu.getName(1), 'lin_2')
        self.assertEqual(menu.getName(2), 'log_1')
        self.assertEqual(menu.getName(3), 'in_1')
        self.assertEqual(menu.getName(4), 'in_2')
        self.assertEqual(menu.getName(5), 'in_3')
        self.assertEqual(menu.getName(6), 'lut_input_3')
        self.assertEqual(menu.getName(7), 'display_lin_1')
        self.assertEqual(menu.getName(8), 'display_lin_2')
        self.assertEqual(menu.getName(9), 'display_log_1')

        params.setSearchReferenceSpaceType(OCIO.SEARCH_REFERENCE_SPACE_SCENE)
        menu = OCIO.ColorSpaceMenuHelper(params)
        self.assertEqual(menu.getNumColorSpaces(), 7)
        params.setSearchReferenceSpaceType(OCIO.SEARCH_REFERENCE_SPACE_DISPLAY)
        menu = OCIO.ColorSpaceMenuHelper(params)
        self.assertEqual(menu.getNumColorSpaces(), 3)

        params.setEncodings('sdr-video')
        params.setSearchReferenceSpaceType(OCIO.SEARCH_REFERENCE_SPACE_SCENE)
        menu = OCIO.ColorSpaceMenuHelper(params)
        self.assertEqual(menu.getNumColorSpaces(), 2)
        self.assertEqual(menu.getName(0), 'in_1')
        self.assertEqual(menu.getName(1), 'in_2')
        params.setSearchReferenceSpaceType(OCIO.SEARCH_REFERENCE_SPACE_DISPLAY)
        menu = OCIO.ColorSpaceMenuHelper(params)
        self.assertEqual(menu.getNumColorSpaces(), 1)
        self.assertEqual(menu.getName(0), 'display_lin_2')
        params.setSearchReferenceSpaceType(OCIO.SEARCH_REFERENCE_SPACE_ALL)
        menu = OCIO.ColorSpaceMenuHelper(params)
        self.assertEqual(menu.getNumColorSpaces(), 3)
예제 #4
0
    def test_menu_creation_colorspaces(self):
        """
        Test the constructor() with only colorspaces.
        """

        # Parameters are needed.

        with self.assertRaises(TypeError):
            OCIO.ColorSpaceMenuHelper(None)

        # Create with sample config.

        params = OCIO.ColorSpaceMenuParameters(config=self.cfg)
        menu = OCIO.ColorSpaceMenuHelper(params)

        # [raw, lin_1, lin_2, log_1, in_1, in_2, in_3, view_1, view_2, view_3, lut_input_1, lut_input_2, lut_input_3,
        # display_lin_1, display_lin_2, display_log_1]
        self.assertEqual(menu.getNumColorSpaces(), 16)
        self.assertEqual(menu.getName(0), 'raw')
        self.assertEqual(menu.getUIName(0), 'raw')
        self.assertEqual(
            menu.getDescription(0),
            'A raw color space. Conversions to and from this space are no-ops.'
        )
        self.assertEqual(menu.getFamily(0), 'Raw')
        hlevels = menu.getHierarchyLevels(0)
        self.assertEqual(len(hlevels), 1)
        self.assertEqual(next(hlevels), 'Raw')

        self.assertEqual(menu.getName(1), 'lin_1')
        self.assertEqual(menu.getName(2), 'lin_2')
        self.assertEqual(menu.getName(3), 'log_1')
        self.assertEqual(menu.getName(4), 'in_1')

        hlevels = menu.getHierarchyLevels(4)
        self.assertEqual(len(hlevels), 3)
        self.assertEqual(next(hlevels), 'Input')
        self.assertEqual(next(hlevels), 'Camera')
        self.assertEqual(next(hlevels), 'Acme')

        self.assertEqual(menu.getName(5), 'in_2')
        self.assertEqual(menu.getName(6), 'in_3')
        self.assertEqual(menu.getName(7), 'view_1')
        self.assertEqual(menu.getName(8), 'view_2')
        self.assertEqual(menu.getName(9), 'view_3')
        self.assertEqual(menu.getName(10), 'lut_input_1')
        self.assertEqual(menu.getName(11), 'lut_input_2')
        self.assertEqual(menu.getName(12), 'lut_input_3')
        self.assertEqual(menu.getName(13), 'display_lin_1')
        self.assertEqual(menu.getName(14), 'display_lin_2')
        self.assertEqual(menu.getName(15), 'display_log_1')
        # Out of range index.
        self.assertEqual(menu.getName(16), '')
        self.assertEqual(menu.getUIName(16), '')
        self.assertEqual(menu.getDescription(16), '')
        self.assertEqual(menu.getFamily(16), '')
        hlevels = menu.getHierarchyLevels(16)
        self.assertEqual(len(hlevels), 0)

        self.assertEqual(
            str(menu),
            'config: $0f5cce49d82e023765b1d657191c3417:$4dd1c89df8002b409e089089ce8f24e7, '
            'includeColorSpaces: true, includeRoles: false, includeNamedTransforms: false, '
            'color spaces = [raw, lin_1, lin_2, log_1, in_1, in_2, in_3, view_1, view_2, view_3, '
            'lut_input_1, lut_input_2, lut_input_3, display_lin_1, display_lin_2, display_log_1]'
        )