def __init__( self ): super( UICharacterTools, self ).__init__() layout = QtGui.QVBoxLayout( self ) # PRESETS presetsLabel = QTWidgets.basicLabel( 'Character Presets', 'bold', 14, 'white', '2B2B30', inIndent=10 ) presetsLabel.setMinimumHeight( 30 ) presetsLabel.setAlignment( QtCore.Qt.AlignCenter ) self.scrollLayout = QtGui.QVBoxLayout() self.scrollLayout.setAlignment( QtCore.Qt.AlignTop ) self.scrollLayout.setContentsMargins( 8,8,8,8 ) self.scrollLayout.setSpacing( 4 ) scrollArea = QTWidgets.scrollArea( self.scrollLayout ) self.updateCards() # TOOLS #--Label toolsLabel = QTWidgets.basicLabel( 'Tools', 'bold', 14, 'white', '2B2B30', inIndent=10 ) toolsLabel.setMinimumHeight( 30 ) toolsLabel.setAlignment( QtCore.Qt.AlignCenter ) #--Combo menu comboRow = QtGui.QHBoxLayout() comboRow.setAlignment( QtCore.Qt.AlignLeft ) self.characterNameList = [] self.characterDict = {} for char in NodeUtility.getCharactersInScene(): charName = cmds.getAttr( '{0}.characterName'.format( char ) ) self.characterNameList.append( charName ) self.characterDict[charName] = char self.characterCombo = QtGui.QComboBox() self.updateCharacterCombo() self.characterCombo.setFixedWidth( 100 ) self.characterCombo.activated.connect( self.setActiveCharacter ) comboRefreshBtn = QTWidgets.imageTextButton( None, ':/riggingUI/icons/icon_refresh20.png', [16,16] ) comboRefreshBtn.setMaximumWidth( 20 ) comboRefreshBtn.setMaximumHeight( 20 ) comboRefreshBtn.clicked.connect( self.updateCharacterCombo ) comboRow.addWidget( self.characterCombo ) comboRow.addWidget( comboRefreshBtn ) #--Buttons modulePrioritiesBtn = QTWidgets.imageTextButton( 'Module Priorities', ':/riggingUI/icons/icon_match_translation.png', [16,16] ) modulePrioritiesBtn.clicked.connect( lambda:self.characterPriorityPromptTrigger() ) saveCharacterBtn = QTWidgets.imageTextButton( 'Save Character', ':/riggingUI/icons/icon_match_translation.png', [16,16] ) saveCharacterBtn.clicked.connect( lambda:self.saveCharacter() ) buildCharacterBtn = QTWidgets.imageTextButton( 'Build Character', ':/riggingUI/icons/icon_match_translation.png', [16,16] ) buildCharacterBtn.clicked.connect( lambda:self.buildCharacter() ) editModulesBtn = QTWidgets.imageTextButton( 'Edit Character Modules', ':/riggingUI/icons/icon_match_translation.png', [16,16] ) editModulesBtn.clicked.connect( lambda:self.characterModulePromptTrigger() ) #--Button grid layout. toolsGrid = QtGui.QGridLayout() toolsGrid.setColumnMinimumWidth( 0, 100 ) toolsGrid.setColumnMinimumWidth( 1, 100 ) toolsGrid.setColumnMinimumWidth( 2, 100 ) toolsGrid.setSpacing( 2 ) toolsGrid.setContentsMargins( 0,0,0,0 ) toolsGrid.addWidget( modulePrioritiesBtn, 0, 0 ) toolsGrid.addWidget( saveCharacterBtn, 0, 1 ) toolsGrid.addWidget( buildCharacterBtn, 0, 2 ) toolsGrid.addWidget( editModulesBtn, 1, 0 ) # SETUP LAYOUT layout.addWidget( presetsLabel ) layout.addWidget( scrollArea ) layout.addWidget( toolsLabel ) layout.addLayout( comboRow ) layout.addLayout( toolsGrid )
def __init__( self ): super( UILatticeTools, self ).__init__() layout = QtGui.QVBoxLayout( self ) # LATTICES SECTIONS latticesLabel = QTWidgets.basicLabel( 'Lattices', 'bold', 14, 'white', '2B2B30', inIndent=10 ) latticesLabel.setMinimumHeight( 30 ) latticesLabel.setAlignment( QtCore.Qt.AlignCenter ) # Grid that holds the toggle buttons for lattice types in the first column, and the # scroll layout for the list of lattices in the second column. latticesGrid = QtGui.QGridLayout() latticesGrid.setContentsMargins( 0, 0, 0, 0 ) latticesGrid.setHorizontalSpacing( 0 ) latticesGrid.setAlignment( QtCore.Qt.AlignTop ) latticesGrid.setVerticalSpacing( 0 ) # Toggle button layout. self.togLayout = QtGui.QVBoxLayout() self.togLayout.setAlignment( QtCore.Qt.AlignTop ) iconSize = [26,26] rootTog = QTWidgets.toggleButton( 'roots', ':/riggingUI/icons/icon_root.png', iconSize ) spineTog = QTWidgets.toggleButton( 'spines', ':/riggingUI/icons/icon_spine.png', iconSize ) armTog = QTWidgets.toggleButton( 'arms', ':/riggingUI/icons/icon_arm.png', iconSize ) legTog = QTWidgets.toggleButton( 'legs', ':/riggingUI/icons/icon_leg.png', iconSize ) handTog = QTWidgets.toggleButton( 'hands', ':/riggingUI/icons/icon_hand.png', iconSize ) footTog = QTWidgets.toggleButton( 'feet', ':/riggingUI/icons/icon_foot.png', iconSize ) headTog = QTWidgets.toggleButton( 'heads', ':/riggingUI/icons/icon_head.png', iconSize ) rootTog.toggled.connect( lambda toggleState:self.updateCards() ) spineTog.toggled.connect( lambda toggleState:self.updateCards() ) armTog.toggled.connect( lambda toggleState:self.updateCards() ) legTog.toggled.connect( lambda toggleState:self.updateCards() ) handTog.toggled.connect( lambda toggleState:self.updateCards() ) footTog.toggled.connect( lambda toggleState:self.updateCards() ) headTog.toggled.connect( lambda toggleState:self.updateCards() ) self.togLayout.addWidget( rootTog ) self.togLayout.addWidget( spineTog ) self.togLayout.addWidget( armTog ) self.togLayout.addWidget( legTog ) self.togLayout.addWidget( handTog ) self.togLayout.addWidget( footTog ) self.togLayout.addWidget( headTog ) self.togLayout.addStretch( 1 ) # Scroll area for lattice list. self.scrollLayout = QtGui.QVBoxLayout() self.scrollLayout.setAlignment( QtCore.Qt.AlignTop ) self.scrollLayout.setContentsMargins( 8,8,8,8 ) self.scrollLayout.setSpacing( 4 ) scrollArea = QTWidgets.scrollArea( self.scrollLayout ) # Put the toggle buttons and lattice scroll list in the main grid layout. latticesGrid.addLayout( self.togLayout, 0, 0 ) latticesGrid.addWidget( scrollArea, 0, 1 ) # TOOLS SECTION toolsLabel = QTWidgets.basicLabel( 'Lattice Tools', 'bold', 14, 'white', '2B2B30', inIndent=10 ) toolsLabel.setMinimumHeight( 30 ) toolsLabel.setAlignment( QtCore.Qt.AlignCenter ) latticeToolsGrid = QtGui.QGridLayout() latticeToolsGrid.setColumnMinimumWidth( 0, 100 ) latticeToolsGrid.setColumnMinimumWidth( 1, 100 ) latticeToolsGrid.setColumnMinimumWidth( 2, 100 ) latticeToolsGrid.setSpacing( 2 ) latticeToolsGrid.setContentsMargins( 0,0,0,0 ) # Buttons saveModeluBtn = QTWidgets.imageTextButton( 'Save Module', ':/riggingUI/icons/icon_match_translation.png', [16,16] ) saveModeluBtn.clicked.connect( lambda:self.saveModulePrompt() ) latticeToolsGrid.addWidget( saveModeluBtn, 0, 0 ) # Build the widget layout.addWidget( latticesLabel ) layout.addLayout( latticesGrid ) layout.addWidget( toolsLabel ) layout.addLayout( latticeToolsGrid )
def __init__( self ): super( UIBitsTools, self ).__init__() layout = QtGui.QVBoxLayout( self ) # Build bits controls # Presets moduleRootBtn = QTWidgets.imageButton( 'Create Module', ':/riggingUI/icons/preset_module.png', [32,32] ) moduleRootBtn.clicked.connect( lambda a=1:self.preset_buttons(a) ) characterRootBtn = QTWidgets.imageButton( 'Create Character', ':/riggingUI/icons/preset_character.png', [32,32] ) characterRootBtn.clicked.connect( lambda a=2:self.preset_buttons(a) ) # Primitive buttons. sphereBtn = QTWidgets.imageButton( 'Sphere', ':/riggingUI/icons/bit_sphere.png', [32,32] ) sphereBtn.clicked.connect( self.primitive_buttons ) boxBtn = QTWidgets.imageButton( 'Box', ':/riggingUI/icons/bit_box.png', [32,32] ) boxBtn.clicked.connect( self.primitive_buttons ) cylinderBtn = QTWidgets.imageButton( 'Cylinder', ':/riggingUI/icons/bit_cylinder.png', [32,32] ) cylinderBtn.clicked.connect( self.primitive_buttons ) coneBtn = QTWidgets.imageButton( 'Cone', ':/riggingUI/icons/bit_cone.png', [32,32] ) coneBtn.clicked.connect( self.primitive_buttons ) torusBtn = QTWidgets.imageButton( 'Torus', ':/riggingUI/icons/bit_torus.png', [32,32] ) torusBtn.clicked.connect( self.primitive_buttons ) # Bit tools. matchTranslationBtn = QTWidgets.imageTextButton( 'Match Translation', ':/riggingUI/icons/icon_match_translation.png', [16,16] ) matchTranslationBtn.clicked.connect( lambda a='tran':TransformUtility.matchTransforms( a ) ) matchRotationBtn = QTWidgets.imageTextButton( 'Match Rotation', ':/riggingUI/icons/icon_match_rotation.png', [16,16] ) matchRotationBtn.clicked.connect( lambda a='rot':TransformUtility.matchTransforms( a ) ) matchAllBtn = QTWidgets.imageTextButton( 'Match All', ':/riggingUI/icons/icon_match_all.png', [16,16] ) matchAllBtn.clicked.connect( lambda a='all':TransformUtility.matchTransforms( a ) ) copyBitSettingsBtn = QTWidgets.imageTextButton( 'Copy Bit Settings', ':/riggingUI/icons/bit_copy_settings.png', [16,16] ) copyBitSettingsBtn.clicked.connect( lambda:NodeUtility.copyBitSettings() ) addChildBtn = QTWidgets.imageTextButton( 'Add Child', ':/riggingUI/icons/bit_add_child.png', [16,16] ) addChildBtn.clicked.connect( lambda:NodeUtility.setBitChild() ) deleteChildBtn = QTWidgets.imageTextButton( 'Delete Child', ':/riggingUI/icons/bit_delete_child.png', [16,16] ) deleteChildBtn.clicked.connect( lambda:NodeUtility.deleteBitChild() ) # Build bits layout. # Presets. presetsHeader = QTWidgets.basicLabel( 'Bit Presets', 'bold', 14, 'white', '2B2B30' ) presetsHeader.setMinimumHeight( 30 ) presetsHeader.setAlignment( QtCore.Qt.AlignCenter ) presetsFrame = QTWidgets.basicFrame() presetsLayout = QtGui.QHBoxLayout() presetsLayout.addWidget( moduleRootBtn ) presetsLayout.addWidget( characterRootBtn ) presetsFrame.setLayout( presetsLayout ) # Primitive buttons bitPrimitivesHeader = QTWidgets.basicLabel( 'Bit Primitives', 'bold', 14, 'white', '2B2B30' ) bitPrimitivesHeader.setMinimumHeight( 30 ) bitPrimitivesHeader.setAlignment( QtCore.Qt.AlignCenter ) primitiveFrame = QTWidgets.basicFrame() primitiveLayout = QtGui.QHBoxLayout() primitiveLayout.addWidget( sphereBtn ) primitiveLayout.addWidget( boxBtn ) primitiveLayout.addWidget( cylinderBtn ) primitiveLayout.addWidget( coneBtn ) primitiveLayout.addWidget( torusBtn ) primitiveFrame.setLayout( primitiveLayout ) # Bit tools. bitToolsHeader = QTWidgets.basicLabel( 'Bit Tools', 'bold', 14, 'white', '2B2B30' ) bitToolsHeader.setMinimumHeight( 30 ) bitToolsHeader.setAlignment( QtCore.Qt.AlignCenter ) bitToolsGrid = QtGui.QGridLayout() bitToolsGrid.setColumnMinimumWidth( 0, 100 ) bitToolsGrid.setColumnMinimumWidth( 1, 100 ) bitToolsGrid.setColumnMinimumWidth( 2, 100 ) bitToolsGrid.setSpacing( 2 ) bitToolsGrid.setContentsMargins( 0,0,0,0 ) # widget, row, col bitToolsGrid.addWidget( matchTranslationBtn, 0, 0 ) bitToolsGrid.addWidget( matchRotationBtn, 0, 1 ) bitToolsGrid.addWidget( matchAllBtn, 0, 2 ) bitToolsGrid.addWidget( copyBitSettingsBtn, 1, 0 ) bitToolsGrid.addWidget( addChildBtn, 1, 1 ) bitToolsGrid.addWidget( deleteChildBtn, 1, 2 ) # Added the bits widgets to the sub-layout of the main window. layout.addWidget( presetsHeader ) layout.addWidget( presetsFrame ) layout.addWidget( bitPrimitivesHeader ) layout.addWidget( primitiveFrame ) layout.addWidget( bitToolsHeader ) layout.addLayout( bitToolsGrid )
def latticeCard( inLatticeType, inLattice, inLatticeDescription, parent=None ): nameLabelHeight = 14 cardHeight = 64 cardBackgroundColor = {'roots':'383232', 'spines':'383832', 'arms':'323834', 'legs':'323638', 'hands':'343238', 'feet':'383237', 'heads':'383232'} cardLabelColor = {'roots':'5d5353', 'spines':'5d5d53', 'arms':'535d56', 'legs':'53595d', 'hands':'57535d', 'feet':'5d535b', 'heads':'5d5353'} cardButtonColor = {'roots':'4b4141', 'spines':'4b4b43', 'arms':'434b45', 'legs':'42474a', 'hands':'45424a', 'feet':'4a4249', 'heads':'4a4242'} latticeName = QtGui.QLabel() latticeName.setIndent( 10 ) latticeName.setText( str.upper( str( inLattice ) ) ) latticeName.setAlignment( QtCore.Qt.AlignLeft ) latticeName.setMaximumHeight( nameLabelHeight ) latticeName.setStyleSheet( 'font:{0}; font-size:{1}px; color:{2}; background-color:#{3}'.format( 'bold', 10, 'white', cardLabelColor[ inLatticeType ] ) ) latticeDescription = QtGui.QLabel() latticeDescription.setMinimumHeight( 45 ) latticeDescription.setMaximumHeight( 45 ) latticeDescription.setWordWrap( True ) latticeDescription.setText( inLatticeDescription ) latticeButton = QTWidgets.imageTextButton( None, ':/riggingUI/icons/icon_plus32.png', [32,32] ) latticeButton.setMaximumSize( QtCore.QSize( 40, 40 ) ) latticeButton.setStyleSheet( 'background-color:#{0}'.format( cardButtonColor[ inLatticeType ]) ) latticeButton.clicked.connect( lambda a=inLatticeType, b=inLattice:XMLUtility.loadModule( a, b ) ) latticeGrid = QtGui.QGridLayout() latticeGrid.setAlignment( QtCore.Qt.AlignTop ) latticeGrid.setContentsMargins( 0, 0, 0, 0 ) latticeGrid.setHorizontalSpacing( 0 ) latticeGrid.addWidget( latticeDescription, 0, 0 ) latticeGrid.addWidget( latticeButton, 0, 1 ) latticeGrid.setColumnMinimumWidth( 1, 40 ) latticeRow = QtGui.QVBoxLayout() latticeRow.setSpacing( 0 ) latticeRow.setContentsMargins( 0,0,0,0 ) latticeRow.addWidget( latticeName ) latticeRow.addLayout( latticeGrid ) frame = QtGui.QFrame() frame.setFrameShadow( QtGui.QFrame.Sunken ) frame.setFrameShape( QtGui.QFrame.StyledPanel ) frame.setLineWidth( 2 ) frame.setStyleSheet( 'padding:1px; background-color:#{0}'.format( cardBackgroundColor[ inLatticeType ] ) ) frame.setMinimumHeight( cardHeight ) frame.setLayout( latticeRow ) return frame
def __init__( self ): super( UIComponentsTools, self ).__init__() layout = QtGui.QVBoxLayout( self ) # COMPONENTS MENU BAR menuFrame = QtGui.QFrame() menuFrame.setMinimumHeight( 20 ) # Meta menu. moduleMeta = QtGui.QAction( '&Module Meta', self) moduleMeta.triggered.connect( lambda a='ModuleRootComponent':Components.addComponentToObject( a ) ) characterMeta = QtGui.QAction( '&Character Meta', self) characterMeta.triggered.connect( lambda a='CharacterRootComponent':Components.addComponentToObject( a ) ) # Joints menu basicJoint = QtGui.QAction( '&Basic Joint', self) #basic_joint.setShortcut('Ctrl+Q') #basic_joint.setStatusTip('Exit application') basicJoint.triggered.connect( lambda a='BasicJointComponent':Components.addComponentToObject( a ) ) # Controls menu squareCurveControl = QtGui.QAction( '&Square', self) squareCurveControl.triggered.connect( lambda a='CurveControlComponent', b='square':Components.addComponentToObject( a, curveType=b ) ) triangleCurveControl = QtGui.QAction( '&Triangle', self) triangleCurveControl.triggered.connect( lambda a='CurveControlComponent', b='triangle':Components.addComponentToObject( a, curveType=b ) ) arrowCurveControl = QtGui.QAction( '&Arrow', self) arrowCurveControl.triggered.connect( lambda a='CurveControlComponent', b='arrow':Components.addComponentToObject( a, curveType=b ) ) plusCurveControl = QtGui.QAction( '&Plus', self) plusCurveControl.triggered.connect( lambda a='CurveControlComponent', b='plus':Components.addComponentToObject( a, curveType=b ) ) pyramidCurveControl = QtGui.QAction( '&Pyramid', self) pyramidCurveControl.triggered.connect( lambda a='CurveControlComponent', b='pyramid':Components.addComponentToObject( a, curveType=b ) ) circleCurveControl = QtGui.QAction( '&Circle', self) circleCurveControl.triggered.connect( lambda a='CurveControlComponent', b='circle':Components.addComponentToObject( a, curveType=b ) ) ringDirectionCurveControl = QtGui.QAction( '&Ring Direction', self) ringDirectionCurveControl.triggered.connect( lambda a='CurveControlComponent', b='ringDirection':Components.addComponentToObject( a, curveType=b ) ) # Setup menus. componentsMenubar = QtGui.QMenuBar( menuFrame ) metaMenu = componentsMenubar.addMenu( '&Meta' ) metaMenu.addAction( moduleMeta ) metaMenu.addAction( characterMeta ) jointsMenu = componentsMenubar.addMenu( '&Joints' ) jointsMenu.addAction( basicJoint ) controlsMenu = componentsMenubar.addMenu( '&Controls' ) controlsCurvesMenu = controlsMenu.addMenu( '&Curves' ) controlsCurvesMenu.addAction( squareCurveControl ) controlsCurvesMenu.addAction( triangleCurveControl ) controlsCurvesMenu.addAction( arrowCurveControl ) controlsCurvesMenu.addAction( plusCurveControl ) controlsCurvesMenu.addAction( pyramidCurveControl ) controlsCurvesMenu.addAction( circleCurveControl ) controlsCurvesMenu.addAction( ringDirectionCurveControl ) constraintsMenu = componentsMenubar.addMenu( '&Constraints' ) deformersMenu = componentsMenubar.addMenu( '&Deformers' ) # SELECTED HEADER self.selectedLockBtn = QTWidgets.imageTextButton( '', ':/riggingUI/icons/lock_off.png', [16,16] ) self.selectedLockBtn.setMaximumWidth( 30 ) self.selectedLockBtn.clicked.connect( self.lockSelection ) self.selectedLockActive = False self.selectedLabel = QTWidgets.basicLabel( 'nothing selected', 'bold', 14, 'white', '2B2B30', inIndent=10 ) self.selectedLabel.setMinimumHeight( 30 ) self.selectedLabel.setAlignment( QtCore.Qt.AlignCenter ) selectedGrid = QtGui.QGridLayout() selectedGrid.setContentsMargins( 0, 0, 0, 0 ) selectedGrid.setHorizontalSpacing( 0 ) selectedGrid.setColumnMinimumWidth( 0, 30 ) selectedGrid.addWidget( self.selectedLockBtn, 0, 0 ) selectedGrid.addWidget( self.selectedLabel, 0, 1 ) # SELECTED COMPONENTS LIST/EDITOR # Add the component specific GUI. self.componentsLayout = QtGui.QVBoxLayout() self.componentsLayout.setAlignment( QtCore.Qt.AlignTop ) scrollArea = QTWidgets.scrollArea( self.componentsLayout ) # Layout hookup layout.addWidget( menuFrame ) layout.addLayout( selectedGrid ) layout.addWidget( scrollArea ) # In order to delete this scriptJob when this UI is destroyed we need to # parent the scriptJob to a Maya UI item. In this case I'm using a text object # with visibility turned off. scriptJobHolder = cmds.text( visible=False ) self.SCRIPT_JOB_NUMBER = cmds.scriptJob( event=[ 'SelectionChanged', self.onSelectionChange ], protected=True, parent=scriptJobHolder ) scriptJobHolderQT = mayaToQtObject( scriptJobHolder ) layout.addWidget( scriptJobHolderQT )