Browse Source

Added unmovableTagList to DirectManipulationControl. Used to specify objects as unmovable

Mark Mine 21 years ago
parent
commit
ae9d2a3d02
1 changed files with 16 additions and 2 deletions
  1. 16 2
      direct/src/directtools/DirectManipulation.py

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

@@ -36,7 +36,8 @@ class DirectManipulationControl(PandaObject):
             ['i', self.plantSelectedNodePath],
             ['i', self.plantSelectedNodePath],
             ]
             ]
         self.optionalSkipFlags = 0
         self.optionalSkipFlags = 0
-
+        self.unmovableTagList = []
+        
     def manipulationStart(self, modifiers):
     def manipulationStart(self, modifiers):
         # Start out in select mode
         # Start out in select mode
         self.mode = 'select'
         self.mode = 'select'
@@ -172,7 +173,13 @@ class DirectManipulationControl(PandaObject):
 
 
     def manipulateObject(self):
     def manipulateObject(self):
         # Only do this if something is selected
         # Only do this if something is selected
-        if direct.selected:
+        selectedList = direct.selected.getSelectedAsList()
+        # See if any of the selected in the don't manipulate tag list
+        for tag in self.unmovableTagList:
+            for selected in selectedList:
+                if selected.hasTag(tag):
+                    return
+        if selectedList:
             # Remove the task to keep the widget attached to the object
             # Remove the task to keep the widget attached to the object
             taskMgr.remove('followSelectedNodePath')
             taskMgr.remove('followSelectedNodePath')
             # and the task to highlight the widget
             # and the task to highlight the widget
@@ -263,6 +270,13 @@ class DirectManipulationControl(PandaObject):
         # Continue
         # Continue
         return Task.cont
         return Task.cont
 
 
+    def addTag(self, tag):
+        if tag not in self.unmovableTagList:
+            self.unmovableTagList.append(tag)
+
+    def removeTag(self, tag):
+        self.unmovableTagList.remove(tag)
+
     ### WIDGET MANIPULATION METHODS ###
     ### WIDGET MANIPULATION METHODS ###
     def xlate1D(self, state):
     def xlate1D(self, state):
         # Constrained 1D Translation along widget axis
         # Constrained 1D Translation along widget axis