From 5b9c717f3dbf51dafc8219c83c1a1999352fdcb1 Mon Sep 17 00:00:00 2001 From: Dave Schuyler Date: Sat, 18 Mar 2006 00:56:30 +0000 Subject: [PATCH] formatting --- direct/src/ffi/FFITypes.py | 140 +++++++++++++++++----------------- direct/src/ffi/jGenPyCode.py | 20 ++--- direct/src/showbase/Loader.py | 13 ++-- direct/src/tkpanels/Placer.py | 73 +++++++++--------- 4 files changed, 122 insertions(+), 124 deletions(-) diff --git a/direct/src/ffi/FFITypes.py b/direct/src/ffi/FFITypes.py index ae8f06cfe4..c164942175 100644 --- a/direct/src/ffi/FFITypes.py +++ b/direct/src/ffi/FFITypes.py @@ -46,7 +46,7 @@ class BaseTypeDescriptor: # The type descriptors for the types we derive from self.parentTypes = [] - + # atomicType may be one of the following # AT_not_atomic = 0 # AT_int = 1 @@ -65,7 +65,7 @@ class BaseTypeDescriptor: def isAtomic(self): return (self.atomicType != 0) - + def generateGlobalCode(self, dir, extensionsDir): # By default generate no code pass @@ -100,7 +100,7 @@ class PrimitiveTypeDescriptor(BaseTypeDescriptor): """ def __init__(self): BaseTypeDescriptor.__init__(self) - + def generateReturnValueWrapper(self, classTypeDesc, file, userManagesMemory, needsDowncast, nesting): """ @@ -117,7 +117,7 @@ class PyObjectTypeDescriptor(BaseTypeDescriptor): """ def __init__(self): BaseTypeDescriptor.__init__(self) - + def generateReturnValueWrapper(self, classTypeDesc, file, userManagesMemory, needsDowncast, nesting): indent(file, nesting, 'return returnValue\n') @@ -154,7 +154,7 @@ class EnumTypeDescriptor(PrimitiveTypeDescriptor): indent(file, nesting, '# CMODULE [' + self.moduleName + ']\n') self.outputComment(file, nesting) self.outputValues(file, nesting) - + def outputComment(self, file, nesting): indent(file, nesting, '\n') @@ -172,7 +172,7 @@ class EnumTypeDescriptor(PrimitiveTypeDescriptor): """ for key in self.values.keys(): indent(file, nesting, key + ' = ' + `self.values[key]` + '\n') - + class DerivedTypeDescriptor(BaseTypeDescriptor): """ @@ -182,7 +182,7 @@ class DerivedTypeDescriptor(BaseTypeDescriptor): def __init__(self): BaseTypeDescriptor.__init__(self) self.typeDescriptor = None - + def recursiveTypeDescriptor(self): """ Attempt to get to the bottom of a type descriptor by @@ -213,26 +213,26 @@ class ClassTypeDescriptor(BaseTypeDescriptor): """ def __init__(self): BaseTypeDescriptor.__init__(self) - + # Methods interrogate told us were constructors self.constructors = [] - + # A method interrogate told us is the destructor self.destructor = None - + # Methods interrogate told us were instance methods # Note: the methods without the this pointer get moved into staticMethods self.instanceMethods = [] - + # Methods interrogate told us were upcast methods self.upcastMethods = [] - + # Methods interrogate told us were downcast methods self.downcastMethods = [] - + # Instance methods that had no this pointer are moved into here self.staticMethods = [] - + # These are dictionaries used to temporarily hold methods for # overloading while generating code self.overloadedClassMethods = {} @@ -305,7 +305,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor): for method in parentType.upcastMethods: upcastMethods.append(method) for method in (self.constructors + [self.destructor] + self.instanceMethods - + self.upcastMethods + self.downcastMethods + + self.upcastMethods + self.downcastMethods + self.staticMethods + upcastMethods): if method: # Get the real return type (not derived) @@ -345,7 +345,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor): """ methodList = self.overloadedClassMethods.setdefault(methodSpec.name, []) methodList.append(methodSpec) - + def recordInstanceMethod(self, methodSpec): """ @@ -437,7 +437,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor): if parentList[pi].hasMethodNamed(methodName): return 1 return 0 - + def copyParentMethodsRecursively(self, parentList, file, nesting): """ Copy all the parents instance methods @@ -464,13 +464,13 @@ class ClassTypeDescriptor(BaseTypeDescriptor): if not self.inheritsMethodNamed(parentList, methodSpecList[0].name): treeColl = FFIOverload.FFIMethodArgumentTreeCollection(self, methodSpecList) treeColl.generateCode(file, nesting) - + # Copy all the parents upcast methods so we transitively pick them up for method in parent.upcastMethods: if not self.inheritsMethodNamed(parentList, method.name): # no downcast for all instance methods that are themselves upcasts # that would cause an infinite loop - method.generateInheritedMethodCode(self, parentList, file, nesting, 0) + method.generateInheritedMethodCode(self, parentList, file, nesting, 0) # Now recurse up the hierarchy until we get to a node that is itself # a multiple inheritance node and stop there because he will have already @@ -511,16 +511,16 @@ class ClassTypeDescriptor(BaseTypeDescriptor): file = open(os.path.join(dir, fileName), 'w') indent(file, 0, FFIConstants.generatedHeader) self.outputBaseImports(file) - self.generateCode1(file, 0,extensionsDir) + self.generateCode1(file, 0, extensionsDir) file.close() - + file = open(os.path.join(dir, fileName1), 'w') indent(file, 0, FFIConstants.generatedHeader) #self.outputBaseImports(file) - self.generateCode2(file, 0,extensionsDir,self.foreignTypeName) + self.generateCode2(file, 0, extensionsDir, self.foreignTypeName) file.close() - + # Copy in any extensions we may have #self.copyExtensions(extensionsDir, file, 0) #self.outputClassFooter(file) @@ -530,7 +530,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor): def generateCode(self, file, nesting, extensionsDir=None): self.recordOverloadedMethods() - self.cullOverloadedMethods() + self.cullOverloadedMethods() self.outputImports(file, nesting) self.outputClassHeader(file, nesting) self.outputClassComment(file, nesting) @@ -559,22 +559,22 @@ class ClassTypeDescriptor(BaseTypeDescriptor): if self.destructor: self.destructor.generateDestructorCode(self, file, nesting) # If you have no destructor, inherit one - + ########################## ## Extension methods moved up locally if extensionsDir: - self.copyExtensions(extensionsDir, file, 0) - + self.copyExtensions(extensionsDir, file, 0) + ########################## ## import return types returnTypeModules = self.getReturnTypeModules() if len(returnTypeModules): for moduleName in returnTypeModules: - indent(file, nesting, 'import ' + moduleName + '\n') - + indent(file, nesting, 'import ' + moduleName + '\n') + ################################ - - + + if len(self.staticMethods): indent(file, nesting+1, '\n') indent(file, nesting+1, '##################################################\n') @@ -613,13 +613,13 @@ class ClassTypeDescriptor(BaseTypeDescriptor): # Copy in all our parent nodes (only does work if we are an MI node) self.copyParentMethods(file, nesting) - + self.generateOverloadedMethods(file, nesting) def generateCode1(self, file, nesting, extensionsDir=None): self.recordOverloadedMethods() - self.cullOverloadedMethods() + self.cullOverloadedMethods() self.outputImports(file, nesting) self.outputClassHeader(file, nesting) self.outputClassComment(file, nesting) @@ -647,28 +647,28 @@ class ClassTypeDescriptor(BaseTypeDescriptor): self.outputBaseDestructor(file, nesting) if self.destructor: self.destructor.generateDestructorCode(self, file, nesting) - # If you have no destructor, inherit one + # If you have no destructor, inherit one ########################## ## Extension methods moved up locally if extensionsDir: - self.copyExtensions(extensionsDir, file, 0) - + self.copyExtensions(extensionsDir, file, 0) + def generateCode2(self, file, nesting, extensionsDir, file1module): - - indent(file, nesting, 'from ' + file1module + ' import *\n') + + indent(file, nesting, 'from ' + file1module + ' import *\n') ########################## ## import return types returnTypeModules = self.getReturnTypeModules() if len(returnTypeModules): for moduleName in returnTypeModules: - indent(file, nesting, 'import ' + moduleName + '\n') - + indent(file, nesting, 'import ' + moduleName + '\n') + ################################ - - + + if len(self.staticMethods): indent(file, nesting+1, '\n') indent(file, nesting+1, '##################################################\n') @@ -707,7 +707,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor): # Copy in all our parent nodes (only does work if we are an MI node) self.copyParentMethods(file, nesting) - + self.generateOverloadedMethods(file, nesting) @@ -744,7 +744,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor): else: # No extensions for this class pass - + def outputBaseImports(self, file): indent(file, 0, '# CMODULE [' + self.moduleName + ']\n') @@ -756,11 +756,11 @@ class ClassTypeDescriptor(BaseTypeDescriptor): indent(file, 0, '# Import all the C modules this class uses\n') for moduleName in self.getCModules(): if moduleName: - indent(file, 0, 'import ' + moduleName + '\n') + indent(file, 0, 'import ' + moduleName + '\n') indent(file, 0, 'import ' + moduleName + 'Downcasts\n') indent(file, 0, '\n') indent(file, 0, 'from direct.ffi import FFIExternalObject\n') - + def outputImportsRecursively(self, parent, file, nesting): @@ -771,7 +771,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor): parentTypeName = parent.foreignTypeName fullNestedName = parent.getFullNestedName() if (fullNestedName != parentTypeName): - nestedChain = fullNestedName.split(".") + nestedChain = fullNestedName.split(".") moduleName = nestedChain[0] indent(file, nesting, 'import ' + moduleName + '\n') else: @@ -781,7 +781,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor): #if len(returnTypeModules): # for moduleName in returnTypeModules: # indent(file, nesting, 'import ' + moduleName + '\n') - + def outputImports(self, file, nesting): """ @@ -795,7 +795,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor): #if len(returnTypeModules): # for moduleName in returnTypeModules: # indent(file, nesting, 'import ' + moduleName + '\n') - + for parentType in self.parentTypes: self.outputImportsRecursively(parentType, file, nesting) indent(file, nesting, '\n') @@ -815,7 +815,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor): indent(file, nesting+1, comment) file.write('\n') indent(file, nesting+1, ('"' * 3) + '\n\n') - + def outputClassHeader(self, file, nesting): """ Output the class definition to the file @@ -824,7 +824,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor): if (self.foreignTypeName == ''): FFIConstants.notify.warning('Class with no name') - + # # If this is the toplevel, we need to delay the generation of this # # class to avoid circular imports, so put the entire class in a function # # that we will call later @@ -858,7 +858,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor): # parentClassModule.parentClass.nestedClass fullNestedName = self.parentTypes[i].getFullNestedName() if (fullNestedName != parentTypeName): - nestedChain = fullNestedName.split(".") + nestedChain = fullNestedName.split(".") moduleName = nestedChain[0] parentTypeName = fullNestedName file.write(moduleName + '.' + parentTypeName) @@ -888,7 +888,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor): #indent(file, 0, " globals()['" + self.foreignTypeName + "'] = " + self.foreignTypeName + '\n') pass - + def outputBaseConstructor(self, file, nesting): """ Output the __init__ constructor for this class. @@ -930,7 +930,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor): Python object is garbage collected. We are going to overwrite it with special cleanup for Panda. """ - if self.destructor: + if self.destructor: indent(file, nesting+1, 'def __del__(self):\n') # Reference counting is now handled in the C++ code @@ -943,10 +943,10 @@ class ClassTypeDescriptor(BaseTypeDescriptor): # we need to call the C++ destructor when Python frees the # shadow object, but only if the userManagesMemory flag is set. # Also make sure we are not destructing a null pointer - indent(file, nesting+2, 'if (self.userManagesMemory and (self.this != 0)):\n') + indent(file, nesting+2, 'if (self.userManagesMemory and (self.this != 0)):\n') self.destructor.outputDestructorBody(self, file, nesting+1) - indent(file, nesting, '\n') - + indent(file, nesting, '\n') + #indent(file, nesting+3, 'self.destructor()\n') @@ -969,18 +969,18 @@ class ClassTypeDescriptor(BaseTypeDescriptor): """ #if classTypeDesc != self: # indent(file, nesting, 'import ' + self.foreignTypeName + '\n') - indent(file,nesting, 'if returnValue == 0: return None\n') + indent(file, nesting, 'if returnValue == 0: return None\n') # Do not put Class.Class if this file is the file that defines Class # Also check for nested classes. They do not need the module name either typeName = FFIOverload.getTypeName(classTypeDesc, self) - #file.write(typeName + '(None)\n') + #file.write(typeName + '(None)\n') ### inline the old constructers - + #indent(file, nesting, 'returnObject = ') - #file.write('FFIExternalObject.FFIInstance('+ typeName + ',returnValue,'+str(userManagesMemory)+')\n') - #indent(file,nesting, 'returnObject.this = 0\n') - #indent(file,nesting, 'returnObject.userManagesMemory = 0\n'); - + #file.write('FFIExternalObject.FFIInstance('+ typeName + ', returnValue,'+str(userManagesMemory)+')\n') + #indent(file, nesting, 'returnObject.this = 0\n') + #indent(file, nesting, 'returnObject.userManagesMemory = 0\n'); + ## #indent(file, nesting, 'returnObject.this = returnValue\n') # Zero this pointers get returned as the Python None object @@ -989,20 +989,20 @@ class ClassTypeDescriptor(BaseTypeDescriptor): # indent(file, nesting, 'returnObject.userManagesMemory = 1\n') #else: # indent(file, nesting, 'returnObject.userManagesMemory = 0\n') - + if needsDowncast: - #indent(file, nesting, 'returnObject = FFIExternalObject.FFIInstance('+ typeName + ',returnValue,'+str(userManagesMemory)+')\n') + #indent(file, nesting, 'returnObject = FFIExternalObject.FFIInstance('+ typeName + ', returnValue,'+str(userManagesMemory)+')\n') if (FFIOverload.inheritsFrom(self, TypedObjectDescriptor) or self == TypedObjectDescriptor): #indent(file, nesting, 'return returnObject.setPointer()\n') - indent(file, nesting, 'return FFIExternalObject.FFIInstance('+ typeName + ',returnValue,'+str(userManagesMemory)+').setPointer()\n') + indent(file, nesting, 'return FFIExternalObject.FFIInstance('+ typeName + ', returnValue,'+str(userManagesMemory)+').setPointer()\n') else: - indent(file, nesting,'return FFIExternalObject.FFIInstance('+ typeName + ',returnValue,'+str(userManagesMemory)+')\n') + indent(file, nesting,'return FFIExternalObject.FFIInstance('+ typeName + ', returnValue,'+str(userManagesMemory)+')\n') #indent(file, nesting, 'return returnObject\n') else: - indent(file, nesting,'return FFIExternalObject.FFIInstance('+ typeName + ',returnValue,'+str(userManagesMemory)+')\n') + indent(file, nesting,'return FFIExternalObject.FFIInstance('+ typeName + ', returnValue,'+str(userManagesMemory)+')\n') #indent(file, nesting, 'return returnObject\n') - + class FunctionTypeDescriptor(BaseTypeDescriptor): diff --git a/direct/src/ffi/jGenPyCode.py b/direct/src/ffi/jGenPyCode.py index f48d71c8c6..0c6b562f4c 100755 --- a/direct/src/ffi/jGenPyCode.py +++ b/direct/src/ffi/jGenPyCode.py @@ -14,7 +14,7 @@ # ############################################################## -import sys,os +import sys, os ############################################################## # @@ -40,8 +40,8 @@ if (PANDAC is None): ############################################################## # -# Locate direct/src/extensions. -# +# Locate direct/src/extensions. +# # It could be inside the direct tree. It may be underneath # a 'src' subdirectory. Or, the direct tree may actually be # a stub that points to the source tree. @@ -83,13 +83,13 @@ DoGenPyCode.etcPath = [os.path.join(PANDAC,"input")] DoGenPyCode.pythonSourcePath = [DIRECT] DoGenPyCode.native = 1 -#print "outputDir = ",DoGenPyCode.outputDir -#print "directDir = ",DoGenPyCode.directDir -#print "extensionsDir = ",DoGenPyCode.extensionsDir -#print "interrogateLib = ",DoGenPyCode.interrogateLib -#print "codeLibs = ",DoGenPyCode.codeLibs -#print "etcPath = ",DoGenPyCode.etcPath -#print "native = ",DoGenPyCode.native +#print "outputDir = ", DoGenPyCode.outputDir +#print "directDir = ", DoGenPyCode.directDir +#print "extensionsDir = ", DoGenPyCode.extensionsDir +#print "interrogateLib = ", DoGenPyCode.interrogateLib +#print "codeLibs = ", DoGenPyCode.codeLibs +#print "etcPath = ", DoGenPyCode.etcPath +#print "native = ", DoGenPyCode.native DoGenPyCode.run() diff --git a/direct/src/showbase/Loader.py b/direct/src/showbase/Loader.py index f86ac126ba..6a71f3f9c6 100644 --- a/direct/src/showbase/Loader.py +++ b/direct/src/showbase/Loader.py @@ -14,7 +14,7 @@ class Loader: """ notify = directNotify.newCategory("Loader") modelCount = 0 - + # special methods def __init__(self, base): self.base = base @@ -23,7 +23,7 @@ class Loader: def destroy(self): del self.base del self.loader - + # model loading funcs def loadModel(self, modelPath, fMakeNodeNamesUnique = 0, loaderOptions = None): @@ -79,7 +79,8 @@ class Loader: want to load a model and immediately set a transform on it. But also consider loadModelCopy(). """ - assert Loader.notify.debug("Loading model once: %s under %s" % (modelPath, underNode)) + assert Loader.notify.debug( + "Loading model once: %s under %s" % (modelPath, underNode)) if phaseChecker: phaseChecker(modelPath) node = ModelPool.loadModel(modelPath) @@ -89,7 +90,7 @@ class Loader: else: nodePath = None return nodePath - + def loadModelCopy(self, modelPath): """loadModelCopy(self, string) Attempt to load a model from modelPool, if not present @@ -108,7 +109,7 @@ class Loader: def loadModelNode(self, modelPath): """ modelPath is a string. - + This is like loadModelOnce in that it loads a model from the modelPool, but it does not then instance it to hidden and it returns a Node instead of a NodePath. This is particularly @@ -296,5 +297,3 @@ class Loader: if (shader == None): Loader.notify.warning("Could not load shader file %s." % shaderPath) return shader - - \ No newline at end of file diff --git a/direct/src/tkpanels/Placer.py b/direct/src/tkpanels/Placer.py index f093c9228a..2ffbb77319 100644 --- a/direct/src/tkpanels/Placer.py +++ b/direct/src/tkpanels/Placer.py @@ -31,7 +31,7 @@ class Placer(AppShell): # Call superclass initialization function AppShell.__init__(self) - + self.initialiseoptions(Placer) def appInit(self): @@ -41,7 +41,7 @@ class Placer(AppShell): 'placerOrbitFromCS') self.orbitToCS = direct.group.attachNewNode('placerOrbitToCS') self.refCS = self.tempCS - + # Dictionary keeping track of all node paths manipulated so far self.nodePathDict = {} self.nodePathDict['camera'] = direct.camera @@ -106,7 +106,7 @@ class Placer(AppShell): 'Toggle widget manipulation mode', label = 'Toggle Widget Mode', command = direct.manipulationControl.toggleObjectHandlesMode) - + # Get a handle to the menu frame menuFrame = self.menuFrame self.nodePathMenu = Pmw.ComboBox( @@ -130,7 +130,7 @@ class Placer(AppShell): menubutton_width = 8) modeMenu.pack(side = 'left', expand = 0) self.bind(modeMenu, 'Select manipulation mode') - + self.refNodePathMenu = Pmw.ComboBox( menuFrame, entry_width = 16, selectioncommand = self.selectRefNodePathNamed, @@ -186,8 +186,8 @@ class Placer(AppShell): self.posX['preCallback'] = self.xformStart self.posX['postCallback'] = self.xformStop self.posX['callbackData'] = ['x'] - self.posX.pack(expand=1,fill='both') - + self.posX.pack(expand=1, fill='both') + self.posY = self.createcomponent('posY', (), None, Floater.Floater, (posInterior,), text = 'Y', relief = FLAT, @@ -197,8 +197,8 @@ class Placer(AppShell): self.posY['preCallback'] = self.xformStart self.posY['postCallback'] = self.xformStop self.posY['callbackData'] = ['y'] - self.posY.pack(expand=1,fill='both') - + self.posY.pack(expand=1, fill='both') + self.posZ = self.createcomponent('posZ', (), None, Floater.Floater, (posInterior,), text = 'Z', relief = FLAT, @@ -208,7 +208,7 @@ class Placer(AppShell): self.posZ['preCallback'] = self.xformStart self.posZ['postCallback'] = self.xformStop self.posZ['callbackData'] = ['z'] - self.posZ.pack(expand=1,fill='both') + self.posZ.pack(expand=1, fill='both') # Create and pack the Hpr Controls hprGroup = Pmw.Group(interior, @@ -223,9 +223,9 @@ class Placer(AppShell): hprMenu.add_command(label = 'Set to zero', command = self.zeroHpr) hprMenu.add_command(label = 'Reset initial', command = self.resetHpr) hprMenubutton['menu'] = hprMenu - hprGroup.pack(side='left',fill = 'both', expand = 1) + hprGroup.pack(side='left', fill = 'both', expand = 1) hprInterior = hprGroup.interior() - + # Create the dials self.hprH = self.createcomponent('hprH', (), None, Dial.AngleDial, (hprInterior,), @@ -237,8 +237,8 @@ class Placer(AppShell): self.hprH['preCallback'] = self.xformStart self.hprH['postCallback'] = self.xformStop self.hprH['callbackData'] = ['h'] - self.hprH.pack(expand=1,fill='both') - + self.hprH.pack(expand=1, fill='both') + self.hprP = self.createcomponent('hprP', (), None, Dial.AngleDial, (hprInterior,), style = 'mini', @@ -249,8 +249,8 @@ class Placer(AppShell): self.hprP['preCallback'] = self.xformStart self.hprP['postCallback'] = self.xformStop self.hprP['callbackData'] = ['p'] - self.hprP.pack(expand=1,fill='both') - + self.hprP.pack(expand=1, fill='both') + self.hprR = self.createcomponent('hprR', (), None, Dial.AngleDial, (hprInterior,), style = 'mini', @@ -261,7 +261,7 @@ class Placer(AppShell): self.hprR['preCallback'] = self.xformStart self.hprR['postCallback'] = self.xformStop self.hprR['callbackData'] = ['r'] - self.hprR.pack(expand=1,fill='both') + self.hprR.pack(expand=1, fill='both') # Create and pack the Scale Controls # The available scaling modes @@ -292,9 +292,9 @@ class Placer(AppShell): variable = self.scalingMode) self.scaleMenubutton['menu'] = scaleMenu # Pack group widgets - scaleGroup.pack(side='left',fill = 'both', expand = 1) + scaleGroup.pack(side='left', fill = 'both', expand = 1) scaleInterior = scaleGroup.interior() - + # Create the dials self.scaleX = self.createcomponent('scaleX', (), None, Floater.Floater, (scaleInterior,), @@ -307,8 +307,8 @@ class Placer(AppShell): self.scaleX['callbackData'] = ['sx'] self.scaleX['preCallback'] = self.xformStart self.scaleX['postCallback'] = self.xformStop - self.scaleX.pack(expand=1,fill='both') - + self.scaleX.pack(expand=1, fill='both') + self.scaleY = self.createcomponent('scaleY', (), None, Floater.Floater, (scaleInterior,), text = 'Y Scale', @@ -320,8 +320,8 @@ class Placer(AppShell): self.scaleY['callbackData'] = ['sy'] self.scaleY['preCallback'] = self.xformStart self.scaleY['postCallback'] = self.xformStop - self.scaleY.pack(expand=1,fill='both') - + self.scaleY.pack(expand=1, fill='both') + self.scaleZ = self.createcomponent('scaleZ', (), None, Floater.Floater, (scaleInterior,), text = 'Z Scale', @@ -333,7 +333,7 @@ class Placer(AppShell): self.scaleZ['callbackData'] = ['sz'] self.scaleZ['preCallback'] = self.xformStart self.scaleZ['postCallback'] = self.xformStop - self.scaleZ.pack(expand=1,fill='both') + self.scaleZ.pack(expand=1, fill='both') # Make sure appropriate labels are showing self.setMovementMode('Relative To:') @@ -414,7 +414,7 @@ class Placer(AppShell): else: if name == 'widget': # Record relationship between selected nodes and widget - direct.selected.getWrtAll() + direct.selected.getWrtAll() # Update active node path self.setActiveNodePath(nodePath) @@ -487,7 +487,7 @@ class Placer(AppShell): else: # Flash entry self.refNodePathMenuEntry.configure(background = 'Pink') - + def addNodePath(self, nodePath): self.addNodePathToDict(nodePath, self.nodePathNames, self.nodePathMenu, self.nodePathDict) @@ -538,21 +538,21 @@ class Placer(AppShell): def updateAuxiliaryCoordinateSystems(self): # Temp CS - self.tempCS.setPosHpr(self['nodePath'], 0,0,0,0,0,0) + self.tempCS.setPosHpr(self['nodePath'], 0, 0, 0, 0, 0, 0) # Orbit CS # At reference - self.orbitFromCS.setPos(self.refCS, 0,0,0) + self.orbitFromCS.setPos(self.refCS, 0, 0, 0) # But aligned with target - self.orbitFromCS.setHpr(self['nodePath'], 0,0,0) + self.orbitFromCS.setHpr(self['nodePath'], 0, 0, 0) # Also update to CS - self.orbitToCS.setPosHpr(self.orbitFromCS, 0,0,0,0,0,0) + self.orbitToCS.setPosHpr(self.orbitFromCS, 0, 0, 0, 0, 0, 0) # Get offset from origin self.posOffset.assign(self['nodePath'].getPos(self.orbitFromCS)) ### NODE PATH TRANSFORMATION OPERATIONS ### def xform(self, value, axis): if axis in ['sx', 'sy', 'sz']: - self.xformScale(value,axis) + self.xformScale(value, axis) elif self.movementMode == 'Relative To:': self.xformRelative(value, axis) elif self.movementMode == 'Orbit:': @@ -565,7 +565,7 @@ class Placer(AppShell): else: # Move the objects with the widget direct.selected.moveWrtWidgetAll() - + def xformStart(self, data): # Record undo point self.pushUndo() @@ -578,7 +578,7 @@ class Placer(AppShell): self.deltaHpr = self['nodePath'].getHpr(self.refCS) # Update placer to reflect new state self.updatePlacer() - + def xformStop(self, data): # Throw event to signal manipulation done # Send nodepath as a list @@ -639,7 +639,7 @@ class Placer(AppShell): elif axis == 'sz': scale.setZ(value) elif mode == 'Scale Uniform': - scale.set(value,value,value) + scale.set(value, value, value) elif mode == 'Scale Proportional': if axis == 'sx': sf = value/scale[0] @@ -743,7 +743,7 @@ class Placer(AppShell): def pushRedo(self): direct.pushRedo([self['nodePath']]) - + def redoHook(self, nodePathList = []): # Reflect new changes self.updatePlacer() @@ -755,7 +755,7 @@ class Placer(AppShell): def redoListEmptyHook(self): # Make sure button is deactivated self.redoButton.configure(state = 'disabled') - + def printNodePathInfo(self): np = self['nodePath'] if np: @@ -780,7 +780,7 @@ class Placer(AppShell): self.tempCS.removeNode() self.orbitFromCS.removeNode() self.orbitToCS.removeNode() - + def place(nodePath): return Placer(nodePath = nodePath) @@ -790,4 +790,3 @@ def place(nodePath): if __name__ == '__main__': root = Pmw.initialise() widget = Placer() -