Exemplo n.º 1
0
    def reloadAllComponents(self):
        krakenUIWidget = self.window().krakenUI
        graphViewWidget = krakenUIWidget.graphViewWidget

        # Sync and Store Graph Data
        graphViewWidget.synchGuideRig()
        rigData = graphViewWidget.guideRig.getData()

        # Create New Rig And Reload All Components.
        graphViewWidget.newRigPreset()
        KrakenSystem.getInstance().reloadAllComponents()

        # Load Saved Data And Update Widget
        graphViewWidget.guideRig.loadRigDefinition(rigData)
        graphViewWidget.graphView.displayGraph(graphViewWidget.guideRig)
Exemplo n.º 2
0
    def reloadAllComponents(self):
        krakenUIWidget = self.window().krakenUI
        graphViewWidget = krakenUIWidget.graphViewWidget

        # Sync and Store Graph Data
        graphViewWidget.synchGuideRig()
        rigData = graphViewWidget.guideRig.getData()

        # Create New Rig And Reload All Components.
        graphViewWidget.newRigPreset()
        KrakenSystem.getInstance().reloadAllComponents()

        # Load Saved Data And Update Widget
        graphViewWidget.guideRig.loadRigDefinition(rigData)
        graphViewWidget.graphView.displayGraph(graphViewWidget.guideRig)
Exemplo n.º 3
0
    def loadRigDefinition(self, jsonData):
        """Load a rig definition from a JSON structure.

        Arguments:
        jsonData -- dict, the JSON data containing the rig definition.

        Return:
        True if successful.

        """

        Profiler.getInstance().push("loadRigDefinition:" + self.getName())

        krakenSystem = KrakenSystem.getInstance()

        if 'name' in jsonData:
            self.setName(jsonData['name'])

        if 'components' in jsonData:
            self._loadComponents(jsonData['components'])

            if 'connections' in jsonData:
                self._makeConnections(jsonData['connections'])


        if 'graphPositions' in jsonData:
            self._loadGraphPositions(jsonData['graphPositions'])

        Profiler.getInstance().pop()
Exemplo n.º 4
0
    def loadRigDefinition(self, jsonData):
        """Load a rig definition from a JSON structure.

        Arguments:
        jsonData -- dict, the JSON data containing the rig definition.

        Return:
        True if successful.

        """

        Profiler.getInstance().push("loadRigDefinition:" + self.getName())

        krakenSystem = KrakenSystem.getInstance()

        if 'name' in jsonData:
            self.setName(jsonData['name'])

        if 'components' in jsonData:
            self._loadComponents(jsonData['components'])

            if 'connections' in jsonData:
                self._makeConnections(jsonData['connections'])

        if 'graphPositions' in jsonData:
            self._loadGraphPositions(jsonData['graphPositions'])

        Profiler.getInstance().pop()
Exemplo n.º 5
0
    def _loadComponents(self, componentsJson):
        """Loads components from a JSON dict.

        Args:
            componentsJson (dict): Dictionary of components to load.

        """

        Profiler.getInstance().push("__loadComponents")

        krakenSystem = KrakenSystem.getInstance()

        for componentData in componentsJson:
            # trim off the class name to get the module path.
            modulePath = '.'.join(componentData['class'].split('.')[:-1])
            if modulePath is not "":
                importlib.import_module(modulePath)

            componentClass = krakenSystem.getComponentClass(
                componentData['class'])
            if 'name' in componentData:
                component = componentClass(name=componentData['name'],
                                           parent=self)
            else:
                component = componentClass(parent=self)
            component.loadData(componentData)

        Profiler.getInstance().pop()
Exemplo n.º 6
0
    def __init__(self, parent):
        super(ContextualNodeList, self).__init__(parent)

        self.setFixedSize(250, 200)

        self.searchLineEdit = SearchLineEdit(self)
        self.searchLineEdit.setObjectName('contextNodeListSearchLine')
        # self.searchLineEdit.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.searchLineEdit.setFocus()

        self.nodesList = NodeList(self)

        self.ks = KrakenSystem.getInstance()
        self.ks.loadComponentModules()

        self.componentClassNames = []
        for componentClassName in sorted(self.ks.getComponentClassNames()):
            cmpCls = self.ks.getComponentClass(componentClassName)
            if cmpCls.getComponentType() != 'Guide':
                continue

            self.componentClassNames.append(componentClassName)

        self.nodes = None
        self.showClosestNames()
        self.searchLineEdit.textEdited.connect(self.showClosestNames)
        self.nodesList.itemClicked.connect(self.createNode)

        self.setIndex(0)

        grid = QtGui.QGridLayout()
        grid.addWidget(self.searchLineEdit, 0, 0)
        grid.addWidget(self.nodesList, 1, 0)
        self.setLayout(grid)
Exemplo n.º 7
0
    def __init__(self, parent):
        super(ComponentLibrary, self).__init__(parent)

        self.setMinimumWidth(175)

        self.searchLineEdit = QtGui.QLineEdit(parent)
        self.searchLineEdit.setObjectName('contextNodeListSearchLine')
        self.searchLineEdit.setFocusPolicy(QtCore.Qt.ClickFocus)

        self.nodesList = NodeList(self)

        self.ks = KrakenSystem.getInstance()
        self.ks.loadComponentModules()

        self.componentClassNames = []
        for componentClassName in sorted(self.ks.getComponentClassNames()):
            cmpCls = self.ks.getComponentClass(componentClassName)
            if cmpCls.getComponentType() != 'Guide':
                continue

            self.componentClassNames.append(componentClassName)

        self.nodes = None
        self.showClosestNames()
        self.searchLineEdit.textEdited.connect(self.showClosestNames)

        self.setIndex(0)

        grid = QtGui.QGridLayout()
        grid.addWidget(self.searchLineEdit, 0, 0)
        grid.addWidget(self.nodesList, 1, 0)
        self.setLayout(grid)
