Ejemplo n.º 1
0
def get_maya_colors(index=None, css=False):
    """
    Returns the list of all custom Maya colors
    or a single color by index.
    This uses a mid gray as the 0-index color.
    :param index: int. Optionnal, default None. The index to get.
    :param css: bool. Optionnal, default False. Return a CSS string.
    :return: List of tuples or tuple.
    """

    # Stylesheet formatting
    stylesheet_pattern = "QWidget{{background:rgb({0},{1},{2})}}"

    # Get actual color
    if index is None:
        color = [Vars.NO_COLOR_GRAY]
        color += [cmds.colorIndex(i, q=1) for i in xrange(1, 32)]
    elif index:
        color = tuple(cmds.colorIndex(index, q=1))
    else:
        color = Vars.NO_COLOR_GRAY

    # Return stylesheet ?
    if css and len(color) == 3:
        c = tuple([x*255 for x in color])
        return stylesheet_pattern.format(*c)
    elif css:
        colors = tuple([(x*255, y*255, z*255) for x, y, z in color])
        return [stylesheet_pattern.format(*c) for c in colors]
    else:
        return color
Ejemplo n.º 2
0
def ui():
    try:
        cmds.deleteUI(WINDOWNAME, window=True)
    except:
        pass

    cmds.window(WINDOWNAME, title="Display Color Override", rtf=True, sizeable=False)        
    colLayout = cmds.columnLayout(adj=True)
    
    columns = 16
    rows = 2
    cell_width = 17
    cell_height = 17
    color_palette = cmds.palettePort('dmptools_display_color',
                                    dimensions=(columns, rows), 
                                    transparent=0,
                                    width=(columns*cell_width),
                                    height=(rows*cell_width),
                                    topDown=True,
                                    colorEditable=False,
                                    cc=overrideColor)
        
    for index in range(1, 32):
        color_component = cmds.colorIndex(index, q=True)
        cmds.palettePort(color_palette,
                         edit=True,
                         rgbValue=(index, color_component[0], color_component[1], color_component[2]))
        
    cmds.palettePort(color_palette,
                   edit=True,
                   rgbValue=(0, 0.6, 0.6, 0.6))

    cmds.showWindow(WINDOWNAME)
Ejemplo n.º 3
0
	def UI_manipShape_colorSorted( self , name , parent ):

		keys = self.CurveShape.fonctionToColorName.keys()
		keys.sort()

		colorSection = ['neutral' , 'left' , 'center'  , 'right' , 'root'   , 'spectial']
		self.colorkeys         = []
		self.colorkeys        += [ 'None'   , 'red'  , 'yellow'  , 'blue'  , 'green'  , 'purple'  ]
		self.colorkeys        += [ 'white'  , 'red2' , 'yellow2' , 'blue2' , 'green2' , 'purple2' ]
		self.colorkeys        += [ 'white2' , 'red3' , 'yellow3' , 'blue3' , 'green3' , 'purple3' ]
		self.colorkeys        += [ 'white3' , 'red4' , 'yellow4' , 'blue4' , 'green4' , 'purple4' ]
		self.colorkeys        += [ 'white4' , 'red5' , 'yellow4' , 'blue4' , 'green4' , 'purple5' ]

		# w = 240	
		rows      = 5
		columns   = 6
		cellHeigh = 19 
		cellWidth = 40

		
		mc.columnLayout(    name , bgc = [ 0.27 , 0.27 , 0.27 ] , columnAttach = [ 'both' , 0 ] , rowSpacing = 0 , columnWidth = (columns * cellWidth)  , parent = parent )

		rowColumnLayoutName = name + 'text'
		mc.rowColumnLayout( rowColumnLayoutName , nc = columns , columnWidth = [ ( i , cellWidth ) for i in range(1,columns) ]  , p = name )
		for elem in colorSection: mc.text( l = elem , h = 15 , p = rowColumnLayoutName );

		paletteName = name + 'Palette'
		mc.palettePort( paletteName , dim = [ columns , rows  ] , width = (columns * cellWidth)  , height = (rows * cellHeigh) , transparent = 0 , topDown = True , colorEditable = False , setCurCell = 0  , p = name  )	
		mc.palettePort( paletteName , e = True , cc = ( '{}.cmds_changeShapeColorButton("{}")'.format(self.variableNameInGlobal,paletteName) ) )	
		
		for i  in range( 1 , rows*columns ):	
			colorIndex  = self.CurveShape.colorNameToIndex[ self.colorkeys[i] ]
			componentColors = mc.colorIndex( colorIndex , q = True )		
			mc.palettePort(   paletteName ,  e = True ,  rgbValue = [ i , componentColors[0] , componentColors[1] , componentColors[2] ]  )
Ejemplo n.º 4
0
    def UI_manipShape_color(self, name, parent):

        # w = 240
        rows = 2
        columns = 16
        cellHeigh = 19
        cellWidth = 15

        mc.palettePort(name,
                       dim=[columns, rows],
                       width=(columns * cellWidth),
                       height=(rows * cellHeigh),
                       transparent=0,
                       topDown=True,
                       colorEditable=False,
                       setCurCell=0,
                       p=parent)
        mc.palettePort(name,
                       e=True,
                       cc=(self.variableNameInGlobal +
                           '.changeShapeColorButton()'))

        for i in range(1, 32):
            componentColors = mc.colorIndex(i, q=True)
            mc.palettePort(name,
                           e=True,
                           rgbValue=[
                               i, componentColors[0], componentColors[1],
                               componentColors[2]
                           ])

        mc.palettePort(name, e=True, rgbValue=[0, 0.6, 0.6, 0.6])
Ejemplo n.º 5
0
 def __getColors(self):
     # This gets Maya's default indexed RGB palette and
     # maps values into range 0-255
     for i in range(1, 32):
         color = cmds.colorIndex(i, q=True)
         for j, c in enumerate(color):
             color[j] = c * 255
         self.COLORS.append(color)
Ejemplo n.º 6
0
def colorButton(color, callBack) :
    c = QtWidgets.QToolButton()
    pm = QtGui.QPixmap( 32, 32 )
    rgb = m.colorIndex ( color, q=True)
    pm.fill( QtGui.QColor( int( rgb[0] * 255), int(rgb[1] * 255), int(rgb[2] * 255)  ) )
    c.setIcon( QtGui.QIcon( pm ) )
    c.pressed.connect( callBack )
    c.setMinimumSize( QtCore.QSize(16, 16) )
    c.setStyleSheet("margin: 0px")
    return c
Ejemplo n.º 7
0
def get_color(self, node):
    # 描画のオーバーライドの色
    if not cmds.getAttr(node + '.overrideEnabled'):
        return None
    if cmds.getAttr(node + '.overrideRGBColors'):
        _color = list(cmds.getAttr(node + '.overrideColorRGB')[0])
    else:
        color_index = cmds.getAttr(node + '.overrideColor')
        _color = cmds.colorIndex(color_index, q=True)
    _color = [int(_c * 255) for _c in _color]
    return QtGui.QColor(_color[0], _color[1], _color[2])
Ejemplo n.º 8
0
def getColorFromIndex(index):
    """
    Get rgb color from given index

    :param index: Override color index
    :type index: int
    :return: rgb color
    :rtype: list
    """
    if index >= 32:
        mayaWarning("Color index out-of-range (must be less than 32)")
    return mc.colorIndex(int(index), q=True)
Ejemplo n.º 9
0
def getColorFromIndex(index):
    """
    Get rgb color from given index

    :param index: Override color index
    :type index: int
    :return: rgb color
    :rtype: list
    """
    if index >= 32:
        mayaWarning("Color index out-of-range (must be less than 32)")
    return mc.colorIndex(int(index), q=True)
