def __init__( self, nodeName, parent=None ): super( componentWidget, self ).__init__( parent ) self.parent = parent def on_context_menu( point, inNodeName ): popMenu = QtGui.QMenu() deleteAction = QtGui.QAction( 'Delete Component', popMenu, triggered=lambda a=inNodeName:self.deleteComponentFromObject( a ) ) popMenu.addAction( deleteAction ) popMenu.exec_( self.componentLabel.mapToGlobal( point ) ) # Setup layout. verticalLayout = QtGui.QVBoxLayout() verticalLayout.setContentsMargins( 0,0,0,0 ) verticalLayout.setSpacing( 0 ) verticalLayout.setAlignment( QtCore.Qt.AlignTop ) # Label for component componentLabel = QTWidgets.basicLabel( nodeName, 'bold', 10, 'black', '6E9094', inIndent=20 ) componentLabel.setMinimumHeight( 18 ) componentLabel.setContextMenuPolicy( QtCore.Qt.CustomContextMenu ) componentLabel.customContextMenuRequested.connect( lambda point, nodeName=nodeName:on_context_menu( point, nodeName ) ) # Properties propertyStack = QtGui.QVBoxLayout() propertyFrame = QTWidgets.basicFrame() propertyFrame.setMinimumHeight( 40 ) propertyFrame.setMaximumHeight( 40 ) # Add string edit property modulePlug = NodeUtility.getPlug( nodeName, 'moduleName' ) moduleValue = NodeUtility.getPlugValue( modulePlug ) moduleTextLayout = QTWidgets.stringProperty( 'Module Name', moduleValue ) ''' ADD EDIT FIELDS FOR PRIORITY AND CHARACTER ROOT!!!!!!!!! ''' # Add everything to the vertical layout. propertyStack.addLayout( moduleTextLayout ) propertyFrame.setLayout( propertyStack ) verticalLayout.addWidget( componentLabel ) verticalLayout.addWidget( propertyFrame ) # Connections moduleTextBox = propertyFrame.findChild( QtGui.QLineEdit, 'Module Name' ) moduleTextBox.editingFinished.connect( lambda inPlugName='moduleName', inQTType='QLineEdit', inPlugValue=moduleTextBox, inNodeName=nodeName :ModuleRootComponent( inNodeName ).setComponentAttributeFromQT( inPlugName, inQTType, inPlugValue, inNodeName ) ) #return mainWidget self.setLayout( verticalLayout )
def __init__( self, nodeName, parent=None ): super( componentWidget, self ).__init__( parent ) self.parent = parent def on_context_menu( point, inNodeName ): popMenu = QtGui.QMenu() buildAction = QtGui.QAction( 'Build Joint', popMenu, triggered=lambda a=inNodeName:self.buildNode( a ) ) popMenu.addAction( buildAction ) deleteAction = QtGui.QAction( 'Delete Component', popMenu, triggered=lambda a=inNodeName:self.deleteComponentFromObject( a ) ) popMenu.addAction( deleteAction ) popMenu.exec_( componentLabel.mapToGlobal( point ) ) # Setup layout. verticalLayout = QtGui.QVBoxLayout() verticalLayout.setContentsMargins( 0,0,0,0 ) verticalLayout.setSpacing( 0 ) verticalLayout.setAlignment( QtCore.Qt.AlignTop ) # Label for component componentLabel = QTWidgets.basicLabel( nodeName, 'bold', 10, 'black', '6E9094', inIndent=20 ) componentLabel.setMinimumHeight( 18 ) componentLabel.setContextMenuPolicy( QtCore.Qt.CustomContextMenu ) componentLabel.customContextMenuRequested.connect( lambda point, node=nodeName:on_context_menu( point, node ) ) # Properties propertyStack = QtGui.QVBoxLayout() propertyFrame = QTWidgets.basicFrame() propertyFrame.setMinimumHeight( 40 ) propertyFrame.setMaximumHeight( 40 ) # Add string edit property propertyPlug = NodeUtility.getPlug( nodeName, 'jointName' ) propertyValue = NodeUtility.getPlugValue( propertyPlug ) jointTextLayout = QTWidgets.stringProperty( 'Joint Name', propertyValue ) propertyStack.addLayout( jointTextLayout ) propertyFrame.setLayout( propertyStack ) verticalLayout.addWidget( componentLabel ) verticalLayout.addWidget( propertyFrame ) # Connections textBox = propertyFrame.findChild( QtGui.QLineEdit ) textBox.editingFinished.connect( lambda inPlugName='jointName', inQTType='QLineEdit', inPlugValue=textBox, inNodeName=nodeName :BasicJointComponent( inNodeName ).setComponentAttributeFromQT( inPlugName, inQTType, inPlugValue, inNodeName ) ) self.setLayout( verticalLayout )
def componentGui( inNodeName ): def on_context_menu( point ): popMenu = QtGui.QMenu() popMenu.addAction( 'actionEdit' ) popMenu.addAction( 'actionDelete' ) popMenu.addSeparator() popMenu.addAction( 'actionAdd' ) popMenu.exec_( componentLabel.mapToGlobal( point ) ) mainWidget = QtGui.QWidget() verticalLayout = QtGui.QVBoxLayout( mainWidget ) verticalLayout.setContentsMargins( 0,0,0,0 ) verticalLayout.setSpacing( 0 ) verticalLayout.setAlignment( QtCore.Qt.AlignTop ) # Label for component componentLabel = QTWidgets.basicLabel( inNodeName, 'bold', 10, 'black', 448094 ) componentLabel.setContextMenuPolicy( QtCore.Qt.CustomContextMenu ) componentLabel.customContextMenuRequested.connect( on_context_menu ) propertyFrame = QTWidgets.basicFrame() propertyFrame.setMinimumHeight( 40 ) propertyFrame.setMaximumHeight( 40 ) # Add string edit property plug = NodeUtility.getPlug( inNodeName, 'jointName' ) plugValue = NodeUtility.getPlugValue( plug ) QTWidgets.stringProperty( propertyFrame, 'Joint Name', plugValue ) # Add everything to the vertical layout. verticalLayout.addWidget( componentLabel ) verticalLayout.addWidget( propertyFrame ) #print 'test2: {0}'.format( prop.takeAt(0).widget() ) #print propertyFrame.count() #print propertyFrame.findChild( QtGui.QLineEdit ) #for item in xrange( propertyFrame.count() ): # print propertyFrame.itemAt( item ).widget() return mainWidget
def updateCards( self ): ''' Updates the character cards. ''' # Clear the lattice list first. clearLayout( self.scrollLayout ) presetsPath = '{0}{1}/'.format( XMLUtility.FRAME_PRESETS_PATH, 'characters' ) latticePresets = XMLUtility.getXMLInFolder( presetsPath ) for lattice in latticePresets: description = 'From here you can search these documents. Enter your search words into the box below and click /"search/".' self.scrollLayout.addWidget( QTWidgets.latticeCard( 'characters', lattice, description, parent=self.scrollLayout ) )
def build_components_gui( self ): # COMPONENTS MENU BAR menu_frame = QtGui.QFrame() menu_frame.setMinimumHeight( 20 ) #HACK!!!!!!!!!!! basic_joint = QtGui.QAction( '&Basic Joint', self) #basic_joint.setShortcut('Ctrl+Q') #basic_joint.setStatusTip('Exit application') basic_joint.triggered.connect( lambda a='BasicJointComponent':self.addComponentToObject( a ) ) components_menubar = QtGui.QMenuBar( menu_frame ) joints_menu = components_menubar.addMenu( '&Joints' ) controls_menu = components_menubar.addMenu( '&Controls' ) constraints_menu = components_menubar.addMenu( '&Constraints' ) deformers_menu = components_menubar.addMenu( '&Deformers' ) joints_menu.addAction( basic_joint ) # SELECTED HEADER self.selected_lock_btn = QtGui.QPushButton() self.selected_lock_btn.setIcon( QtGui.QIcon( ':/riggingUI/icons/lock_off.png' ) ) self.selected_lock_btn.setIconSize( QtCore.QSize(16,16) ) self.selected_lock_btn.setMaximumWidth( 22 ) self.selected_lock_btn.setStyleSheet( 'padding: 4px' ) self.selected_lock_btn.clicked.connect( self.lock_selection ) self.selected_lock_active = False self.selected_label = QtGui.QLabel() self.selected_label.setText( 'nothing selected' ) self.selected_label.setAlignment( QtCore.Qt.AlignCenter ) self.selected_label.setStyleSheet( 'font:bold; font-size:14px; background-color:#2B2B30' ) selected_grid = QtGui.QGridLayout() selected_grid.setContentsMargins( 0, 0, 0, 0 ) selected_grid.setHorizontalSpacing( 0 ) selected_grid.setColumnMinimumWidth( 0, 22 ) selected_grid.addWidget( self.selected_lock_btn, 0, 0 ) selected_grid.addWidget( self.selected_label, 0, 1 ) # SELECTED COMPONENTS LIST/EDITOR # Add the component specific GUI. self.components_layout = QtGui.QVBoxLayout() self.components_layout.setAlignment( QtCore.Qt.AlignTop ) scroll_area = QTWidgets.scrollArea( self.components_layout ) # SUB_LAYOUT HOOKUP self.sub_layout.addWidget( menu_frame ) self.sub_layout.addLayout( selected_grid ) self.sub_layout.addWidget( scroll_area )
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, nodeName, parent=None ): super( componentWidget, self ).__init__( parent ) self.parent = parent def on_context_menu( point, inNodeName ): popMenu = QtGui.QMenu() deleteAction = QtGui.QAction( 'Delete Component', popMenu, triggered=lambda a=inNodeName:self.deleteComponentFromObject( a ) ) popMenu.addAction( deleteAction ) popMenu.exec_( self.componentLabel.mapToGlobal( point ) ) # Colors. userColors = GeneralUtility.getUserDefinedColors( inType=1 ) self.colorList = [] for color in userColors: self.colorList.append( GeneralUtility.convertRGB( color, inType=1 ) ) # Setup layout. verticalLayout = QtGui.QVBoxLayout() verticalLayout.setContentsMargins( 0,0,0,0 ) verticalLayout.setSpacing( 0 ) verticalLayout.setAlignment( QtCore.Qt.AlignTop ) # Label for component #self.componentLabel = QTWidgets.basicLabel( nodeName, 'bold', 10, 'black', '6E9094', inIndent=20 ) self.componentLabel = QtGui.QLabel() self.componentLabel.setText( nodeName ) self.componentLabel.setIndent( 20 ) controlColorPlug = NodeUtility.getPlug( nodeName, 'controlColor' ) self.COLOR = NodeUtility.getPlugValue( controlColorPlug ) self.componentLabel.setStyleSheet( 'font:bold; font-size:10px; color:black; background-color:rgb({0},{1},{2})'.format(self.colorList[self.COLOR-1][0], self.colorList[self.COLOR-1][1], self.colorList[self.COLOR-1][2] ) ) self.componentLabel.setMinimumHeight( 18 ) self.componentLabel.setContextMenuPolicy( QtCore.Qt.CustomContextMenu ) self.componentLabel.customContextMenuRequested.connect( lambda point, nodeName=nodeName:on_context_menu( point, nodeName ) ) propertyFrame = QTWidgets.basicFrame() propertyFrame.setMinimumHeight( 100 ) propertyFrame.setMaximumHeight( 100 ) propertyStack = QtGui.QVBoxLayout() # Add string edit property propertyRow = QtGui.QHBoxLayout() propertyPlug = NodeUtility.getPlug( nodeName, 'controlName' ) propertyValue = NodeUtility.getPlugValue( propertyPlug ) self.textBox = QtGui.QLineEdit() self.textBox.setAlignment( QtCore.Qt.AlignLeft ) self.textBox.setMinimumHeight( 20 ) if propertyValue: self.textBox.setText( propertyValue ) textBoxLabel = QtGui.QLabel() textBoxLabel.setText( 'Control Name' ) textBoxLabel.setAlignment( QtCore.Qt.AlignCenter ) textBoxLabel.setMinimumHeight( 12 ) propertyRow.addWidget( self.textBox ) propertyRow.addWidget( textBoxLabel ) # Colors. colorRow = QtGui.QHBoxLayout() color1Btn = QtGui.QPushButton() color1Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[0][0], self.colorList[0][1], self.colorList[0][2] ) ) color1Btn.clicked.connect( lambda a=nodeName, b=1:self.colorChange( a, b ) ) color2Btn = QtGui.QPushButton() color2Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[1][0], self.colorList[1][1], self.colorList[1][2] ) ) color2Btn.clicked.connect( lambda a=nodeName, b=2:self.colorChange( a, b ) ) color3Btn = QtGui.QPushButton() color3Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[2][0], self.colorList[2][1], self.colorList[2][2] ) ) color3Btn.clicked.connect( lambda a=nodeName, b=3:self.colorChange( a, b ) ) color4Btn = QtGui.QPushButton() color4Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[3][0], self.colorList[3][1], self.colorList[3][2] ) ) color4Btn.clicked.connect( lambda a=nodeName, b=4:self.colorChange( a, b ) ) color5Btn = QtGui.QPushButton() color5Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[4][0], self.colorList[4][1], self.colorList[4][2] ) ) color5Btn.clicked.connect( lambda a=nodeName, b=5:self.colorChange( a, b ) ) color6Btn = QtGui.QPushButton() color6Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[5][0], self.colorList[5][1], self.colorList[5][2] ) ) color6Btn.clicked.connect( lambda a=nodeName, b=6:self.colorChange( a, b ) ) color7Btn = QtGui.QPushButton() color7Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[6][0], self.colorList[6][1], self.colorList[6][2] ) ) color7Btn.clicked.connect( lambda a=nodeName, b=7:self.colorChange( a, b ) ) color8Btn = QtGui.QPushButton() color8Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[7][0], self.colorList[7][1], self.colorList[7][2] ) ) color8Btn.clicked.connect( lambda a=nodeName, b=8:self.colorChange( a, b ) ) colorRow.addWidget( color1Btn ) colorRow.addWidget( color2Btn ) colorRow.addWidget( color3Btn ) colorRow.addWidget( color4Btn ) colorRow.addWidget( color5Btn ) colorRow.addWidget( color6Btn ) colorRow.addWidget( color7Btn ) colorRow.addWidget( color8Btn ) # Edit buttons. self.editButton = QtGui.QToolButton() self.editButton.setCheckable( True ) self.editButton.setText( 'Edit Control' ) self.editButton.toggled.connect( lambda:self.editCurveProperties() ) propertyStack.addLayout( propertyRow ) propertyStack.addLayout( colorRow ) propertyStack.addWidget( self.editButton ) propertyFrame.setLayout( propertyStack ) # Add everything to the vertical layout. verticalLayout.addWidget( self.componentLabel ) verticalLayout.addWidget( propertyFrame ) # Connections self.textBox.editingFinished.connect( lambda inPlugName='controlName', inQTType='QLineEdit', inPlugValue=self.textBox, inNodeName=nodeName :CurveControlComponent( inNodeName ).setComponentAttributeFromQT( inPlugName, inQTType, inPlugValue, inNodeName ) ) #return mainWidget self.setLayout( verticalLayout )
def __init__( self, nodeName, parent=None ): super( componentWidget, self ).__init__( parent ) self.parent = parent def on_context_menu( point, inNodeName ): popMenu = QtGui.QMenu() deleteAction = QtGui.QAction( 'Delete Component', popMenu, triggered=lambda a=inNodeName:self.deleteComponentFromObject( a ) ) popMenu.addAction( deleteAction ) popMenu.exec_( self.componentLabel.mapToGlobal( point ) ) # Setup layout. verticalLayout = QtGui.QVBoxLayout() verticalLayout.setContentsMargins( 0,0,0,0 ) verticalLayout.setSpacing( 0 ) verticalLayout.setAlignment( QtCore.Qt.AlignTop ) # Label for component componentLabel = QTWidgets.basicLabel( nodeName, 'bold', 10, 'black', '6E9094', inIndent=20 ) componentLabel.setMinimumHeight( 18 ) componentLabel.setContextMenuPolicy( QtCore.Qt.CustomContextMenu ) componentLabel.customContextMenuRequested.connect( lambda point, nodeName=nodeName:on_context_menu( point, nodeName ) ) # Properties propertyStack = QtGui.QVBoxLayout() propertyFrame = QTWidgets.basicFrame() propertyFrame.setMinimumHeight( 120 ) propertyFrame.setMaximumHeight( 120 ) # Add string edit property characterPlug = NodeUtility.getPlug( nodeName, 'characterName' ) characterValue = NodeUtility.getPlugValue( characterPlug ) characterTextLayout = QTWidgets.stringProperty( 'Character Name', characterValue ) skelGroupPlug = NodeUtility.getPlug( nodeName, 'skeletonGroupName' ) skelGroupValue = NodeUtility.getPlugValue( skelGroupPlug ) skelGroupTextLayout = QTWidgets.stringProperty( 'Skeleton Group Name', skelGroupValue ) rigGroupPlug = NodeUtility.getPlug( nodeName, 'rigGroupName' ) rigGroupValue = NodeUtility.getPlugValue( rigGroupPlug ) rigGroupTextLayout = QTWidgets.stringProperty( 'Rigging Group Name', rigGroupValue ) ''' ADD MODULES BUTTON. PROBABLY HAVE A POPUP LISTING UNCONNECTED MODULES IN THE SCENE?? ''' # Add everything to the vertical layout. propertyStack.addLayout( characterTextLayout ) propertyStack.addLayout( skelGroupTextLayout ) propertyStack.addLayout( rigGroupTextLayout ) propertyFrame.setLayout( propertyStack ) verticalLayout.addWidget( componentLabel ) verticalLayout.addWidget( propertyFrame ) # Connections charTextBox = propertyFrame.findChild( QtGui.QLineEdit, 'Character Name' ) charTextBox.editingFinished.connect( lambda inPlugName='characterName', inQTType='QLineEdit', inPlugValue=charTextBox, inNodeName=nodeName :CharacterRootComponent( inNodeName ).setComponentAttributeFromQT( inPlugName, inQTType, inPlugValue, inNodeName ) ) skelTextBox = propertyFrame.findChild( QtGui.QLineEdit, 'Skeleton Group Name' ) skelTextBox.editingFinished.connect( lambda inPlugName='skeletonGroupName', inQTType='QLineEdit', inPlugValue=skelTextBox, inNodeName=nodeName :CharacterRootComponent( inNodeName ).setComponentAttributeFromQT( inPlugName, inQTType, inPlugValue, inNodeName ) ) rigTextBox = propertyFrame.findChild( QtGui.QLineEdit, 'Rigging Group Name' ) rigTextBox.editingFinished.connect( lambda inPlugName='rigGroupName', inQTType='QLineEdit', inPlugValue=rigTextBox, inNodeName=nodeName :CharacterRootComponent( inNodeName ).setComponentAttributeFromQT( inPlugName, inQTType, inPlugValue, inNodeName ) ) #return mainWidget self.setLayout( verticalLayout )
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 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( 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 __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 )