Exemplo n.º 8
0
    def loadRigDefinition(self, jsonData):
        """Load a rig definition from a JSON structure.

        Args:
            jsonData (dict): JSON data containing the rig definition.

        Returns:
            bool: True if successful.

        """

        Profiler.getInstance().push("loadRigDefinition:" + self.getName())

        krakenSystem = KrakenSystem.getInstance()

        if 'name' in jsonData:
            self.setName(jsonData['name'])

        if 'components' in jsonData:
            self._loadComponents(jsonData['components'])

            if 'connections' in jsonData:
                self._makeConnections(jsonData['connections'])

        if 'metaData' in jsonData:

            for k, v in jsonData['metaData'].iteritems():
                self.setMetaData(k, v)

        Profiler.getInstance().pop()
Exemplo n.º 9
0
    def __init__(self, parent):
        super(ComponentLibrary, self).__init__(parent)

        self.setMinimumWidth(175)

        self.searchLineEdit = QtGui.QLineEdit(parent)
        self.searchLineEdit.setObjectName('contextNodeListSearchLine')
        self.searchLineEdit.setFocusPolicy(QtCore.Qt.ClickFocus)

        self.nodesList = NodeList(self)

        self.ks = KrakenSystem.getInstance()
        self.ks.loadComponentModules()

        self.componentClassNames = []
        for componentClassName in sorted(self.ks.getComponentClassNames()):
            cmpCls = self.ks.getComponentClass(componentClassName)
            if cmpCls.getComponentType() != 'Guide':
                continue

            self.componentClassNames.append(componentClassName)

        self.nodes = None
        self.showClosestNames()
        self.searchLineEdit.textEdited.connect(self.showClosestNames)

        self.setIndex(0)

        grid = QtGui.QGridLayout()
        grid.addWidget(self.searchLineEdit, 0, 0)
        grid.addWidget(self.nodesList, 1, 0)
        self.setLayout(grid)
Exemplo n.º 10
0
    def _loadComponents(self, componentsJson):
        """Loads components from a JSON dict.

        Args:
            componentsJson (dict): Dictionary of components to load.

        """


        Profiler.getInstance().push("__loadComponents")

        krakenSystem = KrakenSystem.getInstance()

        for componentData in componentsJson:
            # trim off the class name to get the module path.
            modulePath = '.'.join(componentData['class'].split('.')[:-1])
            if modulePath is not "":
                importlib.import_module(modulePath)

            componentClass = krakenSystem.getComponentClass(componentData['class'])
            if 'name' in componentData:
                component = componentClass(name=componentData['name'], parent=self)
            else:
                component = componentClass(parent=self)
            component.loadData(componentData)

        Profiler.getInstance().pop()
Exemplo n.º 11
0
    def __init__(self, parent):
        super(ContextualNodeList, self).__init__(parent)
        self.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.setFocus()

        self.setFixedSize(250, 200)

        self.searchLineEdit = SearchLineEdit(self)
        self.searchLineEdit.setObjectName('contextNodeListSearchLine')
        # self.searchLineEdit.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.searchLineEdit.setFocus()

        self.nodesList = NodeList(self)

        self.ks = KrakenSystem.getInstance()

        self.componentClassNames = []
        for componentClassName in sorted(self.ks.getComponentClassNames()):
            cmpCls = self.ks.getComponentClass(componentClassName)
            if cmpCls.getComponentType() != 'Guide':
                continue

            self.componentClassNames.append(componentClassName)

        self.nodes = None
        self.showClosestNames()
        self.searchLineEdit.textEdited.connect(self.showClosestNames)
        self.nodesList.itemClicked.connect(self.createNode)

        self.setIndex(0)

        grid = QtWidgets.QGridLayout()
        grid.addWidget(self.searchLineEdit, 0, 0)
        grid.addWidget(self.nodesList, 1, 0)
        self.setLayout(grid)
Exemplo n.º 12
0
    def loadRigDefinition(self, jsonData):
        """Load a rig definition from a JSON structure.

        Args:
            jsonData (dict): JSON data containing the rig definition.

        Returns:
            bool: True if successful.

        """

        Profiler.getInstance().push("loadRigDefinition:" + self.getName())

        krakenSystem = KrakenSystem.getInstance()

        if 'name' in jsonData:
            self.setName(jsonData['name'])

        if 'components' in jsonData:
            self._loadComponents(jsonData['components'])

            if 'connections' in jsonData:
                self._makeConnections(jsonData['connections'])

        if 'metaData' in jsonData:

            for k, v in jsonData['metaData'].iteritems():
                self.setMetaData(k, v)

        Profiler.getInstance().pop()
Exemplo n.º 13
0
    def setCurrentConfigByName(self, configName):
        """Set the current config by the name of the config.

        If the config doesn't exist it won't change itself.

        Args:
            configName (str): Config name.

        Returns:
            Type: True if successful.

        """

        if configName == 'Default Config':
            self.setCurrentConfig(0)
        else:
            configs = KrakenSystem.getInstance().getConfigClassNames()
            if configName in configs:
                itemIndex = self.configsWidget.findData(
                    configName, role=QtCore.Qt.UserRole)
                self.setCurrentConfig(itemIndex)
            else:
                logger.warn(
                    "Config from rig file could not be found: {}".format(
                        configName))

        return True
Exemplo n.º 14
0
    def generateData(self):
        """Generates a dictionary with a tree structure of the component paths.

        Returns:
            True if successful

        """

        self.ks = KrakenSystem.getInstance()
        isSuccessful = self.ks.loadComponentModules()

        componentClassNames = []
        for componentClassName in sorted(self.ks.getComponentClassNames()):
            cmpCls = self.ks.getComponentClass(componentClassName)
            if cmpCls.getComponentType() != 'Guide':
                continue

            componentClassNames.append(componentClassName)

        self._data = {'subDirs': {}, 'components': {}}

        for classItem in componentClassNames:

            nameSplit = classItem.rsplit('.', 1)

            className = nameSplit[-1]
            path = nameSplit[0].split('.')
            path.pop(len(path) - 1)

            parent = None
            for i, part in enumerate(path):

                if i == 0:
                    if part not in self._data['subDirs'].keys():
                        self._data['subDirs'][part] = {
                            'subDirs': {},
                            'components': {}
                        }

                    parent = self._data['subDirs'][part]

                    continue

                if part in parent['subDirs'].keys():
                    parent = parent['subDirs'][part]
                    continue

                parent['subDirs'][part] = {'subDirs': {}, 'components': {}}
                parent = parent['subDirs'][part]

            parent['components'][className] = classItem

        return isSuccessful