Ejemplo n.º 10
0
def colorIndexList(*args):
    indexColor = []
    indexColor.append([0.35, 0.35, 0.35])

    for x in range(1, 32, 1):
        c = []

        for y in cmds.colorIndex(x, q=True):
            c.append(round(y, 2))

        indexColor.append(c)

    return indexColor
Ejemplo n.º 11
0
def get_nconstraint_color(constraint_shape):
    '''
    smart function who return the nconstraint viewport color.
    It working as a normal transform override color except if color is
    undefined, it returns 25, 25, 125 
    '''
    parent = cmds.listRelatives(constraint_shape, parent=True)[0]

    if not cmds.getAttr(parent + '.overrideEnabled'):
        return 25, 25, 125

    if cmds.getAttr(parent + '.overrideRGBColors'):
        return [
            int(c * 255) for c in cmds.getAttr(parent + '.overrideColorRGB')[0]
        ]

    color_index = cmds.getAttr(parent + '.overrideColor')
    if color_index > 0:
        return [int(c * 255) for c in cmds.colorIndex(color_index, query=True)]
    else:
        return 25, 25, 125
Ejemplo n.º 12
0
def colorOutliner(node, index):
    """
    Drawing outliner overrides selected controls.

    Args:
        node: Transform node or nurbsCurve.
        index: Color index.
    Returns:
        None.
    Raises:
        None.

    """
    rgb = cmds.colorIndex(index, q=True)
    r, g, b = rgb[0], rgb[1], rgb[2]
    if cmds.objectType(node, isType='nurbsCurve'):
        cmds.setAttr(node + '.useOutlinerColor', 1)
        cmds.setAttr(node + '.outlinerColor', r, g, b)
    elif cmds.objectType(node, isType='transform') or cmds.objectType(
            node, isType='joint'):
        cmds.setAttr(node + '.useOutlinerColor', 1)
        cmds.setAttr(node + '.outlinerColor', r, g, b)
Ejemplo n.º 13
0
    def dpColorizeUI(self, *args):
        """ Show a little window to choose the color of the button and the override the guide.
        """
        #Get Maya colors
        #Manually add the "none" color
        colorList = [[0.627, 0.627, 0.627]]
        #WARNING --> color index in maya start to 1
        colorList += [cmds.colorIndex(iColor, q=True) for iColor in range(1,32)]
                            
        # creating colorIndex Window:
        if cmds.window('dpColorIndexWindow', query=True, exists=True):
            cmds.deleteUI('dpColorIndexWindow', window=True)
        colorIndex_winWidth  = 305
        colorIndex_winHeight = 250
        dpColorIndexWin = cmds.window('dpColorIndexWindow', title='Color Index '+DPCO_VERSION, iconName='dpColorIndex', widthHeight=(colorIndex_winWidth, colorIndex_winHeight), menuBar=False, sizeable=False, minimizeButton=False, maximizeButton=False, menuBarVisible=False, titleBar=True)
        # creating layout:
        colorIndexLayout = cmds.gridLayout('colorIndexLayout', numberOfColumns=8, cellWidthHeight=(20,20))

        # creating buttons
        for colorIndex, colorValues in enumerate(colorList):
            cmds.button('indexColor_'+str(colorIndex)+'_BT', label=str(colorIndex), backgroundColor=(colorValues[0], colorValues[1], colorValues[2]), command=partial(self.dpSetColorToSelect, colorIndex), parent=colorIndexLayout)
        # call colorIndex Window:
        cmds.showWindow(dpColorIndexWin)
Ejemplo n.º 14
0
#crossVector = normalizeVector( crossProduct(primaryVector, secondaryVector ) )
#secondaryVector = crossProduct(crossVector, primaryVector)
#otherVector = normalizeVector( crossProduct(primaryVector, secondaryVector ) )

#newMatrix = list(matrixA)

#newMatrix[primaryMatrixSlice] = multiplyVectors(primaryVector, magnitudeOfVector(matrixA[primaryMatrixSlice]) )
#newMatrix[secondaryMatrixSlice] = multiplyVectors(secondaryVector, magnitudeOfVector(matrixA[secondaryMatrixSlice]) )
#newMatrix[otherMatrixSlice] = multiplyVectors(otherVector, magnitudeOfVector(matrixA[otherMatrixSlice]) )

#pymel.xform(a, matrix=newMatrix, worldSpace=True)

_mayaRGB_to_indexDict = {}
for i in range(32):
    if i != 0:
        r, g, b = cmds.colorIndex(i, q=True)
        _mayaRGB_to_indexDict[(r, g, b)] = i


def colorObjects(nodes=None, index=None, color=None):

    # parse args
    if color == None and index:
        color = cmds.colorIndex(index, q=True)

    if index == None and color:
        key = (color[0], color[1], color[2])
        index = _mayaRGB_to_indexDict.get(key)

    if not nodes:
        nodes = pymel.ls(selection=True)
    def display(cls, *args):
        cls.delete()

        main_window = cmds.window(cls.WINDOW_NAME,
                                  title="Jay's Display Colour Override",
                                  rtf=True,
                                  sizeable=False)

        main_layout = cmds.formLayout(parent=main_window)

        rows = 2
        columns = DisplayColourOverride.MAX_OVERRIDE_COLOURS / rows
        width = columns * cls.COLOUR_PALETTE_CELL_WIDTH
        height = rows * cls.COLOUR_PALETTE_CELL_WIDTH

        cls.colour_palette = cmds.palettePort(dimensions=(columns, rows),
                                              transparent=0,
                                              width=width,
                                              height=height,
                                              topDown=True,
                                              colorEditable=False,
                                              parent=main_layout)

        for index in range(1, DisplayColourOverride.MAX_OVERRIDE_COLOURS):
            colour_component = cmds.colorIndex(index, q=True)
            cmds.palettePort(cls.colour_palette,
                             edit=True,
                             rgbValue=(index, colour_component[0],
                                       colour_component[1],
                                       colour_component[2]))

        cmds.palettePort(cls.colour_palette,
                         edit=True,
                         rgbValue=(0, 0.6, 0.6, 0.6))

        # Create the override and default buttons
        override_button = cmds.button(
            label="Override",
            command="DisplayColourOverrideUI.override()",
            parent=main_layout)

        default_button = cmds.button(
            label="Default",
            command="DisplayColourOverrideUI.default()",
            parent=main_layout)

        # Layout the Colour Palette
        cmds.formLayout(main_layout,
                        edit=True,
                        attachForm=(cls.colour_palette, "top",
                                    cls.FORM_OFFSET))

        cmds.formLayout(main_layout,
                        edit=True,
                        attachForm=(cls.colour_palette, "right",
                                    cls.FORM_OFFSET))

        cmds.formLayout(main_layout,
                        edit=True,
                        attachForm=(cls.colour_palette, "left",
                                    cls.FORM_OFFSET))

        # Layout the override and default buttons
        cmds.formLayout(main_layout,
                        edit=True,
                        attachControl=(override_button, "top", cls.FORM_OFFSET,
                                       cls.colour_palette))
        cmds.formLayout(main_layout,
                        edit=True,
                        attachForm=(override_button, "left", cls.FORM_OFFSET))
        cmds.formLayout(main_layout,
                        edit=True,
                        attachPosition=(override_button, "right", 0, 50))

        cmds.formLayout(main_layout,
                        edit=True,
                        attachOppositeControl=(default_button, "top", 0,
                                               override_button))
        cmds.formLayout(main_layout,
                        edit=True,
                        attachControl=(default_button, "left", 0,
                                       override_button))
        cmds.formLayout(main_layout,
                        edit=True,
                        attachForm=(default_button, "right", cls.FORM_OFFSET))

        cmds.showWindow(main_window)
