示例#1
0
 def __init__(self):
    
     self.list_emitter_delete = []
     if cmds.window('main_random_win',q=1,ex=1):
         cmds.deleteUI('main_random_win')
     cmds.window('main_random_win',menuBar=True,t='random_plan    ---GCX',w=300,h=300,s=1)
     cmds.menu(l='help',tearOff=True)
     self.main_lay = cmds.columnLayout(adj=1)
     cmds.separator(style='in' )
     self.title_lay = cmds.rowLayout(p=self.main_lay,numberOfColumns=5,vis=0)
     cmds.button(l='help',vis=0)
     cmds.text(l='    ')
     self.close_emitter_btn = cmds.button(l='CloseEmitter',vis=1,c=partial(self._delete_emitter),ann='清除发射器(一般用不到)')
     cmds.text(l='    ')
     self.ShowNewObjectList = cmds.button(l='ShowNewObjectList',c=partial(self._hide_show_new_list,1),vis=1,ann='显示新创建物体列表')
     cmds.rowLayout(p=self.main_lay,numberOfColumns=3)
     cmds.text(l=' Plan:',ann='地面')
     self.plan_text = cmds.textField(w=200,ed=0,ann='放入需要产生随机点的地面')
     cmds.button(l='SelectPlan', c=partial(self._sel_plan),ann='添加地面')
     scroll_layout = cmds.rowLayout(p=self.main_lay,numberOfColumns = 3)
     cmds.text(l=' OBJ: ',ann='添加的物体列表')
     self.obj_list = cmds.textScrollList(w=200,ann='放入需要进行随机的模型')
     cmds.columnLayout(p=scroll_layout)
     cmds.button(l='+',w=30,c=partial(self._add_obj),ann='添加需要进行随机的模型')
     cmds.text(l='')
     cmds.button(l='-',w=30,c=partial(self._remove_obj),ann='清除列表里选择的模型')
     cmds.text(l='')
     cmds.button(l='clear',w=30, c=partial(self._remove_all),ann='清除列表里所有的模型')
     
     cmds.text(p=self.main_lay,l='')
     self.trans_item_ui = XYZItem(0,0,0,name='Translate:',string_name='位移属性',parent=self.main_lay)
     cmds.text(p=self.main_lay,l='')
     self.rotate_item_ui = XYZItem(0,360,0,name='Rotate:   ',string_name='旋转属性',parent=self.main_lay)
     cmds.text(p=self.main_lay,l='')
     self.scale_item_ui = XYZItem(0,0,0,name='Scale:      ',string_name='缩放属性',parent=self.main_lay)
     cmds.text(p=self.main_lay,l='')
     
     cmds.rowLayout(p=self.main_lay,numberOfColumns=2)
     self.point_number = cmds.intSliderGrp(l='PointNumber:',field=True,cw3=[73,80,130],minValue=2, 
                         maxValue=999, fieldMinValue=0, 
                         fieldMaxValue=99999, value=200,
                         ann='输入需要随机产生的数量 ')
     cmds.button(p=self.main_lay,l='RandomPoint',w=295,c=partial(self._random_point),
                                                 ann='点击在选择的面上随机复制列表里的模型')
     
     self.list_new_obj = cmds.rowLayout(p=self.main_lay,numberOfColumns=3,vis=0)
     cmds.text(l='New\nObject:')
     self.new_obj_list = cmds.textScrollList(w=200,ann='新创建模型列表')
     cmds.columnLayout(p=self.list_new_obj)
     cmds.button(l='Hide',c=partial(self._hide_show_new_list,0),ann='隐藏新创建物体列表')
     cmds.text(l='')
     cmds.button(l='Select\n new \n object', c=partial(self._random_new_obj),ann='选择列表里的模型')
     
     cmds.button(p=self.main_lay,l='test',c=partial(self.test),vis=0)
     self.progress = cmds.progressBar(p=self.main_lay,w=300,vis=0)
     cmds.helpLine(p=self.main_lay,w=300,bgc=[0.1,0.1,0.1])
     cmds.showWindow()
示例#2
0
    def __exit__(self, *args):
        '''
        Finalize the UI
        '''
        
        mc.setParent(self.form)

        frame = mc.frameLayout(labelVisible=False)
        mc.helpLine()
        
        mc.formLayout( self.form, edit=True,
                     attachForm=((self.column, 'top', 0), (self.column, 'left', 0),
                                 (self.column, 'right', 0), (frame, 'left', 0),
                                 (frame, 'bottom', 0), (frame, 'right', 0)),
                     attachNone=((self.column, 'bottom'), (frame, 'top')) )

        mc.showWindow(self.name)
        mc.window(self.name, edit=True, width=self.width, height=self.height)
示例#3
0
文件: ui.py 项目: jonntd/dmptools
 def helpLine(self):
     """bottom interactive helpline"""
     # form that contains the framelayout
     form = cmds.formLayout('mtn_helplineForm')
     # framelayout that contains the helpline
     frame = cmds.frameLayout('mtn_helplineFrameLayout',
                         borderVisible=False,
                         labelVisible=False,
                         h=20)
     # create helpline
     cmds.helpLine('mtn_helpline', h=10)
     cmds.setParent('..')
     # attach the stuff
     cmds.formLayout(form,
                     edit=True,
                     attachForm=[
                         (frame, 'left', 0),
                         (frame, 'right', 0),
                         (frame, 'top', 0),
                         (frame, 'bottom', 0)
                         ])
     return form
示例#4
0
                    command=boolenInterPush,
                    image1='polyBooleansIntersection.xpm',
                    annotation='ver opciones de BooleanIntersection',
                    p=elementosBoo)

# tercer sub elemento de ventana
elementosRe = cmds.rowLayout(numberOfColumns=2, p=columnMain)
cmds.button(label="Re-Mesh",
            height=50,
            width=134,
            command=reMeshPush,
            annotation='Genera nueva geometria en Triangulos',
            p=elementosRe)
cmds.separator(p=columnMain)
cmds.button(label="Re-Topo",
            height=50,
            width=134,
            command=reTopoPush,
            annotation='Regenera la topologia en Quads',
            p=elementosRe)
cmds.separator(p=columnMain)

# cuarto sub elemento de ventana
cmds.button(label="Borrar Historial",
            width=272,
            command=borrarHistPush,
            annotation='elimina el historial del elemento',
            p=columnMain)
cmds.helpLine(width=272, p=columnMain)

