diff --git a/src/jmap/shape/Signal/ESigAuto.js b/src/jmap/shape/Signal/ESigAuto.js index 099f9a091..c8877fde5 100644 --- a/src/jmap/shape/Signal/ESigAuto.js +++ b/src/jmap/shape/Signal/ESigAuto.js @@ -6,42 +6,48 @@ class ESigPass extends Group { constructor(model) { super(); this.model = model; - this._create(); + this.isNew = false; } _create() { - const model = this.model; - const style = this.model.style; - const rotation = model.drict != 1? 0 : Math.PI; - const point = arrows(model.x, model.y, style.Signal.signalAutoWidth, style.Signal.lamp.signalR * 0.8); - this.arrows = new Polygon({ - zlevel: model.zlevel, - z: model.z, - rotation: rotation, - shape: { - points: point - }, - style: { - stroke: model.stroke, - lineWidth: model.lineWidth, - fill: model.fill - } - }); - this.add(this.arrows); + if (!this.isNew) { + const model = this.model; + const style = this.model.style; + const rotation = model.drict != 1? 0 : Math.PI; + const point = arrows(model.x, model.y, style.Signal.signalAutoWidth, style.Signal.lamp.signalR * 0.8); + this.arrows = new Polygon({ + zlevel: model.zlevel, + z: model.z, + rotation: rotation, + shape: { + points: point + }, + style: { + stroke: model.stroke, + lineWidth: model.lineWidth, + fill: model.fill + } + }); + this.add(this.arrows); + this.isNew = true; + } } // 停止动画 animationRecover() { + this._create(); this.arrows.stopAnimation(false); } // 箭头颜色 setColor(color) { + this._create(); this.arrows.setStyle('fill', color); } // 箭头闪烁 arrowsAnimation() { + this._create(); const style = this.model.style; const fill = this.arrows.style.Signal.fill; this.arrows.animate(true) @@ -54,11 +60,13 @@ class ESigPass extends Group { // 隐藏 hide() { + this._create(); this.arrows.hide(); } // 显示 show() { + this._create(); this.arrows.show(); } } diff --git a/src/jmap/shape/Signal/ESigButton.js b/src/jmap/shape/Signal/ESigButton.js index 19341cdc9..c7bcf3651 100644 --- a/src/jmap/shape/Signal/ESigButton.js +++ b/src/jmap/shape/Signal/ESigButton.js @@ -8,97 +8,99 @@ class ESigButton extends Group { constructor(model) { super(); this.model = model; - this._create(); + this.isNew = false; } _create() { - const model = this.model; - const style = this.model.style; - const padding = 1; - const r = style.Signal.lamp.signalR * 0.8; + if (!this.isNew) { + const model = this.model; + const style = this.model.style; + const padding = 1; + const r = style.Signal.lamp.signalR * 0.8; - this.style = style; - this._subType = 'SignalButton'; + this.sigNormalButtom = new Rect({ + zlevel: model.zlevel, + z: model.z, + _subType: 'SignalButton', + _val: '1', + shape: { + x: model.x - style.Signal.lamp.signalR, + y: model.y - r + r * model.posit, + width: style.Signal.lamp.signalR * 2, + height: style.Signal.lamp.signalR * 2 + }, + style: { + lineWidth: 0.2, + stroke: style.Signal.button.signalButtonDashColor, + fill: style.Signal.button.signalButtonColor + } + }); - this.sigNormalButtom = new Rect({ - zlevel: model.zlevel, - z: model.z, - _subType: this._subType, - _val: '1', - shape: { - x: model.x - style.Signal.lamp.signalR, - y: model.y - r + r * model.posit, - width: style.Signal.lamp.signalR * 2, - height: style.Signal.lamp.signalR * 2 - }, - style: { - lineWidth: 0.2, - stroke: style.Signal.button.signalButtonDashColor, - fill: style.Signal.button.signalButtonColor - } - }); + this.sigReentryButton = new Circle({ + zlevel: model.zlevel, + z: model.z, + _subType: 'SignalButton', + _val: '2', // 折返按钮 + shape: { + cx: model.x, + cy: model.y - 5 / 2 * r * model.posit, + r: style.Signal.lamp.signalR + }, + style: { + lineWidth: 0.2, + stroke: style.Signal.button.signalButtonDashColor, + fill: style.Signal.button.signalButtonColor + } + }); - this.sigReentryButton = new Circle({ - zlevel: model.zlevel, - z: model.z, - _subType: this._subType, - _val: '2', // 折返按钮 - shape: { - cx: model.x, - cy: model.y - 5 / 2 * r * model.posit, - r: style.Signal.lamp.signalR - }, - style: { - lineWidth: 0.2, - stroke: style.Signal.button.signalButtonDashColor, - fill: style.Signal.button.signalButtonColor - } - }); + this.sigNormalButtomDown = new Polyline({ + zlevel: model.zlevel, + z: model.z, + silent: true, + shape: { points: [ + [model.x - padding + r, this.sigNormalButtom.shape.y + padding], + [model.x + padding - r, this.sigNormalButtom.shape.y + padding], + [model.x + padding - r, this.sigNormalButtom.shape.y + padding * 2 + r] + ] }, + style: { + lineWidth: 0.8, + stroke: style.backgroundColor + } + }); - this.sigNormalButtomDown = new Polyline({ - zlevel: model.zlevel, - z: model.z, - silent: true, - shape: { points: [ - [model.x - padding + r, this.sigNormalButtom.shape.y + padding], - [model.x + padding - r, this.sigNormalButtom.shape.y + padding], - [model.x + padding - r, this.sigNormalButtom.shape.y + padding * 2 + r] - ] }, - style: { - lineWidth: 0.8, - stroke: style.backgroundColor - } - }); + this.sigReentryButtonDown = new Arc({ + zlevel: model.zlevel, + z: model.z, + silent: true, + shape: { + cx: this.sigReentryButton.shape.cx, + cy: this.sigReentryButton.shape.cy, + r: this.sigReentryButton.shape.r - padding, + startAngle: Math.PI * 8 / 5, + endAngle: Math.PI * 4 / 5, + clockwise: false + }, + style: { + lineWidth: 0.8, + stroke: style.backgroundColor + } + }); - this.sigReentryButtonDown = new Arc({ - zlevel: model.zlevel, - z: model.z, - silent: true, - shape: { - cx: this.sigReentryButton.shape.cx, - cy: this.sigReentryButton.shape.cy, - r: this.sigReentryButton.shape.r - padding, - startAngle: Math.PI * 8 / 5, - endAngle: Math.PI * 4 / 5, - clockwise: false - }, - style: { - lineWidth: 0.8, - stroke: style.backgroundColor - } - }); - - this.add(this.sigNormalButtom); - this.add(this.sigReentryButton); - this.hide(); + this.add(this.sigNormalButtom); + this.add(this.sigReentryButton); + this.hide(); + this.isNew = true; + } } hide() { + this._create(); this.sigNormalButtom.hide(); this.sigReentryButton.hide(); } show() { + this._create(); this.sigNormalButtom.show(); this.sigReentryButton.show(); } diff --git a/src/jmap/shape/Signal/ESigDelay.js b/src/jmap/shape/Signal/ESigDelay.js index 776603d0c..d9ced14da 100644 --- a/src/jmap/shape/Signal/ESigDelay.js +++ b/src/jmap/shape/Signal/ESigDelay.js @@ -5,43 +5,50 @@ class ESigDelay extends Group { constructor(model) { super(); this.model = model; - this._create(); + this.isNew = false; } _create() { - const model = this.model; - this.name = new Text({ - _subType: model._subType, - zlevel: model.zlevel, - z: model.z, - silent: model.silent || false, - style: { - x: model.x, - y: model.y, - text: model.text, - textFont: model.textFont, - textFill: model.textFill, - textAlign: model.textAlign, - textPosition: model.textPosition || 'inside', - textVerticalAlign: model.textVerticalAlign || null - } - }); - this.add(this.name); + if (!this.isNew) { + const model = this.model; + this.name = new Text({ + _subType: model._subType, + zlevel: model.zlevel, + z: model.z, + silent: model.silent || false, + style: { + x: model.x, + y: model.y, + text: model.text, + textFont: model.textFont, + textFill: model.textFill, + textAlign: model.textAlign, + textPosition: model.textPosition || 'inside', + textVerticalAlign: model.textVerticalAlign || null + } + }); + this.add(this.name); + this.isNew = true; + } } setStyle(model) { + this._create(); this.name.setStyle(model); } setColor(color) { + this._create(); this.name.setStyle('textFill', color); } hide() { + this._create(); this.name.hide(); } show() { + this._create(); this.name.show(); } } diff --git a/src/jmap/shape/Signal/ESigRoute.js b/src/jmap/shape/Signal/ESigRoute.js index 398fe29b5..eb09d95bd 100644 --- a/src/jmap/shape/Signal/ESigRoute.js +++ b/src/jmap/shape/Signal/ESigRoute.js @@ -6,34 +6,40 @@ class ESigDrict extends Group { constructor(model) { super(); this.model = model; - this._create(); + this.isNew = false; } _create() { - const model = this.model; - const style = this.model.style; - this.sigDrict = new Polygon({ - zlevel: model.zlevel, - z: model.z, - shape: { - points: triangular(model.x, model.y, model.drict, style.Signal.lamp.signalR) - }, - style: { - stroke: style.backgroundColor, - lineWidth: 0.5, - fill: style.Signal.route.signalRouteColor - } - }); - this.add(this.sigDrict); + if (!this.isNew) { + const model = this.model; + const style = this.model.style; + this.sigDrict = new Polygon({ + zlevel: model.zlevel, + z: model.z, + shape: { + points: triangular(model.x, model.y, model.drict, style.Signal.lamp.signalR) + }, + style: { + stroke: style.backgroundColor, + lineWidth: 0.5, + fill: style.Signal.route.signalRouteColor + } + }); + + this.add(this.sigDrict); + this.isNew = true; + } } // 隐藏 hide() { + this._create(); this.sigDrict.hide(); } // 显示 show() { + this._create(); this.sigDrict.show(); } }