# https://github.com/bboyle/maya-nurbs-control-color-dialog

import maya.cmds as cmds

# get all selected objects
selected = cmds.ls(sl=True)
cmds.setAttr(selected[0] + '.overrideEnabled', True)
# color: 0-31
cmds.setAttr(selected[0] + '.overrideColor', 17) # yellow

# TODO filter list to nurbs?

# nothing selected? exit

# ask for a colour: limited to 0-31 indexed colours
# use the first selected objects color as the default
# colorEditor([hsvValue=[float, float, float]], [mini=boolean], [parent=string], [position=boolean], [result=boolean], [rgbValue=[float, float, float]])

cmds.window()
cmds.frameLayout(labelVisible=False)

# create palette of 32 colours
cmds.palettePort( 'palette', dim=(8, 4))

for i in range(1, 32):
	rgb = cmds.colorIndex(i, q=True)
	cmds.palettePort('palette', edit=True, scc=i)
	cmds.palettePort('palette', edit=True, rgbValue=(i, rgb[0], rgb[1], rgb[2]))

cmds.showWindow()
Ejemplo n.º 17
0
 def cacheIndexedColors(self):
     for i in range(30):
         c = cmds.colorIndex(i + 1, q=True)
         self.ngSkinLayerCmd(indexedColorIndex=(i + 1),
                             indexedColorValue=self.__floatListAsString(c))
Ejemplo n.º 18
0
 def display(cls):
     # delete if a window exists
     cls.delete()
     
     # create window
     main_window = cmds.window(cls.WINDOW_NAME, title="Drawing Color Override", rtf=True, sizeable=False)
     main_layout = cmds.formLayout(parent=main_window)
     
     # window specs
     rows = 4
     columns = DisplayColorOverride.MAX_OVERRIDE_COLORS / rows
     width = columns * cls.COLOR_PALETTE_CELL_WIDTH
     height = rows * cls.COLOR_PALETTE_CELL_WIDTH
     
     # make color pallete, default = transparent = 0, topDown -> use left top as 0 counting to 32
     cls.color_palette = cmds.palettePort(dimensions=(columns, rows),
                                          transparent=0, 
                                          width=width,
                                          height=height,
                                          topDown=True,
                                          colorEditable=False,
                                          parent=main_layout)
     
     # build color palette with the 32 color
     for index in range(1, DisplayColorOverride.MAX_OVERRIDE_COLORS):
         color_component = cmds.colorIndex(index, q=True)
         cmds.palettePort(cls.color_palette,
                          edit=True,
                          rgbValue=(index, color_component[0], color_component[1], color_component[2]))
     
     # make the 0th - the transparent default
     cmds.palettePort(cls.color_palette,
                      edit=True,
                      rgbValue=(0, 0.6, 0.6, 0.6))
     
     # Now, Create the override and default button
     override_button = cmds.button(label="Override", 
                                   command="DisplayColorOverrideUI.override()",
                                   parent=main_layout)
     
     default_button = cmds.button(label="Default", 
                                   command="DisplayColorOverrideUI.default()",
                                   parent=main_layout)
     
     # Create checkbox
     vis_checkbox = cmds.checkBox(label="Visible", 
                                  onCommand="DisplayColorOverrideUI.turn_visibility_on()",
                                  offCommand="DisplayColorOverrideUI.turn_visibility_off()",
                                  parent=main_layout,
                                  value=True)
                      
     # Layout the Color Palette, offset margin
     cmds.formLayout(main_layout, edit=True,
                     attachForm=(cls.color_palette, "top", cls.FORM_OFFSET))
     cmds.formLayout(main_layout, edit=True,
                     attachForm=(cls.color_palette, "right", cls.FORM_OFFSET))
     cmds.formLayout(main_layout, edit=True,
                     attachForm=(cls.color_palette, "left", cls.FORM_OFFSET))
     
     # Layout the override button, attach top to the palette, left to the form, right to the middle
     cmds.formLayout(main_layout, edit=True,
                     attachControl=(override_button, "top", cls.FORM_OFFSET, cls.color_palette))
     cmds.formLayout(main_layout, edit=True,
                     attachForm=(override_button, "left", cls.FORM_OFFSET))
     cmds.formLayout(main_layout, edit=True,
                     attachPosition=(override_button, "right", 0, 50))
     
     # Layout the default button
     cmds.formLayout(main_layout, edit=True,
                     attachOppositeControl=(default_button, "top", 0, override_button))
     cmds.formLayout(main_layout, edit=True,
                     attachControl=(default_button, "left", 0, override_button))
     cmds.formLayout(main_layout, edit=True,
                     attachForm=(default_button, "right", cls.FORM_OFFSET))
     
     # Layout the checkbox
     cmds.formLayout(main_layout, edit=True,
                     attachControl=(vis_checkbox, "top", cls.FORM_OFFSET, override_button))
     cmds.formLayout(main_layout, edit=True,
                     attachForm=(vis_checkbox, "left", cls.FORM_OFFSET))
     cmds.formLayout(main_layout, edit=True,
                     attachForm=(vis_checkbox, "right", cls.FORM_OFFSET))
     
     cmds.showWindow(main_window)
Ejemplo n.º 19
0
    def Tt_Rig_UI():
        WinName = 'Tt_Rig_controller'
        Tt_Rig_Window = cmds.window(WinName,
                                    title='Tt_Rig_controller',
                                    resizeToFitChildren=1,
                                    sizeable=0)
        mainLayout = cmds.columnLayout(adjustableColumn=1, width=300)
        color_palette = None

        cmds.frameLayout(label='Rig_Controller')
        cmds.scrollLayout(childResizable=1, h=250)
        cmds.gridLayout(numberOfColumns=7, cellWidthHeight=(90, 90), width=100)

        cmds.symbolButton(image='Tt_icons/RigButton01.PNG',
                          command=Tt_Rig_cont.Tt_Rig_Button00)
        cmds.symbolButton(image='Tt_icons/RigButton02.PNG',
                          command=Tt_Rig_cont.Tt_Rig_Button01)
        cmds.symbolButton(image='Tt_icons/RigButton03.PNG',
                          command=Tt_Rig_cont.Tt_Rig_Button02)
        cmds.symbolButton(image='Tt_icons/RigButton04.PNG',
                          command=Tt_Rig_cont.Tt_Rig_Button03)
        cmds.symbolButton(image='Tt_icons/RigButton05.PNG',
                          command=Tt_Rig_cont.Tt_Rig_Button04)
        cmds.symbolButton(image='Tt_icons/RigButton06.PNG',
                          command=Tt_Rig_cont.Tt_Rig_Button05)
        cmds.symbolButton(image='Tt_icons/RigButton07.PNG',
                          command=Tt_Rig_cont.Tt_Rig_Button06)
        cmds.symbolButton(image='Tt_icons/RigButton08.PNG',
                          command=Tt_Rig_cont.Tt_Rig_Button07)
        cmds.symbolButton(image='Tt_icons/RigButton09.PNG',
                          command=Tt_Rig_cont.Tt_Rig_Button08)
        cmds.symbolButton(image='Tt_icons/RigButton10.PNG',
                          command=Tt_Rig_cont.Tt_Rig_Button09)
        cmds.symbolButton(image='Tt_icons/RigButton11.PNG',
                          command=Tt_Rig_cont.Tt_Rig_Button10)
        cmds.symbolButton(image='Tt_icons/RigButton12.PNG',
                          command=Tt_Rig_cont.Tt_Rig_Button11)
        cmds.symbolButton(image='Tt_icons/RigButton13.PNG',
                          command=Tt_Rig_cont.Tt_Rig_Button12)
        cmds.symbolButton(image='Tt_icons/RigButton14.PNG',
                          command=Tt_Rig_cont.Tt_Rig_Button13)
        cmds.symbolButton(image='Tt_icons/RigButton15.PNG',
                          command=Tt_Rig_cont.Tt_Rig_Button14)
        cmds.symbolButton(image='Tt_icons/RigButton16.PNG',
                          command=Tt_Rig_cont.Tt_Rig_Button15)
        cmds.symbolButton(image='Tt_icons/RigButton17.PNG',
                          command=Tt_Rig_cont.Tt_Rig_Button16)

        cmds.setParent(mainLayout)
        cmds.frameLayout(label='Scale')
        cmds.floatSliderGrp('ScaleSlider', label=u'Scale', field=True,\
                                 min=0.1, max=30.0, step=0.1, value=1.0)

        cmds.setParent(mainLayout)
        cmds.frameLayout(label='Color')
        columns = 32 / 2
        rows = 2
        cell_width = 40
        cell_height = 40
        color_palette = cmds.palettePort("color_set",
                                         dimensions=(columns, rows),
                                         transparent=0,
                                         width=(columns * cell_width),
                                         height=(rows * cell_width),
                                         topDown=True,
                                         colorEditable=False)

        for index in range(1, 32):
            color_component = cmds.colorIndex(index, q=True)
            cmds.palettePort(color_palette,
                             edit=True,
                             rgbValue=(index, color_component[0],
                                       color_component[1], color_component[2]))

        cmds.palettePort(color_palette, edit=True, rgbValue=(0, 0.6, 0.6, 0.6))

        cmds.setParent(mainLayout)
        cmds.rowColumnLayout(numberOfRows=1)
        Change_Color = cmds.button(label='Change_Color',
                                   w=320,
                                   backgroundColor=[0.7, 0.7, 0.7],
                                   c=Tt_Rig_cont.ChangeColor_Display)
        Defult_Color = cmds.button(label='Defult_Color',
                                   w=320,
                                   c=Tt_Rig_cont.DefultColor_Display)

        cmds.setParent(mainLayout)

        cmds.button(label='SRT_Match(First Sel >>> Second Sel)',
                    c=Tt_Rig_cont.SRT)
        cmds.button(label='Freeze Transformations', c=Tt_Rig_cont.Freeze)