cmds.showWindow()
示例#5
0
def createUI():
    # Check to see if our window exists
    if cmds.window( "myWindow", exists = True ):
        cmds.deleteUI( "myWindow" )

    # Create our main window
    window = cmds.window( "myWindow", title="L-System Interpreter", s=False, w=450, h=650, mnb=False, mxb=False )
    mainLayout = cmds.columnLayout( w=450, h=650 )
    import os
    pathVar = os.path.dirname(__file__) # This stores the current working directory
    imagePath = pathVar+"/banner.png" # I designed a nice header for it
    cmds.image( w=450, h=160, image=imagePath )

    #--- MAIN FRAME LAYOUT ---#
    mainFrame = cmds.frameLayout( l="L-System String Operations", lv=False, cll=False, cl=True, mw=10, mh=10 )

    #////////////////////////////////////////INSTRUCTIONS//AND//PRESETS////////////////////////////////////////////////////#
    def displayInstructions(*pArgs):
        """Shows in an independent window a list of instructions for the user to set things up quickly"""
        if cmds.window( "instructions_window", exists=True ):
            cmds.deleteUI( "instructions_window" )
        instructions_window = cmds.window( "instructions_window", title="Instructions", s=False, mnb=False, mxb=False )
        instructionsLayout = cmds.frameLayout( l="Instructions", collapsable=False, cl=False, mw = 10, mh=10 )
        cmds.rowColumnLayout( nc=3, cw=[(1,20),(2,480),(3,20)], cal=[(2,"left")], parent=instructionsLayout )
        cmds.separator( st="none" )
        cmds.text( l="1. Write an axiom (or initial word), depth and rules. If you don't know what it is put the mouse over the parameter and read the help line.\n2. Click Generate String. Then you will see the result in the text field below, this is just mere text. Now the string needs to be interpreted.\n3. Set all the 'Geometric Interpretation' attributes (Angle, Segment Length...). Remember to put the mouse over it if your are confused.\n4. Click Create Geometry. You will see the result in your scene. If you want to clean the last plant\n\tclick Clean Plant. If you click Create Geometry again you will get another plant.\n6. Always remember to pay attention to the help line and warnings field." )
        cmds.separator( st="none" )
        cmds.separator( st="none" )
        cmds.text( l="\nThis is the meaning for each character you enter in the rules section:" )
        cmds.separator( st="none" )
        cmds.separator( st="none" )
        cmds.text( l="""        
        F    Move forward
        f    Move forward
        L    Leaf
        B    Blossom
        +    Rotate +X (yaw right)
        -    Rotate -X (yaw left)
        ^    Rotate +Y (roll right)
        &    Rotate -Y (roll left)
        <    Rotate +Z (pitch down)
        >    Rotate -Z (pitch up)
        *    Turtle rotates 180 (as it was facing backwards)
        [    Push current turtle state on the stack
        ]    Pop the current turtle state from the stack""" )
        cmds.showWindow( instructions_window )
    cmds.rowColumnLayout( numberOfColumns=4, cal=[(2,"left")], columnWidth=[(1,5),(2,320),(3,100),(4,5)], parent=mainFrame )
    cmds.separator( st="none" )
    cmds.text( l="You might feel a bit lost, I recommend you to read a quick guide" )
    cmds.button( l="Instructions", en=True, command=displayInstructions )
    cmds.separator( st="none" )

    cmds.rowColumnLayout( nc=7, cw=[(1,103),(2,5),(3,103),(4,5),(5,102),(6,5),(7,102)], parent=mainFrame )

    def preset1Action(*args):
        import presets
        set1 = presets.preset1()
    cmds.button( l="Preset1", c=preset1Action, ann="Loads Preset #1." )
    cmds.separator( st="none" )

    def preset2Action(*args):
        import presets
        set2 = presets.preset2()
    cmds.button( l="Preset2", c=preset2Action, ann="Loads Preset #2." )
    cmds.separator( st="none" )

    def preset3Action(*args):
        import presets
        set3 = presets.preset3()
    cmds.button( l="Preset3", c=preset3Action, ann="Loads Preset #3." )
    cmds.separator( st="none" )

    def preset4Action(*args):
        import presets
        set4 = presets.preset4()
    cmds.button( l="Preset4", c=preset4Action, ann="Loads Preset #4." )


    # !!!!!!!!!!!!!!!!!!!!!!! TO DO --> PRESETS

    cmds.rowColumnLayout( numberOfColumns=1, columnWidth=[(1, 425)], parent=mainFrame )
    cmds.separator( h=1, st="none" )

    #////////////////////////////////////////////////RULES//TAB////////////////////////////////////////////////////////////#
    rulesLayout = cmds.frameLayout( label = "Rules", collapsable=True, cl=False, mw = 10, mh = 10, w=425 )

    #--- Axiom ---#
    cmds.rowColumnLayout( numberOfColumns=2, columnWidth=[(1, 43), (2, 363)], parent=rulesLayout )
    cmds.text( l="Axiom ", align="right" )
    cmds.textField( "axiomTextField", tx="F", ann="Type the initial word you want to start with. The rules will replace each char of the word." )
    
    #--- Depth ---#
    cmds.rowColumnLayout( numberOfColumns=1, columnWidth=[(1, 406)], parent=rulesLayout )
    cmds.intSliderGrp( "depthIntField", l="Depth: ", v=4, cw3=[40,30,350], min=1, max=10, fmx=20, f=True,
        ann="Set the index of recursion. The number of iterations over the generated string. How many times do you want to seach and replace chars in the string?" )

    #--- Probabilities header ---#
    cmds.rowColumnLayout( numberOfColumns=3, cal=[(1,"right")], columnWidth=[(1,325),(2,50),(3,45)], parent=rulesLayout )
    cmds.separator( st="none" )
    cmds.text( l="Prob.(%)", en=True, ebg=True, bgc=[0.0,0.153,0.0666] )
    cmds.separator( st="none" )
 
    #--- Collection of rules ---#
    cmds.rowColumnLayout( nc=7, cal=[(1,"right")], cw=[(1,40),(2,30),(3,20),(4,245),(5,40),(6,5),(7,20)], p=rulesLayout )

     #--- RULE 1 ---#
    cmds.text( l="Rule 1: ", en=True )
    cmds.textField( "prodRulePred1", en=True, tx="F", ann="Enter predecessor string for production rule 1. If this character is found in the string it will be replaced." )
    cmds.text( l="->", en=True )
    cmds.textField( "prodRuleSucc1", en=True, tx="F[&+F]F[->FL][&FB]", ann="Enter successor string for production rule 1. The value you want to replace the predecessor with." )
    cmds.intField( "prodRuleProb1", minValue=0, maxValue=100, value=100,
        ann="Enter the probability (in percentage %) in which you want this rule to be executed. Applies just if you write the same predecessors in different rules." )
    cmds.separator( st="none" )
    cmds.separator( st="none" )

    #--- RULE 2 ---#
    cmds.text( "prodRule2Text_A", l="Rule 2: ", en=False )
    cmds.textField( "prodRulePred2", en=False, ann="Enter predecessor string for production rule 2. If this character is found in the string it will be replaced." )
    cmds.text( "prodRule2Text_B", l="->", en=False )
    cmds.textField( "prodRuleSucc2", en=False, ann="Enter successor string for production rule 2. The value you want to replace the predecessor with." )
    cmds.intField( "prodRuleProb2", minValue=0, maxValue=100, value=0, en=False,
        ann="Enter the probability (in percentage %) in which you want this rule to be executed. Applies just if you write the same predecessors in different rules." )
    cmds.separator( st="none" )
    cmds.checkBox( "prodRuleCheckBox2", l="", value=False, ann="Activates the 2st production rule." )
    def toggleGreyingOut2(*pArgs):
        valueCB2 = cmds.checkBox( "prodRuleCheckBox2", q=True, value=True )
        if valueCB2 == True:
            cmds.text( "prodRule2Text_A", edit=True, en=True )
            cmds.textField( "prodRulePred2", edit=True, en=True )
            cmds.text( "prodRule2Text_B", edit=True, en=True )
            cmds.textField( "prodRuleSucc2", edit=True, en=True )
            cmds.intField( "prodRuleProb2", edit=True, en=True )
            cmds.intField( "prodRuleProb2", edit=True, v=100 )
        if valueCB2 == False:
            cmds.text( "prodRule2Text_A", edit=True, en=False )
            cmds.textField( "prodRulePred2", edit=True, en=False )
            cmds.text( "prodRule2Text_B", edit=True, en=False )
            cmds.textField( "prodRuleSucc2", edit=True, en=False )
            cmds.intField( "prodRuleProb2", edit=True, en=False )
            cmds.intField( "prodRuleProb2", edit=True, v=0 )
    cmds.checkBox( "prodRuleCheckBox2", edit=True, changeCommand=toggleGreyingOut2 )

    #--- RULE 3 ---#
    cmds.text( "prodRule3Text_A", l="Rule 3: ", en=False )
    cmds.textField( "prodRulePred3", en=False, ann="Enter predecessor string for production rule 3. If this character is found in the string it will be replaced." )
    cmds.text( "prodRule3Text_B", l="->", en=False )
    cmds.textField( "prodRuleSucc3", en=False, ann="Enter successor string for production rule 3. The value you want to replace the predecessor with." )
    cmds.intField( "prodRuleProb3", minValue=0, maxValue=100, value=0, en=False,
        ann="Enter the probability (in percentage %) in which you want this rule to be executed. Applies just if you write the same predecessors in different rules." )
    cmds.separator( st="none" )
    cmds.checkBox( "prodRuleCheckBox3", l="", value=False, ann="Activates the 3rd production rule." )
    def toggleGreyingOut3(*pArgs):
        valueCB3 = cmds.checkBox( "prodRuleCheckBox3", q=True, value=True )
        if valueCB3 == True:
            cmds.text( "prodRule3Text_A", edit=True, en=True )
            cmds.textField( "prodRulePred3", edit=True, en=True )
            cmds.text( "prodRule3Text_B", edit=True, en=True )
            cmds.textField( "prodRuleSucc3", edit=True, en=True )
            cmds.intField( "prodRuleProb3", edit=True, en=True )
            cmds.intField( "prodRuleProb3", edit=True, v=100 )
        if valueCB3 == False:
            cmds.text( "prodRule3Text_A", edit=True, en=False )
            cmds.textField( "prodRulePred3", edit=True, en=False )
            cmds.text( "prodRule3Text_B", edit=True, en=False )
            cmds.textField( "prodRuleSucc3", edit=True, en=False )
            cmds.intField( "prodRuleProb3", edit=True, en=False )
            cmds.intField( "prodRuleProb3", edit=True, v=0 )
    cmds.checkBox( "prodRuleCheckBox3", edit=True, changeCommand=toggleGreyingOut3 )

    #--- RULE 4 ---#
    cmds.text( "prodRule4Text_A", l="Rule 4: ", en=False )
    cmds.textField( "prodRulePred4", en=False, ann="Enter predecessor string for production rule 4. If this character is found in the string it will be replaced." )
    cmds.text( "prodRule4Text_B", l="->", en=False )
    cmds.textField( "prodRuleSucc4", en=False, ann="Enter successor string for production rule 4. The value you want to replace the predecessor with." )
    cmds.intField( "prodRuleProb4", minValue=0, maxValue=100, value=0, en=False,
        ann="Enter the probability (in percentage %) in which you want this rule to be executed. Applies just if you write the same predecessors in different rules." )
    cmds.separator( st="none" )
    cmds.checkBox( "prodRuleCheckBox4", l="", value=False, ann="Activates the 4th production rule." )
    def toggleGreyingOut4(*pArgs):
        valueCB4 = cmds.checkBox( "prodRuleCheckBox4", q=True, value=True )
        if valueCB4 == True:
            cmds.text( "prodRule4Text_A", edit=True, en=True )
            cmds.textField( "prodRulePred4", edit=True, en=True )
            cmds.text( "prodRule4Text_B", edit=True, en=True )
            cmds.textField( "prodRuleSucc4", edit=True, en=True )
            cmds.intField( "prodRuleProb4", edit=True, en=True )
            cmds.intField( "prodRuleProb4", edit=True, v=100 )
        if valueCB4 == False:
            cmds.text( "prodRule4Text_A", edit=True, en=False )
            cmds.textField( "prodRulePred4", edit=True, en=False )
            cmds.text( "prodRule4Text_B", edit=True, en=False )
            cmds.textField( "prodRuleSucc4", edit=True, en=False )
            cmds.intField( "prodRuleProb4", edit=True, en=False )
            cmds.intField( "prodRuleProb4", edit=True, v=0 )
    cmds.checkBox( "prodRuleCheckBox4", edit=True, changeCommand=toggleGreyingOut4 )

    #--- Generate String / Clear String  ---#
    cmds.rowColumnLayout( numberOfColumns=3, columnWidth=[(1,196), (2,10), (3,196)], parent=rulesLayout )
    cmds.button( l="Generate String", ann="Click to run the L-System string procedure.", c=generateStringButtonAction )
    cmds.separator( h=5, st="none" )
    cmds.button( l="Clear String", ann="Click to reset the generated string", command=clearStringButtonAction )

    #--- String Output ---#
    cmds.rowColumnLayout( numberOfColumns=1, columnWidth=[(1, 402)], parent=rulesLayout )
    cmds.textField( "output", editable=True, ann="This is the generated string. When you get it proceed to construct the geometry.")
    cmds.rowColumnLayout( numberOfColumns=1, columnWidth=[(1, 402)], parent=mainFrame )
    cmds.separator( h=5, st='none' )

    #//////////////////////////////////////GEOMETRIC//INTERPRETATION///////////////////////////////////////////////////////#
    mInterpret = cmds.frameLayout( label = "Geometric Interpretation", collapsable=True, cl=True, mw = 10, mh = 10, w=425 )
 
    #--- Set of geometric parameters ---#
    cmds.rowColumnLayout( numberOfColumns=1, columnWidth=[(1,406)], parent=mInterpret )
    cmds.floatSliderGrp( "angle", l="Angle: ", pre=1, v=25.2, cal=[2,'center'], cw3=[92,40,788], min=0, max=100, fmx=360,
        f=True, ann="The turtle will yaw, roll or pitch by this angular (degrees) amount each time it finds each corresponding symbol.")
    cmds.floatSliderGrp( "length", l="Segment Length: ", pre=2, v=1.20, cw3=[92,40,788], min=0, max=10, fmx=100, f=True,
        ann= "The length of each turtle's step or segment.")
    cmds.floatSliderGrp( "radius", l="Segment Radius: ", pre=2, v=0.20, cw3=[92,40,788], min=0, max=0.5, fmx=2, f=True,
        ann="The radius of each cylinder (segment) that is placed." )
    cmds.intSliderGrp( "cylSubdivs", l="Cylinder Subdivs: ", v=5, cw3=[92,40,788], min=4, max=20, fmx=20, f=True,
        ann="No. of subdivisions for each cylinder." )
    cmds.intSliderGrp( "length_atenuation", l="Len. Atenuation: ", v=95, cw3=[92,40,788], min=0, max=100, fmx=100, f=True,
        ann="Next's index branch's segment's length will be (this field) percent the length of the previous one." )
    cmds.intSliderGrp( "radius_atenuation", l="Rad. Atenuation: ", v=85, cw3=[92,40,788], min=0, max=100, fmx=100, f=True,
        ann="Next's index branch's segment's radius will be (this field) percent the length of the previous one." )
    cmds.floatSliderGrp( "turtleSpeed", l="Turtle speed: ", v=0, cw3=[92,40,288], min=0, max=1, pre=2, fmx=5, f=True,
        ann="Before proceeding to the next turtle command it will be frozen for this amount of time (in seconds). Useful for keeping track of everything that happens." )
    cmds.separator( h=2, st="none" )

    #--- Colour Fields ---#
    global rgb_branchField, rgb_leafField, rgb_branchField
    cmds.colorSliderGrp( "rgb_branchField", l="Branches", rgb=(0.430,0.230,0.11), cw3=[52,30,328], ann="Branch colour." )
    cmds.separator( h=6, st="none" )
    cmds.colorSliderGrp( "rgb_leafField", l="Leaves", rgb=(0,0.624,0), cw3=[52,30,328], ann="Leaf colour." )
    cmds.separator( h=6, st="none" )
    cmds.colorSliderGrp('rgb_blossomField', l="Blossoms", rgb=(0.624,0,0), cw3=[52,30,328], ann="Blossoms colour." )

    #--- Create Geometry / Clean Plant ---#
    cmds.rowColumnLayout( numberOfColumns=3, columnWidth=[(1,196), (2,10), (3,196)], parent=mInterpret )
    cmds.button( l="Create Geometry", command=createGeometryButtonAction, ann="Go turtle! Go!" )
    cmds.separator( h=5, st="none" )
    cmds.button( l="Clean Plant", command=cleanPlantButtonAction, ann='Deletes the lastest generated plant.' )

    #/////////////////////////////////////WARNINGS//AND//HELPLINE//////////////////////////////////////////////////////////#
    cmds.rowColumnLayout( numberOfColumns=3, columnWidth=[(1,55), (2, 5), (3, 366)], parent=mainFrame )
    cmds.text( l="Warnings" )
    cmds.separator( st="none" )
    cmds.textField( "warningsTextField", editable=False, tx="None" )
    cmds.rowColumnLayout( numberOfColumns=1, columnWidth=[(1, 426)], parent=mainFrame )
    cmds.helpLine( bgc=[0.0,0.0,0.0] ) 

    #--- Credits Layout ---#
    cmds.rowColumnLayout( numberOfColumns=1, columnWidth=[(1, 426)], parent=mainFrame )
    cmds.text( l="Ramon Blanquer - www.ramonblanquer.com - NCCA 2014" )
    cmds.showWindow()
    cmds.showWindow(window)
