Browse Source

*** empty log message ***

Mark Mine 25 years ago
parent
commit
9083cc7224

+ 15 - 1
direct/src/directtools/DirectGrid.py

@@ -51,9 +51,20 @@ class DirectGrid(NodePath,PandaObject):
     def enable(self):
         self.reparentTo(direct.group)
         self.updateGrid()
+        self.fEnabled = 1
 
     def disable(self):
         self.reparentTo(hidden)
+        self.fEnabled = 0
+
+    def toggleGrid(self):
+        if self.fEnabled:
+            self.disable()
+        else:
+            self.enable()
+
+    def isEnabled(self):
+        return self.fEnabled
 
     def updateGrid(self):
 	# Update grid lines based upon current grid spacing and grid size
@@ -136,7 +147,10 @@ class DirectGrid(NodePath,PandaObject):
     def getGridSpacing(self):
         return self.gridSpacing
 
-    def setSize(self, size):
+    def setGridSize(self, size):
 	# Set size of grid back and redraw lines
         self.gridSize = size
 	self.updateGrid()
+
+    def getGridSize(self):
+        return self.gridSize

+ 16 - 0
direct/src/directtools/DirectLights.py

@@ -1,5 +1,6 @@
 from PandaObject import *
 from DirectGeometry import *
+from string import lower
 
 class DirectLights(NodePath):
     def __init__(self, parent = None):
@@ -15,6 +16,7 @@ class DirectLights(NodePath):
         # Create a list of all active lights
         self.lightList = []
         self.nodePathList = []
+        self.nameList = []
         # Counts of the various types of lights
         self.ambientCount = 0
         self.directionalCount = 0
@@ -24,10 +26,17 @@ class DirectLights(NodePath):
     def __getitem__(self, index):
         return self.lightList[index]
 
+    def __len__(self):
+        return len(self.lightList)
+
     def getLightNodePath(self, index):
         return self.nodePathList[index]
 
+    def getLightName(self, index):
+        return self.nameList[index]
+
     def create(self, type):
+        type = type.lower()
         if type == 'ambient':
             self.ambientCount += 1
             light = AmbientLight('ambient_' + `self.ambientCount`)
@@ -44,6 +53,9 @@ class DirectLights(NodePath):
             self.spotCount += 1
             light = Spotlight('spot_' + `self.spotCount`)
             light.setColor(VBase4(1))
+        else:
+            print 'Invalid light type'
+            return None
         # Add the new light
         self.addLight(light)
         # Turn it on as a default
@@ -59,9 +71,13 @@ class DirectLights(NodePath):
         # Attach node to self
         # MRM: This doesn't work for spotlights!
         nodePath = self.attachNewNode(light.upcastToNamedNode())
+        name = light.getName()
         # Store it in the lists
         self.lightList.append(light)
         self.nodePathList.append(nodePath)
+        self.nameList.append(name)
+        # Send an event to all watching objects
+        messenger.send('DirectLights_addLight', [light])
 
     def allOn(self):
         """ Turn on all DIRECT lights """

+ 16 - 2
direct/src/directtools/DirectSession.py

@@ -103,6 +103,8 @@ class DirectSession(PandaObject):
 	self.enableKeyEvents()
 	self.enableMouseEvents()
 	self.enableActionEvents()
+        # Set flag
+        self.fEnabled = 1
 
     def disable(self):
 	# Shut down all display region context tasks
@@ -114,6 +116,14 @@ class DirectSession(PandaObject):
 	self.disableKeyEvents()
 	self.disableMouseEvents()
 	self.disableActionEvents()
+        # Set flag
+        self.fEnabled = 0
+
+    def toggleDirect(self):
+        if self.fEnabled:
+            self.disable()
+        else:
+            self.enable()
 
     def minimumConfiguration(self):
 	# Remove context task
@@ -133,7 +143,6 @@ class DirectSession(PandaObject):
 	self.enable()
 
     # EVENT FUNCTIONS
-
     def enableActionEvents(self):
         for event in self.actionEvents:
             self.accept(event[0], event[1], extraArgs = event[2:])
@@ -378,7 +387,6 @@ class DirectSession(PandaObject):
                     self.flash(np)
 
     # UNDO REDO FUNCTIONS
