diff --git a/src/components/draw-app/properties/SignalProperty.vue b/src/components/draw-app/properties/SignalProperty.vue index 1c78847..dff7be3 100644 --- a/src/components/draw-app/properties/SignalProperty.vue +++ b/src/components/draw-app/properties/SignalProperty.vue @@ -27,6 +27,12 @@ enum directionSelect { 向上 = 'up', 向下 = 'down', } +enum directionMap { + left = '向左', + right = '向右', + up = '向上', + down = '向下', +} drawStore.$subscribe; watch( @@ -34,7 +40,7 @@ watch( (val) => { if (val && val.type == Signal.Type) { signalModel.copyFrom(val.saveData() as SignalData); - signalDirection.value = (directionSelect as never)[signalModel.direction]; + signalDirection.value = (directionMap as never)[signalModel.direction]; } } ); @@ -43,7 +49,7 @@ onMounted(() => { const signal = drawStore.selectedGraphic as Signal; if (signal) { signalModel.copyFrom(signal.saveData()); - signalDirection.value = (directionSelect as never)[signalModel.direction]; + signalDirection.value = (directionMap as never)[signalModel.direction]; } }); diff --git a/src/graphics/signal/Signal.ts b/src/graphics/signal/Signal.ts index cff6ee5..2fd41ae 100644 --- a/src/graphics/signal/Signal.ts +++ b/src/graphics/signal/Signal.ts @@ -134,6 +134,32 @@ export class Signal extends JlGraphic { codeGraph.anchor.set(0.5); codeGraph.style.fill = this.datas.codeColor; codeGraph.position.set(0, signalConsts.nameOffsetY); + if (this.datas.direction === 'left') { + this.lampPost.rotation = Math.PI; + this.circularLamp.rotation = Math.PI; + this.humanControl.rotation = Math.PI; + this.fleetMode.rotation = Math.PI; + this.logicMode.rotation = Math.PI; + } else if (this.datas.direction === 'up') { + this.lampPost.rotation = (Math.PI / 2) * 3; + this.circularLamp.rotation = (Math.PI / 2) * 3; + this.humanControl.rotation = (Math.PI / 2) * 3; + this.fleetMode.rotation = (Math.PI / 2) * 3; + this.logicMode.rotation = (Math.PI / 2) * 3; + } else if (this.datas.direction === 'down') { + this.lampPost.rotation = Math.PI / 2; + this.circularLamp.rotation = Math.PI / 2; + this.humanControl.rotation = Math.PI / 2; + this.fleetMode.rotation = Math.PI / 2; + this.logicMode.rotation = Math.PI / 2; + } else { + this.lampPost.rotation = 0; + this.circularLamp.rotation = 0; + this.humanControl.rotation = 0; + this.fleetMode.rotation = 0; + this.logicMode.rotation = 0; + } + this.position.set(this.datas.point.x, this.datas.point.y); } }