Ejemplo n.º 20
0
    def dpColorizeUI(self, *args):
        """ Show a little window to choose the color of the button and the override the guide.
        """
        #Get Maya colors
        #Manually add the "none" color
        colorList = [[0.627, 0.627, 0.627]]
        #WARNING --> color index in maya start to 1
        colorList += [
            cmds.colorIndex(iColor, q=True) for iColor in range(1, 32)
        ]

        # creating colorOverride Window:
        if cmds.window('dpColorOverrideWindow', query=True, exists=True):
            cmds.deleteUI('dpColorOverrideWindow', window=True)
        colorOverride_winWidth = 170
        colorOverride_winHeight = 115
        dpColorOverrideWin = cmds.window(
            'dpColorOverrideWindow',
            title='Color Override ' + DPCO_VERSION,
            iconName='dpColorOverride',
            widthHeight=(colorOverride_winWidth, colorOverride_winHeight),
            menuBar=False,
            sizeable=True,
            minimizeButton=False,
            maximizeButton=False,
            menuBarVisible=False,
            titleBar=True)

        # creating layout:
        colorTabLayout = cmds.tabLayout('colorTabLayout',
                                        innerMarginWidth=5,
                                        innerMarginHeight=5,
                                        parent=dpColorOverrideWin)

        # Index layout:
        colorIndexLayout = cmds.gridLayout('colorIndexLayout',
                                           numberOfColumns=8,
                                           cellWidthHeight=(20, 20),
                                           parent=colorTabLayout)
        # creating buttons
        for colorIndex, colorValues in enumerate(colorList):
            cmds.button('indexColor_' + str(colorIndex) + '_BT',
                        label=str(colorIndex),
                        backgroundColor=(colorValues[0], colorValues[1],
                                         colorValues[2]),
                        command=partial(self.dpSetColorIndexToSelect,
                                        colorIndex),
                        parent=colorIndexLayout)

        # RGB layout:
        colorRGBLayout = cmds.columnLayout('colorRGBLayout',
                                           adjustableColumn=True,
                                           columnAlign='left',
                                           rowSpacing=10,
                                           parent=colorTabLayout)
        cmds.separator(height=10, style='none', parent=colorRGBLayout)
        self.colorRGBSlider = cmds.colorSliderGrp(
            'colorRGBSlider',
            label='Color',
            columnAlign3=('right', 'left', 'left'),
            columnWidth3=(30, 60, 50),
            columnOffset3=(10, 10, 10),
            rgbValue=(0, 0, 0),
            changeCommand=self.dpSetColorRGBToSelect,
            parent=colorRGBLayout)

        # renaming tabLayouts:
        cmds.tabLayout(colorTabLayout,
                       edit=True,
                       tabLabel=((colorIndexLayout, "Index"), (colorRGBLayout,
                                                               "RGB")))
        # call colorIndex Window:
        cmds.showWindow(dpColorOverrideWin)
Ejemplo n.º 21
0
    def basicModuleLayout(self, *args):
        """ Create a Basic Module Layout.
        """
        # BASIC MODULE LAYOUT:
        self.basicColumn = cmds.rowLayout(numberOfColumns=5,
                                          width=190,
                                          columnWidth5=(30, 20, 80, 20, 35),
                                          adjustableColumn=3,
                                          columnAlign=[
                                              (1, 'left'), (2, 'left'),
                                              (3, 'left'), (4, 'left'),
                                              (5, 'left')
                                          ],
                                          columnAttach=[(1, 'both', 2),
                                                        (2, 'both', 2),
                                                        (3, 'both', 2),
                                                        (4, 'both', 2),
                                                        (5, 'both', 2)],
                                          parent=self.topColumn)
        # create basic module UI:
        self.selectButton = cmds.button(
            label=" ",
            annotation=self.langDic[self.langName]['m004_select'],
            command=partial(self.reCreateEditSelectedModuleLayout, True),
            backgroundColor=(0.5, 0.5, 0.5),
            parent=self.basicColumn)
        self.annotationCheckBox = cmds.checkBox(
            label=" ",
            annotation=self.langDic[self.langName]['m014_annotation'],
            onCommand=partial(self.displayAnnotation, 1),
            offCommand=partial(self.displayAnnotation, 0),
            value=0,
            parent=self.basicColumn)
        self.userName = cmds.textField(
            'userName',
            annotation=self.langDic[self.langName]['m006_customName'],
            text=cmds.getAttr(self.moduleGrp + ".customName"),
            changeCommand=self.editUserName,
            parent=self.basicColumn)
        self.colorButton = cmds.button(
            label=" ",
            annotation=self.langDic[self.langName]['m013_color'],
            command=self.colorizeModuleUI,
            backgroundColor=(0.5, 0.5, 0.5),
            parent=self.basicColumn)
        shapeSizeValue = cmds.getAttr(self.moduleGrp + '.shapeSize')
        self.shapeSizeFF = cmds.floatField(
            'shapeSizeFF',
            annotation=self.langDic[self.langName]['m067_shapeSize'],
            minValue=0.001,
            value=shapeSizeValue,
            precision=2,
            step=0.01,
            changeCommand=self.changeShapeSize,
            parent=self.basicColumn)
        # edit values reading from guide:
        displayAnnotationValue = cmds.getAttr(self.moduleGrp +
                                              '.displayAnnotation')
        cmds.checkBox(self.annotationCheckBox,
                      edit=True,
                      value=displayAnnotationValue)

        # declaring the index color list to override and background color of buttons:
        #Manually add the "none" color
        self.colorList = [[0.627, 0.627, 0.627]]
        #WARNING --> color index in maya start to 1
        self.colorList += [
            cmds.colorIndex(iColor, q=True) for iColor in range(1, 32)
        ]
        '''
        self.colorList = [  [0.627, 0.627, 0.627],
                            [0, 0, 0],
                            [0.247, 0.247, 0.247],
                            [0.498, 0.498, 0.498],
                            [0.608, 0, 0.157],
                            [0, 0.016, 0.373],
                            [0, 0, 1],
                            [0, 0.275, 0.094],
                            [0.145, 0, 0.263],
                            [0.780, 0, 0.78],
                            [0.537, 0.278, 0.2],
                            [0.243, 0.133, 0.122],
                            [0.600, 0.145, 0],
                            [1, 0, 0],
                            [0, 1, 0],
                            [0, 0.255, 0.6],
                            [1, 1, 1],
                            [1, 1, 0],
                            [0.388, 0.863, 1],
                            [0.263, 1, 0.635],
                            [1, 0.686, 0.686],
                            [0.890, 0.675, 0.475],
                            [1, 1, 0.384],
                            [0, 0.6, 0.325],
                            [0.627, 0.412, 0.188],
                            [0.620, 0.627, 0.188],
                            [0.408, 0.627, 0.188],
                            [0.188, 0.627, 0.365],
                            [0.188, 0.627, 0.627],
                            [0.188, 0.404, 0.627],
                            [0.435, 0.188, 0.627],
                            [0.627, 0.188, 0.412] ]
        '''

        # edit current colorIndex:
        currentIndexColor = cmds.getAttr(self.moduleGrp + '.guideColor')
        self.setColorModule(currentIndexColor)
        self.reCreateEditSelectedModuleLayout(self)
