MaterialXLab API  0.0.1
APIs For MaterialXLab Libraries
Loading...
Searching...
No Matches
MxMaterialXMonitor Class Reference

Custom monitor class for MaterialX graph. More...

Inheritance diagram for MxMaterialXMonitor:
MxGraphMonitor

Public Member Functions

 constructor (name)
 
 onDocumentChange (attribute, value, prevValue)
 
 onConnectionChange (node, parentGraph)
 
 onNodeRemoved (node, parentGraph)
 
 onNodeRenamed (node, newName)
 
 onPropertyInfoChanged (nodeName, propertyName, propertyInfoName, newValue, previousValue, node)
 
 onPropertyChanged (nodeName, propertyName, newValue, previousValue, node)
 
- Public Member Functions inherited from MxGraphMonitor
 constructor (name)
 
 debugMessage (text, path)
 Output a debug message to the console.
 
 getPath (node, parentGraph)
 Get a '/' separated path.
 
 onDocumentChange (attribute, value, prevValue)
 Callback for when a scene / document level change is made.
 
 onConnectionChange (node, parentGraph)
 Callback for when a connection changes in the graph.
 
 onConnectOutput (slot, input_type, input, target_node, target_slot, node)
 Callback for connection to output.
 
 onConnectInput (target_slot, output_type, output, source, slot, node)
 Callback for connection to output.
 
 onNodeAdded (node, parentGraph)
 Callback for when a node is added to the graph.
 
 onNodeRemoved (node, parentGraph)
 Callback for when a node is removed from the graph.
 
 getParentPath (node)
 Get the parent path of a node.
 
 onNodeRenamed (node, newName)
 Callback for when a node is renamed in the graph.
 
 onNodeSelected (node, parentGraph)
 Callback for when a node is selected in the graph.
 
 onNodeDeselected (node, parentGraph)
 Callback for when a node is deselected in the graph.
 
 onPropertyChanged (nodeName, propertyName, newValue, previousValue, node)
 Callback for when a property changes on a node in the graph.
 
 onPropertyInfoChanged (nodeName, propertyName, propertyInfoName, newValue, previousValue, node)
 Callback for when a property info changes on a node in the graph.
 
 getName ()
 Get the name of the monitor.
 
 setRenderer (theRenderer)
 Set the renderer for the monitor.
 
 setMonitoring (monitor)
 Set the monitoring state of the monitor.
 
 getMonitoring ()
 Get the monitoring state of the monitor.
 
 setOnConnectionChange (callback)
 Set connection change callback.
 
 setOnNodeAdded (callback)
 Set node added callback.
 
 setOnNodeRemoved (callback)
 Set node removed callback.
 
 setOnNodeRenamed (callback)
 Set node renamed callback.
 
 setOnNodeSelected (callback)
 Set node selected callback.
 
 setOnNodeDeselected (callback)
 Set node deselected callback.
 
 setOnPropertyChanged (callback)
 Set property changed callback.
 
 monitorGraph (theGraph, monitor)
 Core monitoring of graph changes.
 

Detailed Description

Custom monitor class for MaterialX graph.

Allows updates to be passed to any renderer used.

Definition at line 23 of file node_editor.js.

Member Function Documentation

◆ constructor()

MxMaterialXMonitor::constructor ( name)

Definition at line 24 of file node_editor.js.

24 {
25 super(name);
26 }

◆ onConnectionChange()

MxMaterialXMonitor::onConnectionChange ( node,
parentGraph )

Definition at line 40 of file node_editor.js.

40 {
41 if (!this.monitoring) {
42 return;
43 }
44
45 if (this.renderer)
47 if (this.debug) {
48 this.debugMessage('Monitor> Connection change: ', this.getPath(node, parentGraph));
49 }
50 }
debugMessage(text, path)
Output a debug message to the console.
getPath(node, parentGraph)
Get a '/' separated path.
function toggleRequireUpdateUI()

◆ onDocumentChange()

MxMaterialXMonitor::onDocumentChange ( attribute,
value,
prevValue )

Definition at line 28 of file node_editor.js.

28 {
29 if (!this.monitoring) {
30 return;
31 }
32
33 if (this.renderer)
35 if (this.debug) {
36 this.debugMessage('Monitor> Document attribute "' + attribute + '" changed from: ' + prevValue + ' to: ' + value, '');
37 }
38 }

◆ onNodeRemoved()

MxMaterialXMonitor::onNodeRemoved ( node,
parentGraph )

Definition at line 52 of file node_editor.js.

52 {
53 if (!this.monitoring) {
54 return;
55 }
56
57 if (this.renderer)
59 if (this.debug) {
60 this.debugMessage('Monitor> Node removed: ', this.getPath(node, parentGraph));
61 }
62 }

◆ onNodeRenamed()

MxMaterialXMonitor::onNodeRenamed ( node,
newName )

Definition at line 64 of file node_editor.js.

64 {
65 if (!this.monitoring) {
66 return;
67 }
68
69 if (this.renderer)
71
72 if (this.debug) {
73 let parentPath = this.getParentPath(node);
74 let path = parentPath + node.title;
75 let newpath = parentPath + newName;
76 this.debugMessage('Monitor> Node renamed: ', path + ' to: ' + newpath);
77 }
78 }
getParentPath(node)
Get the parent path of a node.

◆ onPropertyChanged()

MxMaterialXMonitor::onPropertyChanged ( nodeName,
propertyName,
newValue,
previousValue,
node )

Definition at line 96 of file node_editor.js.

96 {
97 if (!this.monitoring) {
98 return;
99 }
100
101 let path = this.getParentPath(node) + nodeName;
102
103 if (this.renderer) {
104 if (typeof newValue == 'string') {
106 if (this.debug) {
107 console.log('Renderer> Build required for string change:', path, '. Property: ' + propertyName +
108 '. Value: ' + newValue + '. Previous Value: ' + previousValue + '. Node: ' + node.nodedef_node);
109 }
110 }
111 else {
112 if (node.nodedef_node != 'input')
113 path = path + '/' + propertyName;
114 this.renderer.updateShader(path, newValue);
115 }
116 }
117 else {
118 if (this.debug) {
119 console.log('Monitor> Property changed:', path, '. Property: ' + propertyName +
120 '. Value: ' + newValue + '. Previous Value: ' + previousValue + '. Node: ' + node.nodedef_node);
121 }
122 }
123 }

◆ onPropertyInfoChanged()

MxMaterialXMonitor::onPropertyInfoChanged ( nodeName,
propertyName,
propertyInfoName,
newValue,
previousValue,
node )

Definition at line 80 of file node_editor.js.

80 {
81 if (!this.monitoring) {
82 return;
83 }
84
85 if (this.renderer)
87
88 if (this.debug) {
89 let path = this.getParentPath(node) + nodeName;
90 console.log('Monitor> Property Info changed:', path, '. Property: ' + propertyName +
91 '. Property Info: ' + propertyInfoName +
92 '. Value: ' + newValue + '. Previous Value: ' + previousValue, '. Category:', node.nodedef_node);
93 }
94 }

The documentation for this class was generated from the following file: