######################################################################
#
#       DialFocus5.py
#
#       Copyright (c) 2003 C. Cigas
#
#       craig@castironflamingo.com
#
#       Manipulate morph dial visibility and values.
#
#       This is a fairly complicated script so it"s probably best you
#       dont make any edits unless you really know what you"re doing.
#
#       Thanks to Iuri Wickert for his thoughts on the notebook class
#       used as the basis for the tab class.
#
import poser
from Tkinter import *
from string import lower, find

global ident

######################################################################
#
#       Replacement for parameter .IsMorphTarget() method because
#       "the Poser" doesn"t return the correct values for the Body
#       actor.
#
parmBan = [ "zOffset", "yOffset", "xOffset", "Scale", "xScale", "yScale", "zScale", "yRotate",
            "xRotate", "zRotate", "xTran", "yTran", "zTran", "xTranB", "yTranB", "zTranB" ]

def IsMorph(parm):
        if parm.Actor().Name() == "Body":
                bFound = 1
                for ban in parmBan:
                        if parm.Name() == ban:
                                bFound = 0
                                break
                return(bFound)
        else:
                return(parm.IsMorphTarget())

######################################################################
#
#       Scan all morph channels and show, hide or zero the selected
#       groups.
#
def FigureChannelShowHide(szAction, iValue):
        oldAct = poser.Scene().CurrentActor()
        for act in ident.figure.Actors():
                poser.Scene().SelectActor(act)
                for parm in act.Parameters():
                        if IsMorph(parm):
                                if szAction == "Morph":
                                        parm.SetHidden(iValue)
                                elif szAction == "Zero":
                                        if parm.Value() == 0:
                                                parm.SetHidden(iValue)
                                elif szAction == "Blank":
                                        if parm.Name()[0] == "-":
                                                parm.SetHidden(iValue)
                                elif szAction == "PBM":
                                        if lower(parm.Name()[:3]) == "pbm" or lower(parm.Name()[:3]) == "jcm":
                                                parm.SetHidden(iValue)

        poser.Scene().SelectActor(oldAct)
        poser.Scene().DrawAll()
        poser.Scene().ProcessSomeEvents()

def FigureChannelZero(szAction):
        oldAct = poser.Scene().CurrentActor()
        for act in ident.figure.Actors():
                poser.Scene().SelectActor(act)
                for parm in act.Parameters():
                        if IsMorph(parm):
                                if szAction == "Morph":
                                        parm.SetValue(0)
                                elif szAction == "Blank":
                                        if parm.Name()[0] == "-":
                                                parm.SetValue(0)
                                elif szAction == "PBM":
                                        if lower(parm.Name()[:3]) == "pbm" or lower(parm.Name()[:3]) == "jcm":
                                                parm.SetValue(0)
        poser.Scene().SelectActor(oldAct)
        poser.Scene().DrawAll()
        poser.Scene().ProcessSomeEvents()

######################################################################
#
#       Scan all head morph channels and show, hide or zero selected
#       groups.
#
def HeadChannelShowHide(szAction, iValue):
        act = ident.figure.Actor("Head")
        if szAction == "Zero":
                for parm in act.Parameters():
                        if IsMorph(parm):
                                if parm.Value() == 0:
                                        parm.SetHidden(iValue)
        elif szAction == "PBM":
                for parm in act.Parameters():
                        if IsMorph(parm):
                                if lower(parm.Name()[:3]) == "pbm" or lower(parm.Name()[:3]) == "jcm":
                                        parm.SetHidden(iValue)
        else:
                for parm in ident.baseDict[szAction]:
                        try:
                                act.Parameter(parm).SetHidden(iValue)
                        except:
                                pass
        poser.Scene().SelectActor(ident.figure.Actor("Body"))
        poser.Scene().SelectActor(act)
        poser.Scene().DrawAll()
        poser.Scene().ProcessSomeEvents()

def HeadChannelZero(szAction):
        act = ident.figure.Actor("Head")
        for parm in ident.baseDict[szAction]:
                try:
                        act.Parameter(parm).SetValue(0)
                except:
                        pass
        poser.Scene().SelectActor(ident.figure.Actor("Body"))
        poser.Scene().SelectActor(act)
        poser.Scene().DrawAll()
        poser.Scene().ProcessSomeEvents()

######################################################################
#
#       GUI Support
#
class CMD:
    def __init__(self, callback, *args, **kwargs):
        self.callback = callback
        self.args = args
        self.kwargs = kwargs

    def __call__(self):
        return apply(self.callback, self.args, self.kwargs)

class tabs:
        def __init__(self, master):
                self.masterFrame = Frame(master, borderwidth=2, relief=RIDGE)
                self.activeFrame = None
                self.tabCount = 0
                self.selectedTab = IntVar(0)
                self.tabs = []
                self.radioFrame = Frame(self.masterFrame, borderwidth=2, relief=RIDGE)
                self.radioFrame.grid(row=0, column=0, sticky=N)
                self.tabFrame = Frame(self.masterFrame)
                self.tabFrame.grid(row=0, column=1, sticky=N)

        def __call__(self):
                return self.tabFrame
                
        def addTab(self, frm, title):
                self.tabs.append(Radiobutton(self.radioFrame, text=title, indicatoron=0,
                        variable=self.selectedTab, value=self.tabCount, width=14,
                        command=CMD(self.display,frm)))
                self.tabs[self.tabCount].grid(row=self.tabCount, column=0)
                if not self.activeFrame:
                        frm.grid(row=0, column=0)
                        self.activeFrame = frm
                        self.tabs[self.tabCount].select()
                self.tabCount = self.tabCount + 1
                
        def addSpacer(self, iValue):
                Label(self.radioFrame, height=iValue).grid(row=self.tabCount+1, column=0)
                        
        def display(self, frm):
                self.activeFrame.grid_forget()
                frm.grid(row=0, column=0)
                self.activeFrame = frm