Ejemplo n.º 22
0
    def initialize(self):
        # add validators
        self.data['lineedit']['x'].setValidator(
            QtGui.QDoubleValidator(0, 180, 2))
        self.data['lineedit']['y'].setValidator(
            QtGui.QDoubleValidator(0, 180, 2))
        self.data['lineedit']['z'].setValidator(
            QtGui.QDoubleValidator(0, 180, 2))

        self.data['lineedit']['minScale'].setValidator(
            QtGui.QDoubleValidator(1.0, 100, 2))
        self.data['lineedit']['maxScale'].setValidator(
            QtGui.QDoubleValidator(1.0, 100, 2))

        # add buttons - add control curve
        dirs = os.listdir(ctrls.CONTROLS_DIRECTORY)
        col = 6
        row = 0
        count = 0
        self.mapperAddCurve = QtCore.QSignalMapper()
        for fileName in dirs:
            if fileName.endswith('.json'):
                if count == 6:
                    count = 0
                    row += 1
                btn = QtWidgets.QPushButton()
                btn.setToolTip(fileName)
                iconName = fileName.replace('.json', '.png')
                if iconName in dirs:
                    iconPath = os.path.join(ctrls.CONTROLS_DIRECTORY, iconName)
                    btn.setIcon(QtGui.QIcon(iconPath))
                    btn.setIconSize(QtCore.QSize(30, 30))
                self.data['layouts']['addCurve'].addWidget(btn, row, count)
                count += 1
                self.mapperAddCurve.setMapping(btn, fileName)
                btn.clicked.connect(self.mapperAddCurve.map)
        self.mapperAddCurve.mapped['QString'].connect(self.addCtrlShape)

        # add buttons - color
        self.mapperColor = QtCore.QSignalMapper()
        col = 8
        row = 0
        count = 4
        for i in xrange(1, 32):
            if count == col:
                count = 0
                row += 1
            rgb = cmds.colorIndex(i, q=True)
            r, g, b = rgb[0], rgb[1], rgb[2]
            btn = QtWidgets.QPushButton()
            btn.btnIndex = count
            btn.setAutoFillBackground(True)
            values = "{r}, {g}, {b}, {a}".format(r=r * 255,
                                                 g=g * 255,
                                                 b=b * 255,
                                                 a=255)
            btn.setStyleSheet("QPushButton { background-color: rgba(" +
                              values + "); }")
            self.data['layouts']['color'].addWidget(btn, row, count)
            count += 1
            self.mapperColor.setMapping(btn, i)
            btn.clicked.connect(self.mapperColor.map)
        self.mapperColor.mapped['int'].connect(self.colorShapes)
Ejemplo n.º 23
0
cmds.button(label="reset scale",
            enableBackground=True,
            backgroundColor=[0.18, 0.18, 0.18],
            command=resetScale_def,
            height=20,
            width=30)

cmds.button(label="reset all tansformations",
            enableBackground=True,
            backgroundColor=[0.18, 0.18, 0.18],
            command=resetTransform_def)

# transforms ---------------

#controller colors ----------------

cmds.setParent(diUi["lays"]["grid"])
for x in range(0, 32):
    if x > 0:
        butt = cmds.button(l=str(x), ebg=False, bgc=cmds.colorIndex(x, q=True))
    else:
        butt = cmds.button(l='/')

    cmds.button(butt, e=True, w=20, c=partial(colorize_shapes, [], x))
#controller colors ----------------
cmds.setParent(diUi["lays"]["name"])
cmds.button(label="Help ?", command=help, w=30, h=20)

cmds.showWindow(diUi["window"]["main"])
#MAIN WINDOW -------------------------------------------------------
#UI with help from Sacha Duru
Ejemplo n.º 24
0
    def display(cls):
        '''
        Creates a GUI that can override the drawing color
        of selected objects.
        '''

        # Delete the UI (if it exists)
        cls.delete()

        # Create the window and assign a form layout
        main_window = cmds.window(cls.WINDOW_NAME,
                                  title="Display Color Override",
                                  rtf=True,
                                  sizeable=False)
        main_layout = cmds.formLayout(parent=main_window)

        # Create the palettePort control (2 rows, 16 columns)
        rows = 2
        columns = DisplayColorOverride.MAX_OVERRIDE_COLORS / rows
        width = columns * cls.COLOR_PALETTE_CELL_WIDTH
        height = rows * cls.COLOR_PALETTE_CELL_WIDTH
        cls.color_palette = cmds.palettePort(dimensions=(columns, rows),
                                             transparent=0,
                                             width=width,
                                             height=height,
                                             topDown=True,
                                             colorEditable=False,
                                             parent=main_layout)

        # Set the color for at each index of the palettePort control
        for index in range(1, DisplayColorOverride.MAX_OVERRIDE_COLORS):
            color_component = cmds.colorIndex(index, q=True)
            cmds.palettePort(cls.color_palette,
                             edit=True,
                             rgbValue=(index, color_component[0],
                                       color_component[1], color_component[2]))

        cmds.palettePort(cls.color_palette,
                         edit=True,
                         rgbValue=(0, 0.6, 0.6, 0.6))

        # Create the override and default buttons
        override_button = cmds.button(
            label="Override",
            command="DisplayColorOverrideUi.override()",
            parent=main_layout)

        default_button = cmds.button(
            label="Default",
            command="DisplayColorOverrideUi.default()",
            parent=main_layout)

        # Layout the Color Palette
        cmds.formLayout(main_layout,
                        edit=True,
                        attachForm=(cls.color_palette, "top", cls.FORM_OFFSET))
        cmds.formLayout(main_layout,
                        edit=True,
                        attachForm=(cls.color_palette, "right",
                                    cls.FORM_OFFSET))
        cmds.formLayout(main_layout,
                        edit=True,
                        attachForm=(cls.color_palette, "left",
                                    cls.FORM_OFFSET))

        # Layout the override and default buttons
        cmds.formLayout(main_layout,
                        edit=True,
                        attachControl=(override_button, "top", cls.FORM_OFFSET,
                                       cls.color_palette))
        cmds.formLayout(main_layout,
                        edit=True,
                        attachForm=(override_button, "left", cls.FORM_OFFSET))
        cmds.formLayout(main_layout,
                        edit=True,
                        attachPosition=(override_button, "right", 0, 50))

        cmds.formLayout(main_layout,
                        edit=True,
                        attachOppositeControl=(default_button, "top", 0,
                                               override_button))
        cmds.formLayout(main_layout,
                        edit=True,
                        attachControl=(default_button, "left", 0,
                                       override_button))
        cmds.formLayout(main_layout,
                        edit=True,
                        attachForm=(default_button, "right", cls.FORM_OFFSET))

        # Display the UI
        cmds.showWindow(main_window)