-    
     def pushUndo(self, nodePathList, fResetRedo = 1):
         # Assemble group of changes
         undoGroup = []
@@ -472,6 +480,9 @@ class DirectSession(PandaObject):
     def toggleWidgetVis(self):
         self.widget.toggleWidget()
 
+    def isEnabled(self):
+        return self.fEnabled
+
 class DisplayRegionList:
     def __init__(self):
         self.displayRegionList = []
@@ -482,6 +493,9 @@ class DisplayRegionList:
     def __getitem__(self, index):
         return self.displayRegionList[index]
 
+    def __len__(self):
+        return len(self.displayRegionList)
+
     def updateContext(self):
         for dr in self.displayRegionList:
             dr.contextTask(None)

+ 0 - 13
direct/src/leveleditor/LevelEditor.py

@@ -296,7 +296,6 @@ class LevelEditor(NodePath, PandaObject):
             # Hot key actions
             ('a', self.autoPositionGrid),
             ('.', self.jumpToInsertionPoint),
-            ('p', self.plantSelectedNodePath),
             ('left', self.keyboardXformSelected, ['left']),
             ('right', self.keyboardXformSelected, ['right']),
             ('up', self.keyboardXformSelected, ['up']),
@@ -1475,18 +1474,6 @@ class LevelEditor(NodePath, PandaObject):
         # Calc intersection point
         return planeIntersect(mouseOrigin, mouseDir, ZERO_POINT, Z_AXIS)
 
-    def plantSelectedNodePath(self):
-	""" Move selected object to intersection point of cursor on grid """
-	selectedNode = direct.selected.last
-        if selectedNode:
-            # Where is the mouse relative to the grid?
-            hitPt = self.getGridIntersectionPoint()
-            selectedNode.setPos(direct.grid, hitPt)
-            dnaNode = self.findDNANode(selectedNode)
-            if dnaNode:
-                # Update props placement to reflect current mouse position
-                dnaNode.setPos(direct.selected.last.getPos())
-
     def jumpToInsertionPoint(self):
         """ Move selected object to insertion point """
         selectedNode = direct.selected.last

+ 0 - 6
direct/src/tkpanels/AnimPanel.py

@@ -144,12 +144,6 @@ class AnimPanel(AppShell):
         for actorControl in self.actorControlList:
             actorControl.reset()
 
-    def toggleBalloon(self):
-        if self.toggleBalloonVar.get():
-            self.balloon.configure(state = 'balloon')
-        else:
-            self.balloon.configure(state = 'none')
-
 class ActorControl(Pmw.MegaWidget):
     def __init__(self, parent = None, **kw):
 

+ 7 - 2
direct/src/tkwidgets/AppShell.py

@@ -80,13 +80,18 @@ class AppShell(Pmw.MegaToplevel, PandaObject):
         self.menuBar = self.createcomponent('menubar', (), None,
                                             Pmw.MenuBar,
                                             (self.menuFrame,),
-                                            hull_relief=RAISED,
-                                            hull_borderwidth=1,
+                                            hull_relief=FLAT,
+                                            hull_borderwidth=0,
                                             balloon=self.balloon())
 
         self.menuBar.addmenu('Help', 'About %s' % self.appname, side = 'right')
         self.menuBar.addmenu('File', 'File commands and Quit')
         self.menuBar.pack(fill=X, side = LEFT)
+
+        # Force some space between pull down menus and other widgets
+        spacer = Label(self.menuFrame, text = '   ')
+        spacer.pack(side = LEFT, expand = 0)
+
         self.menuFrame.pack(fill = X)
                             
     def __createDataArea(self):

+ 2 - 2
direct/src/tkwidgets/Dial.py

@@ -236,7 +236,7 @@ class Dial(Pmw.MegaWidget):
     def get(self):
         return self.value
     
-    def set(self, value):
+    def set(self, value, fCommand = 1):
         if not self['fRollover']:
             if value > self['max']:
                 self.baseVal = 0.0
@@ -248,7 +248,7 @@ class Dial(Pmw.MegaWidget):
             self.dialAngle = None
         else:
             self.updateIndicator(value)
-        if self['command']:
+        if fCommand & (self['command'] != None):
             apply(self['command'], [value] + self['commandData'])
 
     def updateIndicator(self, value):