######################################################################
#
#        User Interface
#
class App:
        def __init__(self, master):
                master.resizable(width=NO, height=NO)
                master.title("Cast Iron Flamingo")
                Label(master, text="Dial Focus", font=("Helvetica", 14, "bold")).grid(row=0, column=0)
                Label(master, text="Morphs for Figure \"" + ident.figureName + "\"", font=("Helvetica", 10, "bold")).grid(row=1, column=0)
                Label(master, text=ident.baseName, font=("Helvetica", 10, "bold")).grid(row=2, column=0)
                n = tabs(master)
                n.masterFrame.grid(row=3, column=0)
                #
                #       Tab 0 - Figure
                #
                f0 = Frame(n())
                currow = 0
                Label(f0, text="All morph dials ", font=("", 9, "bold")).grid(row=currow, column=0, sticky=W)
                Button(f0, text="Show", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(FigureChannelShowHide,"Morph",0)).grid(row=currow, column=1)
                Button(f0, text="Hide", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(FigureChannelShowHide,"Morph",1)).grid(row=currow, column=2)
                Button(f0, text="Zero", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(FigureChannelZero,"Morph")).grid(row=currow, column=3)

                currow = currow + 1
                Label(f0, text="Blank dials ", font=("", 9, "normal")).grid(row=currow, column=0, sticky=W)
                Button(f0, text="Show", width=8, padx=0, borderwidth=1, command=CMD(FigureChannelShowHide,"Blank",0)).grid(row=currow, column=1)
                Button(f0, text="Hide", width=8, padx=0, borderwidth=1, command=CMD(FigureChannelShowHide,"Blank",1)).grid(row=currow, column=2)
                Button(f0, text="Zero", width=8, padx=0, borderwidth=1, command=CMD(FigureChannelZero,"Blank")).grid(row=currow, column=3)

                currow = currow + 1
                Label(f0, text="PBM/JCM dials ", font=("", 9, "normal")).grid(row=currow, column=0, sticky=W)
                Button(f0, text="Show", width=8, padx=0, borderwidth=1, command=CMD(FigureChannelShowHide,"PBM",0)).grid(row=currow, column=1)
                Button(f0, text="Hide", width=8, padx=0, borderwidth=1, command=CMD(FigureChannelShowHide,"PBM",1)).grid(row=currow, column=2)
                Button(f0, text="Zero", width=8, padx=0, borderwidth=1, command=CMD(FigureChannelZero,"PBM")).grid(row=currow, column=3)

                currow = currow + 1
                Label(f0, text="Dials set to zero ", font=("", 9, "normal")).grid(row=currow, column=0, sticky=W)
                Button(f0, text="Show", width=8, padx=0, borderwidth=1, command=CMD(FigureChannelShowHide,"Zero",0)).grid(row=currow, column=1)
                Button(f0, text="Hide", width=8, padx=0, borderwidth=1, command=CMD(FigureChannelShowHide,"Zero",1)).grid(row=currow, column=2)
                
                currow = currow + 1
                Label(f0, text="---", height=20)
                #
                #       Tab 1 - Head Anatomy
                #
                f1 = Frame(n())
                currow = 0

                Label(f1, text="Anatomy ", font=("", 9, "bold")).grid(row=currow, column=0, sticky=W)
                Button(f1, text="Show", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(self.cmdAnatomyShowHide,0)).grid(row=currow, column=1)
                Button(f1, text="Hide", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(self.cmdAnatomyShowHide,1)).grid(row=currow, column=2)
                Button(f1, text="Zero", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=self.cmdAnatomyZero).grid(row=currow, column=3)

                currow = currow + 1
                Label(f1, text="Head ", font=("", 9, "normal")).grid(row=currow, column=0, sticky=W)
                Button(f1, text="Show", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"AnatomyHead",0)).grid(row=currow, column=1)
                Button(f1, text="Hide", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"AnatomyHead",1)).grid(row=currow, column=2)
                Button(f1, text="Zero", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelZero,"AnatomyHead")).grid(row=currow, column=3)

                currow = currow + 1
                Label(f1, text="Jaw ", font=("", 9, "normal")).grid(row=currow, column=0, sticky=W)
                Button(f1, text="Show", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"AnatomyJaw",0)).grid(row=currow, column=1)
                Button(f1, text="Hide", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"AnatomyJaw",1)).grid(row=currow, column=2)
                Button(f1, text="Zero", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelZero,"AnatomyJaw")).grid(row=currow, column=3)

                currow = currow + 1
                Label(f1, text="Eye ", font=("", 9, "normal")).grid(row=currow, column=0, sticky=W)
                Button(f1, text="Show", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"AnatomyEye",0)).grid(row=currow, column=1)
                Button(f1, text="Hide", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"AnatomyEye",1)).grid(row=currow, column=2)
                Button(f1, text="Zero", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelZero,"AnatomyEye")).grid(row=currow, column=3)

                currow = currow + 1
                Label(f1, text="Brow ", font=("", 9, "normal")).grid(row=currow, column=0, sticky=W)
                Button(f1, text="Show", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"AnatomyBrow",0)).grid(row=currow, column=1)
                Button(f1, text="Hide", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"AnatomyBrow",1)).grid(row=currow, column=2)
                Button(f1, text="Zero", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelZero,"AnatomyBrow")).grid(row=currow, column=3)

                currow = currow + 1
                Label(f1, text="Ear ", font=("", 9, "normal")).grid(row=currow, column=0, sticky=W)
                Button(f1, text="Show", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"AnatomyEar",0)).grid(row=currow, column=1)
                Button(f1, text="Hide", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"AnatomyEar",1)).grid(row=currow, column=2)
                Button(f1, text="Zero", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelZero,"AnatomyEar")).grid(row=currow, column=3)

                currow = currow + 1
                Label(f1, text="Nose ", font=("", 9, "normal")).grid(row=currow, column=0, sticky=W)
                Button(f1, text="Show", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"AnatomyNose",0)).grid(row=currow, column=1)
                Button(f1, text="Hide", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"AnatomyNose",1)).grid(row=currow, column=2)
                Button(f1, text="Zero", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelZero,"AnatomyNose")).grid(row=currow, column=3)

                currow = currow + 1
                Label(f1, text="Mouth ", font=("", 9, "normal")).grid(row=currow, column=0, sticky=W)
                Button(f1, text="Show", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"AnatomyMouth",0)).grid(row=currow, column=1)
                Button(f1, text="Hide", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"AnatomyMouth",1)).grid(row=currow, column=2)
                Button(f1, text="Zero", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelZero,"AnatomyMouth")).grid(row=currow, column=3)

                currow = currow + 1
                Label(f1, text="Props/PBM ", font=("", 9, "normal")).grid(row=currow, column=0, sticky=W)
                Button(f1, text="Show", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"AnatomyProps",0)).grid(row=currow, column=1)
                Button(f1, text="Hide", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"AnatomyProps",1)).grid(row=currow, column=2)
                Button(f1, text="Zero", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelZero,"AnatomyProps")).grid(row=currow, column=3)

                currow = currow + 1
                Label(f1, text="Head dials set to zero ", font=("", 9, "bold")).grid(row=currow, column=0, sticky=W)
                Button(f1, text="Show", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"Zero",0)).grid(row=currow, column=1)
                Button(f1, text="Hide", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"Zero",1)).grid(row=currow, column=2)

                currow = currow + 1
                Label(f1, text="Head PBM dials ", font=("", 9, "bold")).grid(row=currow, column=0, sticky=W)
                Button(f1, text="Show", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"PBM",0)).grid(row=currow, column=1)
                Button(f1, text="Hide", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"PBM",1)).grid(row=currow, column=2)
                #
                #       Tab 2 - Head Expression
                #
                f2 = Frame(n())
                currow = 0
                Label(f2, text="Expression ", font=("", 9, "bold")).grid(row=currow, column=0, sticky=W)
                Button(f2, text="Show", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(self.cmdExpressionShowHide,0)).grid(row=currow, column=1)
                Button(f2, text="Hide", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(self.cmdExpressionShowHide,1)).grid(row=currow, column=2)
                Button(f2, text="Zero", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=self.cmdExpressionZero).grid(row=currow, column=3)

                currow = currow + 1
                Label(f2, text="Eye ", font=("", 9, "normal")).grid(row=currow, column=0, sticky=W)
                Button(f2, text="Show", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"ExpressionEye",0)).grid(row=currow, column=1)
                Button(f2, text="Hide", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"ExpressionEye",1)).grid(row=currow, column=2)
                Button(f2, text="Zero", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelZero,"ExpressionEye")).grid(row=currow, column=3)

                currow = currow + 1
                Label(f2, text="Brow ", font=("", 9, "normal")).grid(row=currow, column=0, sticky=W)
                Button(f2, text="Show", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"ExpressionBrow",0)).grid(row=currow, column=1)
                Button(f2, text="Hide", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"ExpressionBrow",1)).grid(row=currow, column=2)
                Button(f2, text="Zero", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelZero,"ExpressionBrow")).grid(row=currow, column=3)

                currow = currow + 1
                Label(f2, text="Mouth ", font=("", 9, "normal")).grid(row=currow, column=0, sticky=W)
                Button(f2, text="Show", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"ExpressionMouth",0)).grid(row=currow, column=1)
                Button(f2, text="Hide", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"ExpressionMouth",1)).grid(row=currow, column=2)
                Button(f2, text="Zero", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelZero,"ExpressionMouth")).grid(row=currow, column=3)

                currow = currow + 1
                Label(f2, text="Speech ", font=("", 9, "normal")).grid(row=currow, column=0, sticky=W)
                Button(f2, text="Show", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"ExpressionSpeech",0)).grid(row=currow, column=1)
                Button(f2, text="Hide", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"ExpressionSpeech",1)).grid(row=currow, column=2)
                Button(f2, text="Zero", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelZero,"ExpressionSpeech")).grid(row=currow, column=3)

                currow = currow + 1
                Label(f2, text="Wrinkle ", font=("", 9, "normal")).grid(row=currow, column=0, sticky=W)
                Button(f2, text="Show", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"ExpressionWrinkle",0)).grid(row=currow, column=1)
                Button(f2, text="Hide", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"ExpressionWrinkle",1)).grid(row=currow, column=2)
                Button(f2, text="Zero", width=8, padx=0, borderwidth=1, command=CMD(HeadChannelZero,"ExpressionWrinkle")).grid(row=currow, column=3)

                currow = currow + 1
                Label(f2, text="Head dials set to zero ", font=("", 9, "bold")).grid(row=currow, column=0, sticky=W)
                Button(f2, text="Show", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"Zero",0)).grid(row=currow, column=1)
                Button(f2, text="Hide", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"Zero",1)).grid(row=currow, column=2)

                currow = currow + 1
                Label(f2, text="Head PBM dials ", font=("", 9, "bold")).grid(row=currow, column=0, sticky=W)
                Button(f2, text="Show", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"PBM",0)).grid(row=currow, column=1)
                Button(f2, text="Hide", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"PBM",1)).grid(row=currow, column=2)
                #
                #       Tab 2 - Head Expression
                #
                f3 = Frame(n())
                currow = 0
                Label(f3, text="Extra ", font=("", 9, "bold")).grid(row=currow, column=0, sticky=W)
                Button(f3, text="Show", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"Extra",0)).grid(row=currow, column=1)
                Button(f3, text="Hide", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"Extra",1)).grid(row=currow, column=2)
                Button(f3, text="Zero", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(HeadChannelZero,"Extra")).grid(row=currow, column=3)

                currow = currow + 1
                Label(f3, text="Head dials set to zero ", font=("", 9, "bold")).grid(row=currow, column=0, sticky=W)
                Button(f3, text="Show", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"Zero",0)).grid(row=currow, column=1)
                Button(f3, text="Hide", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"Zero",1)).grid(row=currow, column=2)

                currow = currow + 1
                Label(f3, text="Head PBM dials ", font=("", 9, "bold")).grid(row=currow, column=0, sticky=W)
                Button(f3, text="Show", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"PBM",0)).grid(row=currow, column=1)
                Button(f3, text="Hide", width=8, font=("",8,"bold"), padx=0, borderwidth=1, command=CMD(HeadChannelShowHide,"PBM",1)).grid(row=currow, column=2)

                f0.columnconfigure(0, minsize=150)
                f1.columnconfigure(0, minsize=150)
                f2.columnconfigure(0, minsize=150)
                f3.columnconfigure(0, minsize=150)
                n.addTab(f0, "Figure")
                n.addTab(f1, "Head Anatomy")
                n.addTab(f2, "Head Expression")
                n.addTab(f3, "Other Head")
                n.addSpacer(13)
                if not ident.foundBase():
                        n.tabs[1].config(state=DISABLED)
                        n.tabs[2].config(state=DISABLED)
                        n.tabs[3].config(state=DISABLED)
                root.update_idletasks()
                root.geometry(str(root.winfo_width()) + "x" + str(root.winfo_height()) + "+0+" + str((root.maxsize()[1] - root.winfo_height())/2))
                root.deiconify()
                poser.Scene().DrawAll()
                poser.Scene().ProcessSomeEvents()
        #
        #       Head macro commands
        #
        def cmdAnatomyShowHide(self, iValue):
                for cat in ident.baseDictCategories:
                        if ident.isAnatomyCategory(cat):
                                HeadChannelShowHide(cat, iValue)
        def cmdAnatomyZero(self):
                for cat in ident.baseDictCategories:
                        if ident.isAnatomyCategory(cat):
                                HeadChannelZero(cat)

        def cmdExpressionShowHide(self, iValue):
                for cat in ident.baseDictCategories:
                        if ident.isExpressionCategory(cat):
                                HeadChannelShowHide(cat, iValue)
        def cmdExpressionZero(self):
                for cat in ident.baseDictCategories:
                        if ident.isExpressionCategory(cat):
                                HeadChannelZero(cat)
                
        def quit(self):
                root.destroy()

