node add args & input & output
This commit is contained in:
1 parent
6c3a83ce77
commit
f08e0e3c67
3 files changed
+55
-7
No files matched your search
@@ -14,7 +14,7 @@ export interface BehaviorNodeModel {
|
|||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
desc?: string;
|
desc?: string;
|
||||||
args?: string[][3];
|
args?: {[key: string]: any};
|
||||||
input?: string[];
|
input?: string[];
|
||||||
output?: string;
|
output?: string;
|
||||||
children?: BehaviorNodeModel[];
|
children?: BehaviorNodeModel[];
|
||||||
@@ -28,7 +28,7 @@ export interface BehaviorTreeModel {
|
|||||||
export interface GraphNodeModel extends TreeGraphData {
|
export interface GraphNodeModel extends TreeGraphData {
|
||||||
name: string;
|
name: string;
|
||||||
desc?: string;
|
desc?: string;
|
||||||
args?: string[][3];
|
args?: {[key: string]: any};
|
||||||
input?: string[];
|
input?: string[];
|
||||||
output?: string;
|
output?: string;
|
||||||
children?: GraphNodeModel[];
|
children?: GraphNodeModel[];
|
||||||
|
|||||||
+4
-4
@@ -26,15 +26,15 @@ export const refreshNodeId = (nodeData: GraphNodeModel, id?: number) => {
|
|||||||
|
|
||||||
export const calcTreeNodeSize = (treeNode: GraphNodeModel) => {
|
export const calcTreeNodeSize = (treeNode: GraphNodeModel) => {
|
||||||
var height = 40;
|
var height = 40;
|
||||||
const updateHeight = (arr: any) => {
|
const updateHeight = (obj: any) => {
|
||||||
if(arr && arr.length > 0) {
|
if (Array.isArray(obj) || (obj && Object.keys(obj).length > 0)) {
|
||||||
height += 30;
|
height += 25;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateHeight(treeNode.args);
|
updateHeight(treeNode.args);
|
||||||
updateHeight(treeNode.input);
|
updateHeight(treeNode.input);
|
||||||
updateHeight(treeNode.output);
|
updateHeight(treeNode.output);
|
||||||
return [150, height];
|
return [200, height];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createTreeData = (bNode: BehaviorNodeModel) => {
|
export const createTreeData = (bNode: BehaviorNodeModel) => {
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ export default class Main extends Component {
|
|||||||
},
|
},
|
||||||
style: {
|
style: {
|
||||||
fill: "white",
|
fill: "white",
|
||||||
width: 150,
|
|
||||||
},
|
},
|
||||||
stateStyles: {
|
stateStyles: {
|
||||||
selected: {
|
selected: {
|
||||||
@@ -165,6 +164,7 @@ export default class Main extends Component {
|
|||||||
textBaseline: 'top',
|
textBaseline: 'top',
|
||||||
x: x0 + 18,
|
x: x0 + 18,
|
||||||
y: y0 + 4,
|
y: y0 + 4,
|
||||||
|
fontWeight: 800,
|
||||||
lineHeight: 20,
|
lineHeight: 20,
|
||||||
text: cfg.name,
|
text: cfg.name,
|
||||||
fill: 'black',
|
fill: 'black',
|
||||||
@@ -191,6 +191,54 @@ export default class Main extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const args: any = cfg.args;
|
||||||
|
if (args && Object.keys(args).length > 0) {
|
||||||
|
y += 20;
|
||||||
|
group.addShape('text', {
|
||||||
|
attrs: {
|
||||||
|
textBaseline: 'top',
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
lineHeight: 20,
|
||||||
|
text: `参数:${JSON.stringify(args)}`,
|
||||||
|
fill: 'black',
|
||||||
|
},
|
||||||
|
name: 'args-text',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const input: [] = cfg.input ? cfg.input as [] : [];
|
||||||
|
if (input.length > 0) {
|
||||||
|
y += 20;
|
||||||
|
group.addShape('text', {
|
||||||
|
attrs: {
|
||||||
|
textBaseline: 'top',
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
lineHeight: 20,
|
||||||
|
text: `输入:${JSON.stringify(input)}`,
|
||||||
|
fill: 'black',
|
||||||
|
},
|
||||||
|
name: 'input-text',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const output: [] = cfg.output ? cfg.output as [] : [];
|
||||||
|
if (output.length > 0) {
|
||||||
|
y += 20;
|
||||||
|
group.addShape('text', {
|
||||||
|
attrs: {
|
||||||
|
textBaseline: 'top',
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
lineHeight: 20,
|
||||||
|
text: `输出:${JSON.stringify(output)}`,
|
||||||
|
fill: 'black',
|
||||||
|
},
|
||||||
|
name: 'output-text',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
group.addShape('rect', {
|
group.addShape('rect', {
|
||||||
name: 'drag-up',
|
name: 'drag-up',
|
||||||
attrs: {
|
attrs: {
|
||||||
|
|||||||
Reference in new issue
Block a user