Exemplo n.º 15
0
    def setCurrentConfig(self, index=None):
        if index is None:
            index = self.configsWidget.currentIndex()
        else:
            self.configsWidget.setCurrentIndex(index)

        if index == 0:
            Config.makeCurrent()
        else:
            ks = KrakenSystem.getInstance()
            configs = ks.getConfigClassNames()
            configClass = ks.getConfigClass(configs[index-1])
            configClass.makeCurrent()
Exemplo n.º 16
0
    def setCurrentConfig(self, index=None):
        if index is None:
            index = self.configsWidget.currentIndex()
        else:
            self.configsWidget.setCurrentIndex(index)

        if index == 0:
            Config.makeCurrent()
        else:
            ks = KrakenSystem.getInstance()
            configs = ks.getConfigClassNames()
            configClass = ks.getConfigClass(configs[index - 1])
            configClass.makeCurrent()
Exemplo n.º 17
0
    def generateData(self):
        """Generates a dictionary with a tree structure of the component paths.

        Returns:
            True if successful

        """

        self.ks = KrakenSystem.getInstance()
        isSuccessful = self.ks.loadComponentModules()

        componentClassNames = []
        for componentClassName in sorted(self.ks.getComponentClassNames()):
            cmpCls = self.ks.getComponentClass(componentClassName)
            if cmpCls.getComponentType() != 'Guide':
                continue

            componentClassNames.append(componentClassName)


        self._data  = {'subDirs': {}, 'components': {}}

        for classItem in componentClassNames:

            nameSplit = classItem.rsplit('.', 1)

            className = nameSplit[-1]
            path = nameSplit[0].split('.')
            path.pop(len(path) - 1)

            parent = None
            for i, part in enumerate(path):

                if i == 0:
                    if part not in self._data['subDirs'].keys():
                        self._data['subDirs'][part] = {'subDirs': {}, 'components': {}}

                    parent = self._data['subDirs'][part]

                    continue

                if part in parent['subDirs'].keys():
                        parent = parent['subDirs'][part]
                        continue

                parent['subDirs'][part] = {'subDirs': {}, 'components': {}}
                parent = parent['subDirs'][part]

            parent['components'][className] = classItem

        return isSuccessful
Exemplo n.º 18
0
    def showEvent(self, event):

        krakenSystem = KrakenSystem.getInstance()
        krakenSystem.loadCoreClient()
        krakenSystem.loadExtension('Kraken')

        # Need to wait until window is shown before we update the statusBar with messages
        if hasattr(self, "error_loading_startup"):

            if self.error_loading_startup:
                logger.error('Error Loading Modules')
            else:
                logger.info('Success Loading Modules')

            delattr(self, "error_loading_startup")
Exemplo n.º 19
0
    def dropEvent(self, event):
        textParts = event.mimeData().text().split(':')
        if textParts[0] == 'KrakenComponent':
            componentClassName = textParts[1]

            # Add a component to the rig placed at the given position.
            dropPosition = self.mapToScene(event.pos())

            # construct the node and add it to the graph.
            krakenSystem = KrakenSystem.getInstance()
            componentClass = krakenSystem.getComponentClass(componentClassName)
            component = componentClass(parent=self.getRig())
            component.setGraphPos(Vec2(dropPosition.x(), dropPosition.y()))
            self.addNode(KNode(self, component))

            event.acceptProposedAction()
        else:
            super(GraphView, self).dropEvent(event)
Exemplo n.º 20
0
    def dropEvent(self, event):
        textParts = event.mimeData().text().split(':')
        if textParts[0] == 'KrakenComponent':
            componentClassName = textParts[1]

            # Add a component to the rig placed at the given position.
            dropPosition = self.mapToScene(event.pos())

            # construct the node and add it to the graph.
            krakenSystem = KrakenSystem.getInstance()
            componentClass = krakenSystem.getComponentClass( componentClassName )
            component = componentClass(parent=self.getRig())
            component.setGraphPos(Vec2(dropPosition.x(), dropPosition.y()))
            self.addNode(KNode(self, component) )

            event.acceptProposedAction()
        else:
            super(GraphView, self).dropEvent(event)
Exemplo n.º 21
0
def main():

    os.environ['KRAKEN_DCC'] = 'KL'

    options, args = argOpts()

    ks = KrakenSystem.getInstance()
    numConfigs = len(ks.registeredConfigs)

    if options.config:
        directory, file = os.path.split(options.config)
        filebase, ext = os.path.splitext(file)
        sys.path = [directory] + sys.path  # prepend
        exec("import " + filebase)

        if len(ks.registeredConfigs) > numConfigs:
            configName = next(reversed(ks.registeredConfigs))
            print ("Using config %s from %s" % (configName, options.config))
            ks.getConfigClass(configName).makeCurrent()

        else:
            print ("Failed to use config in %s" % options.config)
            exit()

    guideRig = Rig()
    guideRig.loadRigDefinitionFile(args[0])

    rig = Rig()
    rig.loadRigDefinition(guideRig.getRigBuildData())

    builder = plugins.getBuilder()
    builder.setOutputFolder(args[1])

    config = builder.getConfig()

    config.setMetaData('RigTitle', os.path.split(args[0])[1].partition('.')[0])
    if options.constants:
        config.setMetaData('UseRigConstants', True)
    if options.numframes:
        config.setMetaData('ProfilingFrames', options.numframes)
    if options.logfile:
        config.setMetaData('ProfilingLogFile', options.logfile)

    builder.build(rig)
