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.
 
 getRenderer ()
 Get 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 48 of file node_editor.js.

48 {
49 if (!this.monitoring) {
50 return;
51 }
52
53 if (this.renderer)
54 {
56 }
57 if (this.debug) {
58 this.debugMessage('Monitor> Connection change: ', this.getPath(node, parentGraph));
59 }
60 }
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 // To avoid toggle a change when the colorspace is not set
30 if (attribute == 'colorspace' && !value)
31 {
32 value = 'lin_rec709';
33 }
34
35 if (!this.monitoring || (prevValue == value)) {
36 return;
37 }
38
39 if (this.renderer)
40 {
42 }
43 if (this.debug) {
44 this.debugMessage('Monitor> Document attribute "' + attribute + '" changed from: ' + prevValue + ' to: ' + value, '');
45 }
46 }

◆ onNodeRemoved()

MxMaterialXMonitor::onNodeRemoved ( node,
parentGraph )

Definition at line 62 of file node_editor.js.

62 {
63 if (!this.monitoring) {
64 return;
65 }
66
67 if (this.renderer)
68 {
70 }
71 if (this.debug) {
72 this.debugMessage('Monitor> Node removed: ', this.getPath(node, parentGraph));
73 }
74 }

◆ onNodeRenamed()

MxMaterialXMonitor::onNodeRenamed ( node,
newName )

Definition at line 76 of file node_editor.js.

76 {
77 if (!this.monitoring) {
78 return;
79 }
80
81 if (this.renderer)
82 {
84 }
85
86 if (this.debug) {
87 let parentPath = this.getParentPath(node);
88 let path = parentPath + node.title;
89 let newpath = parentPath + newName;
90 this.debugMessage('Monitor> Node renamed: ', path + ' to: ' + newpath);
91 }
92 }
getParentPath(node)
Get the parent path of a node.

◆ onPropertyChanged()

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

Definition at line 113 of file node_editor.js.

113 {
114 if (!this.monitoring || (previousValue == newValue)) {
115 return;
116 }
117
118 let path = this.getParentPath(node) + nodeName;
119
120 if (this.renderer) {
121 if (typeof newValue == 'string') {
123 if (this.debug) {
124 console.log('Renderer> Build required for string change:', path, '. Property: ' + propertyName +
125 '. Value: ' + newValue + '. Previous Value: ' + previousValue + '. Node: ' + node.nodedef_node);
126 }
127 }
128 else {
129 if (node.nodedef_node != 'input')
130 path = path + '/' + propertyName;
131 this.renderer.updateShader(path, newValue);
132 }
133 }
134 else {
135 if (this.debug) {
136 console.log('Monitor> Property changed:', path, '. Property: ' + propertyName +
137 '. Value: ' + newValue + '. Previous Value: ' + previousValue + '. Node: ' + node.nodedef_node);
138 }
139 }
140 }

◆ onPropertyInfoChanged()

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

Definition at line 94 of file node_editor.js.

94 {
95 if (!this.monitoring || (previousValue == newValue)) {
96 return;
97 }
98
99 if (this.renderer)
100 {
102 }
103
104
105 if (this.debug) {
106 let path = this.getParentPath(node) + nodeName;
107 console.log('Monitor> Property Info changed:', path, '. Property: ' + propertyName +
108 '. Property Info: ' + propertyInfoName +
109 '. Value: ' + newValue + '. Previous Value: ' + previousValue, '. Category:', node.nodedef_node);
110 }
111 }

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