Exemplo n.º 1
0
    def __init__(self, parent=None):

        # constructors of base classes
        super(KGraphViewWidget, self).__init__(parent)

        self._builder = None
        self._guideBuilder = None
        self.guideRig = None

        graphView = KGraphView(parent=self)
        graphView.nodeAdded.connect(self.__onNodeAdded)
        graphView.nodeRemoved.connect(self.__onNodeRemoved)
        graphView.beginConnectionManipulation.connect(
            self.__onBeginConnectionManipulation)
        graphView.endConnectionManipulation.connect(
            self.__onEndConnectionManipulationSignal)
        graphView.connectionAdded.connect(self.__onConnectionAdded)
        graphView.connectionRemoved.connect(self.__onConnectionRemoved)

        graphView.selectionChanged.connect(self.__onSelectionChanged)
        graphView.endSelectionMoved.connect(self.__onSelectionMoved)

        graphView.beginDeleteSelection.connect(self.__onBeginDeleteSelection)
        graphView.endDeleteSelection.connect(self.__onEndDeleteSelection)

        self.setGraphView(graphView)

        # =========================================
        # Setup hotkeys for the following actions.
        # =========================================

        undoShortcut = QtWidgets.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_Z), self)
        undoShortcut.activated.connect(self.undo)

        redoShortcut = QtWidgets.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_Y), self)
        redoShortcut.activated.connect(self.redo)

        openContextualNodeListShortcut = QtWidgets.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.Key_Tab), self)
        openContextualNodeListShortcut.activated.connect(
            self.openContextualNodeList)

        self.newRigPreset()
Exemplo n.º 2
0
    def setGraphView(self, graphView):

        self.graphView = graphView

        # Setup Layout
        layout = QtWidgets.QVBoxLayout(self)
        layout.addWidget(self.graphView)
        self.setLayout(layout)

        #########################
        ## Setup hotkeys for the following actions.
        deleteShortcut = QtWidgets.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.Key_Delete), self)
        deleteShortcut.activated.connect(self.graphView.deleteSelectedNodes)

        frameShortcut = QtWidgets.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.Key_F), self)
        frameShortcut.activated.connect(self.graphView.frameSelectedNodes)

        frameShortcut = QtWidgets.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.Key_A), self)
        frameShortcut.activated.connect(self.graphView.frameAllNodes)
Exemplo n.º 3
0
    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)