Exemplo n.º 22
0
def main():

    options, args = argOpts()

    ks = KrakenSystem.getInstance()
    numConfigs = len(ks.registeredConfigs)

    if options.config:
        directory, file = os.path.split(options.config)
        filebase, ext = os.path.splitext(file)
        sys.path = [directory] + sys.path  # prepend
        exec("import " + filebase)

        if len(ks.registeredConfigs) > numConfigs:
            configName = next(reversed(ks.registeredConfigs))
            print("Using config %s from %s" % (configName, options.config))
            ks.getConfigClass(configName).makeCurrent()

        else:
            print("Failed to use config in %s" % options.config)
            exit()

    guideRig = Rig()
    guideRig.loadRigDefinitionFile(args[0])

    rig = Rig()
    rig.loadRigDefinition(guideRig.getRigBuildData())

    builder = plugins.getBuilder()
    builder.setOutputFolder(args[1])

    config = builder.getConfig()

    config.setMetaData('RigTitle', os.path.split(args[0])[1].partition('.')[0])
    if options.constants:
        config.setMetaData('UseRigConstants', True)
    if options.numframes:
        config.setMetaData('ProfilingFrames', options.numframes)
    if options.logfile:
        config.setMetaData('ProfilingLogFile', options.logfile)
    if options.extensionname:
        config.setMetaData('RigTitle', options.extensionname)

    builder.build(rig)
Exemplo n.º 23
0
    def readSettings(self, settings):
        krakenUIWidget = self.window().krakenUI
        graphViewWidget = krakenUIWidget.graphViewWidget

        settings.beginGroup('KrakenMenu')

        if settings.contains('currentConfigName'):
            configName = str(settings.value('currentConfigName', 0))

            if configName != 'Default Config':

                configs = KrakenSystem.getInstance().getConfigClassNames()
                if configName in configs:
                    itemIndex = self.configsWidget.findData(
                        configName, role=QtCore.Qt.UserRole)
                    self.setCurrentConfig(itemIndex)

        if settings.contains('snapToGrid'):
            if settings.value('snapToGrid') == 'true':
                snapToGrid = True
            else:
                snapToGrid = False

            self.snapToGridAction.setChecked(snapToGrid)
            graphViewWidget.graphView.setSnapToGrid(snapToGrid)

        if settings.contains('recentFiles'):
            recentFiles = settings.value('recentFiles', None)

            if recentFiles is not None:
                fileSplit = recentFiles.split(';')
                for eachFile in fileSplit[:4]:
                    if os.path.exists(eachFile):
                        self.recentFiles.append(eachFile)

        settings.endGroup()

        self.buildRecentFilesMenu()
Exemplo n.º 24
0
        # ============
        # Set IO Xfos
        # ============
        self.rootInputTgt.xfo = boneXfos[0]

        for i in xrange(numJoints):
            self.boneOutputsTgt[i].xfo = boneXfos[i]

        self.chainEndXfoOutputTgt.xfo = data['endXfo']
        self.chainEndPosOutputTgt.xfo = data['endXfo']

        # =============
        # Set IO Attrs
        # =============

        # ====================
        # Evaluate Splice Ops
        # ====================
        # Eval Outputs to Controls Op to evaulate with new outputs and controls
        self.outputsToControlsSpliceOp.evaluate()

        # evaluate the output splice op to evaluate with new outputs and deformers
        self.deformersToOutputsSpliceOp.evaluate()


from kraken.core.kraken_system import KrakenSystem
ks = KrakenSystem.getInstance()
ks.registerComponent(FKChainComponentGuide)
ks.registerComponent(FKChainComponentRig)
Exemplo n.º 25
0
    def createLayout(self):

        self.menuLayout = QtGui.QHBoxLayout()
        self.menuLayout.setContentsMargins(0, 0, 0, 0)
        self.menuLayout.setSpacing(0)

        # Menu
        self.menuBar = QtGui.QMenuBar()

        # File Menu
        self.fileMenu = self.menuBar.addMenu('&File')
        self.newAction = self.fileMenu.addAction('&New')
        self.newAction.setShortcut('Ctrl+N')
        self.newAction.setObjectName("newAction")

        self.openAction = self.fileMenu.addAction('&Open...')
        self.openAction.setShortcut('Ctrl+O')
        self.openAction.setObjectName("openAction")

        self.saveAction = self.fileMenu.addAction('&Save')
        self.saveAction.setShortcut('Ctrl+S')
        self.saveAction.setObjectName("saveAction")

        self.saveAsAction = self.fileMenu.addAction('&Save As...')
        self.saveAsAction.setShortcut('Ctrl+Shift+S')
        self.saveAsAction.setObjectName("saveAsAction")

        self.fileMenu.addSeparator()
        self.recentFilesMenu = self.fileMenu.addMenu('&Recent Files')

        self.fileMenu.addSeparator()

        self.closeAction = self.fileMenu.addAction('&Close')
        self.closeAction.setShortcut('Ctrl+W')
        self.closeAction.setObjectName("closeAction")

        # Edit Menu
        self.editMenu = self.menuBar.addMenu('&Edit')
        self.copyAction = self.editMenu.addAction('&Copy')
        self.copyAction.setShortcut('Ctrl+C')
        self.pasteAction = self.editMenu.addAction('&Paste')
        self.pasteAction.setShortcut('Ctrl+V')
        self.pasteConnectedAction = self.editMenu.addAction('Paste Connected')
        self.pasteConnectedAction.setShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.SHIFT + QtCore.Qt.Key_V))
        self.editMenu.addSeparator()
        self.pasteMirroredAction = self.editMenu.addAction('Paste Mirrored')
        self.pasteMirroredConnectedAction = self.editMenu.addAction('Paste Mirrored Connected')
        self.editMenu.addSeparator()
        self.editAddBackdropAction = self.editMenu.addAction('Add &Backdrop')
        self.editMenu.addSeparator()
        self.editRigNameAction = self.editMenu.addAction('&Rig Name')
        self.editRigNameAction.setObjectName("editRigNameAction")
        self.editMenu.addSeparator()
        self.editPreferencesAction = self.editMenu.addAction('&Preferences...')
        self.editPreferencesAction.setObjectName("editPreferencesAction")

        # Build Menu
        self.buildMenu = self.menuBar.addMenu('&Build')
        self.buildGuideAction = self.buildMenu.addAction('Build &Guide')
        self.buildGuideAction.setShortcut('Ctrl+G')
        self.buildGuideAction.setObjectName("buildGuideAction")

        self.buildRigAction = self.buildMenu.addAction('Build &Rig')
        self.buildRigAction.setShortcut('Ctrl+B')
        self.buildRigAction.setObjectName("buildRigAction")

        # Tools Menu
        self.toolsMenu = self.menuBar.addMenu('&Tools')
        self.reloadComponentsAction = self.toolsMenu.addAction('Reload Component Modules')

        # View Menu
        self.viewMenu = self.menuBar.addMenu('&View')
        self.compLibAction = self.viewMenu.addAction('Component &Library')
        self.compLibAction.setShortcut('Ctrl+Tab')
        self.snapToGridAction = self.viewMenu.addAction('&Snap To Grid')
        self.snapToGridAction.setCheckable(True)

        # Help Menu
        self.helpMenu = self.menuBar.addMenu('&Help')
        self.onlineHelpAction = self.helpMenu.addAction('Online &Help')
        self.onlineHelpAction.setShortcut('Ctrl+H')

        # Logo
        logoWidget = QtGui.QLabel()
        logoWidget.setObjectName('logoWidget')
        logoWidget.setMinimumHeight(20)
        logoWidget.setMinimumWidth(110)

        logoPixmap = QtGui.QPixmap(':/images/KrakenUI_Logo.png')
        logoWidget.setPixmap(logoPixmap)

        # Config Widget
        self.configsParent = QtGui.QFrame(self)
        self.configsParent.setObjectName('configParent')
        self.configsParent.setFrameStyle(QtGui.QFrame.NoFrame)
        self.configsParent.setMinimumWidth(160)

        self.configsLayout = QtGui.QVBoxLayout()
        self.configsLayout.setContentsMargins(0, 0, 0, 0)
        self.configsLayout.setSpacing(0)

        self.configsWidget = QtGui.QComboBox()
        self.configsWidget.setAutoFillBackground(True)
        self.configsWidget.setObjectName('configWidget')
        self.configsWidget.setMinimumWidth(160)
        self.configsWidget.addItem('Default Config')

        self.configsLayout.addWidget(self.configsWidget)
        self.configsParent.setLayout(self.configsLayout)

        configs = KrakenSystem.getInstance().getConfigClassNames()
        for config in configs:
            self.configsWidget.addItem(config.split('.')[-1])

        self.rigNameLabel = RigNameLabel('Rig Name:')

        # Add Widgets
        self.menuLayout.addWidget(logoWidget, 0)
        self.menuLayout.addWidget(self.menuBar, 3)
        self.menuLayout.addWidget(self.configsParent, 0)
        self.menuLayout.addWidget(self.rigNameLabel, 0)

        self.setLayout(self.menuLayout)
