internal_containers.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. from .node_container_common import *
  2. from bpy.types import Node
  3. from .base_definitions import MantisNode
  4. from uuid import uuid4
  5. class DummyNode(MantisNode):
  6. def __init__(self, signature, base_tree, prototype = None, natural_signature=None):
  7. self.signature = signature
  8. self.base_tree = base_tree
  9. self.prototype = prototype
  10. self.inputs={}
  11. self.outputs={}
  12. self.parameters = {}
  13. self.node_type = 'DUMMY'
  14. self.prepared = True
  15. if prototype.bl_idname in ["MantisSchemaGroup"]:
  16. self.node_type = 'DUMMY_SCHEMA'
  17. self.prepared = False
  18. self.uuid = uuid4()
  19. if prototype:
  20. for sock in prototype.inputs:
  21. if sock.identifier == "__extend__" or sock.name == "__extend__":
  22. continue
  23. self.inputs[sock.identifier] = NodeSocket(is_input = True, name = sock.identifier, node = self)
  24. for sock in prototype.outputs:
  25. if sock.identifier == "__extend__" or sock.name == "__extend__":
  26. continue
  27. self.outputs[sock.identifier] = NodeSocket(is_input = False, name = sock.identifier, node = self)
  28. self.parameters[sock.identifier]=None
  29. # keep track of the "natural signature" of Schema nodes - so that they are unambiguous
  30. if natural_signature:
  31. self.natural_signature=natural_signature
  32. # This is necessary for Schema to work if there are multiple Schema nodes using the same Schema tree.
  33. # this is ugly and I hate it.
  34. self.hierarchy_connections = []
  35. self.connections = []
  36. self.hierarchy_dependencies = []
  37. self.dependencies = []
  38. self.executed = False
  39. class NoOpNode(MantisNode):
  40. def __init__(self, signature, base_tree):
  41. self.signature = signature
  42. self.base_tree = base_tree
  43. self.inputs={
  44. "Input" : NodeSocket(is_input = True, name = "Input", node = self),
  45. }
  46. self.outputs = {
  47. "Output" : NodeSocket(name = "Output", node=self),
  48. }
  49. self.parameters = {
  50. "Input" : None,
  51. "Output" : None,
  52. }
  53. self.inputs["Input"].set_traverse_target(self.outputs["Output"])
  54. self.outputs["Output"].set_traverse_target(self.inputs["Input"])
  55. self.node_type = 'UTILITY'
  56. self.prepared = True
  57. self.hierarchy_connections = []; self.connections = []
  58. self.hierarchy_dependencies = []; self.dependencies = []
  59. self.executed = True
  60. # this node is useful for me to insert in the tree and use for debugging especially connections.