Пример #1
0
def uiContents():
    with pm.frameLayout(l='Color', cll=True, mw=3, mh=3 ):
        with pm.columnLayout(adj=True):

            with pm.rowLayout(nc=2):
                pm.text(label='Set Override Color : ', align='right', w=130)
                with pm.rowColumnLayout( nc=10 ):
                    wh=18
                    for i in range(0,32):
                        rgb = (0,0,0)
                        if i == 0:
                            rgb  = (0.5,0.5,0.5)
                            anno = 'Reset'
                            pm.symbolButton( i=iconPath+'ui_colorNone.png', annotation=anno, w=wh, h=wh, c=pm.Callback( setColor.setColor, color=i ) )

                        else:
                            rgb  = pm.colorIndex( i, q=True )
                            anno = '- index : %d\n- RGB : %03.3f %03.3f %03.3f\n- name : %s'%(i, rgb[0], rgb[1], rgb[2], setColor.color_intToStr(i) )

                            pm.canvas(
                                rgbValue   = rgb,
                                annotation = anno,
                                w=wh, h=wh,
                                pressCommand = pm.Callback( setColor.setColor, color=i )
                                ) #partial( self.setColor, i, True , self._toShape)) #partial( self.setColor, i, False, False))

            pm.separator(h=8,style='in')
            with pm.rowLayout( nc=10 ):
                pm.text(label='Set Wire Frame Color : ', align='right', w=130)
                pm.button(label='Object Color Palette', c=pm.Callback( pm.mel.objectColorPalette ), w=180 )

# ======================================
# Buttons
# ======================================
Пример #2
0
    def __init__(self):
        self.customColor = [1.0, 1.0, 1.0]
        self._colorChangeObjs = []

        with rowColumnLayout('Post_Control_Edit', nc=2):
            with columnLayout():
                self.shapeMenu = optionMenu(
                    l='')  # , cc=core.alt.Callback(self.setOverrides) )
                for shape in controller.control.listShapes():
                    menuItem(l=shape)

                button('Copy Shape', c=core.alt.Callback(self.copyShape))
                button('Mirror Shape',
                       c=core.alt.Callback(self.copyShape, True))
                button('Copy Colors', c=core.alt.Callback(self.copyColor))

                self.shapeMenu.changeCommand(
                    core.alt.Callback(self.changeShape))

                with rowColumnLayout(nc=2):
                    button(l='+10%', c=core.alt.Callback(self.scaleCvs, 1.10))
                    button(l='+ 1%', c=core.alt.Callback(self.scaleCvs, 1.01))

                    button(l='-10%', c=core.alt.Callback(self.scaleCvs, 0.90))
                    button(l='- 1%', c=core.alt.Callback(self.scaleCvs, 0.99))

                ShapeEditor()

            with columnLayout():
                text(l='Surface Color')

                self.surfacePalette = palettePort(dim=(7, 4),
                                                  w=(7 * 20),
                                                  h=(4 * 20),
                                                  td=True,
                                                  colorEditable=False)
                self.surfacePalette.changeCommand(
                    core.alt.Callback(self.changeSurfaceColor))

                self.surfacePalette.setRgbValue([0] + self.customColor)
                for i, (name, c) in enumerate(core.shader.namedColors.items()):
                    self.surfacePalette.setRgbValue([i + 1] + list(c))

                text(l='')

                text(l='Curve Color')
                self.palette = palettePort(dim=(8, 4),
                                           w=(8 * 20),
                                           h=(4 * 20),
                                           td=True,
                                           colorEditable=False,
                                           transparent=0)
                self.palette.changeCommand(
                    core.alt.Callback(self.changeCurveColor))

                for i in range(1, 32):
                    param = [i] + colorIndex(i, q=True)
                    self.palette.setRgbValue(param)

                self.palette.setRgbValue((0, .6, .6, .6))
Пример #3
0
 def __init__(self, parent=None):
     super(MPalette, self).__init__(parent)
     self._color = -1
     self._styleSheet = ""
     self.setupUi()
     for i, b in enumerate(self.buttons):
         self.setButtonColor(
             b, [x * 255 for x in pm.colorIndex(i + 1, q=True)])
         b.clicked.connect(lambda index=i + 1: self.accept(index))
Пример #4
0
 def __init__(self, parent=None):
     super(MPalette, self).__init__(parent)
     self._color = -1
     self._styleSheet = ""
     self.setupUi()
     for i, b in enumerate(self.buttons):
         self.setButtonColor(
             b, [x * 255 for x in pm.colorIndex(i + 1, q=True)])
         b.clicked.connect(lambda index=i + 1: self.accept(index))