Exemplo n.º 26
0
    def pasteSettings(self,
                      pos,
                      mirrored=False,
                      createConnectionsToExistingNodes=True):

        clipboardData = self.__class__._clipboardData

        krakenSystem = KrakenSystem.getInstance()
        delta = pos - clipboardData['copyPos']
        self.clearSelection()
        pastedComponents = {}
        nameMapping = {}

        for componentData in clipboardData['components']:
            componentClass = krakenSystem.getComponentClass(
                componentData['class'])
            component = componentClass(parent=self.__rig)
            decoratedName = componentData[
                'name'] + component.getNameDecoration()
            nameMapping[decoratedName] = decoratedName
            if mirrored:
                config = Config.getInstance()
                mirrorMap = config.getNameTemplate()['mirrorMap']
                component.setLocation(mirrorMap[componentData['location']])
                nameMapping[decoratedName] = componentData[
                    'name'] + component.getNameDecoration()
                component.pasteData(componentData, setLocation=False)
            else:
                component.pasteData(componentData, setLocation=True)
            graphPos = component.getGraphPos()
            component.setGraphPos(
                Vec2(graphPos.x + delta.x(), graphPos.y + delta.y()))
            node = KNode(self, component)
            self.addNode(node)
            self.selectNode(node, False)

            # save a dict of the nodes using the orignal names
            pastedComponents[nameMapping[decoratedName]] = component

        for connectionData in clipboardData['connections']:
            sourceComponentDecoratedName, outputName = connectionData[
                'source'].split('.')
            targetComponentDecoratedName, inputName = connectionData[
                'target'].split('.')

            sourceComponent = None

            # The connection is either between nodes that were pasted, or from pasted nodes
            # to unpasted nodes. We first check that the source component is in the pasted group
            # else use the node in the graph.
            if sourceComponentDecoratedName in nameMapping:
                sourceComponent = pastedComponents[
                    nameMapping[sourceComponentDecoratedName]]
            else:
                if not createConnectionsToExistingNodes:
                    continue

                # When we support copying/pasting between rigs, then we may not find the source
                # node in the target rig.
                if not self.hasNode(sourceComponentDecoratedName):
                    continue
                node = self.getNode(sourceComponentDecoratedName)
                sourceComponent = node.getComponent()

            targetComponentDecoratedName = nameMapping[
                targetComponentDecoratedName]
            targetComponent = pastedComponents[targetComponentDecoratedName]

            outputPort = sourceComponent.getOutputByName(outputName)
            inputPort = targetComponent.getInputByName(inputName)

            inputPort.setConnection(outputPort)
            self.connectPorts(srcNode=sourceComponent.getDecoratedName(),
                              outputName=outputPort.getName(),
                              tgtNode=targetComponent.getDecoratedName(),
                              inputName=inputPort.getName())
