def getComponents( inObj ): ''' Creates the components GUI. ''' if inObj is not None: components_list = FrameUtility.getFrameBitSettings( inObj ) else: components_list = None # If the newly selected bit has components then update the UI to show them. # Check to see if any of the components are connected to a meta node. # We do this check so that we don't create a bunch of UI elements # unnecessarily. if components_list is not None and metaNodeCheck( inObj, components_list ): # Loop through each component on the bit. components_class_list = {} for node_name in components_list: # Check to see if the component is connected to a meta node. metaNode = NodeUtility.getNodeAttrDestination( inObj, node_name ) if metaNode: # It has a meta node. # Get the meta node properties. This returns a dict. meta_properties = FrameUtility.getFrameBitSettings( metaNode[0] ) component_class = meta_properties[ 'classType' ] # test hack!!! components_class_list[ node_name ] = component_class return components_class_list else: return None
def buttonTest( *args ): import marigold.utility.FrameUtility as FrameUtility # There are three arguments coming in. # Arg1: The value of the button pressed. This is automatically sent and ignored. # Arg2: The name of the XML file to open. # Arg3: The name of the folder the XML file is located. FrameUtility.buildFrameModule( args[2], args[1] ) '''
def addComponentToObject( self, inClassType ): selList = cmds.ls( selection=True, long=True ) if len( selList ) is 1: prevSel = selList[0] component_class = Components.str_to_class( inClassType ) newNode = component_class.createCompNode( inClassType ) # Add the component attribute to the object. FrameUtility.addPlug( selList[0], newNode.name(), 'attributeType', 'message' ) nodePlug = '{0}.parentName'.format( newNode.name() ) objectPlug = '{0}.{1}'.format( selList[0], newNode.name() ) NodeUtility.connectPlugs( objectPlug, nodePlug ) cmds.select( prevSel )
def addComponentToObject( self, inClassType ): ''' ''' selList = cmds.ls( selection=True, long=True ) if len( selList ) is 1: prevSel = selList[0] newNode = componentNodes.jointComponentNode().createCompNode( inClassType ) # Add the component attribute to the object. FrameUtility.addPlug( selList[0], newNode.name(), 'attributeType', 'message' ) #cmds.addAttr( inObject, longName='jointComponent', attributeType='message', storable=False ) nodePlug = '{0}.parentName'.format( newNode.name() ) objectPlug = '{0}.{1}'.format( selList[0], newNode.name() ) NodeUtility.connectPlugs( objectPlug, nodePlug ) cmds.select( prevSel )
def updateTopMenu( self, inMode ): # Delete the existing menu bar's content. barChildren = cmds.menuBarLayout( self.menuBar, query=True, menuArray=True ) if barChildren is not None: for child in barChildren: cmds.deleteUI( child ) # Now fill the menu layout with the active set. if inMode == 'Bits': self.menuEdit = cmds.menu( parent=self.menuBar, label='Edit' ) cmds.menuItem( parent=self.menuEdit, label='Copy Bit Settings', annotation='Copy one bit\'s setting to another.', command=lambda b:FrameUtility.copyBitSettings() ) cmds.menuItem( parent=self.menuEdit, label='Add Child', annotation='Add child bit to another bit.', command=lambda b:FrameUtility.setBitChild() ) cmds.menuItem( parent=self.menuEdit, label='Delete Child', annotation='Remove child bit from selected bit.', command=lambda b:FrameUtility.deleteBitChild() ) elif inMode == 'Component': self.menuJoints = cmds.menu( parent=self.menuBar, label='Joints' ) cmds.menuItem( parent=self.menuJoints, label='Joint', annotation='Creates a node of type jointComponentNode', command=lambda b, a1='jointComponentNode':self.addComponentToObject(a1) ) self.menuControls = cmds.menu( parent=self.menuBar, label='Controls' ) cmds.menuItem( parent=self.menuControls, label='TEMP', annotation='TEMP' ) self.menuDeformers = cmds.menu( parent=self.menuBar, label='Deformers' ) cmds.menuItem( parent=self.menuDeformers, label='TEMP', annotation='TEMP' ) self.menuConstraints = cmds.menu( parent=self.menuBar, label='Constraints' ) cmds.menuItem( parent=self.menuConstraints, label='TEMP', annotation='TEMP' ) elif inMode == 'Module': self.menuFile = cmds.menu( parent=self.menuBar, label='File' ) cmds.menuItem( parent=self.menuFile, label='Save Module XML', annotation='Save the selected frame module to XML.', command=lambda b:FrameUtility.createFrameModuleXML() ) elif inMode == 'Character': self.menuEdit = cmds.menu( parent=self.menuBar, label='Character Item' ) cmds.menuItem( parent=self.menuEdit, label='TEMP', annotation='TEMP' )
def build_bits_gui( self ): ''' Build the bits GUI sub-layout. ''' # Build bits controls # Primitive buttons. self.sphere_btn = QtGui.QToolButton( self ) self.sphere_btn.setStyleSheet( 'border:0' ) self.sphere_btn.setAutoRaise( True ) self.sphere_btn.setIcon( QtGui.QIcon( ':/riggingUI/icons/bit_sphere.png' ) ) self.sphere_btn.setIconSize( QtCore.QSize(32,32) ) self.sphere_btn.setText( 'Sphere' ) self.sphere_btn.clicked.connect( self.primitive_buttons ) self.box_btn = QtGui.QToolButton( self ) self.box_btn.setStyleSheet( 'border:0' ) self.box_btn.setAutoRaise( True ) self.box_btn.setIcon( QtGui.QIcon( ':/riggingUI/icons/bit_box.png' ) ) self.box_btn.setIconSize( QtCore.QSize(32,32) ) self.box_btn.setText( 'Box' ) self.box_btn.clicked.connect( self.primitive_buttons ) self.cylinder_btn = QtGui.QToolButton( self ) self.cylinder_btn.setStyleSheet( 'border:0' ) self.cylinder_btn.setAutoRaise( True ) self.cylinder_btn.setIcon( QtGui.QIcon( ':/riggingUI/icons/bit_cylinder.png' ) ) self.cylinder_btn.setIconSize( QtCore.QSize(32,32) ) self.cylinder_btn.setText( 'Cylinder' ) self.cylinder_btn.clicked.connect( self.primitive_buttons ) self.cone_btn = QtGui.QToolButton( self ) self.cone_btn.setStyleSheet( 'border:0' ) self.cone_btn.setAutoRaise( True ) self.cone_btn.setIcon( QtGui.QIcon( ':/riggingUI/icons/bit_cone.png' ) ) self.cone_btn.setIconSize( QtCore.QSize(32,32) ) self.cone_btn.setText( 'Cone' ) self.cone_btn.clicked.connect( self.primitive_buttons ) self.torus_btn = QtGui.QToolButton( self ) self.torus_btn.setStyleSheet( 'border:0' ) self.torus_btn.setAutoRaise( True ) self.torus_btn.setIcon( QtGui.QIcon( ':/riggingUI/icons/bit_torus.png' ) ) self.torus_btn.setIconSize( QtCore.QSize(32,32) ) self.torus_btn.setText( 'Torus' ) self.torus_btn.clicked.connect( self.primitive_buttons ) # Bit tools. self.match_translation_btn = QtGui.QPushButton( 'Match Translation' ) self.match_translation_btn.setIcon( QtGui.QIcon( ':/riggingUI/icons/icon_match_translation.png' ) ) self.match_translation_btn.setIconSize( QtCore.QSize(16,16) ) self.match_translation_btn.setStyleSheet( 'text-align: left; padding: 4px' ) self.match_translation_btn.clicked.connect( lambda a='tran':TransformUtility.matchTransforms( a ) ) self.match_rotation_btn = QtGui.QPushButton( 'Match Rotation' ) self.match_rotation_btn.setIcon( QtGui.QIcon( ':/riggingUI/icons/icon_match_rotation.png' ) ) self.match_rotation_btn.setIconSize( QtCore.QSize(16,16) ) self.match_rotation_btn.setStyleSheet( 'text-align: left; padding: 4px' ) self.match_rotation_btn.clicked.connect( lambda a='rot':TransformUtility.matchTransforms( a ) ) self.match_all_btn = QtGui.QPushButton( 'Match All' ) self.match_all_btn.setIcon( QtGui.QIcon( ':/riggingUI/icons/icon_match_all.png' ) ) self.match_all_btn.setIconSize( QtCore.QSize(16,16) ) self.match_all_btn.setStyleSheet( 'text-align: left; padding: 4px' ) self.match_all_btn.clicked.connect( lambda a='all':TransformUtility.matchTransforms( a ) ) self.copy_bit_settings_btn = QtGui.QPushButton( 'Copy Bit Settings' ) self.copy_bit_settings_btn.setIcon( QtGui.QIcon( ':/riggingUI/icons/bit_copy_settings.png' ) ) self.copy_bit_settings_btn.setIconSize( QtCore.QSize(16,16) ) self.copy_bit_settings_btn.setStyleSheet( 'text-align: left; padding: 4px' ) self.copy_bit_settings_btn.clicked.connect( lambda:FrameUtility.copyBitSettings() ) self.add_child_btn = QtGui.QPushButton( 'Add Child' ) self.add_child_btn.setIcon( QtGui.QIcon( ':/riggingUI/icons/bit_add_child.png' ) ) self.add_child_btn.setIconSize( QtCore.QSize(16,16) ) self.add_child_btn.setStyleSheet( 'text-align: left; padding: 4px' ) self.add_child_btn.clicked.connect( lambda:FrameUtility.setBitChild() ) self.delete_child_btn = QtGui.QPushButton( 'Delete Child' ) self.delete_child_btn.setIcon( QtGui.QIcon( ':/riggingUI/icons/bit_delete_child.png' ) ) self.delete_child_btn.setIconSize( QtCore.QSize(16,16) ) self.delete_child_btn.setStyleSheet( 'text-align: left; padding: 4px' ) self.delete_child_btn.clicked.connect( lambda:FrameUtility.deleteBitChild() ) # Build bits layout. # Primitive buttons bit_primitives_header = QtGui.QLabel() bit_primitives_header.setText( 'Bit Primitives' ) bit_primitives_header.setAlignment( QtCore.Qt.AlignCenter ) bit_primitives_header.setStyleSheet( 'font:bold; font-size:14px; background-color:#2B2B30' ) primitive_frame = QtGui.QFrame() primitive_frame.setFrameShadow( QtGui.QFrame.Sunken ) primitive_frame.setFrameShape( QtGui.QFrame.Box ) primitive_frame.setLineWidth( 1 ) #self.primitive_groupbox.setStyleSheet( 'border:4px; border-style:outset' ) primitive_layout = QtGui.QHBoxLayout() primitive_layout.addWidget( self.sphere_btn ) primitive_layout.addWidget( self.box_btn ) primitive_layout.addWidget( self.cylinder_btn ) primitive_layout.addWidget( self.cone_btn ) primitive_layout.addWidget( self.torus_btn ) primitive_frame.setLayout( primitive_layout ) # Bit tools. bit_tools_header = QtGui.QLabel() bit_tools_header.setText( 'Bit Tools' ) bit_tools_header.setAlignment( QtCore.Qt.AlignCenter ) bit_tools_header.setStyleSheet( 'font:bold; font-size:14px; background-color:#2B2B30' ) bit_tools_grid = QtGui.QGridLayout() bit_tools_grid.setColumnMinimumWidth( 0, 100 ) bit_tools_grid.setColumnMinimumWidth( 1, 100 ) bit_tools_grid.setColumnMinimumWidth( 2, 100 ) bit_tools_grid.setSpacing( 2 ) bit_tools_grid.setContentsMargins( 0,0,0,0 ) # widget, row, col bit_tools_grid.addWidget( self.match_translation_btn, 0, 0 ) bit_tools_grid.addWidget( self.match_rotation_btn, 0, 1 ) bit_tools_grid.addWidget( self.match_all_btn, 0, 2 ) bit_tools_grid.addWidget( self.copy_bit_settings_btn, 1, 0 ) bit_tools_grid.addWidget( self.add_child_btn, 1, 1 ) bit_tools_grid.addWidget( self.delete_child_btn, 1, 2 ) # Added the bits widgets to the sub-layout of the main window. self.sub_layout.addWidget( bit_primitives_header ) self.sub_layout.addWidget( primitive_frame ) self.sub_layout.addWidget( bit_tools_header ) self.sub_layout.addLayout( bit_tools_grid )
def componentsGUI( self, inBit=None ): ''' Creates the components GUI. ''' if inBit is None: components = None else: # Get the components of the selected bit. components = FrameUtility.getFrameBitSettings( inBit ) # Clean up the compArea layout prior to adding new children by # removing the previously selected bit's information from the UI. mainChildren = cmds.columnLayout( self.fillArea, query=True, childArray=True ) if mainChildren is not None: for child in mainChildren: cmds.deleteUI( child ) col = cmds.columnLayout( adjustableColumn=True, columnAttach=('both', 5), parent=self.fillArea ) # HIGHLIGHTED cmds.separator( style='none', height=4, width=413 ) self.selName = cmds.text( label=str.upper( 'nothing selected' ), height=20, font='boldLabelFont', backgroundColor=[0.2,0.2,0.2] ) cmds.separator( style='none', height=10 ) # If the newly selected bit has components then update the UI to show them. # Check to see if any of the components are connected to a meta node. # We do this check so that we don't create a bunch of UI elements # unnecessarily. if components is not None and self.metaNodeCheck( inBit, components ): # Create the scroll layout. mainScroll = cmds.scrollLayout( parent=col ) # Loop through each component on the bit. for comName in components: # Check to see if the component is connected to a meta node. metaNode = NodeUtility.getNodeAttrDestination( inBit, comName ) if metaNode: # It has a meta node. # Get the meta node parameters. metaParameters = FrameUtility.getFrameBitSettings( metaNode[0] ) # Make the component UI elements. frameOne = cmds.frameLayout( parent=mainScroll, borderStyle='out', label=comName, collapsable=True ) cmds.popupMenu() #bit name, component name, meta node name cmds.menuItem( label='Delete Component', command=lambda b, a1=inBit, a2=comName, a3=metaNode[0]:self.deleteComponent(a1, a2, a3) ) cmds.menuItem( label='Build Component', command=lambda b, a1=metaNode[0]:self.buildComponent(a1) ) compColumn = cmds.rowColumnLayout( numberOfColumns=1 ) # Loop through the parameters and add them to the component UI. for param in metaParameters: #print isinstance(param, unicode) if not( param == u'parentName' or param == u'classType' ): propRow = cmds.rowColumnLayout( numberOfColumns=4, columnWidth=[(1,100),(2,100),(3,40),(4,40)], columnSpacing=[(1,10),(2,10),(3,10),(4,2)] ) cmds.text( label=param, align='left' ) cmds.textField( text=metaParameters[param], enterCommand=lambda b, a1=metaNode[0], a2=param:self.updateComponentParameter(a1, a2, b) ) cmds.setParent( '..' )#propRow cmds.setParent( '..' )#compColumn cmds.setParent( '..' )#frameOne cmds.setParent( '..' )#mainScroll cmds.setParent( '..' )#col # Selection script job self.selJob = cmds.scriptJob( event=[ 'SelectionChanged', self.onSelectionChange ], parent=col, protected=True )