Browse Source

*** empty log message ***

Mark Mine 24 years ago
parent
commit
15563af70d

+ 18 - 3
direct/src/directtools/DirectCameraControl.py

@@ -14,10 +14,12 @@ class DirectCameraControl(PandaObject):
         self.coaDist = 100
         self.coaDist = 100
         self.coaMarker = loader.loadModel('models/misc/sphere')
         self.coaMarker = loader.loadModel('models/misc/sphere')
         self.coaMarker.setName('DirectCameraCOAMarker')
         self.coaMarker.setName('DirectCameraCOAMarker')
+        self.coaMarker.setTransparency(1)
         self.coaMarker.setColor(1,0,0)
         self.coaMarker.setColor(1,0,0)
         self.coaMarker.setPos(0,100,0)
         self.coaMarker.setPos(0,100,0)
         useDirectRenderStyle(self.coaMarker)
         useDirectRenderStyle(self.coaMarker)
         self.coaMarkerPos = Point3(0)
         self.coaMarkerPos = Point3(0)
+        self.fUpdateCOA = 1
 	self.camManipRef = direct.group.attachNewNode('camManipRef')
 	self.camManipRef = direct.group.attachNewNode('camManipRef')
         t = CAM_MOVE_DURATION
         t = CAM_MOVE_DURATION
         self.actionEvents = [
         self.actionEvents = [
@@ -68,7 +70,7 @@ class DirectCameraControl(PandaObject):
             node, hitPt, hitPtDist = direct.iRay.pickGeom(
             node, hitPt, hitPtDist = direct.iRay.pickGeom(
                 fIntersectUnpickable = 1)
                 fIntersectUnpickable = 1)
             coa = Point3(0)
             coa = Point3(0)
-            if node:
+            if self.fUpdateCOA and node:
                 # Set center of action
                 # Set center of action
                 coa.assign(hitPt)
                 coa.assign(hitPt)
                 coaDist = hitPtDist
                 coaDist = hitPtDist
@@ -82,7 +84,7 @@ class DirectCameraControl(PandaObject):
                         coa.set(0,100,0)
                         coa.set(0,100,0)
                         coaDist = 100
                         coaDist = 100
             else:
             else:
-                # If no intersection point:
+                # If no intersection point or COA is locked:
                 # Use existing point
                 # Use existing point
                 coa.assign(self.coaMarker.getPos(direct.camera))
                 coa.assign(self.coaMarker.getPos(direct.camera))
                 coaDist = Vec3(coa - ZERO_POINT).length()
                 coaDist = Vec3(coa - ZERO_POINT).length()
@@ -96,7 +98,8 @@ class DirectCameraControl(PandaObject):
             self.spawnXZTranslateOrHPanYZoom()
             self.spawnXZTranslateOrHPanYZoom()
             # END MOUSE IN CENTRAL REGION
             # END MOUSE IN CENTRAL REGION
         else:
         else:
-            if ((abs(direct.dr.mouseX) > 0.9) and (abs(direct.dr.mouseY) > 0.9)):
+            if ((abs(direct.dr.mouseX) > 0.9) and
+                (abs(direct.dr.mouseY) > 0.9)):
                 # Mouse is in corners, spawn roll task
                 # Mouse is in corners, spawn roll task
                 self.spawnMouseRollTask()
                 self.spawnMouseRollTask()
             else:
             else:
@@ -266,6 +269,15 @@ class DirectCameraControl(PandaObject):
         direct.camera.setMat(self.camManipRef, wrtMat)
         direct.camera.setMat(self.camManipRef, wrtMat)
         return Task.cont
         return Task.cont
 
 
+    def lockCOA(self):
+        self.fUpdateCOA = 0
+
+    def unlockCOA(self):
+        self.fUpdateCOA = 1
+
+    def toggleCOALock(self):
+        self.fUpdateCOA = 1 - self.fUpdateCOA
+
     def updateCoa(self, cam2point, coaDist = None):
     def updateCoa(self, cam2point, coaDist = None):
         self.coa.set(cam2point[0], cam2point[1], cam2point[2])
         self.coa.set(cam2point[0], cam2point[1], cam2point[2])
         if coaDist:
         if coaDist:
@@ -290,6 +302,9 @@ class DirectCameraControl(PandaObject):
         if sf == 0.0:
         if sf == 0.0:
             sf = 0.1
             sf = 0.1
         self.coaMarker.setScale(sf)
         self.coaMarker.setScale(sf)
+        # Lerp color to fade out
+        self.coaMarker.lerpColor(VBase4(1,0,0,1), VBase4(1,0,0,0), 3.0,
+                                 task = 'fadeAway')
 
 
     def homeCam(self):
     def homeCam(self):
         # Record undo point
         # Record undo point

+ 1 - 1
direct/src/directtools/DirectSelection.py

@@ -4,7 +4,7 @@ from DirectSelection import *
 import __builtin__
 import __builtin__
 
 
 UNPICKABLE = ['x-disc-visible', 'y-disc-visible', 'z-disc-visible',
 UNPICKABLE = ['x-disc-visible', 'y-disc-visible', 'z-disc-visible',
-              'gridBack']
+              'gridBack', 'unpickable']
 
 
 # MRM: To do: handle broken node paths in selected and deselected dicts
 # MRM: To do: handle broken node paths in selected and deselected dicts
 class DirectNodePath(NodePath):
 class DirectNodePath(NodePath):

+ 4 - 1
direct/src/directtools/DirectSession.py

@@ -122,7 +122,8 @@ class DirectSession(PandaObject):
                           'shift', 'shift-up', 'alt', 'alt-up',
                           'shift', 'shift-up', 'alt', 'alt-up',
                           'page_up', 'page_down', 
                           'page_up', 'page_down', 
                           '[', '{', ']', '}',
                           '[', '{', ']', '}',
-                          'A', 'b', 'l', 'p', 'r', 'R', 's', 't', 'v', 'w']
+                          'A', 'b', 'l', 'L', 'p', 'r', 'R', 's',
+                          't', 'v', 'w']
         self.mouseEvents = ['mouse1', 'mouse1-up',
         self.mouseEvents = ['mouse1', 'mouse1-up',
                             'mouse2', 'mouse2-up',
                             'mouse2', 'mouse2-up',
                             'mouse3', 'mouse3-up']
                             'mouse3', 'mouse3-up']