Exemplo n.º 27
0
    def pasteSettings(self, pos, mirrored=False, createConnectionsToExistingNodes=True):

        clipboardData = self.__class__._clipboardData

        krakenSystem = KrakenSystem.getInstance()
        delta = pos - clipboardData['copyPos']
        self.clearSelection()
        pastedComponents = {}
        nameMapping = {}

        for componentData in clipboardData['components']:
            componentClass = krakenSystem.getComponentClass(componentData['class'])
            component = componentClass(parent=self.__rig)
            decoratedName = componentData['name'] + component.getNameDecoration()
            nameMapping[decoratedName] = decoratedName
            if mirrored:
                config = Config.getInstance()
                mirrorMap = config.getNameTemplate()['mirrorMap']
                component.setLocation(mirrorMap[componentData['location']])
                nameMapping[decoratedName] = componentData['name'] + component.getNameDecoration()
                component.pasteData(componentData, setLocation=False)
            else:
                component.pasteData(componentData, setLocation=True)
            graphPos = component.getGraphPos()
            component.setGraphPos(Vec2(graphPos.x + delta.x(), graphPos.y + delta.y()))
            node = KNode(self, component)
            self.addNode(node)
            self.selectNode(node, False)

            # save a dict of the nodes using the orignal names
            pastedComponents[nameMapping[decoratedName]] = component


        for connectionData in clipboardData['connections']:
            sourceComponentDecoratedName, outputName = connectionData['source'].split('.')
            targetComponentDecoratedName, inputName = connectionData['target'].split('.')

            sourceComponent = None

            # The connection is either between nodes that were pasted, or from pasted nodes
            # to unpasted nodes. We first check that the source component is in the pasted group
            # else use the node in the graph.
            if sourceComponentDecoratedName in nameMapping:
                sourceComponent = pastedComponents[nameMapping[sourceComponentDecoratedName]]
            else:
                if not createConnectionsToExistingNodes:
                    continue

                # When we support copying/pasting between rigs, then we may not find the source
                # node in the target rig.
                if not self.hasNode(sourceComponentDecoratedName):
                    continue
                node = self.getNode(sourceComponentDecoratedName)
                sourceComponent = node.getComponent()

            targetComponentDecoratedName = nameMapping[targetComponentDecoratedName]
            targetComponent = pastedComponents[targetComponentDecoratedName]

            outputPort = sourceComponent.getOutputByName(outputName)
            inputPort = targetComponent.getInputByName(inputName)

            inputPort.setConnection(outputPort)
            self.connectPorts(
                srcNode=sourceComponent.getDecoratedName(), outputName=outputPort.getName(),
                tgtNode=targetComponent.getDecoratedName(), inputName=inputPort.getName()
            )
Exemplo n.º 28
0
    def createLayout(self):

        self.menuLayout = QtGui.QHBoxLayout()
        self.menuLayout.setContentsMargins(0, 0, 0, 0)
        self.menuLayout.setSpacing(0)

        # Menu
        self.menuBar = QtGui.QMenuBar()

        # File Menu
        self.fileMenu = self.menuBar.addMenu('&File')
        self.newAction = self.fileMenu.addAction('&New')
        self.newAction.setShortcut('Ctrl+N')
        self.newAction.setObjectName("newAction")

        self.openAction = self.fileMenu.addAction('&Open...')
        self.openAction.setShortcut('Ctrl+O')
        self.openAction.setObjectName("openAction")

        self.saveAction = self.fileMenu.addAction('&Save')
        self.saveAction.setShortcut('Ctrl+S')
        self.saveAction.setObjectName("saveAction")

        self.saveAsAction = self.fileMenu.addAction('&Save As...')
        self.saveAsAction.setShortcut('Ctrl+Shift+S')
        self.saveAsAction.setObjectName("saveAsAction")

        self.fileMenu.addSeparator()
        self.recentFilesMenu = self.fileMenu.addMenu('&Recent Files')

        self.fileMenu.addSeparator()

        self.closeAction = self.fileMenu.addAction('&Close')
        self.closeAction.setShortcut('Ctrl+W')
        self.closeAction.setObjectName("closeAction")

        # Edit Menu
        self.editMenu = self.menuBar.addMenu('&Edit')
        self.copyAction = self.editMenu.addAction('&Copy')
        self.copyAction.setShortcut('Ctrl+C')
        self.pasteAction = self.editMenu.addAction('&Paste')
        self.pasteAction.setShortcut('Ctrl+V')
        self.pasteConnectedAction = self.editMenu.addAction('Paste Connected')
        self.pasteConnectedAction.setShortcut(
            QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.SHIFT +
                               QtCore.Qt.Key_V))
        self.editMenu.addSeparator()
        self.pasteMirroredAction = self.editMenu.addAction('Paste Mirrored')
        self.pasteMirroredConnectedAction = self.editMenu.addAction(
            'Paste Mirrored Connected')
        self.editMenu.addSeparator()
        self.editAddBackdropAction = self.editMenu.addAction('Add &Backdrop')
        self.editMenu.addSeparator()
        self.editRigNameAction = self.editMenu.addAction('&Rig Name')
        self.editRigNameAction.setObjectName("editRigNameAction")
        self.editMenu.addSeparator()
        self.editPreferencesAction = self.editMenu.addAction('&Preferences...')
        self.editPreferencesAction.setObjectName("editPreferencesAction")

        # Build Menu
        self.buildMenu = self.menuBar.addMenu('&Build')
        self.buildGuideAction = self.buildMenu.addAction('Build &Guide')
        self.buildGuideAction.setShortcut('Ctrl+G')
        self.buildGuideAction.setObjectName("buildGuideAction")

        self.buildRigAction = self.buildMenu.addAction('Build &Rig')
        self.buildRigAction.setShortcut('Ctrl+B')
        self.buildRigAction.setObjectName("buildRigAction")

        # Tools Menu
        self.toolsMenu = self.menuBar.addMenu('&Tools')
        self.reloadComponentsAction = self.toolsMenu.addAction(
            'Reload Component Modules')

        # View Menu
        self.viewMenu = self.menuBar.addMenu('&View')
        self.compLibAction = self.viewMenu.addAction('Component &Library')
        self.compLibAction.setShortcut('Ctrl+Tab')
        self.snapToGridAction = self.viewMenu.addAction('&Snap To Grid')
        self.snapToGridAction.setCheckable(True)

        # Help Menu
        self.helpMenu = self.menuBar.addMenu('&Help')
        self.onlineHelpAction = self.helpMenu.addAction('Online &Help')
        self.onlineHelpAction.setShortcut('Ctrl+H')

        # Logo
        logoWidget = QtGui.QLabel()
        logoWidget.setObjectName('logoWidget')
        logoWidget.setMinimumHeight(20)
        logoWidget.setMinimumWidth(110)

        logoPixmap = QtGui.QPixmap(':/images/KrakenUI_Logo.png')
        logoWidget.setPixmap(logoPixmap)

        # Config Widget
        self.configsParent = QtGui.QFrame(self)
        self.configsParent.setObjectName('configParent')
        self.configsParent.setFrameStyle(QtGui.QFrame.NoFrame)
        self.configsParent.setMinimumWidth(160)

        self.configsLayout = QtGui.QVBoxLayout()
        self.configsLayout.setContentsMargins(0, 0, 0, 0)
        self.configsLayout.setSpacing(0)

        self.configsWidget = QtGui.QComboBox()
        self.configsWidget.setAutoFillBackground(True)
        self.configsWidget.setObjectName('configWidget')
        self.configsWidget.setMinimumWidth(160)
        self.configsWidget.addItem('Default Config')

        self.configsLayout.addWidget(self.configsWidget)
        self.configsParent.setLayout(self.configsLayout)

        configs = KrakenSystem.getInstance().getConfigClassNames()
        for config in configs:
            self.configsWidget.addItem(config.split('.')[-1])

        self.rigNameLabel = RigNameLabel('Rig Name:')

        # Add Widgets
        self.menuLayout.addWidget(logoWidget, 0)
        self.menuLayout.addWidget(self.menuBar, 3)
        self.menuLayout.addWidget(self.configsParent, 0)
        self.menuLayout.addWidget(self.rigNameLabel, 0)

        self.setLayout(self.menuLayout)