Пример #5
0
def getOverrideColor(obj):
    colorId = getOverrideColorId(
        obj)  # search for colorIndex of the obj or its parents

    if colorId:
        floatColor = pm.colorIndex(
            colorId, q=1)  # get float RGB values from Maya for given id
        intVal = [int(math.ceil(v * 255))
                  for v in floatColor]  # convert float values to integers
        return hexColor(intVal)  # convert to hex and return
    else:
        return None
Пример #6
0
def fill_color_palette(color_palette):
    """ This module is to fill the color palette of the UI
    :param color_palette: this is the maya's default colors
    :return: None
    """
    for i in range(1, 32):
        color_component = pm.colorIndex(i, q=True)
        pm.palettePort(color_palette,
                       e=True,
                       rgb=(i, color_component[0], color_component[1],
                            color_component[2]))
    pm.palettePort(color_palette, e=True, rgb=(0, 0.6, 0.6, 0.6))
Пример #7
0
def add_ctrl_shader(ctrl_list):
    ctrl_list = pm.ls(ctrl_list)
    sweep_geo_list = ctrl_paintEffect(ctrl_list)

    for cv in ctrl_list:
        cv_shape_list = cv.getShapes()
        for cv_shape in cv_shape_list:
            stroke = pm.listConnections(cv_shape.worldSpace)[-1]
            ctrl_geo = pm.listConnections(stroke.worldMainMesh)[-1]

            try:
                rgb_color = pm.colorIndex(cv.overrideColor.get(), q=True)
            except:
                if cv.getShape().overrideEnabled.get() == 0:
                    cv.getShape().overrideEnabled.set(1)
                    cv.getShape().ovc.set(1)
                    
                rgb_color = pm.colorIndex(cv.getShape().overrideColor.get(), q=True)

            shader_name = str(ctrl_geo.name()).replace('geo', 'mat')
            surface_shader = shader_base.build_surfaceshader(shaderName=shader_name,
                                                             color=(rgb_color[0], rgb_color[1], rgb_color[2]))
            shader_base.assign_shader(ctrl_geo, surface_shader)
Пример #8
0
    def __init__(self):
        self._colorChangeObjs = []

        columnLayout()
        self.curvePalette = palettePort(dim=(8, 4),
                                        w=(8 * 20),
                                        h=(4 * 20),
                                        td=True,
                                        colorEditable=False,
                                        transparent=0)
        self.curvePalette.changeCommand(
            core.alt.Callback(self.changeCurveColor))

        for i in range(1, 32):
            param = [i] + colorIndex(i, q=True)
            self.curvePalette.setRgbValue(param)

        self.curvePalette.setRgbValue((0, .6, .6, .6))
Пример #9
0
    def __init__(self, grid):
        self._colorChangeObjs = []
        """
        columnLayout()
        self.curvePalette = palettePort(
            dim=(8, 4),
            w=(8 * 20),
            h=(4 * 20),
            td=True,
            colorEditable=False,
            transparent=0)
        self.curvePalette.changeCommand( core.alt.Callback(self.changeCurveColor) )
        
        for i in range(1, 32):
            param = [i] + colorIndex(i, q=True)
            self.curvePalette.setRgbValue( param )
        
        self.curvePalette.setRgbValue( (0, .6, .6, .6) )
        """

        for i in range(1, 32):
            col = i % self.WIDTH
            row = math.floor(i / self.WIDTH)

            b = PySide2.QtWidgets.QPushButton('    ')
            pal = b.palette()
            color = colorIndex(i, q=True)
            pal.setColor(
                PySide2.QtGui.QPalette.Button,
                PySide2.QtGui.QColor(color[0] * 255.0, color[1] * 255.0,
                                     color[2] * 255.0))
            b.setAutoFillBackground(True)
            b.setPalette(pal)

            b.clicked.connect(partial(self.changeCurveColor, i))

            grid.addWidget(b, row, col)
Пример #10
0
        def cmd(rgbColor=rgbColor):
            ka_util.colorObjects(color=rgbColor)

        MENU_COLOR.add(cmd, label=label, icon=rgbColor)

    # MAYA Colors
    for i in range(32):
        if i == 0:

            def cmd():
                mel.eval("kaRig_colourSelection \"black\";")

            MENU_COLOR.add(cmd, label='#%s None' % str(i))
        else:
            rgb = pymel.colorIndex(i, q=True)

            def cmd(i=i):
                ka_util.colorObjects(index=i)

            MENU_COLOR.add(cmd, label='#%s' % str(i), icon=rgb)