示例#6
0
    def create_ui(self, pWindowTitle, pApplyCallBack, pSavePreset, pLoadPreset):
        windowID = 'miniTree'
        if cmds.window(windowID, exists=True):
            cmds.deleteUI(windowID)

        cmds.window(windowID, title=pWindowTitle, sizeable=False, resizeToFitChildren=True, w = 100)

        cmds.rowColumnLayout(numberOfColumns=1)
        logopath = cmds.internalVar(upd=True) + "icons/mini_tree_logo.png"
        cmds.image(image=logopath)
        cmds.separator(h=10, style='none')
        cmds.setParent('..')

        form = cmds.formLayout()
        tabs = cmds.tabLayout(innerMarginWidth=5, innerMarginHeight=5)
        cmds.formLayout(form, edit=True,
                        attachForm=((tabs, 'top', 0), (tabs, 'left', 0), (tabs, 'bottom', 0), (tabs, 'right', 0)))

        child1 = cmds.rowColumnLayout(numberOfColumns=1)

        cmds.separator(h=10, style='in')
        cmds.text(label='General', align='center')
        cmds.separator(h=10, style='in')

        polyNumberField = cmds.intSliderGrp("polyNumberField", label='Polygons:', min=3, max=20, value=4, step=1,
                                            field=True,
                                            annotation='Changes number of polygons in each tree segment')
        treeDepthField = cmds.intSliderGrp("treeDepthField", label='Levels (tree size):', min=1, max=8, value=3, step=1,
                                           field=True,
                                           annotation='Changes number of branching levels')
        treeFirstSegmentLength = cmds.floatSliderGrp("treeFirstSegmentLength", label='Base length:', min=0.1, max=5,
                                                     value=1, step=0.1,
                                                     field=True,
                                                     annotation='Increases/decreases the length of the first tree segment')
        cmds.separator(h=10, style='in')
        cmds.text(label='Branch length', align='center')
        cmds.separator(h=10, style='in')
        treeSegmentLength = cmds.floatSliderGrp("treeSegmentLength", label='Length:', min=0.2, max=20, value=5,
                                                step=0.1, field=True,
                                                annotation='Changes the initial length of each branch')

        treeLengthDecrease = cmds.floatSliderGrp("treeLengthDecrease", label='Decrease:', min=0.0, max=1, value=0.8,
                                                 step=0.01, field=True,
                                                 annotation='Affects how the length of each branch decreases as the tree grows')
        cmds.separator(h=10, style='in')
        cmds.text(label='Trunk/branch radius', align='center')
        cmds.separator(h=10, style='in')
        trunkRadius = cmds.floatSliderGrp("trunkRadius", label='Radius:', min=0.1, max=10, value=1, step=0.1,
                                          field=True,
                                          annotation='Changes the initial radius of the tree trunk')
        radiusDecrease = cmds.floatSliderGrp("radiusDecrease", label='Decrease:', min=0.0, max=1, value=0.45, step=0.01,
                                             field=True,
                                             annotation='Affects how the radius of the branches decreases as the tree grows')
        cmds.separator(h=10, style='in')
        cmds.text(label='Branching', align='center')
        cmds.separator(h=10, style='in')
        treeBranches = cmds.intSliderGrp("treeBranches", label='Max branches:', min=1, max=8, value=2, step=1,
                                         field=True,
                                         annotation='Changes the maximum number of branches that may occur when branching')
        treeBranches_a = cmds.floatSliderGrp("treeBranches_a", label='Branches angle:', min=0, max=math.pi, value=0.5,
                                             step=0.01,
                                             field=True, annotation='Manipulates the angle of braches')
        cmds.separator(h=10, style='in')
        cmds.text(label='Randomness', align='center')
        cmds.separator(h=10, style='in')
        branchingChance = cmds.floatSliderGrp("branchingChance", label='Branching chance:', min=0, max=1, value=0.9,
                                              step=0.01,
                                              field=True,
                                              annotation='Lower values increase a chance of a branch not appearing')
        cmds.separator(h=10, style='in')
        branchAngleChance = cmds.floatSliderGrp("branchAngleChance", label='Angle shift shance:', min=0, max=1,
                                                value=0.9,
                                                step=0.01,
                                                field=True,
                                                annotation='Chance of a branch angle deviating from the angle of all other branches')
        branchAngleRAmount = cmds.floatSliderGrp("branchAngleRAmount", label='Angle random amount:', min=0, max=math.pi,
                                                 value=math.pi / 6,
                                                 step=0.01,
                                                 field=True,
                                                 annotation='Angle of how much a branch angle can change randomly')
        cmds.separator(h=10, style='in')
        branchTurnChance = cmds.floatSliderGrp("branchTurnChance", label='Turn shift chance:', min=0, max=1, value=0.9,
                                               step=0.01,
                                               field=True,
                                               annotation='Chance of a branch turn deviating from the turn of all other branches')
        branchTurnRAmount = cmds.floatSliderGrp("branchTurnRAmount", label='Turn random amount:', min=0, max=math.pi,
                                                value=math.pi / 2,
                                                step=0.01,
                                                field=True, annotation='Angle of how much a branch can turn randomly')

        cmds.separator(h=10, style='in')
        cmds.text(label='Colour', align='center')
        cmds.separator(h=10, style='in')
        treeColor = cmds.colorSliderGrp("treeColor", label='Tree colour:', rgb=(0.4, 0.3, 0.3),
                                        annotation='Double click the colour to open the palette, changes tree colour')
        cmds.separator(h=10, style='none')

        cmds.setParent('..')

        child2 = cmds.rowColumnLayout(numberOfColumns=1)

        cmds.separator(h=10, style='in')
        cmds.text(label='General', align='center')
        cmds.separator(h=10, style='in')
        treeFoliageSze = cmds.floatSliderGrp("treeFoliageSze", label='Size:', min=0.1, max=6, value=1, step=0.01,
                                             field=True,
                                             annotation='Size of each foliage sphere')
        treeFoliageRes = cmds.intSliderGrp("treeFoliageRes", label='Resolution:', min=0, max=4, value=1, step=1,
                                           field=True,
                                           annotation='Subdivides each of the foliage spheres')
        cmds.separator(h=10, style='in')
        cmds.text(label='More foliage', align='center')
        cmds.separator(h=10, style='in')
        treeFoliageNumber = cmds.intSliderGrp("treeFoliageNumber", label='Spheres number:', min=1, max=20, value=1,
                                              step=1, field=True,
                                              annotation='Number of foliage spheres per branch')
        treeFoliageSpread = cmds.floatSliderGrp("treeFoliageSpread", label='Randomise positions:', min=0, max=5,
                                                value=0, step=0.01,
                                                field=True,
                                                annotation='Randomise the foliage spheres position (necessary when changing foliage number)')

        cmds.separator(h=10, style='in')
        cmds.text(label='Colour', align='center')
        cmds.separator(h=10, style='in')
        foliageColor = cmds.colorSliderGrp("foliageColor", label='Foliage colour:', rgb=(0.30, 0.7, 0.40),
                                           annotation='Double click the colour to open the palette, changes foliage colour')
        cmds.separator(h=10, style='none')

        cmds.setParent('..')

        cmds.tabLayout(tabs, edit=True, tabLabel=((child1, 'Tree'), (child2, 'Foliage')))
        cmds.setParent('..')
        cmds.setParent('..')

        cmds.rowColumnLayout(numberOfColumns=1)

        treeTypeSelect = cmds.radioButtonGrp("treeTypeSelect", label='Tree type', sl=1, labelArray2=['Normal', 'Pine'],
                                             numberOfRadioButtons=2)
        cmds.separator(h=10, style='none')

        def changeTextFld(*args):
            cmds.intFieldGrp("randomSeed", edit=True, v1=random.randint(0, 9999))

        cmds.separator(h=10, style='none')
        cmds.separator(h=10, style='none')

        cmds.rowColumnLayout(numberOfColumns=2)
        cmds.button(label='Randomize seed', command=changeTextFld, annotation='Changes seed value to a random value')
        randomSeed = cmds.intFieldGrp("randomSeed", label='Seed:', numberOfFields=1, value1=9981,
                                      annotation='Number affecting random generation of the tree')
        #cmds.separator(h=10, style='none')

        cmds.setParent('..')
        cmds.separator(h=10, style='none')
        cmds.separator(h=10, style='in')
        cmds.separator(h=10, style='none')

        cmds.rowColumnLayout(numberOfColumns=3, columnWidth=[(1, 300),(2, 20), (3, 100)])
        cmds.button(label='Create tree', h = 60, align='center', annotation='Create a tree using the above settings',
                    command=functools.partial(pApplyCallBack,
                                              polyNumberField,
                                              treeDepthField,
                                              treeSegmentLength,
                                              treeLengthDecrease,
                                              trunkRadius,
                                              radiusDecrease,
                                              treeBranches,
                                              treeBranches_a,
                                              treeFoliageSze,
                                              treeFoliageRes,
                                              randomSeed,
                                              foliageColor,
                                              treeColor,
                                              treeFoliageNumber,
                                              treeFoliageSpread,
                                              treeFirstSegmentLength,
                                              treeTypeSelect,
                                              branchingChance,
                                              branchAngleChance,
                                              branchTurnChance,
                                              branchTurnRAmount,
                                              branchAngleRAmount
                                              ))
        cmds.separator(h=10, style='none')
        cmds.rowColumnLayout(numberOfColumns=1, columnWidth=[(1, 90)])

        cmds.button(label='Save preset', annotation='Saves current settings as a preset',
                    command=functools.partial(pSavePreset,
                                              polyNumberField,
                                              treeDepthField,
                                              treeSegmentLength,
                                              treeLengthDecrease,
                                              trunkRadius,
                                              radiusDecrease,
                                              treeBranches,
                                              treeBranches_a,
                                              treeFoliageSze,
                                              treeFoliageRes,
                                              randomSeed,
                                              foliageColor,
                                              treeColor,
                                              treeFoliageNumber,
                                              treeFoliageSpread,
                                              treeFirstSegmentLength,
                                              treeTypeSelect,
                                              branchingChance,
                                              branchAngleChance,
                                              branchTurnChance,
                                              branchTurnRAmount,
                                              branchAngleRAmount
                                              ))
        cmds.separator(h=10, style='none')
        cmds.button(label='Load preset', annotation='Loads current settings as a preset',
                                 command=functools.partial(pLoadPreset))
        cmds.separator(h=10, style='in')
        cmds.text('preset_text', label='default', align='center')
        cmds.setParent('..')
        cmds.setParent('..')
        cmds.helpLine()

        def cancelCallBack(*pArgs):
            if cmds.window(windowID, exists=True):
                cmds.deleteUI(windowID)

        # cmds.button(label='Cancel', command=cancelCallBack)
        cmds.showWindow()
