Exemplo n.º 1
0
    def wrapper(self, *args, **kwargs):
        result = None
        ui_state = self.has_ui
        window_title = '"{args[0]}" ({args[2].__name__})'.format(args=args)

        if ui_state == self.UI_MAINWINDOW_VISIBLE:
            # Remove added kwarg from Katana's Callbacks.addCallback
            kwargs.pop('objectHash', None)
            result = show_func(self, *args, **kwargs)

        elif ui_state:
            self.logger.info(
                'Delaying %s for %s until Katana main window is showing.',
                show_func.__name__, window_title,
            )
            func = partial(wrapper, self, *args, **kwargs)
            Callbacks.addCallback(Callbacks.Type.onStartupComplete, func)
        else:
            self.logger.error(
                "Sorry, this environment doesn't support UI display! Can't"
                ' show the requested window %s.', window_title,
            )

        # lastly, return the instantiated widget
        return result
Exemplo n.º 2
0
def tank_ensure_callbacks_registered():
    """
    Make sure that we have callbacks tracking context state changes.
    """
    global g_tank_callbacks_registered
    if not g_tank_callbacks_registered:
        Callbacks.addCallback(Callbacks.Type.onSceneLoad, __tank_on_scene_event_callback) # onSceneAboutToLoad ?
        Callbacks.addCallback(Callbacks.Type.onSceneSave, __tank_on_scene_event_callback)
        g_tank_callbacks_registered = True
Exemplo n.º 3
0
 def post_app_init(self):
     if self.has_ui:
         try:
             self.add_katana_menu()
         except AttributeError:
             # Katana is probably not fully started and the main menu is not available yet
             Callbacks.addCallback(Callbacks.Type.onStartupComplete, self.add_katana_menu)
         except:
             traceback.print_exc()
Exemplo n.º 4
0
def tank_ensure_callbacks_registered():
    """
    Make sure that we have callbacks tracking context state changes.
    """
    global g_tank_callbacks_registered
    if not g_tank_callbacks_registered:
        Callbacks.addCallback(Callbacks.Type.onSceneLoad, __tank_on_scene_event_callback) # onSceneAboutToLoad ?
        Callbacks.addCallback(Callbacks.Type.onSceneSave, __tank_on_scene_event_callback)
        g_tank_callbacks_registered = True
Exemplo n.º 5
0
 def post_app_init(self):
     if self.has_ui:
         try:
             if self.main_window_ready():
                 self.add_katana_menu()
             else:
                 self.logger.debug(
                     'Adding onStartupComplete callback for '
                     '"KatanaEngine.add_katana_menu" as '
                     'main Katana window is not ready yet.'
                 )
                 Callbacks.addCallback(
                     Callbacks.Type.onStartupComplete,
                     self.add_katana_menu,
                 )
         except Exception:
             self.logger.error(
                 'Failed to add Katana menu\n%s',
                 traceback.format_exc(),
             )
Exemplo n.º 6
0
 def post_app_init(self):
     Callbacks.addCallback(Callbacks.Type.onStartupComplete,
                           self.add_katana_menu)
Exemplo n.º 7
0
def customMenuCallback():
    Callbacks.addCallback(Callbacks.Type.onStartupComplete, onStartupComplete)
Exemplo n.º 8
0
            #            'noAlbedoDivide.filteroverride.json',
            #            'noDepth.filteroverride.json',
            #            'noFireflyKiller.filteroverride.json',
            #            'nonsplitVariances.filteroverride.json',
            #            'noUnpremultiply:wColor.filteroverride.json',
            #            'splitVariances.filteroverride.json',
            #            'unpremultiplyColor.filteroverride.json',
            #            'unpremultiplyFeatures.filteroverride.json'
            #            ]
        })


# FarmAPI.AddFarmSettingString('rrEnvFile', hints={'widget': 'assetIdInput'})
# FarmAPI.AddFarmSettingString('stepSize', hints={'widget': 'fileInput'})

Callbacks.addCallback(Callbacks.Type.onStartup, onStartup)


def initUi():
    global dialog
    if dialog is not None:
        dialog.close()


################################################################################
# initialize Export


def localExport():
    initExport('local')
Exemplo n.º 9
0
                int(os.environ['PYTHON_CREATE_NODE']) - 1)
            return
        #print 'PYTHON_CREATE_NODE : ',os.environ['PYTHON_CREATE_NODE']

        old_name = node.getName()
        value = node.getParameter('nodeType').getValue(0)

        parent_node = node.getParent()
        parent_str = ''
        if parent_node and parent_node.getType(
        ) == 'Group' and parent_node.getName().endswith('_mtl'):
            parent_str = parent_node.getName()[:-3]
        node.getParameter('nodeType').setValue(value, 0)
        node.setName(parent_str + value)
        node.getParameter('name').setValue(node.getName(), 0)
        print 'rename ', old_name, ' --> ', parent_str + value

    except Exception, e:
        print e
        pass


log.info("Registering onStartupComplete callback...")
Callbacks.addCallback(Callbacks.Type.onStartupComplete, onStartupComplete)
Callbacks.addCallback(Callbacks.Type.onSceneAboutToLoad,
                      __before_open_callback)