Ejemplo n.º 25
0
    def BuildLayout(self):

        self.window = cmds.window(widthHeight=(400, 300),
                                  title="Master Control Program",
                                  resizeToFitChildren=1)

        # RENAMER SECTION
        cmds.frameLayout(label="Renamer", collapsable=0)
        cmds.columnLayout(rowSpacing=5)
        self.renameField = cmds.textField(placeholderText="Prefix_#_Suffix",
                                          width=200)
        cmds.text(label="Num-Padding:")
        self.numPadding = cmds.intField()
        cmds.button(label="Execute", command=lambda x: self.CheckRenameField())
        cmds.setParent('..')
        cmds.setParent('..')

        # ---------------------------------------------------------------------------------------------- #

        # PLACEMENT RANDOMIZER SECTION
        cmds.frameLayout(label="Random Placer", collapsable=0, height=100)
        cmds.columnLayout(rowSpacing=5)
        cmds.rowLayout(numberOfColumns=4, columnWidth4=(100, 2, 100, 100))
        cmds.text(label="# of Duplicates")
        cmds.separator(style="single")
        cmds.text(label="Min Range")
        cmds.text(label="Max Range")
        cmds.setParent('..')

        cmds.rowLayout(numberOfColumns=4, columnWidth4=(100, 2, 100, 100))
        self.duplicatesField = cmds.intField()
        cmds.separator(style="single")
        self.minRangeField = cmds.floatField()
        self.maxRangeField = cmds.floatField()
        cmds.setParent('..')

        cmds.rowLayout(numberOfColumns=1)
        cmds.button(label="Execute",
                    command=lambda x: self.CheckRandomizerFields())
        cmds.setParent('..')
        cmds.setParent('..')
        cmds.setParent('..')

        # ---------------------------------------------------------------------------------------------- #

        # CONTROL UTILITY SECTION
        cmds.frameLayout(label="Control Parameters", collapsable=1)
        cmds.rowLayout(numberOfColumns=3)

        # Control Shape Selector
        cmds.columnLayout()
        cmds.text(label="DO NOT USE YET")
        self.radio1 = cmds.radioCollection()
        cmds.radioButton(label="Circle")
        cmds.radioButton(label="Star")
        cmds.radioButton(label="Box")
        cmds.setParent('..')

        cmds.separator(style="single", width=50, horizontal=0)

        # Control Color Selector
        cmds.columnLayout()
        # Parameters for making custom color palettes.
        maxOverrideColors = 32
        formOffset = 2
        columns = maxOverrideColors / 2
        rows = 2
        cellWidth = 17
        cellHeight = 17

        cmds.text(label="Select Color")

        # Create a color palette with all of the available override colors.
        MCC.colorPalette = cmds.palettePort("myPallete",
                                            dimensions=(columns, rows),
                                            transparent=0,
                                            width=(columns * cellWidth),
                                            height=(rows * cellHeight),
                                            topDown=1,
                                            colorEditable=0)

        for i in range(1, maxOverrideColors):
            colorComponent = cmds.colorIndex(i, query=1)
            cmds.palettePort(MCC.colorPalette,
                             edit=1,
                             rgbValue=(i, colorComponent[0], colorComponent[1],
                                       colorComponent[2]))

        cmds.palettePort(MCC.colorPalette, edit=1, rgbValue=(0, 0.6, 0.6, 0.6))
        cmds.setParent('..')  # columnLayout
        cmds.setParent('..')  # rowLayout
        cmds.setParent('..')  # frameLayout

        ##########################################################################

        cmds.frameLayout(label="Execute", collapsable=0)
        cmds.rowLayout(numberOfColumns=3)
        cmds.button(label="Create Circle Controls",
                    command=lambda x: MCC.CreateCircleControls())
        cmds.button(label="Create Square Controls",
                    command=lambda x: MCC.CreateSquareControls())
        cmds.button(label="Color Controls", command=lambda x: MCC.Colorizer())
        cmds.setParent('..')
        cmds.setParent('..')

        # ---------------------------------------------------------------------------------------------- #

        # CENTER LOCATOR SECTION
        cmds.frameLayout(label="Center Locator")
        cmds.columnLayout(adjustableColumn=True)
        cmds.button(label='Create Locator (Bounding Box)',
                    c=lambda x: LocTool.CreateLoc(1))
        cmds.button(label='Create Locator (Pivot)',
                    c=lambda x: LocTool.CreateLoc(2))
        cmds.setParent('..')
        cmds.setParent('..')

        # ---------------------------------------------------------------------------------------------- #

        # FK JOINT CREATOR SECTION
        cmds.frameLayout(label="Joint Creator")
        cmds.columnLayout(adjustableColumn=True)
        cmds.button(label='Create FK Joint Chain',
                    c=lambda x: JointCreator.ChainBuilder())
        cmds.setParent('..')
        cmds.setParent('..')

        cmds.showWindow(self.window)
Ejemplo n.º 26
0
def colorObjects(nodes=None, index=None, color=None):

    # parse args
    if color == None and index:
        color = cmds.colorIndex(index, q=True)

    if index == None and color:
        key = (color[0], color[1], color[2])
        index = _mayaRGB_to_indexDict.get(key)

    if not nodes:
        nodes = pymel.ls(selection=True)

    if not isinstance(nodes, list):
        nodes = [nodes]

    nodes = ka_pymel.getAsPyNodes(nodes)

    # Find nodes to color
    nodesToColor = []
    for node in nodes:
        shapes = node.getShapes()
        if shapes:
            for shape in shapes:
                nodesToColor.append(shape)

        else:
            nodesToColor.append(node)

    # Color Nodes
    for node in nodesToColor:
        nodeType = node.nodeType()

        if nodeType == 'rigControlsNode':
            node.lineColor.unlock()
            node.lineColorR.unlock()
            node.lineColorG.unlock()
            node.lineColorB.unlock()
            node.lineColor.set(color[0], color[1], color[2])

        else:
            try:
                node.overrideEnabled.unlock()
                node.overrideEnabled.set(1)
            except:
                printError()

            try:

                if index != None:
                    # set the new 2015 attribute
                    try:
                        node.overrideRGBColors.unlock()
                        if node.overrideRGBColors.isConnected():
                            node.overrideRGBColors.disconnect()
                        node.overrideRGBColors.set(0)

                    except:
                        printError()

                    if node.overrideColor.isConnected():
                        node.overrideColor.disconnect()

                    node.overrideColor.unlock()
                    node.overrideColor.set(index)

                elif color:
                    # set the new 2015 attribute
                    try:
                        node.overrideRGBColors.unlock()
                        if node.overrideRGBColors.isConnected():
                            node.overrideRGBColors.disconnect()
                        node.overrideRGBColors.set(1)

                    except:
                        printError()

                    if node.overrideColorRGB.isConnected():
                        node.overrideColorRGB.disconnect()

                    node.overrideColorRGB.unlock()
                    node.overrideColorRGB.set(color)

            except:
                printError()