@@ -250,6 +251,8 @@ class DirectSession(PandaObject):
             base.toggleBackface()
             base.toggleBackface()
         elif input == 'l':
         elif input == 'l':
             self.lights.toggle()
             self.lights.toggle()
+        elif input == 'L':
+            self.cameraControl.toggleCOALock()
         elif input == 'p':
         elif input == 'p':
             if self.selected.last:
             if self.selected.last:
                 self.setActiveParent(self.selected.last)
                 self.setActiveParent(self.selected.last)

+ 23 - 18
direct/src/showbase/PythonUtil.py

@@ -160,10 +160,11 @@ def _varnames(function):
     return function.func_code.co_varnames
     return function.func_code.co_varnames
 
 
 def _getcode(f):
 def _getcode(f):
-    """_getcode(f)
-
+    """
+    _getcode(f)
     This function returns the name and function object of a callable
     This function returns the name and function object of a callable
-    object."""
+    object.
+    """
     def method_get(f):
     def method_get(f):
         return f.__name__, f.im_func
         return f.__name__, f.im_func
     def function_get(f):
     def function_get(f):
@@ -189,13 +190,14 @@ def _getcode(f):
                  types.MethodType       : method_get,
                  types.MethodType       : method_get,
                  types.FunctionType     : function_get,
                  types.FunctionType     : function_get,
                  types.InstanceType     : instance_get,
                  types.InstanceType     : instance_get,
-                 types.ClassType        : class_get
+                 types.ClassType        : class_get,
                  }
                  }
     try:
     try:
         return codedict[type(f)](f)
         return codedict[type(f)](f)
     except KeyError:
     except KeyError:
         if callable(f): # eg, built-in functions and methods
         if callable(f): # eg, built-in functions and methods
-            raise ValueError, "type %s not supported yet." % type(f)
+            # raise ValueError, "type %s not supported yet." % type(f)
+            return f.__name__, None
         else:
         else:
             raise TypeError, ("object %s of type %s is not callable." %
             raise TypeError, ("object %s of type %s is not callable." %
                                      (f, type(f)))
                                      (f, type(f)))
@@ -239,19 +241,22 @@ class Signature:
             pass
             pass
         return mapping
         return mapping
     def __repr__(self):
     def __repr__(self):
-        defaults = self.defaults()
-        specials = self.special_args()
-        l = []
-        for arg in self.ordinary_args():
-            if defaults.has_key(arg):
-                l.append( arg + '=' + str(defaults[arg]) )
-            else:
-                l.append( arg )
-        if specials.has_key('positional'):
-            l.append( '*' + specials['positional'] )
-        if specials.has_key('keyword'):
-            l.append( '**' + specials['keyword'] )
-        return "%s(%s)" % (self.name, string.join(l, ', '))
+        if self.func:
+            defaults = self.defaults()
+            specials = self.special_args()
+            l = []
+            for arg in self.ordinary_args():
+                if defaults.has_key(arg):
+                    l.append( arg + '=' + str(defaults[arg]) )
+                else:
+                    l.append( arg )
+            if specials.has_key('positional'):
+                l.append( '*' + specials['positional'] )
+            if specials.has_key('keyword'):
+                l.append( '**' + specials['keyword'] )
+            return "%s(%s)" % (self.name, string.join(l, ', '))
+        else:
+            return "%s(?)" % self.name
 
 
 
 
 def aproposAll(obj):
 def aproposAll(obj):