Callbacks.addCallback(Callbacks.Type.onSceneLoad, __after_open_callback)
Callbacks.addCallback(Callbacks.Type.onSceneSave, __before_save_callback)
Callbacks.addCallback(Callbacks.Type.onNodeCreate, __on_create_node)
#Callbacks.addCallback(Callbacks.Type.onNodeCreate,__on_create_srf_node)
Exemplo n.º 10
0
from Katana import Callbacks


def studio_pipe_menu(**kwargs):
    from resources import menu
    pipe_menu = menu.Menu('studio_toolkits')
    pipe_menu.show_pipe_menu()
    
    
callback_type = Callbacks.Type.onStartupComplete
Callbacks.addCallback(callback_type, studio_pipe_menu, callbackObjectHash=None)        
Exemplo n.º 11
0
    reload(KatanaSceneBuild)
    print "Module KatanaSceneBuild Import Successed..."
    KatanaSceneBuild.execute()


def testScript():
    from KtnPyMili import Test
    reload(Test)


def NetworkMaterialInterfaceAutomatorScript():
    from KtnPyMili import NetworkMaterialInterfaceAutomator
    reload(NetworkMaterialInterfaceAutomator)


log = logging.getLogger("Startup Mili Pipeline")
log.info("Registering onStartupComplete callback...")
Callbacks.addCallback(Callbacks.Type.onStartupComplete, onStartupComplete)
"""
#~ Test

def onNewScene(objectHash):
	print "@onNewScene"

Callbacks.addCallback(Callbacks.Type.onNewScene, onNewScene)

def onNodeCreate(**kwargs):
	print "@OnNodeCreate"

Callbacks.addCallback(Callbacks.Type.onNodeCreate, onNodeCreate)
"""
# Copyright (c) 2012 The Foundry Visionmongers Ltd. All Rights Reserved.

"""
An example script that black-lists a ViewportManipulator for locations that
contain certain attributes.
"""

import ViewerManipulators
from Katana import Callbacks

def addToBlackList(objectHash):
    # Suppress the Scale manipulator for all locations that contain the 
    # attribute 'geometry.fov'
    ViewerManipulators.AddToBlacklist('Scale', ('geometry.fov',) )

Callbacks.addCallback(Callbacks.Type.onStartupComplete, addToBlackList)
Exemplo n.º 13
0
                variable_switch = self.__node
                variable_name = variable_switch.getParameter('variableName').getValue(0)
                variable_patterns_parm = variable_switch.getParameter('patterns')
                gsv_parm = NodegraphAPI.GetNode('rootNode').getParameter('variables.%s'%variable_name)

                if gsv_parm:
                    # delete previous ports and patterns
                    # remove all input ports
                    for port in variable_switch.getInputPorts():
                        variable_switch.removeInputPort(port.getName())
                    # remove all child parameters
                    for child in variable_patterns_parm.getChildren():
                        variable_patterns_parm.deleteChild(child)

                    for child in gsv_parm.getChild('options').getChildren():
                        # create new port with pattern
                        name = child.getValue(0)
                        # mechanic on the variable switch will automagically create the
                        # parameters when you create the port
                        variable_switch.addInputPort(name)

        def addToContextMenu(self, menu, node):
            menu.addAction(self._addAllGSVOptions(menu, node))

    RegisterActionDelegate("VariableSwitch", UpdateGSVOptions())


Callbacks.addCallback(Callbacks.Type.onStartupComplete, contextMenu)
Callbacks.addCallback(Callbacks.Type.onStartupComplete, createGSV)
Callbacks.addCallback(Callbacks.Type.onSceneLoad, createGSV)
Callbacks.addCallback(Callbacks.Type.onStartupComplete, createMenuItem)
Exemplo n.º 14
0
        from Katana import UI4
        from UI4.App.Application import QtGui

        layoutsMenus = [
            x for x in QtGui.qApp.topLevelWidgets()
            if type(x).__name__ == 'LayoutsMenu'
        ]
        if len(layoutsMenus) == 1:
            main_menu = layoutsMenus[0].parent()

            Katana.CEREBRO_MENU = dict()
            cerebro_menu = QtGui.QMenu('Cerebro', main_menu)
            Katana.CEREBRO_MENU['/Main/Cerebro'] = cerebro_menu
            main_menu.addMenu(cerebro_menu)

            cerebro_menu.addAction('Todo list', menu.todolist)
            cerebro_menu.addAction('Link/Embed', menu.browser)
            cerebro_menu.addAction('Save as version', menu.createreport)
            cerebro_menu.addAction('Publish', menu.publish)
            cerebro_menu.addSeparator()
            cerebro_menu.addAction('Logout', menu.logout)
            cerebro_menu.addSeparator()
            cerebro_menu.addAction('Change working directory', menu.workdir)
            cerebro_menu.addSeparator()
            cerebro_menu.addAction('About', menu.about)


if capp.HOST == capp.KATANA:
    from Katana import Callbacks
    Callbacks.addCallback(Callbacks.Type.onStartupComplete, init_menu)