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)
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()
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)
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()
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()
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)
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()
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
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")
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)
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)
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() )
def showEvent(self, event): krakenSystem = KrakenSystem.getInstance() krakenSystem.loadCoreClient() krakenSystem.loadExtension('Kraken')
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)
def __init__(self): super(CustomConfig, self).__init__() # ====================== # Name Template Methods # ====================== def initNameTemplate(self): """Initializes the name template. Returns: dict: name template. """ nameTemplate = super(CustomConfig, self).initNameTemplate() nameTemplate["formats"] = { "Container": ["name"], "Layer": ["container", "sep", "name"], "ComponentGroup": ["location", "sep", "name", "sep", "type"], "default": ["location", "sep", "component", "sep", "name", "sep", "type"], } return nameTemplate from kraken.core.kraken_system import KrakenSystem ks = KrakenSystem.getInstance() ks.registerConfig(CustomConfig)
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)
def createLayout(self): self.menuLayout = QtWidgets.QHBoxLayout() self.menuLayout.setContentsMargins(0, 0, 0, 0) self.menuLayout.setSpacing(0) # Menu self.menuBar = QtWidgets.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 = QtWidgets.QMenu(title='&Recent Files', parent=self.fileMenu) self.fileMenu.addMenu(self.recentFilesMenu) 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') self.reloadComponentsAction.setShortcut('Ctrl+Shift+R') # 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.krakenWebSiteAction = self.helpMenu.addAction('Kraken Web Site') self.krakenDocumentationAction = self.helpMenu.addAction( 'Kraken Documentation') self.fabricForumsAction = self.helpMenu.addAction('Fabric Forums') self.helpMenu.addSeparator() self.aboutKrakenAction = self.helpMenu.addAction('About Kraken') # Logo logoWidget = QtWidgets.QLabel() logoWidget.setObjectName('logoWidget') logoWidget.setMinimumHeight(20) logoWidget.setMinimumWidth(110) logoPixmap = QtGui.QPixmap(':/images/KrakenUI_Logo.png') logoWidget.setPixmap(logoPixmap) # Config Widget self.configsParent = QtWidgets.QFrame(self) self.configsParent.setObjectName('configParent') self.configsParent.setFrameStyle(QtWidgets.QFrame.NoFrame) self.configsParent.setMinimumWidth(160) self.configsLayout = QtWidgets.QVBoxLayout() self.configsLayout.setContentsMargins(0, 0, 0, 0) self.configsLayout.setSpacing(0) self.configsWidget = QtWidgets.QComboBox() self.configsWidget.setAutoFillBackground(True) self.configsWidget.setObjectName('configWidget') self.configsWidget.setMinimumWidth(160) self.configsWidget.addItem('Default Config', userData='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], userData=config) 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)
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())
# 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)
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)