From fb31b81f7ea551fe9018e0394e120859b3edfdb1 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Wed, 27 Dec 2017 14:48:15 -0800 Subject: [PATCH] Update motor SVG assets and connections --- sim/visuals/assets/Large Motor.svg | 126 +++++++++++++++------------ sim/visuals/assets/LargeMotorsvg.ts | 126 +++++++++++++++------------ sim/visuals/assets/MediumMotor.svg | 45 +++++----- sim/visuals/assets/MediumMotorsvg.ts | 47 +++++----- sim/visuals/layoutView.ts | 14 +++ sim/visuals/nodes/largeMotorView.ts | 8 +- sim/visuals/nodes/mediumMotorView.ts | 8 +- 7 files changed, 217 insertions(+), 157 deletions(-) diff --git a/sim/visuals/assets/Large Motor.svg b/sim/visuals/assets/Large Motor.svg index 68a857fe..b25fe9ae 100644 --- a/sim/visuals/assets/Large Motor.svg +++ b/sim/visuals/assets/Large Motor.svg @@ -1,69 +1,87 @@ - + - - + + - - + + - - + + Large Motor - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + + + + + diff --git a/sim/visuals/assets/LargeMotorsvg.ts b/sim/visuals/assets/LargeMotorsvg.ts index 3e791aac..c38ce09b 100644 --- a/sim/visuals/assets/LargeMotorsvg.ts +++ b/sim/visuals/assets/LargeMotorsvg.ts @@ -1,70 +1,88 @@ namespace pxsim { - export const LARGE_MOTOR_SVG = ` + export const LARGE_MOTOR_SVG = ` - - + + - - + + - - + + Large Motor - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + + + + + diff --git a/sim/visuals/assets/MediumMotor.svg b/sim/visuals/assets/MediumMotor.svg index be04262c..0bc67d30 100644 --- a/sim/visuals/assets/MediumMotor.svg +++ b/sim/visuals/assets/MediumMotor.svg @@ -1,28 +1,33 @@ - + - - - + + + MediumMotor - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - diff --git a/sim/visuals/assets/MediumMotorsvg.ts b/sim/visuals/assets/MediumMotorsvg.ts index 32354672..33054802 100644 --- a/sim/visuals/assets/MediumMotorsvg.ts +++ b/sim/visuals/assets/MediumMotorsvg.ts @@ -1,30 +1,35 @@ namespace pxsim.visuals { - export const MEDIUM_MOTOR_SVG = ` + export const MEDIUM_MOTOR_SVG = ` - - - + + + - Medium Motor - - - - - - - + MediumMotor + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - `; } \ No newline at end of file diff --git a/sim/visuals/layoutView.ts b/sim/visuals/layoutView.ts index 962e07e9..b2184303 100644 --- a/sim/visuals/layoutView.ts +++ b/sim/visuals/layoutView.ts @@ -222,6 +222,20 @@ namespace pxsim.visuals { const contentHeight = this.height; if (!contentHeight) return; + const noConnections = this.outputs.concat(this.inputs).filter(m => m.getId() != NodeType.Port).length == 0; + + if (noConnections) { + // No connections render the entire board + this.brick.resize(contentWidth, contentHeight); + this.brick.translate(0, 0); + + // Hide all other connections + this.outputs.concat(this.inputs).forEach(m => m.setVisible(false)); + return; + } else { + this.outputs.concat(this.inputs).forEach(m => m.setVisible(true)); + } + const moduleHeight = this.getModuleHeight(); const brickHeight = this.getBrickHeight(); diff --git a/sim/visuals/nodes/largeMotorView.ts b/sim/visuals/nodes/largeMotorView.ts index 6fb728fe..62ef88c9 100644 --- a/sim/visuals/nodes/largeMotorView.ts +++ b/sim/visuals/nodes/largeMotorView.ts @@ -3,7 +3,7 @@ namespace pxsim.visuals { export class LargeMotorView extends ModuleView implements LayoutElement { - private static ROTATING_ECLIPSE_ID = "1eb2ae58-2419-47d4-86bf-4f26a7f0cf61"; + private static ROTATING_ECLIPSE_ID = "hole"; constructor(port: number) { super(LARGE_MOTOR_SVG, "large-motor", NodeType.LargeMotor, port); @@ -20,14 +20,14 @@ namespace pxsim.visuals { private setMotorAngle(angle: number) { const holeEl = this.content.getElementById(this.normalizeId(LargeMotorView.ROTATING_ECLIPSE_ID)) - const width = 34; - const height = 34; + const width = 125.92; + const height = 37.9; const transform = `rotate(${angle} ${width / 2} ${height / 2})`; holeEl.setAttribute("transform", transform); } getWiringRatio() { - return 0.62; + return 0.37; } } } \ No newline at end of file diff --git a/sim/visuals/nodes/mediumMotorView.ts b/sim/visuals/nodes/mediumMotorView.ts index 10371475..b1f17f3f 100644 --- a/sim/visuals/nodes/mediumMotorView.ts +++ b/sim/visuals/nodes/mediumMotorView.ts @@ -6,7 +6,7 @@ namespace pxsim.visuals { export class MediumMotorView extends ModuleView implements LayoutElement { - private static ROTATING_ECLIPSE_ID = "Hole"; + private static ROTATING_ECLIPSE_ID = "medmotor_Hole"; private hasPreviousAngle: boolean; private previousAngle: number; @@ -30,9 +30,9 @@ namespace pxsim.visuals { private setMotorAngle(angle: number) { const holeEl = this.content.getElementById(this.normalizeId(MediumMotorView.ROTATING_ECLIPSE_ID)) - const width = 47.9; - const height = 47.2; - const transform = `translate(-1.5 -1.49) rotate(${angle} ${width / 2} ${height / 2})`; + const width = 44.45; + const height = 44.45; + const transform = `translate(2 1.84) rotate(${angle} ${width / 2} ${height / 2})`; holeEl.setAttribute("transform", transform); } }