+ 6 - 6
direct/src/tkwidgets/SceneGraphExplorer.py

@@ -8,7 +8,7 @@ DEFAULT_MENU_ITEMS = ['Select', 'Deselect', 'Flash', 'Toggle Vis',
 
 class SceneGraphExplorer(Pmw.MegaWidget):
     "Graphical display of a scene graph"
-    def __init__(self, root = render, parent = None, **kw):
+    def __init__(self, parent = None, nodePath = render, **kw):
         # Define the megawidget options.
         optiondefs = (
             ('menuItems',   [],   Pmw.INITOPT),
@@ -19,7 +19,7 @@ class SceneGraphExplorer(Pmw.MegaWidget):
         Pmw.MegaWidget.__init__(self, parent)
         
         # Initialize some class variables
-        self.root = root
+        self.nodePath = nodePath
 
         # Create the components.
         
@@ -32,12 +32,12 @@ class SceneGraphExplorer(Pmw.MegaWidget):
             'scrolledCanvas',
             (), None,
             Pmw.ScrolledCanvas, (interior,),
-            hull_width = 200, hull_height = 400,
+            hull_width = 200, hull_height = 500,
             usehullsize = 1)
         self._canvas = self._scrolledCanvas.component('canvas')
         self._canvas['scrollregion'] = ('0i', '0i', '2i', '4i')
         self._scrolledCanvas.resizescrollregion()
-        self._scrolledCanvas.pack(padx = 5, pady = 5, expand=1, fill = BOTH)
+        self._scrolledCanvas.pack(padx = 3, pady = 3, expand=1, fill = BOTH)
         
         self._canvas.bind('<ButtonPress-2>', self.mouse2Down)
         self._canvas.bind('<B2-Motion>', self.mouse2Motion)
@@ -46,7 +46,7 @@ class SceneGraphExplorer(Pmw.MegaWidget):
                           sc.resizescrollregion())
 
         # Create the contents
-        self._treeItem = SceneGraphExplorerItem(self.root)
+        self._treeItem = SceneGraphExplorerItem(self.nodePath)
 
         self._node = TreeNode(self._canvas, None, self._treeItem,
                               DEFAULT_MENU_ITEMS + self['menuItems'])
@@ -127,6 +127,6 @@ class SceneGraphExplorerItem(TreeItem):
 def explore(nodePath = render):
     tl = Toplevel()
     tl.title('Explore: ' + nodePath.getName())
-    sge = SceneGraphExplorer(parent = tl, root = nodePath)
+    sge = SceneGraphExplorer(parent = tl, nodePath = nodePath)
     sge.pack(expand = 1, fill = 'both')
     return sge

+ 5 - 5
direct/src/tkwidgets/VectorWidgets.py

@@ -163,16 +163,16 @@ class VectorEntry(Pmw.MegaWidget):
     def getAt(self,index):
         return self._value[index]
                                                                                       
-    def set(self, value, fCommand = 0):
+    def set(self, value, fCommand = 1):
         for i in range(self['dim']):
             self._value[i] = value[i]
             self.variableList[i].set(self.entryFormat % value[i])
         self.action(fCommand)
 
-    def setAt(self, index, value):
+    def setAt(self, index, value, fCommand = 1):
         self.variableList[index].set(self.entryFormat % value)
         self._value[index] = value
-        self.action()
+        self.action(fCommand)
         
     def _entryUpdateAt(self, index):
         entryVar = self.variableList[index]
@@ -207,7 +207,7 @@ class VectorEntry(Pmw.MegaWidget):
         if self._floaters:
             self._floaters.set(self._value, 0)
         
-    def action(self, fCommand = 0):
+    def action(self, fCommand = 1):
         self._refreshFloaters()
         if fCommand & (self['command'] != None):
             self['command'](self._value)        
@@ -259,7 +259,7 @@ class ColorEntry(VectorEntry):
             ('min',                     0.0,                None),
             ('max',                     255.0,              None),
             ('significantDigits',       0,                  None),
-            ('Valuator_resolution',      1.0,                None),
+            ('Valuator_resolution',     1.0,                None),
             )
         self.defineoptions(kw, optiondefs)
         #kw['valuatorType'] = EntryScale.EntryScaleGroup