@selenite/graph-editor
Version:
A graph editor for visual programming, based on rete and svelte.
73 lines (72 loc) • 2.58 kB
JavaScript
import { PythonObject, PythonProperty } from '../../../../backend-interaction/python';
import { Node } from '../../Node.svelte';
// TODO : autogenerate outputs from the python object
export class BreakNode extends Node {
state = { ...this.state, type: 'any' };
constructor({ factory }) {
super({ label: 'Break Shot', factory, height: 225 });
this.oldAddInData({
name: 'object',
displayName: 'Shot',
socketLabel: 'Shot',
type: 'pythonObject'
});
this.oldAddOutData({
name: 'xml',
displayName: 'XML',
type: 'pythonProperty'
});
this.oldAddOutData({
name: 'sourceCoords',
displayName: 'Source Coords',
type: 'pythonProperty'
});
this.oldAddOutData({
name: 'receiverCoords',
displayName: 'Receiver Coords',
type: 'pythonProperty'
});
this.oldAddOutData({
name: 'id',
displayName: 'ID',
type: 'pythonProperty'
});
this.pythonComponent.setDataCodeGetter('xml', () => '$(object).xml');
this.pythonComponent.setDataCodeGetter('sourceCoords', () => '$(object).getSourceCoords()');
this.pythonComponent.setDataCodeGetter('receiverCoords', () => '$(object).getReceiverCoords()');
this.pythonComponent.setDataCodeGetter('id', () => '$(object).id');
this.changeType('utilities.acquisition.Shot.Shot');
}
applyState() {
super.applyState();
this.changeType(this.state.type);
}
changeType(type) {
this.state.type = type;
const makutuClasses = this.factory.makutuClasses;
if (type in makutuClasses) {
console.log(makutuClasses[type]);
}
// this.pythonComponent.setVariableType('object', type);
}
data(inputs) {
const res = {
xml: undefined,
sourceCoords: undefined,
receiverCoords: undefined,
id: undefined
};
if (!inputs)
return { ...super.data(inputs), res };
const object = inputs.object;
if (!object)
return { ...super.data(inputs), res };
return {
...super.data(inputs),
xml: new PythonProperty(object, 'xml'),
sourceCoords: new PythonProperty(object, 'sourcesCoords'),
receiverCoords: new PythonProperty(object, 'receiverCoords'),
id: new PythonProperty(object, 'id')
};
}
}