######################################################################
#
#       Define a class to identify a figure"s base geometry and
#       preload a bunch of constants without burning up a lot of
#       resources.
#
class Ident:
        def __init__(self, curFig):
                self.figure = curFig
                self.figureName = ""
                self.baseName = ""
                self.baseDict = {}
                self.baseDictCategories = ["AnatomyHead","AnatomyJaw","AnatomyEye","AnatomyBrow","AnatomyEar","AnatomyNose","AnatomyMouth","AnatomyProps","ExpressionBrow","ExpressionEye","ExpressionMouth","ExpressionSpeech","ExpressionWrinkle","Extra"]

                if self.figure:
                        self.figureName = self.figure.Name()
                        #
                        #       Check for the signature morphs (those unique to a base figure) to identify the base.
                        #
                        if self.__checkParms(["AdamsApple", "BeardFLong", "BeardVLong", "BeardVandyke", "BigFoot", "ChinReceed", "EyesCrowFt", "LipCurveUp", "Open Lips", "Part Lips", "Thin"]):
                                self.baseName = "Michael 1.0"
                                self.baseDict["AnatomyHead"] = ["AfAmerHead","AsianHead","NatvAmerHead","Old","BigFoot","FaceFlat","FaceHeart","FaceLong","FaceRound","FaceSquare","AdamsApple","Thin"]
                                self.baseDict["AnatomyJaw"] = ["JawFull","FangTop","FangBot","TeethFlatter","TeethBuck","CheekBones","ChinCleft","ChinReceed"]
                                self.baseDict["AnatomyEye"] = ["EyesCloser","EyesBaggy","EyesRound","EyesDown"]
                                self.baseDict["AnatomyBrow"] = ["BrowsHeavy"]
                                self.baseDict["AnatomyEar"] = ["EarElf","EarSmall","EarLobeLong","EarLobeAttch"]
                                self.baseDict["AnatomyNose"] = ["NoseBig","NoseHeight","NoseFaerie","NoseBridge","NoseBump","NoseFlare","NoseFlat","NosePinch","NoseRound","NoseSlope","NoseUp","NoseWide"]
                                self.baseDict["AnatomyMouth"] = ["Philtrum","MouthRaised","MouthNarrow","LipRoundUp","LipCurveUp","LipFullUp","LipFullLo","LipThinUp","LipThinLo"]
                                self.baseDict["AnatomyProps"] = [ "BeardFull","BeardFLong","BeardGoatee","BeardVandyke","BeardVLong","BeardFork","Mustache"]
                                self.baseDict["ExpressionBrow"] = ["RBrowDown","LBrowDown","RBrowUp","LBrowUp"]
                                self.baseDict["ExpressionEye"] = ["Worry Right","Worry Left","Blink Right","Blink Left","Wince Right","Wince Left"]
                                self.baseDict["ExpressionMouth"] = ["Frown","Frown Right","Frown Left","Part Lips","Open Lips","Yell","Smile","Open Smile","Snarl Right","Snarl Left"]
                                self.baseDict["ExpressionSpeech"] = ["Mouth A","Mouth E","Mouth O","Mouth F","Mouth M","Tongue T","Mouth CH","Tongue L","TongueOut","TongueUp","TongueDown","TongueRight","TongueLeft"]
                                self.baseDict["ExpressionWrinkle"] = ["Dimple","EyesCrowFt","ForeHeadFlat"]

                        elif self.__checkParms(["BrdFullLong", "BrdGoateLng", "BrdVanDyke", "BrowIn", "BrowRidgeIn", "BrowThin", "ChinDimple", "EarAnimal3", "EarElf1", "EarElf2", "EarElf3", "EyesBaggy1", "EyesWrinkle", "FaceFull", "FaceLong1",
                                        "FaceLong2", "ForhdSmooth", "ForhdWrinkle", "HdMichael2", "HeadAlien2", "HeadBigFoot", "HeadNkOld", "HeadOld1", "HeadOld2", "HeadTroll", "JawStrong", "LipLowFull1", "LipLowFull2", "LipTopSmooth",
                                        "Lips4", "MthNarrow1", "MthNarrow2", "NoseAnimal", "NoseBeak", "NoseBig1", "NoseBig2", "NoseBrdgIn", "NoseHeight1", "NoseHeight2", "NoseTipLeft", "NoseTipRight", "NsBrdgThin1", "NsBrdgThin2", "NsChkSmooth",
                                        "NsRidgCrkd", "PurseLips", "pbmAdamApplDn", "pbmAdamsApple", "pbmEmaciated", "pbmMuscular1", "pbmMuscular2", "pbmMuscular3", "pbmMuscular4", "pbmNeckEmaciated", "pbmThin", "pbmTrapezius2", "pbmTrapsSmall", "pbmYoung"]):
                                self.baseName = "Michael 2.0"
                                self.baseDict["AnatomyHead"] = ["FaceFlat","FaceFull","FaceHeart","FaceLong1","FaceLong2","FaceRound","FaceSmooth","FaceSquare","HdAfAmer2","HdEmaciated","HdMichael2","HdNatvAmer","Head1","Head2","HeadAfAmer",
                                        "HeadAlien","HeadAlien2","HeadAsian","HeadAsian2","HeadAsian3","HeadBigFoot","HeadFaerie","HeadNkHeavy","HeadNkOld","HeadOld1","HeadOld2","HeadStylized","HeadTroll","HeadYoung","TemplesIn"]
                                self.baseDict["AnatomyJaw"] = ["CheekBones","ChinBack","ChinCleft","ChinDimple","JawFull","JawSmall","JawStrong","JawYoung","TeethFlatter","TeethGone","TeethHeight","TeethLoFang","TeethLoPoint","TeethUpBad",
                                        "TeethUpBuck","TeethUpFang","TeethUpGap","TeethUpPoint","TeethWidth","ToothUpGone"]
                                self.baseDict["AnatomyEye"] = ["EyeCornerDn","EyeDepth","EyeHeightL","EyeHeightR","EyeLidsAsian","EyeLidsHeavy","EyeWidth","EyesAlien","EyesCloser","EyesRound","EyesSlant"]
                                self.baseDict["AnatomyBrow"] = ["BrowHeavy","BrowIn","BrowRidgOut","BrowRidgeIn","BrowThin","BrowsGone","LashLoStrait","LashLowFull","LashUpFull","LashUpStrait","LashesLong"]
                                self.baseDict["AnatomyEar"] = ["EarAnimal1","EarAnimal2","EarAnimal3","EarBig","EarElf1","EarElf2","EarElf3","EarElfOut1","EarElfOut2","EarElfOut3","EarGremlin","EarIn","EarLobeAttch","EarLobeLong","EarOut",
                                        "EarSmall","EarUpL","EarUpR"]
                                self.baseDict["AnatomyNose"] = ["Nose1","Nose2","Nose3","Nose4","NoseAnimal","NoseBeak","NoseBig1","NoseBig2","NoseBrdgFlat","NoseBrdgIn","NoseBrdgOut","NoseBrdgUp","NoseBulbous","NoseBump","NoseCat",
                                        "NoseFaerie","NoseFlat","NoseHeight1","NoseHeight2","NosePinch","NoseRound","NoseSlope","NoseSmall","NoseStylized","NoseTipDown","NoseTipLeft","NoseTipRight","NoseTipUp","NoseUp","NoseWide",
                                        "NostrilFlare","NostrilHeight","NostrilWidth","NsBrdgThin1","NsBrdgThin2","NsBrdgWide","NsChkSmooth","NsRidgCrkd","NsRidgThin","NsRidgWide"]
                                self.baseDict["AnatomyMouth"] = ["LipLoNarrow","LipLoStylized","LipLowFull1","LipLowFull2","LipLowIn","LipLowOut","LipLowThin","LipTopSmooth","LipUpCurves","LipUpFull","LipUpIn","LipUpRound","LipUpSides",
                                        "LipUpStylized","LipUpThin","Lips1","Lips2","Lips3","Lips4","MouthCat","MouthRaise","MthNarrow1","MthNarrow2","Philtrum","TngForkLong","TongueDown","TongueFork","TongueLeft","TongueOut",
                                        "TongueRight","TongueUp"]
                                self.baseDict["AnatomyProps"] = ["BeardFork","BeardFull","BeardGoatee","BrdFullLong","BrdGoateLng","BrdVanDyke","Mustache"]
                                self.baseDict["ExpressionBrow"] = ["BrowAngleUp","BrowArchL","BrowArchR","BrowDownL","BrowDownR","BrowFrownL","BrowFrownR","BrowUpL","BrowUpR","BrowWorryL","BrowWorryR"]
                                self.baseDict["ExpressionEye"] = ["EyeBlinkL","EyeBlinkR","EyeWideL","EyeWideR","EyeWince1L","EyeWince1R","EyeWince2L","EyeWince2R","EyesBaggy1","EyesBaggy2","EyesPuffy","EyesWrinkle"]
                                self.baseDict["ExpressionMouth"] = ["CheekBalloon","OpenLips","OpenMouth","PartLips","PuckerLips","PurseLips","Smile Left","Smile Right","Smile1","Smile2","SmileOpen","Snarl Left","Snarl Right","Yell","Frown",
                                        "Frown Left","Frown Right"]
                                self.baseDict["ExpressionSpeech"] = ["Mouth A","Mouth CH","Mouth E","Mouth F","Mouth F!","Mouth M","Mouth O","Mouth SH","Mouth TH","Tongue L","Tongue T"]
                                self.baseDict["ExpressionWrinkle"] = ["BrowWrinkle","CheekDimple","CheekWrinkle","ChkCreaseL","ChkCreaseR","EyeWrinkleL","EyeWrinkleR","ForeheadFlat","ForhdSmooth","ForhdWrinkle","NoseWrinkle"]

                        elif self.__checkParms(["PBMHeavySpandex", "PBMMuscular1", "PBMMuscular2", "PBMMuscular3", "PBMNeckSpandex", "PBMNeckWattle", "PBMStocky", "PBMTone"]):
                                self.baseName = "Michael 3.0"
                                self.baseDict["AnatomyHead"] = ["FaceFlat","FaceHeart","FaceRound","FaceSquare","TemplesIn","HdAfrican","HdAfrican2","HdAfrican3","HdAsian","HdAsian2","HdChinese","HdJapanese","HdPolynesian","HdLatin","HdNtvAmer",
                                        "HdIndian","HdYoung","HdOld","HdOld2","HdAlien","HdChimp","HdFeline","HdGargoyle","HdFrankentn","FaceLong","FaceSoft","FaceLoThin","HairlineSml","ScalpAlien"]
                                self.baseDict["AnatomyJaw"] = ["CheekBones","ChinBack","ChinCleft","JawFull","JawSmall","JawYoung","ChkBoneSml","MandibleSml","ChinProtrude","ChinSmall","ChinStrong","GumUpBad","GumUpHeal","GumLoBad","GumLoHeal",
                                        "TthNosferatu","TthUpVamp","TthLoVamp","TthUpFang","TthLoFang","TthUpWolf","TthLoWolf","TthUpSharp","TthLoSharp","TthUpLarge","TthUpGap","TthUpChip","TthUpBgChip","TthUpSlant","TthUpCrkd","TthUpExCrkd",
                                        "TthLoCrkd","TthLoExCrkd","TthUpMlrGo","TthLoMlrGo","TthUpWisGo","TthLoWisGo","TthUpHeight","TthUpWidth","TthUpDepth","TthUpBack","TthUpXrot","TthLoHeight","TthLoWidth","TthLoDepth","TthLoBack","TthLoXrot"]
                                self.baseDict["AnatomyEye"] = ["EyesSmall","EyesBig","EyeRound","EyeLidShllw","EyeLidsHvy","EyeCreaseGo","EyeCornerBk","EyeCornerIn","LacrimalSize","LashLoFull","EyeCornerDn","EyeDepth","EyeHeightL","EyeHeightR",
                                        "EyeLidsAsian","EyeWidth","EyesAlien","EyesSlant"]
                                self.baseDict["AnatomyBrow"] = ["BrowHeavy","BrowsGone","LashLoStrait","LashUpFull","LashUpStrait","LashesLong","BrowOut","BrowSmall","BrowSoft","BrowRdgIn"]
                                self.baseDict["AnatomyEar"] = ["EarAnimal1","EarAnimal2","EarBig","EarIn","EarLobeAttch","EarLobeLong","EarSmall","EarsFrwd","EarsUp","EarlobeSize","EarElfSmall","EarElfBig","EarElven","EarChimp","EarDeer",
                                        "EarDeerBk","EarFeline","EarFelineBk","EarFin","EarRodent","EarRodentBk"]
                                self.baseDict["AnatomyNose"] = ["Nose1","Nose2","NoseBrdgFlat","NoseBrdgOut","NoseBrdgUp","NoseBulbous","NoseBump","NoseFaerie","NoseFlat","NosePinch","NoseRound","NoseSlope","NoseSmall","NoseUp","NoseWide",
                                        "NostrilFlare","NostrilHeight","NostrilWidth","NoseBig","NoseHeight","NoseRidgThin","NoseBrdgThin","NostrilSmall","NostrilSize"]
                                self.baseDict["AnatomyMouth"] = ["LipLoNarrow","LipLowOut","LipLowThin","LipUpCurves","LipUpFull","LipUpRound","LipUpSides","LipUpThin","MouthCat","MouthRaise","Philtrum","TongueDown","TongueLeft","TongueOut",
                                        "TongueRight","Philtrum2","PhiltrumIn","LipsStylized","LipsThin","LipLoLarge","LipLowFull","MouthSmall","MouthNarrow","MthCrnrSml","TongueFork1","TongueFork2","TongueThin","TongueHght","TongueWidth"]
                                self.baseDict["AnatomyProps"] = []
                                self.baseDict["ExpressionBrow"] = ["BrowAngleUp","BrowArchL","BrowArchR","BrowDownL","BrowDownR","BrowFrownL","BrowFrownR","BrowWorryL","BrowWorryR","RBrowUp","LBrowUp"]
                                self.baseDict["ExpressionEye"] = ["EyeWince1L","EyeWince1R","EyeWince2L","EyeWince2R","EyesBaggy2","EyesPuffy","EyesBaggy","EyesBaggy3","Blink Left","Blink Right"]
                                self.baseDict["ExpressionMouth"] = ["CheekBalloon","OpenLips","OpenMouth","PartLips","Smile1","Smile2","SmileOpen","CheekSink","TongueInDn","TongueInUp","TongueToTth","TongueOut2","TngueOutDn","TongueOutUp",
                                        "CheekSmileR","CheekSmileL","OpenLips2","MouthSing","MouthSpeak","MouthYell","SmileRight","SmileLeft","Snarl","SnarlRight","SnarlLeft","MouthDisgust","LipUpDown","LipLoDown","LipsPucker","LipsPucker2",
                                        "LipsPucker3","Frown","Frown Left","Frown Right",]
                                self.baseDict["ExpressionSpeech"] = [ "Mouth A","Mouth CH","Mouth F","Mouth F!","Mouth M","Mouth O","Mouth SH","Mouth TH","Tongue L","Tongue T","Mouth U"]
                                self.baseDict["ExpressionWrinkle"] = [ "BrowWrinkle","CheekDimple","ChkCreaseL","ChkCreaseR","EyeWrinkleL","EyeWrinkleR","ForeheadFlat","NoseWrinkle","FrhdWrinkle"]

                        elif self.__checkParms(["FRKHdBeast", "FRKHdChin", "FRKHdComicHero", "FRKHdGoat", "FRKHdGoblin", "FRKHdGoblin2", "FRKHdMichael3", "FRKHdOgre", "FRKHdOgre2", "FRKHdOrc", "FRKHdOrc2", "FRKHdReptile", "FRKHdSuperHero",
                                        "FRKHdTroll", "FRKHdZombie", "FRKHornFront1", "FRKHornFront2", "FRKHornsBrow", "FRKHornsSide", "FRKMouthHuge", "PBMFRKComicHero", "PBMFRKHeavy", "PBMFRKNeckSpandex", "PBMFRKOgre"]):
                                self.baseName = "Freak"
                                self.baseDict["AnatomyHead"] = ["FaceFlat","FaceHeart","FaceRound","FaceSquare","TemplesIn","HdAfrican","HdAfrican2","HdAfrican3","HdAsian","HdAsian2","HdChinese","HdJapanese","HdPolynesian","HdLatin","HdNtvAmer",
                                        "HdIndian","HdYoung","HdOld","HdOld2","HdAlien","HdChimp","HdFeline","HdGargoyle","HdFrankentn","FaceLong","FaceSoft","FaceLoThin","HairlineSml","ScalpAlien","FRKHdComicHero","FRKHdSuperHero","FRKHdGoblin",
                                        "FRKHdGoblin2","FRKHdOrc","FRKHdOrc2","FRKHdOgre","FRKHdOgre2","FRKHdTroll","FRKHdZombie","FRKHdBeast","FRKHdGoat","FRKHdReptile","FRKHdMichael3"]
                                self.baseDict["AnatomyEye"] = ["EyesSmall","EyesBig","EyeRound","EyeLidShllw","EyeLidsHvy","EyeCreaseGo","EyeCornerBk","EyeCornerIn","LacrimalSize","LashLoFull","EyeCornerDn","EyeDepth","EyeHeightL","EyeHeightR",
                                        "EyeLidsAsian","EyeWidth","EyesAlien","EyesSlant"]
                                self.baseDict["AnatomyJaw"] = ["CheekBones","ChinBack","ChinCleft","JawFull","JawSmall","JawYoung","ChkBoneSml","MandibleSml","ChinProtrude","ChinSmall","ChinStrong","GumUpBad","GumUpHeal","GumLoBad","GumLoHeal",
                                        "TthNosferatu","TthUpVamp","TthLoVamp","TthUpFang","TthLoFang","TthUpWolf","TthLoWolf","TthUpSharp","TthLoSharp","TthUpLarge","TthUpGap","TthUpChip","TthUpBgChip","TthUpSlant","TthUpCrkd","TthUpExCrkd",
                                        "TthLoCrkd","TthLoExCrkd","TthUpMlrGo","TthLoMlrGo","TthUpWisGo","TthLoWisGo","TthUpHeight","TthUpWidth","TthUpDepth","TthUpBack","TthUpXrot","TthLoHeight","TthLoWidth","TthLoDepth","TthLoBack","TthLoXrot",
                                        "FRKHdChin"]
                                self.baseDict["AnatomyBrow"] = ["BrowHeavy","BrowsGone","LashLoStrait","LashUpFull","LashUpStrait","LashesLong","BrowOut","BrowSmall","BrowSoft","BrowRdgIn"]
                                self.baseDict["AnatomyEar"] = ["EarAnimal1","EarAnimal2","EarBig","EarIn","EarLobeAttch","EarLobeLong","EarSmall","EarsFrwd","EarsUp","EarlobeSize","EarElfSmall","EarElfBig","EarElven","EarChimp","EarDeer",
                                        "EarDeerBk","EarFeline","EarFelineBk","EarFin","EarRodent","EarRodentBk"]
                                self.baseDict["AnatomyNose"] = ["Nose1","Nose2","NoseBrdgFlat","NoseBrdgOut","NoseBrdgUp","NoseBulbous","NoseBump","NoseFaerie","NoseFlat","NosePinch","NoseRound","NoseSlope","NoseSmall","NoseUp","NoseWide",
                                        "NostrilFlare","NostrilHeight","NostrilWidth","NoseBig","NoseHeight","NoseRidgThin","NoseBrdgThin","NostrilSmall","NostrilSize"]
                                self.baseDict["AnatomyMouth"] = ["LipLoNarrow","LipLowOut","LipLowThin","LipUpCurves","LipUpFull","LipUpRound","LipUpSides","LipUpThin","MouthCat","MouthRaise","Philtrum","TongueDown","TongueLeft","TongueOut",
                                        "TongueRight","Philtrum2","PhiltrumIn","LipsStylized","LipsThin","LipLoLarge","LipLowFull","MouthSmall","MouthNarrow","MthCrnrSml","TongueFork1","TongueFork2","TongueThin","TongueHght","TongueWidth",
                                        "FRKMouthHuge"]
                                self.baseDict["AnatomyProps"] = ["FRKHornsBrow","FRKHornsSide","FRKHornFront1","FRKHornFront2"]
                                self.baseDict["ExpressionBrow"] = ["BrowAngleUp","BrowArchL","BrowArchR","BrowDownL","BrowDownR","BrowFrownL","BrowFrownR","BrowWorryL","BrowWorryR","RBrowUp","LBrowUp"]
                                self.baseDict["ExpressionEye"] = ["EyeWince1L","EyeWince1R","EyeWince2L","EyeWince2R","EyesBaggy2","EyesPuffy","EyesBaggy","EyesBaggy3","Blink Left","Blink Right"]
                                self.baseDict["ExpressionMouth"] = ["CheekBalloon","OpenLips","OpenMouth","PartLips","Smile1","Smile2","SmileOpen","CheekSink","TongueInDn","TongueInUp","TongueToTth","TongueOut2","TngueOutDn","TongueOutUp",
                                        "CheekSmileR","CheekSmileL","OpenLips2","MouthSing","MouthSpeak","MouthYell","SmileRight","SmileLeft","Snarl","SnarlRight","SnarlLeft","MouthDisgust","LipUpDown","LipLoDown","LipsPucker","LipsPucker2",
                                        "LipsPucker3","Frown","Frown Left","Frown Right"]
                                self.baseDict["ExpressionSpeech"] = ["Mouth A","Mouth CH","Mouth F","Mouth F!","Mouth M","Mouth O","Mouth SH","Mouth TH","Tongue L","Tongue T","Mouth U"]
                                self.baseDict["ExpressionWrinkle"] = ["BrowWrinkle","CheekDimple","ChkCreaseL","ChkCreaseR","EyeWrinkleL","EyeWrinkleR","ForeheadFlat","NoseWrinkle","FrhdWrinkle"]

                        elif self.__checkParms(["ChkMouthIn", "HdVictoria2", "HeadFox", "HeadHag", "HeadMonkey", "HeadOld", "pbmAnimeHdNeck"]):
                                self.baseName = "Victoria 2.0"
                                self.baseDict["AnatomyHead"] = ["HdVictoria2","HeadAsian","HeadAsian2","HeadAsian3","HeadAfAmer","HdAfAmer2","HdNatvAmer","Head1","Head2","HeadStylized","HeadFaerie","HeadHag","HeadAlien","HeadFox","HeadMonkey",
                                        "HeadYoung","HeadOld","HeadNkHeavy","HdEmaciated","FaceFlat","FaceHeart","FaceLong","FaceRound","FaceSquare","FaceSmooth","TemplesIn"]
                                self.baseDict["AnatomyJaw"] = ["TeethGone","TeethWidth","TeethHeight","TeethFlatter","TeethUpGap","ToothUpGone","CheekBones","ChkMouthIn","JawYoung","JawSmall","JawFull","ChinBack","ChinStrong","ChinCleft"]
                                self.baseDict["AnatomyEye"] = ["EyeWidth","EyeHeightR","EyeHeightL","EyeDepth","EyeLidsHeavy","EyeLidsAsian","EyeCornerBk","EyeCornerIn","EyeCornerDn","EyesCloser","EyesRound","EyesSlant","EyesPuffy","EyesBaggy",
                                        "EyesAlien","LashesLong","LashUpFull","LashLowFull","LashUpStrait","LashLoStrait"]
                                self.baseDict["AnatomyBrow"] = ["BrowHeavy","BrowsGone","BrowRidgOut"]
                                self.baseDict["AnatomyEar"] = ["EarIn","EarSmall","EarLobeLong","EarLobeAttch","EarElfSmall","EarElfBig","EarAnimal1","EarAnimal2"]
                                self.baseDict["AnatomyNose"] = ["Nose1","Nose2","NoseStylized","NoseFaerie","NoseSmall","NoseBig","NoseHeight","NoseBrdgFlat","NoseBrdgOut","NoseBrdgUp","NoseBrdgThin","NoseRidgThin","NoseBump","NoseFlat",
                                        "NoseSlope","NoseWide","NoseUp","NosePinch","NoseRound","NoseBulbous","NoseCat","NostrilWidth","NostrilFlare","NostrilHeight"]
                                self.baseDict["AnatomyMouth"] = ["Philtrum","MouthRaise","MouthNarrow","MouthCat","Lips1","Lips2","Lips3","LipUpStylized","LipLoStylized","LipUpRound","LipUpSides","LipUpCurves","LipUpFull","LipLowFull","LipUpThin",
                                        "LipLowThin","LipLoNarrow","LipLowOut","TeethUpBad","TeethUpBuck","TeethUpFang","TeethLoFang","TeethUpPoint","TeethLoPoint","TongueFork1","TongueFork2","TongueOut","TongueUp","TongueDown","TongueRight",
                                        "TongueLeft"]
                                self.baseDict["AnatomyProps"] = []
                                self.baseDict["ExpressionBrow"] = ["BrowAngleUp","BrowArchR","BrowArchL","BrowUpR","BrowUpL","BrowDownR","BrowDownL","BrowFrownR","BrowFrownL","BrowWorryR","BrowWorryL"]
                                self.baseDict["ExpressionEye"] = ["EyeBlinkR","EyeBlinkL","EyeWince1R","EyeWince1L","EyeWince2R","EyeWince2L"]
                                self.baseDict["ExpressionMouth"] = ["CheekBalloon","PartLips","OpenLips","OpenMouth","Yell","Smile1","Smile2","SmileOpen","Smile Right","Smile Left","Snarl Right","Snarl Left","Frown","Frown Right","Frown Left"]
                                self.baseDict["ExpressionSpeech"] = ["Mouth A","Mouth O","Mouth F","Mouth F !","Tongue L","Mouth M","Tongue T","Mouth CH","Mouth SH","Mouth TH"]
                                self.baseDict["ExpressionWrinkle"] = ["ForeheadFlat","CheekDimple","EyeWrinkleR","EyeWrinkleL","NoseWrinkle","ChkCreaseR","ChkCreaseL"]

                        elif self.__checkParms(["BrwBoneSml", "EyeHeight", "EyesSlant1", "EyesSlant2", "HdAfrican4", "HdAlien2", "HdAlien2Male", "HdAlienMale", "HdCeltic", "HdChinese2", "HdFaerie", "HdFrench", "HdGermanic", "HdHag",
                                        "HdJapanese2", "HdKorean", "HdMale", "HdMale2", "HdNordic", "HdNtvAmer2", "HdPhilipino", "HdSlavic", "LashUpPnt", "LipsMasculn", "PBMFaerie", "PBMRubenesque"]):
                                self.baseName = "Victoria 3.0"
                                self.baseDict["AnatomyHead"] = ["FaceFlat","FaceHeart","FaceRound","FaceSquare","TemplesIn","HdAfrican","HdAfrican2","HdAfrican3","HdAsian","HdAsian2","HdChinese","HdJapanese","HdPolynesian","HdLatin","HdNtvAmer",
                                        "HdIndian","HdYoung","HdOld","HdOld2","HdAlien","HdChimp","HdFeline","HdGargoyle","FaceLong","FaceSoft","FaceLoThin","HairlineSml","ScalpAlien","HdAfrican4","HdChinese2","HdJapanese2","HdKorean",
                                        "HdPhilipino","HdNtvAmer2","HdCeltic","HdFrench","HdGermanic","HdNordic","HdSlavic","HdMale","HdMale2","HdFaerie","HdAlien2","HdAlienMale","HdAlien2Male","HdHag"]
                                self.baseDict["AnatomyEye"] = ["EyesSmall","EyesBig","EyeRound","EyeLidShllw","EyeLidsHvy","EyeCreaseGo","EyeCornerBk","EyeCornerIn","LacrimalSize","LashLoFull","EyeCornerDn","EyeDepth","EyeLidsAsian","EyeWidth",
                                        "EyesAlien","EyeHeight","EyesSlant1","EyesSlant2","LashUpPnt"]
                                self.baseDict["AnatomyJaw"] = ["CheekBones","ChinBack","ChinCleft","JawFull","JawSmall","JawYoung","ChkBoneSml","MandibleSml","ChinProtrude","ChinSmall","ChinStrong","GumUpBad","GumUpHeal","GumLoBad","GumLoHeal",
                                        "TthNosferatu","TthUpVamp","TthLoVamp","TthUpFang","TthLoFang","TthUpWolf","TthLoWolf","TthUpSharp","TthLoSharp","TthUpLarge","TthUpGap","TthUpChip","TthUpBgChip","TthUpSlant","TthUpCrkd","TthUpExCrkd",
                                        "TthLoCrkd","TthLoExCrkd","TthUpMlrGo","TthLoMlrGo","TthUpWisGo","TthLoWisGo","TthUpHeight","TthUpWidth","TthUpDepth","TthUpBack","TthUpXrot","TthLoHeight","TthLoWidth","TthLoDepth","TthLoBack","TthLoXrot"]
                                self.baseDict["AnatomyBrow"] = ["BrowHeavy","BrowsGone","LashLoStrait","LashUpFull","LashUpStrait","LashesLong","BrowSmall","BrowSoft","BrwBoneSml"]
                                self.baseDict["AnatomyEar"] = ["EarAnimal1","EarAnimal2","EarBig","EarIn","EarLobeAttch","EarLobeLong","EarSmall","EarsFrwd","EarsUp","EarlobeSize","EarElfSmall","EarElfBig","EarElven","EarChimp","EarDeer",
                                        "EarDeerBk","EarFeline","EarFelineBk","EarFin","EarRodent","EarRodentBk"]
                                self.baseDict["AnatomyNose"] = ["Nose1","NoseBrdgFlat","NoseBrdgOut","NoseBrdgUp","NoseBulbous","NoseBump","NoseFaerie","NoseFlat","NosePinch","NoseRound","NoseSlope","NoseSmall","NoseUp","NoseWide","NostrilFlare",
                                        "NostrilHeight","NostrilWidth","NoseBig","NoseHeight","NoseRidgThin","NoseBrdgThin","NostrilSmall","NostrilSize","NoseStylized"]
                                self.baseDict["AnatomyMouth"] = ["LipLoNarrow","LipLowOut","LipLowThin","LipUpCurves","LipUpFull","LipUpRound","LipUpSides","LipUpThin","MouthCat","MouthRaise","Philtrum","TongueLeft","TongueOut","TongueRight",
                                        "Philtrum2","PhiltrumIn","LipsThin","LipLoLarge","LipLowFull","MouthSmall","MouthNarrow","MthCrnrSml","TongueFork1","TongueFork2","TongueThin","TongueHght","TongueWidth","Lips2","Lips3","LipsMasculn","Lips1"]
                                self.baseDict["AnatomyProps"] = []
                                self.baseDict["ExpressionBrow"] = ["BrowAngleUp","BrowArchL","BrowArchR","BrowDownL","BrowDownR","BrowFrownL","BrowFrownR","BrowWorryL","BrowWorryR","RBrowUp","LBrowUp"]
                                self.baseDict["ExpressionEye"] = ["EyeWince1L","EyeWince1R","EyeWince2L","EyeWince2R","EyesBaggy2","EyesPuffy","EyesBaggy","EyesBaggy3","Blink Left","Blink Right"]
                                self.baseDict["ExpressionMouth"] = ["CheekBalloon","OpenLips","OpenMouth","PartLips","Smile1","Smile2","SmileOpen","CheekSink","TongueInDn","TongueInUp","TngueOutDn","TongueOutUp","OpenLips2","MouthSing",
                                        "MouthSpeak","MouthYell","SmileRight","SmileLeft","Snarl","SnarlRight","SnarlLeft","MouthDisgust","LipsPucker","Frown","Frown Left","Frown Right"]
                                self.baseDict["ExpressionSpeech"] = ["Mouth A","Mouth CH","Mouth F","Mouth M","Mouth O","Mouth SH","Mouth TH","Tongue L","Tongue T","Mouth U"]
                                self.baseDict["ExpressionWrinkle"] = ["CheekDimple","ChkCreaseL","ChkCreaseR","EyeWrinkleL","EyeWrinkleR","ForeheadFlat","NoseWrinkle"]

                        elif self.__checkParms(["EyeSize", "EyeWinceL", "EyeWinceR", "FrownLeft", "FrownRight", "LipsStylized1", "LipsStylized2", "MouthTH", "NoseTipWide", "PhiltrumSmth", "SmileOpen1", "SmileOpen2", "SmileOpen3", "pbmStephanie"]):
                                self.baseName = "Stephanie 1.0"
                                self.baseDict["AnatomyHead"] = ["HeadAsian","HeadAfAmer","HeadFaerie","FaceFlat","FaceLong","FaceRound"]
                                self.baseDict["AnatomyJaw"] = ["CheekBones","TeethGone","TeethWidth","TeethHeight","TeethFlatter","TeethUpGap","ToothUpGone","TeethUpBad","TeethUpBuck","TeethUpFang","TeethLoFang","TeethUpPoint","TeethLoPoint",
                                        "JawFull","ChinBack","ChinCleft"]
                                self.baseDict["AnatomyEye"] = ["EyeWideR","EyeWideL","EyeBlinkR","EyeBlinkL","EyeWinceR","EyeWinceL","EyeSize","EyeWidth","EyeHeightR","EyeHeightL","EyeDepth","EyeLidsHeavy","EyeLidsAsian","EyeCornerDn","EyesSlant",
                                        "LashesLong","LashUpFull","LashLowFull","LashUpStrait","LashLoStrait"]
                                self.baseDict["AnatomyBrow"] = ["BrowsGone"]
                                self.baseDict["AnatomyEar"] = ["EarBig","EarSmall","EarUpR","EarUpL","EarIn","EarOut","EarLobeLong","EarLobeAttch","EarElf","EarElfOut1","EarElfOut2","EarElfOut3","EarAnimal1","EarAnimal2","EarGremlin"]
                                self.baseDict["AnatomyNose"] = ["Nose1","Nose2","Nose3","Nose4","NoseSmall","NoseBig","NoseHeight","NoseStylized","NoseFaerie","NoseCat","NoseBrdgOut","NoseBrdgUp","NoseBrdgThin","NsBrdgWide","NoseBrdgFlat",
                                        "NsRidgThin","NsRidgWide","NoseBump","NoseFlat","NoseSlope","NoseWide","NosePinch","NoseRound","NoseBulbous","NoseTipUp","NoseTipDown","NoseTipWide","NostrilWidth","NostrilFlare","NostrilHeight"]
                                self.baseDict["AnatomyMouth"] = ["TongueFork","TngForkLong","TongueOut","TongueUp","TongueDown","TongueRight","TongueLeft","Philtrum","PhiltrumSmth","MouthRaise","MouthNarrow","MouthCat","Lips1","Lips2",
                                        "LipsStylized1","LipsStylized2","LipUpStylized","LipLoStylized","LipUpRound","LipUpCurves","LipUpFull","LipLowFull","LipUpThin","LipLowThin","LipLoNarrow","LipLowOut","LipUpIn","LipLowIn"]
                                self.baseDict["AnatomyProps"] = []
                                self.baseDict["ExpressionBrow"] = ["BrowAngleUp","BrowArchR","BrowArchL","BrowUpR","BrowUpL","BrowDownR","BrowDownL","BrowFrownR","BrowFrownL","BrowWorryR","BrowWorryL"]
                                self.baseDict["ExpressionEye"] = []
                                self.baseDict["ExpressionMouth"] = ["Snarl","SnarlRight","SnarlLeft","PuckerLips","PartLips","OpenLips","OpenMouth","Yell","Smile1","Smile2","SmileOpen1","SmileOpen2","SmileOpen3","SmileRight","SmileLeft",
                                        "CheekBalloon","Frown","FrownRight","FrownLeft"]
                                self.baseDict["ExpressionSpeech"] = ["Mouth A","Mouth O","Mouth F","Tongue L","Mouth M","Tongue T","Mouth CH","Mouth SH","MouthTH"]
                                self.baseDict["ExpressionWrinkle"] = ["ChkCreaseR","ChkCreaseL","EyeWrinkleR","EyeWrinkleL","NoseWrinkle","BrowWrinkle","CheekDimple","CheekWrinkle"]
                        elif self.__checkParms(["AfAmerHead","AnimeHdNeck","AsianHead","Blink Left","Blink Right","Brows In","BrowsHeavy","CheekBones","ChinCleft","Dimple","EarElf","EarLobeAttch","EarLobeLong","EarSmall","EyeCornrBk","EyeLashes",
                                        "EyesBaggy","EyesCloser","EyesDown","EyesRound","FaceFlat","FaceHeart","FaceLong","FaceRound","FaceSquare","FaerieHdNeck","FaerieHead","FangBot","FangTop","ForeHeadFlat","Frown","Frown Left","Frown Right",
                                        "JawFull","JawSmall","LBrowDown","LBrowUp","LipCurvesUp","LipFullLo","LipFullUp","LipRoundUp","LipThinLo","LipThinUp","Monkey","Mouth A","Mouth CH","Mouth F","Mouth F !","Mouth M","Mouth O","MouthNarrow",
                                        "MouthRaised","NatvAmerHead","NoseBig","NoseBridge","NoseBump","NoseFaerie","NoseFlare","NoseFlat","NoseHeight","NosePinch","NoseRound","NoseSlope","NoseUp","NoseWide","Old","Open Smile","OpenLips",
                                        "Philtrum","RBrowDown","RBrowUp","Smile","Snarl Left","Snarl Right","TeethBuck","TeethFlatter","Tongue L","Tongue T","Wince Left","Wince Right","Worry Left","Worry Right","Yell"]):
                                        #
                                        #       Victoria 1.0 is a special case since her morph list is a perfect subset of all the others. We have to check
                                        #       for Victoria 2.0 and 3.0"s signature morphs then check for all of Victoria 1.0"s morphs to identify.
                                        #
                                self.baseName = "Victoria 1.0"
                                self.baseDict["AnatomyHead"] = ["AfAmerHead","AsianHead","NatvAmerHead","FaerieHead","FaerieHdNeck","AnimeHdNeck","Old","Monkey","FaceFlat","FaceHeart","FaceLong","FaceRound","FaceSquare"]
                                self.baseDict["AnatomyJaw"] = ["FangTop","FangBot","TeethFlatter","TeethBuck","CheekBones","ChinCleft","JawFull","JawSmall"]
                                self.baseDict["AnatomyEye"] = ["EyeLashes","EyeCornrBk","EyesCloser","EyesBaggy","EyesRound","EyesDown"]
                                self.baseDict["AnatomyBrow"] = ["BrowsHeavy","Brows In"]
                                self.baseDict["AnatomyEar"] = ["EarElf","EarSmall","EarLobeLong","EarLobeAttch"]
                                self.baseDict["AnatomyNose"] = ["NoseBig","NoseHeight","NoseFaerie","NoseBridge","NoseBump","NoseFlare","NoseFlat","NosePinch","NoseRound","NoseSlope","NoseUp","NoseWide"]
                                self.baseDict["AnatomyMouth"] = ["Philtrum","MouthRaised","MouthNarrow","LipRoundUp","LipCurvesUp","LipFullUp","LipFullLo","LipThinUp","LipThinLo"]
                                self.baseDict["AnatomyProps"] = []
                                self.baseDict["ExpressionBrow"] = ["RBrowDown","LBrowDown","RBrowUp","LBrowUp","Worry Right","Worry Left","Blink Right","Blink Left","Wince Right","Wince Left"]
                                self.baseDict["ExpressionEye"] = []
                                self.baseDict["ExpressionMouth"] = ["OpenLips","Yell","Smile","Open Smile","Snarl Right","Snarl Left","Frown","Frown Right","Frown Left"]
                                self.baseDict["ExpressionSpeech"] = ["Mouth A","Mouth O","Mouth F","Mouth F !","Mouth M","Tongue T","Mouth CH","Tongue L"]
                                self.baseDict["ExpressionWrinkle"] = ["ForeHeadFlat","Dimple"]
                #
                #       Dump any extra morphs into a separate category
                #
                if self.foundBase():
                        self.__colParm = []
                        for parm in self.figure.Actor("Head").Parameters():
                                if parm.IsMorphTarget():
                                        if lower(parm.Name()[:3]) != "pbm" and lower(parm.Name()[:3]) != "jcm":
                                                self.__colParm.append(parm.Name())
                        for cat in self.baseDictCategories:
                                if cat != "Extra":
                                        for parm in self.baseDict[cat]:
                                                try:
                                                        self.__colParm.remove(parm)
                                                except:
                                                        pass
                        self.baseDict["Extra"] = self.__colParm

        def foundBase(self):
                return(len(self.baseName) != 0)

        def isAnatomyCategory(self, cat):
                return(find(cat, "Anatomy") == 0)

        def isExpressionCategory(self, cat):
                return(find(cat, "Expression") == 0)

        def __checkParms(self, lstIdent):
                bFound = 0
                for szParmName in lstIdent:
                        try:
                                pzrParm = self.figure.Actor("Head").Parameter(szParmName).Name()
                                bFound = 1
                        except:
                                bFound = 0
                                break
                return(bFound)

######################################################################
#
#       Main
#
ident = Ident(poser.Scene().CurrentFigure())
if ident.figure:
        root = Tk()
        app = App(root)
        root.mainloop()