Exemplo n.º 29
0
    def createLayout(self):

        self.menuLayout = QtGui.QHBoxLayout()
        self.menuLayout.setContentsMargins(0, 0, 0, 0)
        self.menuLayout.setSpacing(0)

        # Menu
        self.menuBar = QtGui.QMenuBar()

        # File Menu
        self.fileMenu = self.menuBar.addMenu("&File")
        self.newAction = self.fileMenu.addAction("&New")
        self.newAction.setShortcut("Ctrl+N")
        self.newAction.setObjectName("newAction")

        self.saveAction = self.fileMenu.addAction("&Save")
        self.saveAction.setShortcut("Ctrl+S")
        self.saveAction.setObjectName("saveAction")

        self.loadAction = self.fileMenu.addAction("&Load")
        self.loadAction.setShortcut("Ctrl+L")
        self.loadAction.setObjectName("loadAction")

        self.fileMenu.addSeparator()

        self.closeAction = self.fileMenu.addAction("&Close")
        self.closeAction.setShortcut("Ctrl+W")
        self.closeAction.setObjectName("closeAction")

        # Edit Menu
        self.editMenu = self.menuBar.addMenu("&Edit")
        self.copyAction = self.editMenu.addAction("&Copy")
        self.copyAction.setShortcut("Ctrl+C")
        self.pasteAction = self.editMenu.addAction("&Paste")
        self.pasteAction.setShortcut("Ctrl+V")
        self.pasteConnectedAction = self.editMenu.addAction("Paste Connected")
        self.pasteConnectedAction.setShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.SHIFT + QtCore.Qt.Key_V))
        self.editMenu.addSeparator()
        self.pasteMirroredAction = self.editMenu.addAction("Paste Mirrored")
        self.pasteMirroredConnectedAction = self.editMenu.addAction("Paste Mirrored Connected")
        self.editMenu.addSeparator()
        self.editRigNameAction = self.editMenu.addAction("&Rig Name")
        self.editRigNameAction.setObjectName("editRigNameAction")

        # Build Menu
        self.buildMenu = self.menuBar.addMenu("&Build")
        self.buildGuideAction = self.buildMenu.addAction("Build &Guide")
        self.buildGuideAction.setShortcut("Ctrl+G")
        self.buildGuideAction.setObjectName("buildGuideAction")

        self.buildRigAction = self.buildMenu.addAction("Build &Rig")
        self.buildRigAction.setShortcut("Ctrl+B")
        self.buildRigAction.setObjectName("buildRigAction")

        # Panel Menu
        self.panelsMenu = self.menuBar.addMenu("&Panels")
        self.compLibAction = self.panelsMenu.addAction("Component &Library")
        self.compLibAction.setShortcut("Ctrl+Tab")

        # Help Menu
        self.helpMenu = self.menuBar.addMenu("&Help")
        self.onlineHelpAction = self.helpMenu.addAction("Online &Help")
        self.onlineHelpAction.setShortcut("Ctrl+H")

        # Logo
        logoWidget = QtGui.QLabel()
        logoWidget.setObjectName("logoWidget")
        logoWidget.setMinimumHeight(20)
        logoWidget.setMinimumWidth(110)

        logoPixmap = QtGui.QPixmap(
            os.path.join(os.path.dirname(os.path.realpath(__file__)), "images", "KrakenUI_Logo.png")
        )
        logoWidget.setPixmap(logoPixmap)

        # Config Widget
        self.configsParent = QtGui.QFrame(self)
        self.configsParent.setObjectName("configParent")
        self.configsParent.setFrameStyle(QtGui.QFrame.NoFrame)
        self.configsParent.setMinimumWidth(160)

        self.configsLayout = QtGui.QVBoxLayout()
        self.configsLayout.setContentsMargins(0, 0, 0, 0)
        self.configsLayout.setSpacing(0)

        self.configsWidget = QtGui.QComboBox()
        self.configsWidget.setAutoFillBackground(True)
        self.configsWidget.setObjectName("configWidget")
        self.configsWidget.setMinimumWidth(160)
        self.configsWidget.addItem("Default Config")

        self.configsLayout.addWidget(self.configsWidget)
        self.configsParent.setLayout(self.configsLayout)

        configs = KrakenSystem.getInstance().getConfigClassNames()
        for config in configs:
            self.configsWidget.addItem(config.split(".")[-1])

        self.rigNameLabel = RigNameLabel("Rig Name:")

        # Add Widgets
        self.menuLayout.addWidget(logoWidget, 0)
        self.menuLayout.addWidget(self.menuBar, 3)
        self.menuLayout.addWidget(self.configsParent, 0)
        self.menuLayout.addWidget(self.rigNameLabel, 0)

        self.setLayout(self.menuLayout)