Ejemplo n.º 27
0
    def basicModuleLayout(self, *args):
        """ Create a Basic Module Layout.
        """
        # BASIC MODULE LAYOUT:
        self.basicColumn = cmds.rowLayout(numberOfColumns=5, width=190, columnWidth5=(30, 20, 80, 20, 35), adjustableColumn=3, columnAlign=[(1, 'left'), (2, 'left'), (3, 'left'), (4, 'left'), (5, 'left')], columnAttach=[(1, 'both', 2), (2, 'both', 2), (3, 'both', 2), (4, 'both', 2), (5, 'both', 2)], parent=self.topColumn)
        # create basic module UI:
        self.selectButton = cmds.button(label=" ", annotation=self.langDic[self.langName]['m004_select'], command=partial(self.reCreateEditSelectedModuleLayout, True), backgroundColor=(0.5, 0.5, 0.5), parent=self.basicColumn)
        self.annotationCheckBox = cmds.checkBox(label=" ", annotation=self.langDic[self.langName]['m014_annotation'], onCommand=partial(self.displayAnnotation, 1), offCommand=partial(self.displayAnnotation, 0), value=0, parent=self.basicColumn)
        self.userName = cmds.textField('userName', annotation=self.langDic[self.langName]['m006_customName'], text=cmds.getAttr(self.moduleGrp+".customName"), changeCommand=self.editUserName, parent=self.basicColumn)
        self.colorButton = cmds.button(label=" ", annotation=self.langDic[self.langName]['m013_color'], command=self.colorizeModuleUI, backgroundColor=(0.5, 0.5, 0.5), parent=self.basicColumn)
        shapeSizeValue = cmds.getAttr(self.moduleGrp+'.shapeSize')
        self.shapeSizeFF = cmds.floatField('shapeSizeFF', annotation=self.langDic[self.langName]['m067_shapeSize'], minValue=0.001, value=shapeSizeValue, precision=2, step=0.01, changeCommand=self.changeShapeSize, parent=self.basicColumn)
        # edit values reading from guide:
        displayAnnotationValue = cmds.getAttr(self.moduleGrp+'.displayAnnotation')
        cmds.checkBox(self.annotationCheckBox, edit=True, value=displayAnnotationValue)
        
        # declaring the index color list to override and background color of buttons:
         #Manually add the "none" color
        colorList = [[0.627, 0.627, 0.627]]
        #WARNING --> color index in maya start to 1
        colorList += [cmds.colorIndex(iColor, q=True) for iColor in range(1,32)]

        '''
        self.colorList = [  [0.627, 0.627, 0.627],
                            [0, 0, 0],
                            [0.247, 0.247, 0.247],
                            [0.498, 0.498, 0.498],
                            [0.608, 0, 0.157],
                            [0, 0.016, 0.373],
                            [0, 0, 1],
                            [0, 0.275, 0.094],
                            [0.145, 0, 0.263],
                            [0.780, 0, 0.78],
                            [0.537, 0.278, 0.2],
                            [0.243, 0.133, 0.122],
                            [0.600, 0.145, 0],
                            [1, 0, 0],
                            [0, 1, 0],
                            [0, 0.255, 0.6],
                            [1, 1, 1],
                            [1, 1, 0],
                            [0.388, 0.863, 1],
                            [0.263, 1, 0.635],
                            [1, 0.686, 0.686],
                            [0.890, 0.675, 0.475],
                            [1, 1, 0.384],
                            [0, 0.6, 0.325],
                            [0.627, 0.412, 0.188],
                            [0.620, 0.627, 0.188],
                            [0.408, 0.627, 0.188],
                            [0.188, 0.627, 0.365],
                            [0.188, 0.627, 0.627],
                            [0.188, 0.404, 0.627],
                            [0.435, 0.188, 0.627],
                            [0.627, 0.188, 0.412] ]
        '''
        
        # edit current colorIndex:
        currentIndexColor = cmds.getAttr(self.moduleGrp+'.guideColor')
        self.setColorModule(currentIndexColor)
        self.reCreateEditSelectedModuleLayout(self)
Ejemplo n.º 28
0
 def display(cls):
     '''
     Classmethod to display UI
     '''
     cls.delete()
     
     main_window = cmds.window(cls.WINDOW_NAME, title='JC_DisplayColorOverride', rtf=1, sizeable=False)
     main_layout = cmds.formLayout(parent=main_window)
     
     rows = 2
     columns = DisplayColorOverride.MAX_OVERRIDE_COLORS / rows
     width = columns * cls.COLOR_PALETTE_CELL_WIDTH
     height = rows * cls.COLOR_PALETTE_CELL_WIDTH
     cls.color_palette = cmds.palettePort(dimensions = (columns, rows),
                                          transparent = 0, 
                                          width = width,
                                          height = height,
                                          topDown = True,
                                          colorEditable = False,
                                          parent = main_layout);
     
     for index in range(1, DisplayColorOverride.MAX_OVERRIDE_COLORS):
         color_component = cmds.colorIndex(index, q=True)
         cmds.palettePort(cls.color_palette, edit=True,
                          rgbValue=(index, color_component[0], color_component[1], color_component[2]))
         
         cmds.palettePort(cls.color_palette, e=True, rgbValue=(0, 0.6, 0.6, 0.6), r=True)
         
         # Create override and default buttons
         override_button = cmds.button(l='Override', 
                                       command = 'DisplayColorOverrideUI.override()',
                                       parent = main_layout)
         
         default_button = cmds.button(l='Default',
                                      command = 'DisplayColorOverrideUI.default()',
                                      parent = main_layout)
         
         # Layout out the Color Palette
         cmds.formLayout(main_layout, e=True,
                         attachForm=(cls.color_palette, 'top', cls.FORM_OFFSET))
         
         cmds.formLayout(main_layout, e=True,
                         attachForm=(cls.color_palette, 'right', cls.FORM_OFFSET))
         
         cmds.formLayout(main_layout, e=True,
                         attachForm=(cls.color_palette, 'left', cls.FORM_OFFSET))
         
         # Layout the override and default buttons
         cmds.formLayout(main_layout, e=True,
                         attachControl = (override_button, 'top', cls.FORM_OFFSET, cls.color_palette))
         cmds.formLayout(main_layout, e=True,
                         attachForm = (override_button, 'left', cls.FORM_OFFSET))
         cmds.formLayout(main_layout, e=True,
                         attachPosition = (override_button, 'right', 5, 50))
         
         cmds.formLayout(main_layout, e=True,
                         attachOppositeControl = (default_button, 'top', 0, override_button))
         cmds.formLayout(main_layout, e=True,
                         attachControl = (default_button, 'left', 0, override_button))
         cmds.formLayout(main_layout, e=True,
                         attachForm = (default_button, 'right', cls.FORM_OFFSET))
         
                         
         cmds.showWindow(main_window)                
