Proxy class for a DocumentObjectGroupPython
CollisionDetector instance.
More...
Public Member Functions | |
def | __init__ (self, fp) |
Initialization method for CollsionDetectorProxy. More... | |
def | onDocumentRestored (self, fp) |
Method called when document is restored to make sure everything is as it was. More... | |
def | onBeforeChange (self, fp, prop) |
Method called before DocumentObjectGroupPython CollisionDetector is changed. More... | |
def | onChanged (self, fp, prop) |
Method called after DocumentObjectGroupPython CollisionDetector was changed. More... | |
def | resetObject (self, object_) |
Method that resets style of an object_ to what it was before. More... | |
def | loadObjects (self, objects, save_style=True) |
Adds shape info and loads object to restore them during reset. More... | |
def | execute (self, fp) |
Method called when recomputing a DocumentObjectGroupPython CollisionDetector. More... | |
def | setProperties (self, fp) |
Method to set properties during initialization or document restoration. More... | |
def | checkCollisions (self) |
Method which checks for collisions among observed objects. More... | |
def | exploreGroup (self, group) |
Method to explore a group for all objects and shapes inside. More... | |
def | intersection (self, obj1, obj2) |
Method to check intersection between obj1 and obj2 . More... | |
def | makeCollisionObject (self, shape, cause1, cause2, color) |
Method to make a collision object and add it to the CollisionDetector . More... | |
def | visualize (self, ok, in_collision) |
Method to visualize which object are in-collision and which have collided. More... | |
def | reset (self) |
Method to reset CollisionDetector. More... | |
def | setChecking (self, value) |
Method necessary to be able to set checking attribute with delayed execution. More... | |
def | setResetting (self, value) |
Method necessary for setting resetting attribute with delayed execution. More... | |
def | executeLater (self, var, command, args) |
Method to postpone execution after coin is finished (and avoid crashing coin). More... | |
def | executeCommandQueue (self) |
Method to execute queue of postponed commands so that coin does not crash. More... | |
def | __getstate__ (self) |
Necessary method to save unserializable objects. More... | |
def | __setstate__ (self, data) |
Necessary method to restore unserializable objects when loading document. More... | |
Public Attributes | |
observed_objects_before | |
An ObservedObjects property before change. More... | |
in_collision | |
A set of objects which are in-collision together. More... | |
collided | |
A set of objects which have collided since the last reset. More... | |
original_styles | |
A dict of objects and their style original style. More... | |
shape_info | |
A dict of objects, Part object s inside them and fused shapes. More... | |
fp | |
A DocumentObjectGroupPython associated with the proxy. More... | |
checking | |
A flag to signal collision checking is in progress. More... | |
resetting | |
A flag to signal resetting objects to previous state. More... | |
command_queue | |
Static Public Attributes | |
list | command_queue = [] |
A list of commands interfering with Coin3D to execute later. More... | |
Proxy class for a DocumentObjectGroupPython
CollisionDetector instance.
A CollisionDetectorProxy instance adds properties to a DocumentObjectGroupPython
CollisionDetector instance and responds to theirs changes. It detects collisions among ObservedObjects
.
To connect this Proxy
object to a DocumentObjectGroupPython
CollisionDetector do:
Definition at line 67 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.__init__ | ( | self, | |
fp | |||
) |
Initialization method for CollsionDetectorProxy.
A class instance is created and made a Proxy
for a generic DocumentObjectGroupPython
CollisionDetector object. During initialization number of properties are specified and preset.
fp | A barebone CollisionDetector object to be extended. |
Definition at line 107 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.__getstate__ | ( | self | ) |
Necessary method to save unserializable objects.
We use this to save original_styles
dictionary, collided
and in_collision
sets.
Definition at line 740 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.__setstate__ | ( | self, | |
data | |||
) |
Necessary method to restore unserializable objects when loading document.
We use this to restore original_styles
dictionary, collided
and in_collision
sets.
data | A JSON string representation of a Python data structure. |
Definition at line 756 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.checkCollisions | ( | self | ) |
Method which checks for collisions among observed objects.
If observed objects are valid and checking is not already in progress, the collision checking is started.
Definition at line 384 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.execute | ( | self, | |
fp | |||
) |
Method called when recomputing a DocumentObjectGroupPython
CollisionDetector.
Collisions are checked upon recompute.
fp | A DocumentObjectGroupPython CollisionDetector object. |
Definition at line 249 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.executeCommandQueue | ( | self | ) |
Method to execute queue of postponed commands so that coin does not crash.
Call this method using a singleshot timer. For the fastest execution set time to 0.
Usage example: PySide2.QtCore.QTimer.singleShot(0, self.executeCommandQueue)
Definition at line 713 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.executeLater | ( | self, | |
var, | |||
command, | |||
args | |||
) |
Method to postpone execution after coin is finished (and avoid crashing coin).
Removing objects is necessary to do using this method, otherwise coin will crash. When using with variable or arguments, its crutial that they stay available and unchanged until the command is executed.
Usage example: self.executeLater(None, self.fp.removeObjectsFromDocument, None)
var | A variable to be assigned return value from a command or None. |
command | A command to be executed. |
args | A tuple or arguments to used in a command, an argument or None. |
Definition at line 694 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.exploreGroup | ( | self, | |
group | |||
) |
Method to explore a group
for all objects and shapes inside.
All object in the group are added to a groupobjects
list and their shapes are fused into a groupshape
.
group | A group object. |
group
. groupobjects
or None. Definition at line 475 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.intersection | ( | self, | |
obj1, | |||
obj2 | |||
) |
Method to check intersection between obj1
and obj2
.
Based on selected checking level this method checks for collisions and makes an intersection object if required.
obj1 | An object to check for a mutual intersection. |
obj2 | Another object to check for a mutual intersection. |
group
. groupobjects
or None. Definition at line 534 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.loadObjects | ( | self, | |
objects, | |||
save_style = True |
|||
) |
Adds shape info and loads object to restore them during reset.
Groups and GroupExtensions are explored and shapes inside are added to the shape_info dictionary. Their styles are recorded.
objects | A list or set of added objects. |
Definition at line 196 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.makeCollisionObject | ( | self, | |
shape, | |||
cause1, | |||
cause2, | |||
color | |||
) |
Method to make a collision object and add it to the CollisionDetector
.
shape | A shape of a common volume between objects cause1 and cause2. |
cause1 | An intersecting object. |
cause2 | An intersecting object. |
color | A color assigned to the collision object. |
Definition at line 573 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.onBeforeChange | ( | self, | |
fp, | |||
prop | |||
) |
Method called before DocumentObjectGroupPython
CollisionDetector is changed.
A list of ObservedObjects is loaded to check which objects were added or removed so that their style can be changed appropriately.
fp | A DocumentObjectGroupPython CollisionDetector object. |
prop | A str of a property about to change. |
Definition at line 135 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.onChanged | ( | self, | |
fp, | |||
prop | |||
) |
Method called after DocumentObjectGroupPython
CollisionDetector was changed.
A list of ObservedObjects is loaded and checked for added or removed objects so that their style can be changed appropriately.
fp | A DocumentObjectGroupPython CollisionDetector object. |
prop | A str of a changed property. |
Definition at line 149 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.onDocumentRestored | ( | self, | |
fp | |||
) |
Method called when document is restored to make sure everything is as it was.
Reinitialization it creates properties and sets them to default, if they were not restored automatically. Properties of connected ViewObject
are also recreated and reset if necessary.
fp | A restored DocumentObjectGroupPython CollisionDetector object. |
Definition at line 121 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.reset | ( | self | ) |
Method to reset CollisionDetector.
Deletes CollisionObject
s and returns all ObservedObjects
to their original style.
Definition at line 635 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.resetObject | ( | self, | |
object_ | |||
) |
Method that resets style of an object_
to what it was before.
The object can be a Part::PartFeature
, a group object
or a Part object
. Its Transparency, ShapeColor, LineColor and LineWidth are restored to previous values.
object_ | An observed object. |
Definition at line 174 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.setChecking | ( | self, | |
value | |||
) |
Method necessary to be able to set checking
attribute with delayed execution.
In order to be able to check when a Collision is deleted/moved by user instead of a CollisionDetector
instance owning it, it's necessary to set checking
attribute to False
after all collisions are removed.
value | A bool flagging that CollisionDetector is checking for Collisions. |
Definition at line 663 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.setProperties | ( | self, | |
fp | |||
) |
Method to set properties during initialization or document restoration.
The properties are set if they are not already present and an AnimateDocumentObserver
is recreated.
fp | A restored or barebone CollisionDetector object. |
Definition at line 261 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.setResetting | ( | self, | |
value | |||
) |
Method necessary for setting resetting
attribute with delayed execution.
In order to be able to check when a Collision is deleted/moved by user instead of a CollisionDetector
instance owning it, it's necessary to set resetting
attribute to False
after all collisions are removed.
value | A bool flagging that CollisionDetector is resetting Collisions. |
Definition at line 676 of file CollisionDetector.py.
def CollisionDetector.CollisionDetectorProxy.visualize | ( | self, | |
ok, | |||
in_collision | |||
) |
Method to visualize which object are in-collision and which have collided.
Sets of collided and in-collision objects are kept up to date in this method. Then these sets are highlighted using style properties (Transparency, Shape Color, Line Color, Line Width).
ok | A set of objects that are not in-collision. |
in_collision | A set of objects that are in-collision. |
Definition at line 592 of file CollisionDetector.py.
CollisionDetector.CollisionDetectorProxy.checking |
A flag to signal collision checking is in progress.
Definition at line 367 of file CollisionDetector.py.
CollisionDetector.CollisionDetectorProxy.collided |
A set of objects which have collided since the last reset.
Definition at line 355 of file CollisionDetector.py.
|
static |
A list of commands interfering with Coin3D to execute later.
Definition at line 95 of file CollisionDetector.py.
CollisionDetector.CollisionDetectorProxy.fp |
A DocumentObjectGroupPython
associated with the proxy.
Definition at line 366 of file CollisionDetector.py.
CollisionDetector.CollisionDetectorProxy.in_collision |
A set of objects which are in-collision together.
Definition at line 352 of file CollisionDetector.py.
CollisionDetector.CollisionDetectorProxy.observed_objects_before |
An ObservedObjects
property before change.
Definition at line 137 of file CollisionDetector.py.
CollisionDetector.CollisionDetectorProxy.original_styles |
A dict of objects and their style original style.
Definition at line 359 of file CollisionDetector.py.
CollisionDetector.CollisionDetectorProxy.resetting |
A flag to signal resetting objects to previous state.
Definition at line 368 of file CollisionDetector.py.
CollisionDetector.CollisionDetectorProxy.shape_info |
A dict of objects, Part object
s inside them and fused shapes.
Definition at line 363 of file CollisionDetector.py.