Exemplo n.º 30
0
    def showEvent(self, event):

        krakenSystem = KrakenSystem.getInstance()
        krakenSystem.loadCoreClient()
        krakenSystem.loadExtension('Kraken')
Exemplo n.º 31
0
    def showEvent(self, event):

        krakenSystem = KrakenSystem.getInstance()
        krakenSystem.loadCoreClient()
        krakenSystem.loadExtension('Kraken')
Exemplo n.º 32
0
        # Update number of deformers and outputs
        self.setNumDeformers(numDeformers)

        # Updating constraint to use the updated last output.
        self.tailEndOutputConstraint.setConstrainer(self.tailOutputs[-1], index=0)

        # ============
        # Set IO Xfos
        # ============

        # ====================
        # Evaluate Splice Ops
        # ====================
        # evaluate the spine op so that all the output transforms are updated.
        self.bezierTailKLOp.evaluate()

        # evaluate the constraint op so that all the joint transforms are updated.
        self.deformersToOutputsKLOp.evaluate()

        # evaluate the constraints to ensure the outputs are now in the correct location.
        self.tailBaseHandleInputConstraint.evaluate()
        self.tailBaseOutputConstraint.evaluate()
        self.tailEndOutputConstraint.evaluate()



from kraken.core.kraken_system import KrakenSystem
ks = KrakenSystem.getInstance()
ks.registerComponent(FabriceTailGuide)
ks.registerComponent(FabriceTailRig)
Exemplo n.º 33
0
    def createLayout(self):

        self.menuLayout = QtGui.QHBoxLayout()
        self.menuLayout.setContentsMargins(0, 0, 0, 0)
        self.menuLayout.setSpacing(0)

        # Menu
        self.menuBar = QtGui.QMenuBar()

        # File Menu
        self.fileMenu = self.menuBar.addMenu('&File')
        self.newAction = self.fileMenu.addAction('&New')
        self.newAction.setShortcut('Ctrl+N')
        self.newAction.setObjectName("newAction")

        self.saveAction = self.fileMenu.addAction('&Save')
        self.saveAction.setShortcut('Ctrl+S')
        self.saveAction.setObjectName("saveAction")

        self.loadAction = self.fileMenu.addAction('&Load')
        self.loadAction.setShortcut('Ctrl+L')
        self.loadAction.setObjectName("loadAction")

        self.fileMenu.addSeparator()

        self.closeAction = self.fileMenu.addAction('&Close')
        self.closeAction.setShortcut('Ctrl+W')
        self.closeAction.setObjectName("closeAction")

        # Edit Menu
        self.editMenu = self.menuBar.addMenu('&Edit')
        self.copyAction = self.editMenu.addAction('&Copy')
        self.copyAction.setShortcut('Ctrl+C')
        self.pasteAction = self.editMenu.addAction('&Paste')
        self.pasteAction.setShortcut('Ctrl+V')
        self.pasteConnectedAction = self.editMenu.addAction('Paste Connected')
        self.pasteConnectedAction.setShortcut(
            QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.SHIFT +
                               QtCore.Qt.Key_V))
        self.editMenu.addSeparator()
        self.pasteMirroredAction = self.editMenu.addAction('Paste Mirrored')
        self.pasteMirroredConnectedAction = self.editMenu.addAction(
            'Paste Mirrored Connected')
        self.editMenu.addSeparator()
        self.editRigNameAction = self.editMenu.addAction('&Rig Name')
        self.editRigNameAction.setObjectName("editRigNameAction")

        # Build Menu
        self.buildMenu = self.menuBar.addMenu('&Build')
        self.buildGuideAction = self.buildMenu.addAction('Build &Guide')
        self.buildGuideAction.setShortcut('Ctrl+G')
        self.buildGuideAction.setObjectName("buildGuideAction")

        self.buildRigAction = self.buildMenu.addAction('Build &Rig')
        self.buildRigAction.setShortcut('Ctrl+B')
        self.buildRigAction.setObjectName("buildRigAction")

        # Panel Menu
        self.panelsMenu = self.menuBar.addMenu('&Panels')
        self.compLibAction = self.panelsMenu.addAction('Component &Library')
        self.compLibAction.setShortcut('Ctrl+Tab')

        # Help Menu
        self.helpMenu = self.menuBar.addMenu('&Help')
        self.onlineHelpAction = self.helpMenu.addAction('Online &Help')
        self.onlineHelpAction.setShortcut('Ctrl+H')

        # Logo
        logoWidget = QtGui.QLabel()
        logoWidget.setObjectName('logoWidget')
        logoWidget.setMinimumHeight(20)
        logoWidget.setMinimumWidth(110)

        logoPixmap = QtGui.QPixmap(
            os.path.join(os.path.dirname(os.path.realpath(__file__)), 'images',
                         'KrakenUI_Logo.png'))
        logoWidget.setPixmap(logoPixmap)

        # Config Widget
        self.configsParent = QtGui.QFrame(self)
        self.configsParent.setObjectName('configParent')
        self.configsParent.setFrameStyle(QtGui.QFrame.NoFrame)
        self.configsParent.setMinimumWidth(160)

        self.configsLayout = QtGui.QVBoxLayout()
        self.configsLayout.setContentsMargins(0, 0, 0, 0)
        self.configsLayout.setSpacing(0)

        self.configsWidget = QtGui.QComboBox()
        self.configsWidget.setAutoFillBackground(True)
        self.configsWidget.setObjectName('configWidget')
        self.configsWidget.setMinimumWidth(160)
        self.configsWidget.addItem('Default Config')

        self.configsLayout.addWidget(self.configsWidget)
        self.configsParent.setLayout(self.configsLayout)

        configs = KrakenSystem.getInstance().getConfigClassNames()
        for config in configs:
            self.configsWidget.addItem(config.split('.')[-1])

        self.rigNameLabel = RigNameLabel('Rig Name:')

        # Add Widgets
        self.menuLayout.addWidget(logoWidget, 0)
        self.menuLayout.addWidget(self.menuBar, 3)
        self.menuLayout.addWidget(self.configsParent, 0)
        self.menuLayout.addWidget(self.rigNameLabel, 0)

        self.setLayout(self.menuLayout)