+ 1 - 1
direct/src/showbase/ShowBaseGlobal.py

@@ -33,7 +33,7 @@ directNotify.setDconfigLevels()
 
 
 def inspect(anObject):
 def inspect(anObject):
     import Inspector
     import Inspector
-    Inspector.inspect(anObject)
+    return Inspector.inspect(anObject)
 
 
 __builtin__.inspect = inspect
 __builtin__.inspect = inspect
 
 

+ 11 - 3
direct/src/tkpanels/Inspector.py

@@ -5,7 +5,7 @@
 
 
 import string
 import string
 from Tkinter import *
 from Tkinter import *
-from TkGlobal import *
+import Pmw
 
 
 
 
 ### public API
 ### public API
@@ -14,6 +14,7 @@ def inspect(anObject):
     inspector = inspectorFor(anObject)
     inspector = inspectorFor(anObject)
     inspectorWindow = InspectorWindow(inspector)
     inspectorWindow = InspectorWindow(inspector)
     inspectorWindow.open()
     inspectorWindow.open()
+    return inspectorWindow
 
 
 ### private
 ### private
 
 
@@ -237,12 +238,19 @@ class InspectorWindow:
         scrollbar.config(command = listWidget.yview)
         scrollbar.config(command = listWidget.yview)
         scrollbar.pack(side=RIGHT, fill=Y)
         scrollbar.pack(side=RIGHT, fill=Y)
         listWidget.pack(side=LEFT, fill=BOTH, expand=1)
         listWidget.pack(side=LEFT, fill=BOTH, expand=1)
+        # If you click in the list box, take focus so you can navigate
+        # with the cursor keys
+        listWidget.bind('<ButtonPress-1>',
+                        lambda e, s = self: s.listWidget.focus_set())
         listWidget.bind('<ButtonRelease-1>',  self.listSelectionChanged)
         listWidget.bind('<ButtonRelease-1>',  self.listSelectionChanged)
+        listWidget.bind('<Up>',  self.listSelectionChanged)
+        listWidget.bind('<Down>',  self.listSelectionChanged)
+        listWidget.bind('<Return>',  self.popOrDive)
         listWidget.bind("<Double-Button-1>", self.popOrDive)
         listWidget.bind("<Double-Button-1>", self.popOrDive)
 
 
     def createTextWidget(self):
     def createTextWidget(self):
-        self.textWidget = Text(self.top)
-        self.textWidget.pack(side=RIGHT, fill=BOTH, expand=1)
+        self.textWidget = Pmw.ScrolledText(self.top)
+        self.textWidget.pack(fill=BOTH, expand=1)
         # self.textWidget.grid(row=0, column=1, columnspan=2, sticky=N+W+S+E)
         # self.textWidget.grid(row=0, column=1, columnspan=2, sticky=N+W+S+E)
 
 
     def createMenus(self):
     def createMenus(self):

+ 10 - 1
direct/src/tkwidgets/Floater.py

@@ -188,6 +188,16 @@ class Floater(Pmw.MegaWidget):
     def reset(self):
     def reset(self):
         self.set(self['initialValue'])
         self.set(self['initialValue'])
 
 
+    def disable(self):
+        self.scale['state'] = 'disabled'
+        self.label['state'] = 'disabled'
+        self.component('entry')['state'] = 'disabled'
+
+    def enable(self):
+        self.scale['state'] = 'normal'
+        self.label['state'] = 'normal'
+        self.component('entry')['state'] = 'normal'
+
     def onReturn(self, *args):
     def onReturn(self, *args):
         """ User redefinable callback executed on <Return> in entry """
         """ User redefinable callback executed on <Return> in entry """
         pass
         pass
@@ -322,7 +332,6 @@ class FloaterGroup(Pmw.MegaToplevel):
         self.set(self['initialValue'])
         self.set(self['initialValue'])
 
 
 
 
-
 ## SAMPLE CODE
 ## SAMPLE CODE
 if __name__ == '__main__':
 if __name__ == '__main__':
     # Initialise Tkinter and Pmw.
     # Initialise Tkinter and Pmw.