示例#7
0
    def buildUI(self, *args):
        self.mainWin = cmds.window(self.winName,
                                   width=self.winWidth,
                                   height=self.winHeight,
                                   title=self.winTitle,
                                   sizeable=False)

        # Main Layout
        mainCL = cmds.columnLayout(adjustableColumn=True)

        # Layout variables
        mainWidths = [self.winWidth * 0.8, self.winWidth * 0.2]
        mainHeights = [
            self.winHeight * 0.89, self.winHeight * 0.09, self.winHeight * 0.02
        ]
        scrollWidth = self.defaultFontSize + 6
        tabWidth = self.winWidth - scrollWidth
        buttonWidth = self.defaultFontSize * 28
        spacing = [
            self.defaultFontSize * 0.8, self.defaultFontSize * 1.5,
            self.defaultFontSize * 3.5, self.defaultFontSize * 4.5,
            self.defaultFontSize * 10
        ]

        # Header Layout
        headerRL = cmds.rowLayout(width=self.winWidth,
                                  height=mainHeights[1],
                                  numberOfColumns=2,
                                  columnWidth2=mainWidths,
                                  rowAttach=(2, 'top', 0))
        cmds.columnLayout(width=mainWidths[0], adjustableColumn=True)
        cmds.text(label='Rigging Tools', font='obliqueLabelFont')
        cmds.columnLayout(parent=headerRL, width=mainWidths[1])
        cmds.button(label='Error',
                    ann='This helpful button creates random errors',
                    width=mainWidths[1],
                    height=mainHeights[1],
                    command=self.errorButton)

        # Main Body Tab Layout
        cmds.formLayout(parent=mainCL, height=mainHeights[0])
        pane = cmds.paneLayout(configuration='horizontal2',
                               width=self.winWidth,
                               height=mainHeights[0],
                               paneSize=[1, 100, 80])
        self.tabs = cmds.tabLayout(innerMarginWidth=5, innerMarginHeight=5)

        tab_kwargs = {
            'tabLayout': self.tabs,
            'width': tabWidth,
            'scrollBarThickness': scrollWidth,
            'buttonWidth': buttonWidth,
            'spacing': spacing
        }

        # Tab 1 - Renaming Tools
        sRename.RenameUI(**tab_kwargs)

        # Tab 2 - Joint Tools
        sJoint.JointsUI(**tab_kwargs)

        # Tab 3 - Control Tools
        sControl.ControlsUI(**tab_kwargs)

        # Tab 4 - Attribute Tools
        sAttributes.AttributesUI(**tab_kwargs)

        # Notes Section
        self.notes = cmds.columnLayout(parent=pane)
        cmds.text(label='Notes')
        self.notesField = cmds.scrollField(editable=True,
                                           wordWrap=True,
                                           width=self.winWidth,
                                           height=11 * self.defaultFontSize,
                                           text='><>')
        cmds.scrollField(self.notesField,
                         edit=True,
                         changeCommand=partial(self.setNotesHeight,
                                               self.notesField))

        # Helpline Footer
        self.form2 = cmds.formLayout(parent=mainCL,
                                     width=self.winWidth,
                                     height=mainHeights[2])
        self.lineHelp = cmds.helpLine()
        cmds.formLayout(self.form2,
                        edit=True,
                        attachForm=((self.lineHelp, 'left', 0), (self.lineHelp,
                                                                 'bottom', 0),
                                    (self.lineHelp, 'right', 0)))

        # Show and Resize Window
        cmds.showWindow(self.winName)
        cmds.window(self.winName,
                    edit=True,
                    width=self.winWidth,
                    height=self.winHeight)