# LOCK / UNLOCK MENU
MENU_LOCK_UNLOCK = kMenu.KMenu(label='Lock / Unlock', icon='lock.png')
if MENU_LOCK_UNLOCK:
    with MENU_LOCK_UNLOCK.addSubMenu(label='Lock', icon='lock.png'):
        MENU_LOCK_UNLOCK.add(ka_maya.lockTranslate)
        MENU_LOCK_UNLOCK.add(ka_maya.lockRotate)
        MENU_LOCK_UNLOCK.add(ka_maya.lockScale)
        MENU_LOCK_UNLOCK.add(ka_maya.lockVis)
        MENU_LOCK_UNLOCK.add(ka_maya.lockRadius)
    def initialiseLayout(self):
        
        #=======================================================================
        # Top Level Layout
        #=======================================================================
        self.widgets['top_level_layout'] = pm.verticalLayout()
        self.widgets['top_level_column'] = pm.columnLayout(adj=True, rowSpacing=2, columnAttach = ['both', 5])

        #=======================================================================
        # NAME
        #=======================================================================
        #------------------------------------------------------------- Separator
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.separator(style='out')
        pm.text(label=' Name ')
        pm.separator(style='out')
        h.redistribute(1,1,1)           

        #------------------------------------------------------- Prefix / Suffix
        pm.setParent(self.widgets['top_level_column'])
        self.widgets["suffix_TFG"] = pm.textFieldGrp(label='Suffix :', cw=[1,50], adj=2, text='ctrl')

        #=======================================================================
        # CONTROL
        #=======================================================================
        #------------------------------------------------------------- Separator
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.separator(style='out')
        pm.text(label=' Control ')
        pm.separator(style='out')
        h.redistribute(1,1,1)        

        #----------------------------------------------------------- Offset Node
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        self.widgets['offsetNode_CB'] = pm.checkBox( label = 'Offset Node ', value=True)
        self.widgets['offsetNode_TF'] = pm.textField(text='Offset')
        h.redistribute(1,2)
        
        #--------------------------------------------------------------- Cluster
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        self.widgets['cluster_CB'] = pm.checkBox( label = 'Control Cluster', value=False)
        self.widgets['clusterGroup_RBG'] = pm.radioButtonGrp( labelArray2=['Each', 'All'], 
                                                              numberOfRadioButtons=2 , 
                                                              cw=[1,100], 
                                                              adj=3, 
                                                              select=1)
        h.redistribute(1,2)
        
        #------------------------------------------------------------- ShapeNode
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        self.widgets['shape_CB'] = pm.checkBox( label = 'Shape Node ', value=True)
        self.widgets['shape_TSL'] = pm.textScrollList( numberOfRows=5, 
                                                       allowMultiSelection=False, 
                                                       append = self.shapeList, 
                                                       selectIndexedItem=1)
        h.redistribute(1,2)
        
        #------------------------------------------------------------ Shape Axis
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.text(label = 'Shape Axis')
        self.widgets['shapeAxis_OM'] = pm.optionMenu()
        pm.menuItem(label = "+x")
        pm.menuItem(label = "+y")
        pm.menuItem(label = "+z")
        pm.menuItem(label = "-x")
        pm.menuItem(label = "-y")
        pm.menuItem(label = "-z")        
        h.redistribute(1,2)
        
        #------------------------------------------------------------- Hierarchy
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()  
        pm.text(label='Parent')      
        self.widgets['hierarchry_RB'] = pm.radioButtonGrp( labelArray2=['World', 'Selection Order'], 
                                                           numberOfRadioButtons=2 , 
                                                           cw=[1,100], 
                                                           adj=3, 
                                                           select=1)
        h.redistribute(1,2)        
        
        #------------------------------------------------------- Constraint Type
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.text(label='Constraint Type:')
        self.widgets['tConst_CB'] = pm.checkBox(label='Point', value=False)
        self.widgets['rConst_CB'] = pm.checkBox(label='Orient', value=False)
        h.redistribute(1,1,1)
        
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.text(label="")
        self.widgets['pConst_CB'] = pm.checkBox(label='Parent', value=True)
        self.widgets['sConst_CB'] = pm.checkBox(label='Scale', value=True)
        h.redistribute(1,1,1)   
        
        #--------------------------------------------------------- Create Button
        pm.setParent(self.widgets['top_level_column'])
        self.widgets['create_BTN'] = pm.button( label="Create Control(s)",
                                                h=50, 
                                                c=pm.Callback(self.create_BTN_pressed))
        
        
        #=======================================================================
        # EDIT
        #=======================================================================

        #------------------------------------------------------------- Separator
        pm.setParent(self.widgets['top_level_column'])
        pm.separator(style="none", h=10)
                
        h = pm.horizontalLayout()
        pm.separator(style='out')
        pm.text(label=' Edit Color')
        pm.separator(style='out')
        h.redistribute(1,1,1)            
        
        #----------------------------------------------------------------- Color
        pm.setParent(self.widgets['top_level_column'])
        main_layout = pm.formLayout()
        columns = 32 / 2
        rows = 2
        cell_width = 24
        cell_height = 24

        self.widgets['color_palette'] = pm.palettePort( dimensions=(columns, rows), 
                                                        transparent=0,
                                                        width=(columns*cell_width),
                                                        height=(rows*cell_height),
                                                        topDown=True,
                                                        colorEditable=False,
                                                        changeCommand=pm.Callback(self.color_palette_changed));
        for index in range(1, 32):
            color_component = pm.colorIndex(index, q=True)
            pm.palettePort( self.widgets['color_palette'],
                            edit=True,
                            rgbValue=(index, color_component[0], color_component[1], color_component[2]))


        #------------------------------------------------------------- Separator
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.separator(style='out')
        pm.text(label=' Edit Channels')
        pm.separator(style='out')
        h.redistribute(1,1,1)     
        
        #--------------------------------------------------------------- Channel
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.text(label='Translate')
        self.widgets['tHide_BTN'] = pm.button(label='Hide', command=pm.Callback(self.tHide_BTN_pressed))        
        self.widgets['tShow_BTN'] = pm.button(label='Show', command=pm.Callback(self.tShow_BTN_pressed))
        pm.text(label='Rotate')
        self.widgets['rHide_BTN'] = pm.button(label='Hide', command=pm.Callback(self.rHide_BTN_pressed))        
        self.widgets['rShow_BTN'] = pm.button(label='Show', command=pm.Callback(self.rShow_BTN_pressed))
        h.redistribute(1,1,1,1,1,1)

        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.text(label='Scale')
        self.widgets['sHide_BTN'] = pm.button(label='Hide', command=pm.Callback(self.sHide_BTN_pressed))        
        self.widgets['sShow_BTN'] = pm.button(label='Show', command=pm.Callback(self.sShow_BTN_pressed))
        pm.text(label='Visibility')
        self.widgets['vHide_BTN'] = pm.button(label='Hide', command=pm.Callback(self.vHide_BTN_pressed))        
        self.widgets['vShow_BTN'] = pm.button(label='Show', command=pm.Callback(self.vShow_BTN_pressed))
        h.redistribute(1,1,1,1,1,1)        

        #------------------------------------------------------------ Separator
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.separator(style='out')
        pm.text(label=' Pivot Offset Control')
        pm.separator(style='out')
        h.redistribute(1,1,1)     
        
        #---------------------------------------------------------- Pivot Offset
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        self.widgets['pivotOffset_IFG'] = pm.intFieldGrp( numberOfFields=1, 
                                                          value1=1, 
                                                          label='Control Size :', 
                                                          cw2=[100, 50], 
                                                          adj=2)        
        self.widgets['add_pivotOffset_BTN'] = pm.button( label = 'Add', command=pm.Callback(self.add_pivotOffset_BTN_pressed))
        self.widgets['remove_pivotOffset_BTN'] = pm.button( label = 'Remove', command=pm.Callback(self.remove_pivotOffset_BTN_pressed))
        h.redistribute(3,1,1)
        
        #------------------------------------------------------------ Separator
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        pm.separator(style='out')
        pm.text(label=' Text Shape')
        pm.separator(style='out')
        h.redistribute(1,1,1)     
                
        #------------------------------------------------------------ Text Shape
        pm.setParent(self.widgets['top_level_column'])
        h = pm.horizontalLayout()
        self.widgets['textShape_TFG'] = pm.textFieldGrp(  label='Text :', 
                                                          cw2=[100, 50], 
                                                          adj=2)        
        self.widgets['add_textShape_BTN'] = pm.button( label = 'Add', command=pm.Callback(self.add_textShape_BTN_pressed))
        h.redistribute(3,2)        
        
        #=======================================================================
        # Redistribute
        #=======================================================================
        self.widgets['top_level_layout'].redistribute()