Browse Source

Added tag functionality

Mark Mine 21 years ago
parent
commit
0a816d9092
2 changed files with 16 additions and 7 deletions
  1. 14 0
      direct/src/directtools/DirectSelection.py
  2. 2 7
      direct/src/directtools/DirectUtil.py

+ 14 - 0
direct/src/directtools/DirectSelection.py

@@ -46,6 +46,14 @@ class DirectNodePath(NodePath):
 class SelectedNodePaths(PandaObject):
     def __init__(self):
         self.reset()
+        self.tagList = []
+
+    def addTag(self, tag):
+        if tag not in self.tagList:
+            self.tagList.append(tag)
+
+    def removeTag(self, tag):
+        self.tagList.remove(tag)
 
     def reset(self):
         self.selectedDict = {}
@@ -62,6 +70,12 @@ class SelectedNodePaths(PandaObject):
         # Reset selected objects and highlight if multiSelect is false
         if not fMultiSelect:
             self.deselectAll()
+
+        # Select tagged object if present
+        for tag in self.tagList:
+            if nodePath.hasNetTag(tag):
+                nodePath = nodePath.findNetTag(tag)
+                break
         
         # Get this pointer
         id = nodePath.id()

+ 2 - 7
direct/src/directtools/DirectUtil.py

@@ -8,13 +8,8 @@ def ROUND_TO(value, divisor):
 def ROUND_INT(val):
     return int(round(val))
 
-def CLAMP(val, min, max):
-    if val < min:
-        return min
-    elif val > max:
-        return max
-    else:
-        return val
+def CLAMP(val, minVal, maxVal):
+    return min(max(val, minVal), maxVal)
 
 # Create a tk compatible color string
 def getTkColorString(color):