v11.points = obj.obj.points

改为
if( obj.hasOwnProperty("points")) {
	v11.points = obj.points
}
该属性不一定存在
main
zcy 2024-03-26 01:03:05 +08:00
parent a3aa0f292d
commit 2611df4898
2 changed files with 7 additions and 29 deletions

View File

@ -154,7 +154,6 @@ function renderSchematic(data)
renderer.render();
}
</script>
</body>
</html

View File

@ -63,7 +63,7 @@ class AltiumSchematicRenderer
this.graph = new mxGraph(document.getElementById('graphContainer'));
mxConnectionHandler.prototype.movePreviewAway = false;
mxConnectionHandler.prototype.movePreviewAway = true;
mxConnectionHandler.prototype.waypointsEnabled = true;
mxGraph.prototype.resetEdgesOnConnect = true;
mxConstants.SHADOWCOLOR = '#C0C0C0';
@ -544,8 +544,9 @@ class AltiumSchematicRenderer
}
}
if((geo != null) && (this.getModel.isEdge(terminal.cell))){
if((geo != null) && (this.getModel().isEdge(terminal.cell))) {
console.log(terminal.cell)
return [new mxConnectionConstraint(new mxPoint(0, 0), false)];
}
return null;
};
@ -697,29 +698,7 @@ class AltiumSchematicRenderer
}
results.innerText = bom.join("\n");
// for (let obj of doc.objects.filter((o) => o instanceof AltiumWire))
// {
// // for (let i = 1; i < obj.points.length; i++)
// // {
// // obj.points[i].y = 840 - obj.points[i].y
// // }
// var obj1 = this.graph.getCellAt(obj.points[0].x,obj.points[0].y,parent)
// var obj2 = this.graph.getCellAt(obj.points[obj.points.length - 1].x,
// obj.points[obj.points.length - 1].y,parent)
// mxLog.debug(obj1,obj2)
// // if (!this.#shouldShow(obj)) continue;
// // ctx.strokeStyle = this.#altiumColourToHex(obj.colour);
// // ctx.lineWidth = obj.width;
// // ctx.beginPath();
// // ctx.moveTo(obj.points[0].x, obj.points[0].y);
// // for (let i = 1; i < obj.points.length; i++)
// // {
// // ctx.lineTo(obj.points[i].x, obj.points[i].y);
// // }
// // ctx.stroke();
// }
for (let obj of doc.objects.filter((o) => o instanceof AltiumBus))
{
// if (!this.#shouldShow(obj)) continue;
@ -984,8 +963,9 @@ class AltiumSchematicRenderer
// mxLog.debug(style)
var v11 = this.graph.insertVertex(parent, null, '', obj.points[0], obj.points[0],
1,1,style);
v11.points = obj.obj.points
if( obj.hasOwnProperty("points")) {
v11.points = obj.points
}
v11.geometry.relative = false;
if(chips[obj.owner_record_index] == undefined){
chips[obj.owner_record_index] = []
@ -1341,7 +1321,6 @@ class AltiumSchematicRenderer
e6.geometry.setTerminalPoint(new mxPoint(obj.points[obj.points.length - 1].x,
obj.points[obj.points.length - 1].y), false)
if(this.wires == undefined){
this.wires = []
this.wires.push(e6)