diff --git a/altium_sch_renderer.js b/altium_sch_renderer.js index 424ae36..e03a354 100644 --- a/altium_sch_renderer.js +++ b/altium_sch_renderer.js @@ -63,12 +63,12 @@ class AltiumSchematicRenderer render() { let oldMove = mxGraphHandler.prototype.mouseMove mxGraphHandler.prototype.mouseMove = function(sender, me){ - console.log("mouse move",sender,me) + // console.log("mouse move",sender,me) // https://github.com/jgraph/mxgraph/blob/master/javascript/src/js/handler/mxGraphHandler.js#L901 if (!this.livePreviewUsed && this.shape == null) { this.shape = this.createPreviewShape(this.bounds); }else if(this.shape != null){ - console.log("mouseMove",this) + // console.log("mouseMove",this) } oldMove.call(this, sender, me); } @@ -103,6 +103,9 @@ class AltiumSchematicRenderer }; this.graph = new mxGraph(document.getElementById('graphContainer')); + + + this.graph.setPanning(true); this.graph.setConnectable(true); this.graph.setConnectableEdges(true); @@ -208,6 +211,8 @@ class AltiumSchematicRenderer style['movable'] = '0'; style['strokeWidth'] = strokeWidth; style['rounded'] = '0'; + style[mxConstants.STYLE_FONTSIZE] = '11'; + // Sets join node size style['startSize'] = joinNodeSize; @@ -220,7 +225,7 @@ class AltiumSchematicRenderer style['fillColor'] = 'none'; style['fontColor'] = fontColor; style['fontStyle'] = '1'; - style['fontSize'] = '12'; + style['fontSize'] = '6'; style['resizable'] = '0'; style['strokeWidth'] = strokeWidth; // let canvas = this.canvas; @@ -444,6 +449,7 @@ class AltiumSchematicRenderer for (let obj of doc.objects.filter((o) => o instanceof AltiumTextFrame)) { + obj = obj // if (!this.#shouldShow(obj)) continue; // if (!obj.transparent) @@ -462,6 +468,8 @@ class AltiumSchematicRenderer for (let obj of doc.objects.filter((o) => o instanceof AltiumEllipse)) { + obj = obj + // if (!this.#shouldShow(obj)) continue; // if (!obj.transparent) @@ -478,12 +486,20 @@ class AltiumSchematicRenderer for (let obj of doc.objects.filter((o) => o instanceof AltiumPin)) { var style = 'shape=line;fontColor=#000000;strokeColor=#000000;' + let name = '' + if(obj.show_name){ + name = obj.name + } + if(obj.angle == 0){ + style = style + 'labelPosition=left;' + } if(obj.angle == 90){ style += 'rotation=90' obj.y = obj.y + obj.length/2 obj.x = obj.x - obj.length/2 } if(obj.angle == 180){ + style = style + 'labelPosition=right;' obj.x = obj.x - obj.length } if(obj.angle == 270){ @@ -494,7 +510,7 @@ class AltiumSchematicRenderer obj.y = 840 - obj.y // console.log(style) - var v11 = this.graph.insertVertex(parent, null, '', obj.x, obj.y, + var v11 = this.graph.insertVertex(parent, null, name, obj.x, obj.y, obj.length, 1, style); v11.geometry.relative = false; @@ -562,6 +578,8 @@ class AltiumSchematicRenderer for (let obj of doc.objects.filter((o) => o instanceof AltiumArc)) { + obj = obj + // if (!this.#shouldShow(obj)) continue; // ctx.strokeStyle = this.#altiumColourToHex(obj.colour); @@ -575,7 +593,26 @@ class AltiumSchematicRenderer for (let obj of doc.objects.filter((o) => o instanceof AltiumPolygon)) { - + obj = obj + mxCellRenderer.registerShape('polygon', mxPolygon); + obj.x2 = 840 - obj.x2 + obj.y2 = 840 - obj.y2 + style = 'shape=polygon;strokeColor=#0000ff;' + // console.log(style) + var v11 = this.graph.insertVertex(parent, null, '', obj.points[0], obj.points[0], + 1,1,style); + + v11.points = obj.obj.points + v11.geometry.relative = false; + if(chips[obj.owner_record_index] == undefined){ + chips[obj.owner_record_index] = [] + } + if(chips[obj.owner_record_index] == undefined){ + chips[obj.owner_record_index] = [] + } + v11.setConnectable(false); + + chips[obj.owner_record_index].push(v11) // if (!this.#shouldShow(obj)) continue; // ctx.strokeStyle = this.#altiumColourToHex(obj.line_colour); @@ -595,6 +632,7 @@ class AltiumSchematicRenderer for (let obj of doc.objects.filter((o) => o instanceof AltiumJunction)) { + obj = obj // if (!this.#shouldShow(obj)) continue; @@ -701,13 +739,17 @@ class AltiumSchematicRenderer for (let obj of doc.objects.filter((o) => o instanceof AltiumLabel)) { obj.y = 840 - obj.y - var v11 = this.graph.insertVertex(parent, null, obj.text, obj.x, obj.y, - 0, 0, - "shape=label"); - v11.geometry.relative = false; - v11.setConnectable(false); - if(obj.owner_record_index != 1) - chips[obj.owner_record_index].push(v11) + if(obj.text != undefined){ + console.log(obj.text.length) + var v11 = this.graph.insertVertex(parent, null, obj.text, obj.x, obj.y - 4, + obj.text.length*9/2, 0, + "shape=label;fontSize=9;"); + v11.geometry.relative = false; + v11.setConnectable(false); + if(obj.owner_record_index != 1) + chips[obj.owner_record_index].push(v11) + } + // if (!this.#shouldShow(obj)) continue; @@ -727,6 +769,18 @@ class AltiumSchematicRenderer for (let obj of doc.objects.filter((o) => o instanceof AltiumDesignator)) { + obj = obj + obj.y = 840 - obj.y + if(obj.text != undefined){ + console.log(obj.text.length) + var v11 = this.graph.insertVertex(parent, null, obj.text, obj.x, obj.y - 4, + obj.text.length*9/2, 0, + "shape=label;fontSize=9;"); + v11.geometry.relative = false; + v11.setConnectable(false); + if(obj.owner_record_index != 1) + chips[obj.owner_record_index].push(v11) + } // if (!this.#shouldShow(obj)) continue; // if (obj.hidden) @@ -919,7 +973,6 @@ class AltiumSchematicRenderer e6.geometry.points = poi e6.geometry.setTerminalPoint(new mxPoint(obj.points[0].x, obj.points[0].y), true) - e6.geometry.setTerminalPoint(new mxPoint(obj.points[obj.points.length - 1].x, obj.points[obj.points.length - 1].y), false) diff --git a/mxclient/js/mxClient.js b/mxclient/js/mxClient.js index b49fa2c..2220693 100644 --- a/mxclient/js/mxClient.js +++ b/mxclient/js/mxClient.js @@ -693,6 +693,8 @@ if (mxForceIncludes || !(typeof module === 'object' && module.exports != null)) mxClient.include(mxClient.basePath+'/js/shape/mxStencilRegistry.js'); mxClient.include(mxClient.basePath+'/js/shape/mxMarker.js'); mxClient.include(mxClient.basePath+'/js/shape/mxActor.js'); + mxClient.include(mxClient.basePath+'/js/shape/mxPolygon.js'); + mxClient.include(mxClient.basePath+'/js/shape/mxCloud.js'); mxClient.include(mxClient.basePath+'/js/shape/mxRectangleShape.js'); mxClient.include(mxClient.basePath+'/js/shape/mxEllipse.js');