Ejemplo n.º 29
0
    def display():
        DisplayColorOverrideUi.delete()
        
        main_window = cmds.window(DisplayColorOverrideUi.WINDOW_NAME, title="Display Color Override", rtf=True, sizeable=False)        
        main_layout = cmds.formLayout(parent=main_window)

        columns = DisplayColorOverride.MAX_OVERRIDE_COLORS / 2
        rows = 2
        cell_width = 17
        cell_height = 17
        DisplayColorOverrideUi.color_palette = cmds.palettePort(dimensions=(columns, rows), 
                                                                transparent=0,
                                                                width=(columns*cell_width),
                                                                height=(rows*cell_width),
                                                                topDown=True,
                                                                colorEditable=False);
        
        for index in range(1, DisplayColorOverride.MAX_OVERRIDE_COLORS):
            color_component = cmds.colorIndex(index, q=True)
            cmds.palettePort(DisplayColorOverrideUi.color_palette,
                             edit=True,
                             rgbValue=(index, color_component[0], color_component[1], color_component[2]))
            
        cmds.palettePort(DisplayColorOverrideUi.color_palette,
                       edit=True,
                       rgbValue=(0, 0.6, 0.6, 0.6))
        
        
        
        # Create the Override and Default buttons
        override_button = cmds.button(label="Override",
                                      command="DisplayColorOverrideUi.override()",
                                      parent=main_layout)
                                    
        default_button = cmds.button(label="Default",
                                     command="DisplayColorOverrideUi.default()",
                                     parent=main_layout)
        

                
        # Layout the Color Palette
        cmds.formLayout(main_layout, edit=True, 
                        attachForm=(DisplayColorOverrideUi.color_palette, "top", DisplayColorOverrideUi.FORM_OFFSET));
        cmds.formLayout(main_layout, edit=True, 
                        attachForm=(DisplayColorOverrideUi.color_palette, "left", DisplayColorOverrideUi.FORM_OFFSET));
        cmds.formLayout(main_layout, edit=True, 
                        attachForm=(DisplayColorOverrideUi.color_palette, "right", DisplayColorOverrideUi.FORM_OFFSET));        
        
        # Layout the Override and Default buttons
        cmds.formLayout(main_layout, edit=True, 
                        attachControl=(override_button, "top", DisplayColorOverrideUi.FORM_OFFSET, DisplayColorOverrideUi.color_palette))        
        cmds.formLayout(main_layout, edit=True, 
                        attachForm=(override_button, "left", DisplayColorOverrideUi.FORM_OFFSET))
        cmds.formLayout(main_layout, edit=True, 
                        attachPosition=(override_button, "right", 0, 50))
        
        cmds.formLayout(main_layout, edit=True, 
                        attachOppositeControl=(default_button, "top", 0, override_button))
        cmds.formLayout(main_layout, edit=True, 
                        attachControl=(default_button, "left", 0, override_button))
        cmds.formLayout(main_layout, edit=True, 
                        attachForm=(default_button, "right", DisplayColorOverrideUi.FORM_OFFSET))
        
        cmds.showWindow(main_window)
    def ControlUI(self):
        self.window = cmds.window(widthHeight=(500, 200),
                                  title="Master Control Utility")

        cmds.frameLayout(label="Control Parameters", collapsable=1)
        cmds.rowLayout(numberOfColumns=3)

        # Control Shape Selector
        cmds.columnLayout()
        cmds.text(label="DO NOT USE YET")
        self.radio1 = cmds.radioCollection()
        cmds.radioButton(label="Circle")
        cmds.radioButton(label="Star")
        cmds.radioButton(label="Box")
        cmds.setParent('..')

        cmds.separator(style="single", width=50, horizontal=0)

        # Control Color Selector
        cmds.columnLayout()
        # Parameters for making custom color palettes.
        maxOverrideColors = 32
        formOffset = 2
        columns = maxOverrideColors / 2
        rows = 2
        cellWidth = 17
        cellHeight = 17

        cmds.text(label="Select Color")

        # Create a color palette with all of the available override colors.
        self.colorPalette = cmds.palettePort("myPallete",
                                             dimensions=(columns, rows),
                                             transparent=0,
                                             width=(columns * cellWidth),
                                             height=(rows * cellHeight),
                                             topDown=1,
                                             colorEditable=0)

        for i in range(1, maxOverrideColors):
            colorComponent = cmds.colorIndex(i, query=1)
            cmds.palettePort(self.colorPalette,
                             edit=1,
                             rgbValue=(i, colorComponent[0], colorComponent[1],
                                       colorComponent[2]))

        cmds.palettePort(self.colorPalette,
                         edit=1,
                         rgbValue=(0, 0.6, 0.6, 0.6))
        cmds.setParent('..')  #columnLayout
        cmds.setParent('..')  #rowLayout
        cmds.setParent('..')  #frameLayout

        #######################################################################################

        cmds.frameLayout(label="Execute", collapsable=0)
        cmds.rowLayout(numberOfColumns=3)
        cmds.button(label="Create Circle Controls",
                    command=lambda x: self.CreateCircleControls())
        cmds.button(label="Create Square Controls",
                    command=lambda x: self.CreateSquareControls())
        cmds.button(label="Color Controls", command=lambda x: self.Colorizer())
        cmds.setParent('..')
        cmds.setParent('..')

        cmds.showWindow(self.window)
Ejemplo n.º 31
0
    def display():
        DisplayColorOverrideUi.delete()
        
        main_window = cmds.window(DisplayColorOverrideUi.WINDOW_NAME, title="Display Color Override", rtf=True, sizeable=False)        
        main_layout = cmds.formLayout(parent=main_window)

        columns = DisplayColorOverride.MAX_OVERRIDE_COLORS / 2
        rows = 2
        cell_width = 17
        cell_height = 17
        DisplayColorOverrideUi.color_palette = cmds.palettePort(dimensions=(columns, rows), 
                                                                transparent=0,
                                                                width=(columns*cell_width),
                                                                height=(rows*cell_width),
                                                                topDown=True,
                                                                colorEditable=False);
        
        for index in range(1, DisplayColorOverride.MAX_OVERRIDE_COLORS):
            color_component = cmds.colorIndex(index, q=True)
            cmds.palettePort(DisplayColorOverrideUi.color_palette,
                             edit=True,
                             rgbValue=(index, color_component[0], color_component[1], color_component[2]))
            
        cmds.palettePort(DisplayColorOverrideUi.color_palette,
                       edit=True,
                       rgbValue=(0, 0.6, 0.6, 0.6))
        
        
        
        # Create the Override and Default buttons
        override_button = cmds.button(label="Override",
                                      command="DisplayColorOverrideUi.override()",
                                      parent=main_layout)
                                    
        default_button = cmds.button(label="Default",
                                     command="DisplayColorOverrideUi.default()",
                                     parent=main_layout)
        

                
        # Layout the Color Palette
        cmds.formLayout(main_layout, edit=True, 
                        attachForm=(DisplayColorOverrideUi.color_palette, "top", DisplayColorOverrideUi.FORM_OFFSET));
        cmds.formLayout(main_layout, edit=True, 
                        attachForm=(DisplayColorOverrideUi.color_palette, "left", DisplayColorOverrideUi.FORM_OFFSET));
        cmds.formLayout(main_layout, edit=True, 
                        attachForm=(DisplayColorOverrideUi.color_palette, "right", DisplayColorOverrideUi.FORM_OFFSET));        
        
        # Layout the Override and Default buttons
        cmds.formLayout(main_layout, edit=True, 
                        attachControl=(override_button, "top", DisplayColorOverrideUi.FORM_OFFSET, DisplayColorOverrideUi.color_palette))        
        cmds.formLayout(main_layout, edit=True, 
                        attachForm=(override_button, "left", DisplayColorOverrideUi.FORM_OFFSET))
        cmds.formLayout(main_layout, edit=True, 
                        attachPosition=(override_button, "right", 0, 50))
        
        cmds.formLayout(main_layout, edit=True, 
                        attachOppositeControl=(default_button, "top", 0, override_button))
        cmds.formLayout(main_layout, edit=True, 
                        attachControl=(default_button, "left", 0, override_button))
        cmds.formLayout(main_layout, edit=True, 
                        attachForm=(default_button, "right", DisplayColorOverrideUi.FORM_OFFSET))
        
        cmds.showWindow(main_window)