示例#8
0
def createUI():
    # Check to see if our window exists
    if cmds.window("myWindow", exists=True):
        cmds.deleteUI("myWindow")

    # Create our main window
    window = cmds.window("myWindow",
                         title="L-System Interpreter",
                         s=False,
                         w=450,
                         h=650,
                         mnb=False,
                         mxb=False)
    mainLayout = cmds.columnLayout(w=450, h=650)
    import os
    pathVar = os.path.dirname(
        __file__)  # This stores the current working directory
    imagePath = pathVar + "/banner.png"  # I designed a nice header for it
    cmds.image(w=450, h=160, image=imagePath)

    #--- MAIN FRAME LAYOUT ---#
    mainFrame = cmds.frameLayout(l="L-System String Operations",
                                 lv=False,
                                 cll=False,
                                 cl=True,
                                 mw=10,
                                 mh=10)

    #////////////////////////////////////////INSTRUCTIONS//AND//PRESETS////////////////////////////////////////////////////#
    def displayInstructions(*pArgs):
        """Shows in an independent window a list of instructions for the user to set things up quickly"""
        if cmds.window("instructions_window", exists=True):
            cmds.deleteUI("instructions_window")
        instructions_window = cmds.window("instructions_window",
                                          title="Instructions",
                                          s=False,
                                          mnb=False,
                                          mxb=False)
        instructionsLayout = cmds.frameLayout(l="Instructions",
                                              collapsable=False,
                                              cl=False,
                                              mw=10,
                                              mh=10)
        cmds.rowColumnLayout(nc=3,
                             cw=[(1, 20), (2, 480), (3, 20)],
                             cal=[(2, "left")],
                             parent=instructionsLayout)
        cmds.separator(st="none")
        cmds.text(
            l="1. Write an axiom (or initial word), depth and rules. If you don't know what it is put the mouse over the parameter and read the help line.\n2. Click Generate String. Then you will see the result in the text field below, this is just mere text. Now the string needs to be interpreted.\n3. Set all the 'Geometric Interpretation' attributes (Angle, Segment Length...). Remember to put the mouse over it if your are confused.\n4. Click Create Geometry. You will see the result in your scene. If you want to clean the last plant\n\tclick Clean Plant. If you click Create Geometry again you will get another plant.\n6. Always remember to pay attention to the help line and warnings field."
        )
        cmds.separator(st="none")
        cmds.separator(st="none")
        cmds.text(
            l="\nThis is the meaning for each character you enter in the rules section:"
        )
        cmds.separator(st="none")
        cmds.separator(st="none")
        cmds.text(l="""        
        F    Move forward
        f    Move forward
        L    Leaf
        B    Blossom
        +    Rotate +X (yaw right)
        -    Rotate -X (yaw left)
        ^    Rotate +Y (roll right)
        &    Rotate -Y (roll left)
        <    Rotate +Z (pitch down)
        >    Rotate -Z (pitch up)
        *    Turtle rotates 180 (as it was facing backwards)
        [    Push current turtle state on the stack
        ]    Pop the current turtle state from the stack""")
        cmds.showWindow(instructions_window)

    cmds.rowColumnLayout(numberOfColumns=4,
                         cal=[(2, "left")],
                         columnWidth=[(1, 5), (2, 320), (3, 100), (4, 5)],
                         parent=mainFrame)
    cmds.separator(st="none")
    cmds.text(
        l="You might feel a bit lost, I recommend you to read a quick guide")
    cmds.button(l="Instructions", en=True, command=displayInstructions)
    cmds.separator(st="none")

    cmds.rowColumnLayout(nc=7,
                         cw=[(1, 103), (2, 5), (3, 103), (4, 5), (5, 102),
                             (6, 5), (7, 102)],
                         parent=mainFrame)

    def preset1Action(*args):
        import presets
        set1 = presets.preset1()

    cmds.button(l="Preset1", c=preset1Action, ann="Loads Preset #1.")
    cmds.separator(st="none")

    def preset2Action(*args):
        import presets
        set2 = presets.preset2()

    cmds.button(l="Preset2", c=preset2Action, ann="Loads Preset #2.")
    cmds.separator(st="none")

    def preset3Action(*args):
        import presets
        set3 = presets.preset3()

    cmds.button(l="Preset3", c=preset3Action, ann="Loads Preset #3.")
    cmds.separator(st="none")

    def preset4Action(*args):
        import presets
        set4 = presets.preset4()

    cmds.button(l="Preset4", c=preset4Action, ann="Loads Preset #4.")

    # !!!!!!!!!!!!!!!!!!!!!!! TO DO --> PRESETS

    cmds.rowColumnLayout(numberOfColumns=1,
                         columnWidth=[(1, 425)],
                         parent=mainFrame)
    cmds.separator(h=1, st="none")

    #////////////////////////////////////////////////RULES//TAB////////////////////////////////////////////////////////////#
    rulesLayout = cmds.frameLayout(label="Rules",
                                   collapsable=True,
                                   cl=False,
                                   mw=10,
                                   mh=10,
                                   w=425)

    #--- Axiom ---#
    cmds.rowColumnLayout(numberOfColumns=2,
                         columnWidth=[(1, 43), (2, 363)],
                         parent=rulesLayout)
    cmds.text(l="Axiom ", align="right")
    cmds.textField(
        "axiomTextField",
        tx="F",
        ann=
        "Type the initial word you want to start with. The rules will replace each char of the word."
    )

    #--- Depth ---#
    cmds.rowColumnLayout(numberOfColumns=1,
                         columnWidth=[(1, 406)],
                         parent=rulesLayout)
    cmds.intSliderGrp(
        "depthIntField",
        l="Depth: ",
        v=4,
        cw3=[40, 30, 350],
        min=1,
        max=10,
        fmx=20,
        f=True,
        ann=
        "Set the index of recursion. The number of iterations over the generated string. How many times do you want to seach and replace chars in the string?"
    )

    #--- Probabilities header ---#
    cmds.rowColumnLayout(numberOfColumns=3,
                         cal=[(1, "right")],
                         columnWidth=[(1, 325), (2, 50), (3, 45)],
                         parent=rulesLayout)
    cmds.separator(st="none")
    cmds.text(l="Prob.(%)", en=True, ebg=True, bgc=[0.0, 0.153, 0.0666])
    cmds.separator(st="none")

    #--- Collection of rules ---#
    cmds.rowColumnLayout(nc=7,
                         cal=[(1, "right")],
                         cw=[(1, 40), (2, 30), (3, 20), (4, 245), (5, 40),
                             (6, 5), (7, 20)],
                         p=rulesLayout)

    #--- RULE 1 ---#
    cmds.text(l="Rule 1: ", en=True)
    cmds.textField(
        "prodRulePred1",
        en=True,
        tx="F",
        ann=
        "Enter predecessor string for production rule 1. If this character is found in the string it will be replaced."
    )
    cmds.text(l="->", en=True)
    cmds.textField(
        "prodRuleSucc1",
        en=True,
        tx="F[&+F]F[->FL][&FB]",
        ann=
        "Enter successor string for production rule 1. The value you want to replace the predecessor with."
    )
    cmds.intField(
        "prodRuleProb1",
        minValue=0,
        maxValue=100,
        value=100,
        ann=
        "Enter the probability (in percentage %) in which you want this rule to be executed. Applies just if you write the same predecessors in different rules."
    )
    cmds.separator(st="none")
    cmds.separator(st="none")

    #--- RULE 2 ---#
    cmds.text("prodRule2Text_A", l="Rule 2: ", en=False)
    cmds.textField(
        "prodRulePred2",
        en=False,
        ann=
        "Enter predecessor string for production rule 2. If this character is found in the string it will be replaced."
    )
    cmds.text("prodRule2Text_B", l="->", en=False)
    cmds.textField(
        "prodRuleSucc2",
        en=False,
        ann=
        "Enter successor string for production rule 2. The value you want to replace the predecessor with."
    )
    cmds.intField(
        "prodRuleProb2",
        minValue=0,
        maxValue=100,
        value=0,
        en=False,
        ann=
        "Enter the probability (in percentage %) in which you want this rule to be executed. Applies just if you write the same predecessors in different rules."
    )
    cmds.separator(st="none")
    cmds.checkBox("prodRuleCheckBox2",
                  l="",
                  value=False,
                  ann="Activates the 2st production rule.")

    def toggleGreyingOut2(*pArgs):
        valueCB2 = cmds.checkBox("prodRuleCheckBox2", q=True, value=True)
        if valueCB2 == True:
            cmds.text("prodRule2Text_A", edit=True, en=True)
            cmds.textField("prodRulePred2", edit=True, en=True)
            cmds.text("prodRule2Text_B", edit=True, en=True)
            cmds.textField("prodRuleSucc2", edit=True, en=True)
            cmds.intField("prodRuleProb2", edit=True, en=True)
            cmds.intField("prodRuleProb2", edit=True, v=100)
        if valueCB2 == False:
            cmds.text("prodRule2Text_A", edit=True, en=False)
            cmds.textField("prodRulePred2", edit=True, en=False)
            cmds.text("prodRule2Text_B", edit=True, en=False)
            cmds.textField("prodRuleSucc2", edit=True, en=False)
            cmds.intField("prodRuleProb2", edit=True, en=False)
            cmds.intField("prodRuleProb2", edit=True, v=0)

    cmds.checkBox("prodRuleCheckBox2",
                  edit=True,
                  changeCommand=toggleGreyingOut2)

    #--- RULE 3 ---#
    cmds.text("prodRule3Text_A", l="Rule 3: ", en=False)
    cmds.textField(
        "prodRulePred3",
        en=False,
        ann=
        "Enter predecessor string for production rule 3. If this character is found in the string it will be replaced."
    )
    cmds.text("prodRule3Text_B", l="->", en=False)
    cmds.textField(
        "prodRuleSucc3",
        en=False,
        ann=
        "Enter successor string for production rule 3. The value you want to replace the predecessor with."
    )
    cmds.intField(
        "prodRuleProb3",
        minValue=0,
        maxValue=100,
        value=0,
        en=False,
        ann=
        "Enter the probability (in percentage %) in which you want this rule to be executed. Applies just if you write the same predecessors in different rules."
    )
    cmds.separator(st="none")
    cmds.checkBox("prodRuleCheckBox3",
                  l="",
                  value=False,
                  ann="Activates the 3rd production rule.")

    def toggleGreyingOut3(*pArgs):
        valueCB3 = cmds.checkBox("prodRuleCheckBox3", q=True, value=True)
        if valueCB3 == True:
            cmds.text("prodRule3Text_A", edit=True, en=True)
            cmds.textField("prodRulePred3", edit=True, en=True)
            cmds.text("prodRule3Text_B", edit=True, en=True)
            cmds.textField("prodRuleSucc3", edit=True, en=True)
            cmds.intField("prodRuleProb3", edit=True, en=True)
            cmds.intField("prodRuleProb3", edit=True, v=100)
        if valueCB3 == False:
            cmds.text("prodRule3Text_A", edit=True, en=False)
            cmds.textField("prodRulePred3", edit=True, en=False)
            cmds.text("prodRule3Text_B", edit=True, en=False)
            cmds.textField("prodRuleSucc3", edit=True, en=False)
            cmds.intField("prodRuleProb3", edit=True, en=False)
            cmds.intField("prodRuleProb3", edit=True, v=0)

    cmds.checkBox("prodRuleCheckBox3",
                  edit=True,
                  changeCommand=toggleGreyingOut3)

    #--- RULE 4 ---#
    cmds.text("prodRule4Text_A", l="Rule 4: ", en=False)
    cmds.textField(
        "prodRulePred4",
        en=False,
        ann=
        "Enter predecessor string for production rule 4. If this character is found in the string it will be replaced."
    )
    cmds.text("prodRule4Text_B", l="->", en=False)
    cmds.textField(
        "prodRuleSucc4",
        en=False,
        ann=
        "Enter successor string for production rule 4. The value you want to replace the predecessor with."
    )
    cmds.intField(
        "prodRuleProb4",
        minValue=0,
        maxValue=100,
        value=0,
        en=False,
        ann=
        "Enter the probability (in percentage %) in which you want this rule to be executed. Applies just if you write the same predecessors in different rules."
    )
    cmds.separator(st="none")
    cmds.checkBox("prodRuleCheckBox4",
                  l="",
                  value=False,
                  ann="Activates the 4th production rule.")

    def toggleGreyingOut4(*pArgs):
        valueCB4 = cmds.checkBox("prodRuleCheckBox4", q=True, value=True)
        if valueCB4 == True:
            cmds.text("prodRule4Text_A", edit=True, en=True)
            cmds.textField("prodRulePred4", edit=True, en=True)
            cmds.text("prodRule4Text_B", edit=True, en=True)
            cmds.textField("prodRuleSucc4", edit=True, en=True)
            cmds.intField("prodRuleProb4", edit=True, en=True)
            cmds.intField("prodRuleProb4", edit=True, v=100)
        if valueCB4 == False:
            cmds.text("prodRule4Text_A", edit=True, en=False)
            cmds.textField("prodRulePred4", edit=True, en=False)
            cmds.text("prodRule4Text_B", edit=True, en=False)
            cmds.textField("prodRuleSucc4", edit=True, en=False)
            cmds.intField("prodRuleProb4", edit=True, en=False)
            cmds.intField("prodRuleProb4", edit=True, v=0)

    cmds.checkBox("prodRuleCheckBox4",
                  edit=True,
                  changeCommand=toggleGreyingOut4)

    #--- Generate String / Clear String  ---#
    cmds.rowColumnLayout(numberOfColumns=3,
                         columnWidth=[(1, 196), (2, 10), (3, 196)],
                         parent=rulesLayout)
    cmds.button(l="Generate String",
                ann="Click to run the L-System string procedure.",
                c=generateStringButtonAction)
    cmds.separator(h=5, st="none")
    cmds.button(l="Clear String",
                ann="Click to reset the generated string",
                command=clearStringButtonAction)

    #--- String Output ---#
    cmds.rowColumnLayout(numberOfColumns=1,
                         columnWidth=[(1, 402)],
                         parent=rulesLayout)
    cmds.textField(
        "output",
        editable=True,
        ann=
        "This is the generated string. When you get it proceed to construct the geometry."
    )
    cmds.rowColumnLayout(numberOfColumns=1,
                         columnWidth=[(1, 402)],
                         parent=mainFrame)
    cmds.separator(h=5, st='none')

    #//////////////////////////////////////GEOMETRIC//INTERPRETATION///////////////////////////////////////////////////////#
    mInterpret = cmds.frameLayout(label="Geometric Interpretation",
                                  collapsable=True,
                                  cl=True,
                                  mw=10,
                                  mh=10,
                                  w=425)

    #--- Set of geometric parameters ---#
    cmds.rowColumnLayout(numberOfColumns=1,
                         columnWidth=[(1, 406)],
                         parent=mInterpret)
    cmds.floatSliderGrp(
        "angle",
        l="Angle: ",
        pre=1,
        v=25.2,
        cal=[2, 'center'],
        cw3=[92, 40, 788],
        min=0,
        max=100,
        fmx=360,
        f=True,
        ann=
        "The turtle will yaw, roll or pitch by this angular (degrees) amount each time it finds each corresponding symbol."
    )
    cmds.floatSliderGrp("length",
                        l="Segment Length: ",
                        pre=2,
                        v=1.20,
                        cw3=[92, 40, 788],
                        min=0,
                        max=10,
                        fmx=100,
                        f=True,
                        ann="The length of each turtle's step or segment.")
    cmds.floatSliderGrp(
        "radius",
        l="Segment Radius: ",
        pre=2,
        v=0.20,
        cw3=[92, 40, 788],
        min=0,
        max=0.5,
        fmx=2,
        f=True,
        ann="The radius of each cylinder (segment) that is placed.")
    cmds.intSliderGrp("cylSubdivs",
                      l="Cylinder Subdivs: ",
                      v=5,
                      cw3=[92, 40, 788],
                      min=4,
                      max=20,
                      fmx=20,
                      f=True,
                      ann="No. of subdivisions for each cylinder.")
    cmds.intSliderGrp(
        "length_atenuation",
        l="Len. Atenuation: ",
        v=95,
        cw3=[92, 40, 788],
        min=0,
        max=100,
        fmx=100,
        f=True,
        ann=
        "Next's index branch's segment's length will be (this field) percent the length of the previous one."
    )
    cmds.intSliderGrp(
        "radius_atenuation",
        l="Rad. Atenuation: ",
        v=85,
        cw3=[92, 40, 788],
        min=0,
        max=100,
        fmx=100,
        f=True,
        ann=
        "Next's index branch's segment's radius will be (this field) percent the length of the previous one."
    )
    cmds.floatSliderGrp(
        "turtleSpeed",
        l="Turtle speed: ",
        v=0,
        cw3=[92, 40, 288],
        min=0,
        max=1,
        pre=2,
        fmx=5,
        f=True,
        ann=
        "Before proceeding to the next turtle command it will be frozen for this amount of time (in seconds). Useful for keeping track of everything that happens."
    )
    cmds.separator(h=2, st="none")

    #--- Colour Fields ---#
    global rgb_branchField, rgb_leafField, rgb_branchField
    cmds.colorSliderGrp("rgb_branchField",
                        l="Branches",
                        rgb=(0.430, 0.230, 0.11),
                        cw3=[52, 30, 328],
                        ann="Branch colour.")
    cmds.separator(h=6, st="none")
    cmds.colorSliderGrp("rgb_leafField",
                        l="Leaves",
                        rgb=(0, 0.624, 0),
                        cw3=[52, 30, 328],
                        ann="Leaf colour.")
    cmds.separator(h=6, st="none")
    cmds.colorSliderGrp('rgb_blossomField',
                        l="Blossoms",
                        rgb=(0.624, 0, 0),
                        cw3=[52, 30, 328],
                        ann="Blossoms colour.")

    #--- Create Geometry / Clean Plant ---#
    cmds.rowColumnLayout(numberOfColumns=3,
                         columnWidth=[(1, 196), (2, 10), (3, 196)],
                         parent=mInterpret)
    cmds.button(l="Create Geometry",
                command=createGeometryButtonAction,
                ann="Go turtle! Go!")
    cmds.separator(h=5, st="none")
    cmds.button(l="Clean Plant",
                command=cleanPlantButtonAction,
                ann='Deletes the lastest generated plant.')

    #/////////////////////////////////////WARNINGS//AND//HELPLINE//////////////////////////////////////////////////////////#
    cmds.rowColumnLayout(numberOfColumns=3,
                         columnWidth=[(1, 55), (2, 5), (3, 366)],
                         parent=mainFrame)
    cmds.text(l="Warnings")
    cmds.separator(st="none")
    cmds.textField("warningsTextField", editable=False, tx="None")
    cmds.rowColumnLayout(numberOfColumns=1,
                         columnWidth=[(1, 426)],
                         parent=mainFrame)
    cmds.helpLine(bgc=[0.0, 0.0, 0.0])

    #--- Credits Layout ---#
    cmds.rowColumnLayout(numberOfColumns=1,
                         columnWidth=[(1, 426)],
                         parent=mainFrame)
    cmds.text(l="Ramon Blanquer - www.ramonblanquer.com - NCCA 2014")
    cmds.showWindow()
    cmds.showWindow(window)
