import { PathCommand } from "../lib/types/path.types"; import { DrawLine } from '../lib/drawLine' import { DrawPath } from '../lib/drawPath' import { DrawGroup } from '../lib/drawGroup' import { DrawEllipse } from "../lib/drawEllipse"; import { cal_rotation_dim } from '../lib/drawFunktions' import { Injectable } from "@nestjs/common"; import { DrawDto, DrawShapeOptionenDto } from "src/_dto/draw.dto"; import { DrawHeader } from "../lib/drawHeader"; import { Line } from "src/_schemas/visu-elements.schema"; interface Para { scale?: number, } @Injectable() export class DrawAnlageDurmin { obj_height = 1100; obj_width = 1700; constructor() { } createSiloSued(data: { length: number, height: number, wand: number, posX: number, posY: number }) { let { height, length, posX, posY, wand } = data; const pSilo: PathCommand[] = [ { type: "M", x: posX, y: posY }, { relative: true, type: "V", y: height }, // -- { relative: true, type: "H", x: length }, // -- { relative: true, type: "V", y: -height }, // T { relative: true, type: "H", x: -wand }, // -- { relative: true, type: "V", y: height - wand }, // { relative: true, type: "H", x: -(length - (wand * 2)) }, // -- { relative: true, type: "V", y: -(height - wand) }, // { type: "Z" } ]; return pSilo; } createSiloNord(data: { length: number, height: number, wand: number, posX: number, posY: number }) { let { height, length, posX, posY, wand } = data; const pSilo: PathCommand[] = [ { type: "M", x: posX, y: posY }, { relative: true, type: "V", y: height }, // -- { relative: true, type: "H", x: wand }, // -- { relative: true, type: "V", y: -(height - wand) }, // T { relative: true, type: "H", x: length - (wand * 2) }, // innen oben { relative: true, type: "V", y: height - wand }, // { relative: true, type: "H", x: wand }, // -- { relative: true, type: "V", y: -height }, // { type: "Z" } ]; return pSilo; } createSiloWest(data: { length: number, height: number, wand: number, posX: number, posY: number }) { let { height, length, posX, posY, wand } = data; const pSilo: PathCommand[] = [ { type: "M", x: posX, y: posY }, { relative: true, type: "V", y: length }, // -- { relative: true, type: "H", x: height }, // -- { relative: true, type: "V", y: -wand }, // T { relative: true, type: "H", x: -(height - wand) }, // innen oben { relative: true, type: "V", y: -(length - 2 * wand) }, // { relative: true, type: "H", x: height - wand }, // -- { relative: true, type: "V", y: -wand }, // { type: "Z" } ]; return pSilo; } createFahrschine(data: { length: number, height: number, abstand: number, posX: number, posY: number, nordSued: boolean }) { let { height, length, posX, posY, abstand, nordSued } = data; if (nordSued) { height = data.length; length = data.height; } const pSchine1: PathCommand[] = [ { type: "M", x: posX, y: posY }, { relative: true, type: "V", y: height }, // -- { relative: true, type: "H", x: length }, // -- { relative: true, type: "V", y: -height }, // T { type: "Z" } ]; let abstand_x = nordSued ? abstand : 0; let abstand_y = nordSued ? 0 : abstand; const pSchine2: PathCommand[] = [ { type: "M", x: posX + abstand_x, y: posY + abstand_y }, { relative: true, type: "V", y: height }, // -- { relative: true, type: "H", x: length }, // -- { relative: true, type: "V", y: -height }, // T { type: "Z" } ]; return [pSchine1, pSchine2]; } createBand(data: { width: number, height: number, posX: number, posY: number, nordSued: boolean, boxEnde?: boolean, boxStart?: boolean }) { let { height, width, posX, posY, nordSued } = data; if (nordSued) { height = data.width; width = data.height; } const pBand1: PathCommand[] = [ { type: "M", x: 0, y: 0 }, { relative: true, type: "V", y: height }, // -- { relative: true, type: "H", x: width }, // -- { relative: true, type: "V", y: -height }, // T { type: "Z" } ]; let offsetX = nordSued ? 10 : 0; let offsetY = nordSued ? 0 : 6; let belt2Pos = { width: width - offsetX, height: height - offsetY } const pBand2: PathCommand[] = [ { type: "M", x: offsetX / 2, y: offsetY / 2 }, { relative: true, type: "V", y: belt2Pos.height }, // -- { relative: true, type: "H", x: belt2Pos.width }, // -- { relative: true, type: "V", y: -belt2Pos.height }, // T { type: "Z" } ]; //--- Boxen am Band Anfang und Ende let boxHeight = 20; let boxUeberstand = 5; // pro seite let box2_padding = 4; let boxDim = { height: nordSued ? boxHeight : height + (2 * boxUeberstand), width: nordSued ? width + (2 * boxUeberstand) : boxHeight } const pBandBoxStart: PathCommand[] = [ { type: "M", x: nordSued ? -boxUeberstand : 0, y: nordSued ? 0 : -boxUeberstand }, { relative: true, type: "V", y: boxDim.height }, // -- { relative: true, type: "H", x: boxDim.width }, // -- { relative: true, type: "V", y: -boxDim.height }, // T { type: "Z" } ]; const pBandBoxStartInnen: PathCommand[] = [ { type: "M", x: nordSued ? -boxUeberstand + box2_padding : box2_padding, y: nordSued ? box2_padding : -boxUeberstand + box2_padding }, { relative: true, type: "V", y: boxDim.height - (2 * box2_padding) }, // -- { relative: true, type: "H", x: boxDim.width - (2 * box2_padding) }, // -- { relative: true, type: "V", y: -boxDim.height + (2 * box2_padding) }, // T { type: "Z" } ]; let box_end_start_ende = nordSued ? height - boxHeight : width - boxHeight; const pBandBoxEnd: PathCommand[] = [ { type: "M", x: nordSued ? - boxUeberstand : box_end_start_ende, y: nordSued ? box_end_start_ende : -boxUeberstand }, { relative: true, type: "V", y: boxDim.height }, // -- { relative: true, type: "H", x: boxDim.width }, // -- { relative: true, type: "V", y: -boxDim.height }, // T { type: "Z" } ]; const pBandBoxEndInnen: PathCommand[] = [ { type: "M", x: nordSued ? - boxUeberstand + 4 : box_end_start_ende + 4, y: nordSued ? box_end_start_ende + 4 : -boxUeberstand + 4 }, { relative: true, type: "V", y: boxDim.height - (2 * box2_padding) }, // -- { relative: true, type: "H", x: boxDim.width - (2 * box2_padding) }, // -- { relative: true, type: "V", y: -boxDim.height + (2 * box2_padding) }, // T { type: "Z" } ]; const group = new DrawGroup({}); group.setAtrr({ translate_y: posY, translate_x: posX }) const belt1 = new DrawPath(pBand1); belt1.setAtrr({ fill: "#404040", stroke: "#404040" }) const belt2 = new DrawPath(pBand2); belt2.setAtrr({ fill: "#202020", stroke: "#606060" }) const beltBoxStart = new DrawPath(pBandBoxStart); beltBoxStart.setAtrr({ fill: "#e0e0e0", stroke: "#101010" }) const beltBoxStartInnen = new DrawPath(pBandBoxStartInnen); beltBoxStartInnen.setAtrr({ fill: "#505050", stroke: "#a0a0a0" }) const beltBoxEnd = new DrawPath(pBandBoxEnd); beltBoxEnd.setAtrr({ fill: "#e0e0e0", stroke: "#101010" }) const beltBoxEndInnen = new DrawPath(pBandBoxEndInnen); beltBoxEndInnen.setAtrr({ fill: "#505050", stroke: "#a0a0a0" }) if (data.boxStart) { group.add(beltBoxStartInnen) group.add(beltBoxStart) } if (data.boxEnde) { group.add(beltBoxEndInnen) group.add(beltBoxEnd) } //group.add(belt3) group.add(belt2) group.add(belt1) return group; } create(optionen?: DrawShapeOptionenDto): DrawGroup { let color = "#000000"; const silo_h = 196; const silo_b = 196; const silo_wand = 8; const posSiloSued = 1700 - 300; const siloWestPos = { x: 200, y: 100 } const siloSuedPos = { x: 700, y: siloWestPos.y + (silo_b * 3) + (silo_b / 2) - (silo_h / 2) } const siloNordPos = { x: 700, y: siloWestPos.y + (silo_b * 1) + (silo_b / 2) - (silo_h / 2) } const obj_h = this.obj_height; const obj_w = this.obj_width; const groupInhalt = new DrawGroup({}); const group1 = new DrawGroup({}); // Silo Süd let silo_posX = siloSuedPos.x; let silo_posY = siloSuedPos.y; const zBa2S1 = new DrawPath(this.createSiloSued({ posX: silo_posX, posY: silo_posY, length: silo_b, height: silo_h, wand: silo_wand })); silo_posX += silo_b - silo_wand; const zBa2S2 = new DrawPath(this.createSiloSued({ posX: silo_posX, posY: silo_posY, length: silo_b, height: silo_h, wand: silo_wand })); silo_posX += silo_b - silo_wand; const zBa2S3 = new DrawPath(this.createSiloSued({ posX: silo_posX, posY: silo_posY, length: silo_b, height: silo_h, wand: silo_wand })); silo_posX += silo_b - silo_wand; const zBa2S4 = new DrawPath(this.createSiloSued({ posX: silo_posX, posY: silo_posY, length: silo_b, height: silo_h, wand: silo_wand })); silo_posX += silo_b - silo_wand; const zBa2S5 = new DrawPath(this.createSiloSued({ posX: silo_posX, posY: silo_posY, length: silo_b, height: silo_h, wand: silo_wand })); zBa2S1.setAtrr({ fill: "#303030", strokeWidth: 1, stroke: "#303030" }) zBa2S2.setAtrr({ fill: "#303030", strokeWidth: 1, stroke: "#303030" }) zBa2S3.setAtrr({ fill: "#303030", strokeWidth: 1, stroke: "#303030" }) zBa2S4.setAtrr({ fill: "#303030", strokeWidth: 1, stroke: "#303030" }) zBa2S5.setAtrr({ fill: "#303030", strokeWidth: 1, stroke: "#303030" }) // Schiene let [pBa1Schiene1, pBa1Schiene2] = this.createFahrschine({ length: silo_b * 5 + 50, height: 4, abstand: 50, posX: siloSuedPos.x - 30, posY: siloSuedPos.y + (silo_h / 2) - 25, nordSued: false }); const zBa1Schine1 = new DrawPath(pBa1Schiene1); const zBa1Schine2 = new DrawPath(pBa1Schiene2); // Silo Nord silo_posX = siloNordPos.x; silo_posY = siloNordPos.y; const zBa1S1 = new DrawPath(this.createSiloNord({ posX: silo_posX, posY: silo_posY, length: silo_b, height: silo_h, wand: silo_wand })); silo_posX += silo_b - silo_wand; const zBa1S2 = new DrawPath(this.createSiloNord({ posX: silo_posX, posY: silo_posY, length: silo_b, height: silo_h, wand: silo_wand })); silo_posX += silo_b - silo_wand; const zBa1S3 = new DrawPath(this.createSiloNord({ posX: silo_posX, posY: silo_posY, length: silo_b, height: silo_h, wand: silo_wand })); silo_posX += silo_b - silo_wand; const zBa1S4 = new DrawPath(this.createSiloNord({ posX: silo_posX, posY: silo_posY, length: silo_b, height: silo_h, wand: silo_wand })); silo_posX += silo_b - silo_wand; const zBa1S5 = new DrawPath(this.createSiloNord({ posX: silo_posX, posY: silo_posY, length: silo_b, height: silo_h, wand: silo_wand })); zBa1S1.setAtrr({ fill: "#303030", strokeWidth: 1, stroke: "#303030" }) zBa1S2.setAtrr({ fill: "#303030", strokeWidth: 1, stroke: "#303030" }) zBa1S3.setAtrr({ fill: "#303030", strokeWidth: 1, stroke: "#303030" }) zBa1S4.setAtrr({ fill: "#303030", strokeWidth: 1, stroke: "#303030" }) zBa1S5.setAtrr({ fill: "#303030", strokeWidth: 1, stroke: "#303030" }) // Schiene let [pBa2Schiene1, pBa2Schiene2] = this.createFahrschine({ length: silo_b * 5 + 50, height: 4, abstand: 50, posX: siloNordPos.x - 30, posY: siloNordPos.y + (silo_h / 2) - 25, nordSued: false }); const zBa2Schine1 = new DrawPath(pBa2Schiene1); const zBa2Schine2 = new DrawPath(pBa2Schiene2); // Silo West silo_posX = siloWestPos.x; silo_posY = siloWestPos.y; const zBa3S1 = new DrawPath(this.createSiloWest({ posX: silo_posX, posY: silo_posY, length: silo_b, height: silo_h, wand: silo_wand })); silo_posY += silo_b - silo_wand; const zBa3S2 = new DrawPath(this.createSiloWest({ posX: silo_posX, posY: silo_posY, length: silo_b, height: silo_h, wand: silo_wand })); silo_posY += silo_b - silo_wand; const zBa3S3 = new DrawPath(this.createSiloWest({ posX: silo_posX, posY: silo_posY, length: silo_b, height: silo_h, wand: silo_wand })); silo_posY += silo_b - silo_wand; const zBa3S4 = new DrawPath(this.createSiloWest({ posX: silo_posX, posY: silo_posY, length: silo_b, height: silo_h, wand: silo_wand })); silo_posY += silo_b - silo_wand; const zBa3S5 = new DrawPath(this.createSiloWest({ posX: silo_posX, posY: silo_posY, length: silo_b, height: silo_h, wand: silo_wand })); zBa3S1.setAtrr({ fill: "#303030", strokeWidth: 1, stroke: "#303030" }) zBa3S2.setAtrr({ fill: "#303030", strokeWidth: 1, stroke: "#303030" }) zBa3S3.setAtrr({ fill: "#303030", strokeWidth: 1, stroke: "#303030" }) zBa3S4.setAtrr({ fill: "#303030", strokeWidth: 1, stroke: "#303030" }) zBa3S5.setAtrr({ fill: "#303030", strokeWidth: 1, stroke: "#303030" }) // Schiene let [pBa3Schiene1, pBa3Schiene2] = this.createFahrschine({ length: silo_b * 5 + 50, height: 4, abstand: 50, posX: siloWestPos.x + (silo_h / 2) - 25, posY: siloWestPos.y - 30, nordSued: true }); const zBa3Schine1 = new DrawPath(pBa3Schiene1); const zBa3Schine2 = new DrawPath(pBa3Schiene2); this.obj_height = obj_h //+ 30; this.obj_width = obj_w; let zufuefband_l = 600; let zufuefband_b = 40; let verteilband_l = 560; let verteilband_b = 34; let kopfband_l = 160; let kopfband_b = 34; let ba1_pos_hf_x = 283 let ba1_pos_hf_y = 390 //anfanf(B1) 130 B2 310; B3 ende 520 let ba2_pos_hf_x = 750 let ba2_pos_hf_y = 380 //anfanf(B1) 130 B2 310; B3 ende 520 let ba3_pos_hf_x = 750 let ba3_pos_hf_y = 770 //anfanf(B1) 130 B2 310; B3 ende 520 /* group1.add(new DrawLine({x1:0,y1:100,x2:1500,y2:100})); group1.add(new DrawLine({x1:0,y1:110,x2:1500,y2:110})); group1.add(new DrawLine({x1:0,y1:120,x2:1500,y2:120})); group1.add(new DrawLine({x1:0,y1:130,x2:1500,y2:130})); group1.add(new DrawLine({x1:0,y1:140,x2:1500,y2:140})); group1.add(new DrawLine({x1:0,y1:150,x2:1500,y2:150})); group1.add(new DrawLine({x1:0,y1:160,x2:1500,y2:160})); group1.add(new DrawLine({x1:0,y1:170,x2:1500,y2:170})); group1.add(new DrawLine({x1:0,y1:180,x2:1500,y2:180})); group1.add(new DrawLine({x1:0,y1:190,x2:1500,y2:190})); group1.add(new DrawLine({x1:0,y1:200,x2:1500,y2:200})); group1.add(new DrawLine({x1:10,y1:0,x2:10,y2:1100})); group1.add(new DrawLine({x1:20,y1:0,x2:20,y2:1100})); group1.add(new DrawLine({x1:30,y1:0,x2:30,y2:1100})); group1.add(new DrawLine({x1:40,y1:0,x2:40,y2:1100})); group1.add(new DrawLine({x1:50,y1:0,x2:50,y2:1100})); group1.add(new DrawLine({x1:60,y1:0,x2:60,y2:1100})); group1.add(new DrawLine({x1:70,y1:0,x2:70,y2:1100})); group1.add(new DrawLine({x1:80,y1:0,x2:80,y2:1100})); group1.add(new DrawLine({x1:90,y1:0,x2:90,y2:1100})); group1.add(new DrawLine({x1:100,y1:0,x2:100,y2:1100})); */ //group1.add(this.createBand({ posX: 100, posY: 20, width: zufuefband_l, height: zufuefband_b, nordSued: true, boxEnde: true })) // BA1 Zufuehrband //group1.add(this.createBand({ posX: ba1_pos_hf_x, posY: ba1_pos_hf_y, width: verteilband_l, height: verteilband_b, nordSued: true, boxEnde: true, boxStart: true }))// BA1 Verteilband //group1.add(this.createBand({ posX: ba1_pos_hf_x - (kopfband_l / 2 - verteilband_b / 2), posY: ba1_pos_hf_y - (kopfband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: false, boxEnde: true, boxStart: true }))// BA2 Kopfband hinten //group1.add(this.createBand({ posX: ba1_pos_hf_x - (kopfband_l / 2 - verteilband_b / 2), posY: ba1_pos_hf_y + verteilband_l - (kopfband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: false, boxEnde: true, boxStart: true }))// BA2 Kopfband vorne //group1.add(this.createBand({ posX: 340, posY: 240, width: zufuefband_l + 400, height: zufuefband_b, nordSued: false, boxStart: true, boxEnde: true }))// BA2 Zufuehrband //group1.add(this.createBand({ posX: ba2_pos_hf_x, posY: ba2_pos_hf_y, width: verteilband_l, height: verteilband_b, nordSued: false, boxEnde: true, boxStart: true }))// BA1 Verteilband //group1.add(this.createBand({ posX: ba2_pos_hf_x - (kopfband_b / 2), posY: ba2_pos_hf_y - (kopfband_l / 2) + (verteilband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: true, boxEnde: true, boxStart: true }))// BA2 Kopfband hinten //group1.add(this.createBand({ posX: ba2_pos_hf_x + verteilband_l - (kopfband_b / 2), posY: ba2_pos_hf_y - (kopfband_l / 2) + (verteilband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: true, boxEnde: true, boxStart: true }))// BA2 Kopfband vorne //group1.add(this.createBand({ posX: 360, posY: 900, width: zufuefband_l + 400, height: zufuefband_b, nordSued: false, boxStart: true, boxEnde: true }))// BA2 Zufuehrband //group1.add(this.createBand({ posX: ba3_pos_hf_x, posY: ba3_pos_hf_y, width: verteilband_l, height: verteilband_b, nordSued: false, boxEnde: true, boxStart: true }))// BA1 Verteilband //group1.add(this.createBand({ posX: ba3_pos_hf_x - (kopfband_b / 2), posY: ba3_pos_hf_y - (kopfband_l / 2) + (verteilband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: true, boxEnde: true, boxStart: true }))// BA2 Kopfband hinten //group1.add(this.createBand({ posX: ba3_pos_hf_x + verteilband_l - (kopfband_b / 2), posY: ba3_pos_hf_y - (kopfband_l / 2) + (verteilband_b / 2), width: kopfband_l, height: kopfband_b, nordSued: true, boxEnde: true, boxStart: true }))// BA2 Kopfband vorne group1.add(zBa1Schine1); group1.add(zBa1Schine2); group1.add(zBa1S1); group1.add(zBa1S2); group1.add(zBa1S3); group1.add(zBa1S4); group1.add(zBa1S5); group1.add(zBa2Schine1); group1.add(zBa2Schine2); group1.add(zBa2S1); group1.add(zBa2S2); group1.add(zBa2S3); group1.add(zBa2S4); group1.add(zBa2S5); group1.add(zBa3Schine1); group1.add(zBa3Schine2); group1.add(zBa3S1); group1.add(zBa3S2); group1.add(zBa3S3); group1.add(zBa3S4); group1.add(zBa3S5); groupInhalt.add(group1) groupInhalt.setAtrr({ translate_y: 11, translate_x: 11 }) return groupInhalt; } getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto { const groupSvg = this.create(optionen) const getXaml = true; const svg = groupSvg.getChildString(!getXaml, 0) let xaml = groupSvg.getChildString(getXaml, 0) const header = new DrawHeader({ lenght: this.obj_width, height: this.obj_height }); header.add(groupSvg); xaml = header.getChildString(getXaml, 0); return { name: "anlageDurmin", height: this.obj_height, length: this.obj_width, px_height: this.obj_height, px_width: this.obj_width, raster: 1, scale: 1, offset_x: 0, offset_y: 0, svg, xaml: xaml, graphicsData: [ { state: 'inactive', svg: svg, xaml: xaml, xamlBase64: Buffer.from(xaml, "utf-8").toString("base64") } ] } } getSvg(optionen?: DrawShapeOptionenDto): string { const groupSvg = this.create(optionen) const xaml = optionen && optionen.xaml ? true : false; const header = new DrawHeader({ lenght: this.obj_width, height: this.obj_height }); header.add(groupSvg); return header.getChildString(xaml, 0); } }