示例#9
0
def createUI():
    """
    Creates a user graphics interface.

    Keyword arguments:
    NONE

    On Exit:  All the functions will have been passed properly and the GUI will be initialised.
    """
    global windowID
    windowID = 'theWindow'

    # If the instance previously existed, delete it.
    if cmds.window(windowID, exists=True):
        cmds.deleteUI(windowID)

    # Main window setup.
    cmds.window(windowID,
                title="Towers Of Hanoi",
                sizeable=False,
                width=470,
                rtf=True)

    # Header image for the interface.
    import os
    pathVar = os.path.dirname(
        __file__)  # This stores the current working directory
    imagePath = pathVar + '/banner.png'
    cmds.columnLayout()
    cmds.image(image=imagePath)

    # We start a Tab Layout. We will parent a "Main" tab and a "Materials" tab.
    tabs = cmds.tabLayout()
    """A. MAIN SUPER-LAYOUT"""
    mainLayout = cmds.columnLayout(w=470)

    cmds.columnLayout()
    cmds.separator(h=10, style='none')

    def displayInstructions(*pArgs):
        """
        Shows in an independent window a list of instructions for the user to set things up quickly. It acts as a kind of
        user guide.

        Keyword arguments:
        NONE.

        On Exit:  Pops a window displaying some instructions for the user.
        """
        if cmds.window('instructions_window', exists=True):
            cmds.deleteUI('instructions_window')
        instructions_window = cmds.window('instructions_window',
                                          title="Instructions",
                                          s=False,
                                          mnb=False,
                                          mxb=False)
        instructionsLayout = cmds.frameLayout(l="Instructions",
                                              collapsable=False,
                                              cl=False,
                                              mw=10,
                                              mh=10)
        cmds.rowColumnLayout(nc=3,
                             cw=[(1, 20), (2, 480), (3, 20)],
                             cal=[(2, "left")],
                             parent=instructionsLayout)
        cmds.separator(st='none')
        cmds.text(
            l="- 1. Select the numbers of disks you want to play with.\n- 2. Click 'Place Disks' first. Then you "
            "will see that the disks has been brought to scene.\n- 3. Click 'Solve it!'. A lot of keyframes will appear on "
            "your timeline. Furthermore you will be able to\n       see each movement written down if you see the Script "
            "Editor window.\n- 4. If you want to change the number of disks FIRST CLEAR the scene by pressing 'Clear All'."
            "If\n       you skip this step you might crash the program.\n- 5. Once you are finished press the 'Exit' button"
            " and it will delete all the elements that\nhave been created for you"
        )
        cmds.separator(st='none')
        cmds.showWindow(instructions_window)

    """Layout 1: Instructions."""
    cmds.rowColumnLayout(nc=5,
                         cw=[(1, 20), (2, 245), (3, 10), (4, 175), (5, 20)],
                         cal=[(2, 'right')])
    cmds.separator(st='none')
    cmds.text(l="Click at the Instructions button for a quick guide -")
    cmds.separator(st='none')
    cmds.button(l="Instructions",
                c=displayInstructions,
                ann="Displays a quick guide for running this script properly.")
    cmds.separator(st='none')
    cmds.setParent(mainLayout)
    # Bottom margin.
    cmds.columnLayout()
    cmds.separator(h=5, st='none')
    cmds.setParent(mainLayout)
    """Layout 2: Number of Disks integer slider."""
    cmds.columnLayout()
    global diskNumUIField
    diskNumUIField = cmds.intSliderGrp(
        l="Number of Disks: ",
        v=3,
        cw3=[115, 20, 305],
        min=1,
        max=10,
        fmx=20,
        f=True,
        ann="Number of disks you want to stack in the first peg")
    cmds.setParent(mainLayout)
    # Bottom margin.
    cmds.columnLayout()
    cmds.separator(h=5, st='none')
    cmds.setParent(mainLayout)
    """Layout 3: First row of buttons, 'Place Disks' and 'Clear All'."""
    cmds.rowColumnLayout(nc=5,
                         cw=[(1, 20), (2, 212), (3, 6), (4, 212), (5, 20)])
    cmds.separator(st='none')
    # This global definition and declaration prevents the program from crashing because of non-defined variables. This
    # variable, later on, will contain the name of the board geometric object so that we can apply the shader easier.
    global board
    board = 0
    cmds.button(l="Place Disks",
                c=placeDisks,
                ann="Stacks a pile of disks into the source peg.")
    cmds.separator(st='none')
    cmds.button(l="Clear All", c=clearTowers, ann="Clears the disks.")
    cmds.separator(st='none')
    cmds.setParent(mainLayout)

    cmds.columnLayout()
    cmds.separator(h=3, st='none')
    cmds.setParent(mainLayout)
    """Layout 4: Second row of buttons, 'Solve it!' and 'Exit'."""
    cmds.rowColumnLayout(nc=5,
                         cw=[(1, 20), (2, 212), (3, 6), (4, 212), (5, 20)])
    cmds.separator(st='none')
    cmds.button(
        l="Solve it!",
        c=solvePuzzle,
        ann="Press to solve the puzzle once you have placed the disks.")
    cmds.separator(st='none')
    cmds.button(l="Exit", c=exitProcedure, ann="Quits the application")
    cmds.separator(st='none')
    cmds.setParent(mainLayout)
    # Bottom margin.
    cmds.columnLayout()
    cmds.separator(h=10, st='none')
    cmds.setParent(mainLayout)
    """Layout 5: Warnings line."""
    cmds.rowColumnLayout(nc=4, cw=[(1, 20), (2, 70), (3, 360), (4, 20)])
    cmds.separator(st='none')
    cmds.text(l="Warnings")
    global warnings
    warnings = cmds.text(l="None.", en=False, ebg=True, bgc=[0, 0.66, 0.05])
    cmds.separator(st='none')
    cmds.setParent(mainLayout)
    # Bottom margin.
    cmds.columnLayout()
    cmds.separator(st='none')
    cmds.setParent(mainLayout)
    """Layout 6: Help line."""
    cmds.rowColumnLayout(nc=3, cw=[(1, 20), (2, 430), (3, 20)])
    cmds.separator(st='none')
    cmds.helpLine(bgc=[0.0, 0.0, 0.0])
    cmds.separator(st='none')
    cmds.setParent(mainLayout)
    # Bottom margin.
    cmds.columnLayout()
    cmds.separator(h=10, st='none')
    cmds.setParent(mainLayout)

    #Parents the whole thing (Layout 1, 2, 3, 4, 5 and 6 to a TAB in the tab layout.
    cmds.setParent(tabs)
    """B. MATERIALS SUPER-LAYOUT"""
    materialsLayout = cmds.columnLayout()
    """Layout 7: Colour pickers."""
    cmds.columnLayout()
    cmds.separator(h=35, st='none')
    cmds.colorSliderGrp('rgb_board',
                        l="Board: ",
                        rgb=(0.430, 0.230, 0.11),
                        cw3=[52, 30, 368],
                        ann="Board colour.")
    cmds.separator(st='none', h=10)
    cmds.colorSliderGrp('rgb_pegs',
                        l="Pegs: ",
                        rgb=(0.6, 0.6, 0.6),
                        cw3=[52, 30, 368],
                        ann="Pegs colour.")
    cmds.separator(st='none', h=10)
    cmds.colorSliderGrp('rgb_disks',
                        l="Disks: ",
                        rgb=(1.0, 0.0, 0.0),
                        cw3=[52, 30, 368],
                        ann="Disks colour.")
    cmds.setParent(materialsLayout)

    # Parents the Layout 7 under the 'Materials' TAB in the tab layout.
    cmds.setParent(tabs)

    # Naming the tabs.
    cmds.tabLayout(tabs,
                   e=True,
                   tabLabel=((mainLayout, "Main"), (materialsLayout,
                                                    "Materials")))
    cmds.showWindow()
示例#10
0
def createUI():
    """
    Creates a user graphics interface.

    Keyword arguments:
    NONE

    On Exit:  All the functions will have been passed properly and the GUI will be initialised.
    """
    global windowID
    windowID = 'theWindow'
    
    # If the instance previously existed, delete it.
    if cmds.window( windowID, exists=True ):
        cmds.deleteUI( windowID )

    # Main window setup.
    cmds.window( windowID, title="Towers Of Hanoi", sizeable=False, width=470, rtf=True )

    # Header image for the interface.
    import os
    pathVar = os.path.dirname(__file__) # This stores the current working directory
    imagePath = pathVar+'/banner.png'
    cmds.columnLayout()
    cmds.image( image=imagePath )

    # We start a Tab Layout. We will parent a "Main" tab and a "Materials" tab.
    tabs = cmds.tabLayout()

    """A. MAIN SUPER-LAYOUT"""
    mainLayout = cmds.columnLayout( w=470 )
    
    cmds.columnLayout()
    cmds.separator( h=10, style='none' )

    def displayInstructions( *pArgs ):
        """
        Shows in an independent window a list of instructions for the user to set things up quickly. It acts as a kind of
        user guide.

        Keyword arguments:
        NONE.

        On Exit:  Pops a window displaying some instructions for the user.
        """
        if cmds.window( 'instructions_window', exists=True ):
            cmds.deleteUI( 'instructions_window' )
        instructions_window = cmds.window( 'instructions_window', title="Instructions", s=False, mnb=False, mxb=False )
        instructionsLayout = cmds.frameLayout( l="Instructions", collapsable=False, cl=False, mw = 10, mh=10 )
        cmds.rowColumnLayout( nc=3, cw=[(1,20),(2,480),(3,20)], cal=[(2,"left")], parent=instructionsLayout )
        cmds.separator( st='none' )
        cmds.text( l="- 1. Select the numbers of disks you want to play with.\n- 2. Click 'Place Disks' first. Then you "
            "will see that the disks has been brought to scene.\n- 3. Click 'Solve it!'. A lot of keyframes will appear on "
            "your timeline. Furthermore you will be able to\n       see each movement written down if you see the Script "
            "Editor window.\n- 4. If you want to change the number of disks FIRST CLEAR the scene by pressing 'Clear All'."
            "If\n       you skip this step you might crash the program.\n- 5. Once you are finished press the 'Exit' button"
            " and it will delete all the elements that\nhave been created for you" )
        cmds.separator( st='none' )
        cmds.showWindow( instructions_window )

    """Layout 1: Instructions."""
    cmds.rowColumnLayout( nc=5, cw=[(1,20),(2,245),(3,10),(4,175),(5,20)], cal=[(2,'right')] )
    cmds.separator( st='none' )
    cmds.text( l="Click at the Instructions button for a quick guide -" )
    cmds.separator( st='none' )
    cmds.button( l="Instructions", c=displayInstructions, ann="Displays a quick guide for running this script properly." )
    cmds.separator( st='none' )
    cmds.setParent( mainLayout )
    # Bottom margin.
    cmds.columnLayout()
    cmds.separator( h=5, st='none' )
    cmds.setParent( mainLayout )

    """Layout 2: Number of Disks integer slider."""
    cmds.columnLayout()
    global diskNumUIField
    diskNumUIField = cmds.intSliderGrp( l="Number of Disks: ", v=3, cw3=[115,20,305], min=1, max=10, fmx=20, f=True,
        ann="Number of disks you want to stack in the first peg" )
    cmds.setParent( mainLayout )
    # Bottom margin.
    cmds.columnLayout()
    cmds.separator( h=5, st='none' )
    cmds.setParent( mainLayout )

    """Layout 3: First row of buttons, 'Place Disks' and 'Clear All'."""
    cmds.rowColumnLayout( nc=5, cw=[(1,20),(2,212),(3,6),(4,212),(5,20)] )
    cmds.separator( st='none' )
    # This global definition and declaration prevents the program from crashing because of non-defined variables. This
    # variable, later on, will contain the name of the board geometric object so that we can apply the shader easier.
    global board
    board = 0
    cmds.button( l="Place Disks", c=placeDisks, ann="Stacks a pile of disks into the source peg." )
    cmds.separator( st='none' )
    cmds.button( l="Clear All", c=clearTowers, ann="Clears the disks." )
    cmds.separator( st='none' )
    cmds.setParent( mainLayout )

    cmds.columnLayout()
    cmds.separator( h=3, st='none' )
    cmds.setParent( mainLayout )
    
    """Layout 4: Second row of buttons, 'Solve it!' and 'Exit'."""
    cmds.rowColumnLayout( nc=5, cw=[(1,20),(2,212),(3,6),(4,212),(5,20)] )
    cmds.separator( st='none' )
    cmds.button( l="Solve it!", c=solvePuzzle, ann="Press to solve the puzzle once you have placed the disks.")
    cmds.separator( st='none' )
    cmds.button( l="Exit", c=exitProcedure, ann="Quits the application" )
    cmds.separator( st='none' )
    cmds.setParent( mainLayout )
    # Bottom margin.
    cmds.columnLayout()
    cmds.separator( h=10, st='none' )
    cmds.setParent( mainLayout )

    """Layout 5: Warnings line."""
    cmds.rowColumnLayout( nc=4, cw=[(1,20),(2,70),(3,360),(4,20)] )
    cmds.separator( st='none' )
    cmds.text( l="Warnings" )
    global warnings
    warnings = cmds.text( l="None.", en=False, ebg=True, bgc=[0,0.66,0.05] )
    cmds.separator( st='none' )
    cmds.setParent( mainLayout )
    # Bottom margin.
    cmds.columnLayout()
    cmds.separator( st='none' )
    cmds.setParent( mainLayout )

    """Layout 6: Help line."""
    cmds.rowColumnLayout( nc=3, cw=[(1,20),(2,430),(3,20)] )
    cmds.separator( st='none' )
    cmds.helpLine( bgc=[0.0,0.0,0.0] )
    cmds.separator( st='none' )
    cmds.setParent( mainLayout )
    # Bottom margin.
    cmds.columnLayout()
    cmds.separator( h=10, st='none' )
    cmds.setParent( mainLayout )
    
    #Parents the whole thing (Layout 1, 2, 3, 4, 5 and 6 to a TAB in the tab layout.
    cmds.setParent(tabs)
    
    """B. MATERIALS SUPER-LAYOUT"""
    materialsLayout = cmds.columnLayout()

    """Layout 7: Colour pickers."""
    cmds.columnLayout()
    cmds.separator( h=35, st='none' )
    cmds.colorSliderGrp( 'rgb_board', l="Board: ", rgb=(0.430,0.230,0.11), cw3=[52,30,368], ann="Board colour." )
    cmds.separator( st='none', h=10 )
    cmds.colorSliderGrp( 'rgb_pegs', l="Pegs: ", rgb=(0.6,0.6,0.6), cw3=[52,30,368], ann="Pegs colour." )
    cmds.separator( st='none', h=10 )
    cmds.colorSliderGrp( 'rgb_disks', l="Disks: ", rgb=(1.0,0.0,0.0), cw3=[52,30,368], ann="Disks colour." )
    cmds.setParent( materialsLayout )
    
    # Parents the Layout 7 under the 'Materials' TAB in the tab layout.
    cmds.setParent( tabs )

    # Naming the tabs.
    cmds.tabLayout( tabs, e=True, tabLabel=((mainLayout,"Main"),(materialsLayout,"Materials")) )
    cmds.showWindow()