procon aggregate

This commit is contained in:
marco committed 2026-10-22 07:57:46 +02:00
1 parent e284fae7b4
commit d0655f3638
32 files changed
+1520 -1058

No files matched your search

+142 -44
View File
@@ -8,6 +8,7 @@ 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,
@@ -107,7 +108,7 @@ export class DrawAnlageDurmin {
return [pSchine1, pSchine2];
}
createBand(data: { width: number, height: number, posX: number, posY: number, nordSued: boolean }) {
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) {
@@ -123,46 +124,102 @@ export class DrawAnlageDurmin {
{ type: "Z" }
];
let offsetX = nordSued ? 4 : 0;
let offsetX = nordSued ? 10 : 0;
let offsetY = nordSued ? 0 : 6;
let belt2Pos = {width:width-offsetX,height:height-offsetY}
let belt2Pos = { width: width - offsetX, height: height - offsetY }
const pBand2: PathCommand[] = [
{ type: "M", x: offsetX/2, y: offsetY/2 },
{ 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" }
];
let boxWidth = nordSued ? width : 10;
let boxHeight = nordSued ? 10: height;
let boxValues = {width:boxWidth,height:boxHeight}
//--- 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: 0, y: 0 },
{ relative: true, type: "V", y: boxValues.height }, // --
{ relative: true, type: "H", x: boxValues.width }, // --
{ relative: true, type: "V", y: -boxValues.height }, // T
{ 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"})
belt1.setAtrr({ fill: "#404040", stroke: "#404040" })
const belt2 = new DrawPath(pBand2);
belt2.setAtrr({fill:"#606060", stroke:"#606060"})
belt2.setAtrr({ fill: "#202020", stroke: "#606060" })
const beltBoxStart = new DrawPath(pBandBoxStart);
beltBoxStart.setAtrr({fill:"#101010", stroke:"#101010"})
beltBoxStart.setAtrr({ fill: "#e0e0e0", stroke: "#101010" })
group.add(beltBoxStart)
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;
}
@@ -179,8 +236,8 @@ export class DrawAnlageDurmin {
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 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) }
@@ -206,14 +263,14 @@ export class DrawAnlageDurmin {
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", storkWidth: 1, stroke: "#303030" })
zBa2S2.setAtrr({ fill: "#303030", storkWidth: 1, stroke: "#303030" })
zBa2S3.setAtrr({ fill: "#303030", storkWidth: 1, stroke: "#303030" })
zBa2S4.setAtrr({ fill: "#303030", storkWidth: 1, stroke: "#303030" })
zBa2S5.setAtrr({ fill: "#303030", storkWidth: 1, stroke: "#303030" })
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 });
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);
@@ -231,14 +288,14 @@ export class DrawAnlageDurmin {
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", storkWidth: 1, stroke: "#303030" })
zBa1S2.setAtrr({ fill: "#303030", storkWidth: 1, stroke: "#303030" })
zBa1S3.setAtrr({ fill: "#303030", storkWidth: 1, stroke: "#303030" })
zBa1S4.setAtrr({ fill: "#303030", storkWidth: 1, stroke: "#303030" })
zBa1S5.setAtrr({ fill: "#303030", storkWidth: 1, stroke: "#303030" })
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 });
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);
@@ -255,22 +312,51 @@ export class DrawAnlageDurmin {
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", storkWidth: 1, stroke: "#303030" })
zBa3S2.setAtrr({ fill: "#303030", storkWidth: 1, stroke: "#303030" })
zBa3S3.setAtrr({ fill: "#303030", storkWidth: 1, stroke: "#303030" })
zBa3S4.setAtrr({ fill: "#303030", storkWidth: 1, stroke: "#303030" })
zBa3S5.setAtrr({ fill: "#303030", storkWidth: 1, stroke: "#303030" })
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 });
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;
group1.add(this.createBand({posX:600,posY:200,width:200,height:40,nordSued:false}))
group1.add(this.createBand({posX:500,posY:100,width:100,height:40,nordSued:true}))
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(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);
@@ -278,7 +364,7 @@ export class DrawAnlageDurmin {
group1.add(zBa1S3);
group1.add(zBa1S4);
group1.add(zBa1S5);
group1.add(zBa2Schine1);
group1.add(zBa2Schine2);
group1.add(zBa2S1);
@@ -307,7 +393,11 @@ export class DrawAnlageDurmin {
const groupSvg = this.create(optionen)
const getXaml = true;
const svg = groupSvg.getChildString(!getXaml, 0)
const xaml = 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,
@@ -319,7 +409,15 @@ export class DrawAnlageDurmin {
offset_x: 0,
offset_y: 0,
svg,
xaml
xaml: xaml,
graphicsData: [
{
state: 'inactive',
svg: svg,
xaml: xaml,
xamlBase64: Buffer.from(xaml, "utf-8").toString("base64")
}
]
}
}
@@ -0,0 +1,43 @@
import { describe, expect, it } from '@jest/globals';
import { DrawBandOben } from './drawBandOben';
import { parseBandObenRequest } from '../../_dto/band-oben.dto';
describe('BandOben render', () => {
it.each([
[false, false, 202, 42],
[true, false, 42, 202],
[false, true, 202, 52],
[true, true, 52, 202],
])('berechnet die Gesamtmaße (Nord-Süd %s, Trichter %s)', (fromNorthToSouth, trichterStart, width, height) => {
const result = new DrawBandOben().getObject({ width: 40, length: 200 }, { fromNorthToSouth, trichterStart });
expect(result.width).toBe(width);
expect(result.height).toBe(height);
expect(result.svg[0].data).toContain('<svg xmlns=');
expect(result.svg[0].data).toContain('viewBox="0 0 ' + width + ' ' + height + '"');
expect(result.xaml[0].data).toContain('<Viewbox xmlns=');
expect(result.xaml[0].data).toContain('Width="' + width + '" Height="' + height + '"');
});
it('setzt fehlende Optionen auf false und erhält explizites false', () => {
const input = parseBandObenRequest({ config: { width: 40, length: 200 }, options: { trichterStart: false } });
expect(input.options).toEqual({ fromNorthToSouth: false, trichterStart: false, trichterEnd: false });
});
it.each([
null, {}, { config: { width: '40', length: 200 } },
{ config: { width: 10, length: 200 } },
{ config: { width: 40, length: Infinity } },
{ config: { width: 40, length: 200 }, options: { fromNorthToSouth: 'false' } },
{ config: { width: 40, length: 200 }, options: { unbekannt: true } },
{ config: { width: 40, length: 10 }, options: { trichterStart: true } },
])('weist ungültige Anfragen zurück: %j', input => {
expect(() => parseBandObenRequest(input)).toThrow();
});
it('verwendet keine Maße des vorherigen Aufrufs', () => {
const generator = new DrawBandOben();
const expected = generator.getObject({ width: 40, length: 200 });
generator.getObject({ width: 60, length: 300 }, { fromNorthToSouth: true, trichterEnd: true });
expect(generator.getObject({ width: 40, length: 200 })).toEqual(expected);
});
});
+197
View File
@@ -0,0 +1,197 @@
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 { DrawDataDto, DrawDto, DrawShapeOptionenDto } from "src/_dto/draw.dto";
import { DrawHeader } from "../lib/drawHeader";
import { BandObenConfig, BandObenOptions } from "./types";
import type { GraphicGenerator } from './graphic-generator';
interface Para {
scale?: number,
}
@Injectable()
export class DrawBandOben implements GraphicGenerator<BandObenConfig, BandObenOptions> {
red = "#f00000";
normal = "#808080";
green = "#00f000";
constructor() {
}
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({});
const ueberstand = data.boxStart || data.boxEnde ? boxUeberstand : 0;
group.setAtrr({ translate_y: posY + (nordSued ? 0 : ueberstand) + 1, translate_x: posX + (nordSued ? ueberstand : 0) + 1 })
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(belt2)
group.add(belt1)
return {
band: group,
width: width + (nordSued ? 2 * ueberstand : 0) + 2,
height: height + (nordSued ? 0 : 2 * ueberstand) + 2
};
}
calcData() {
}
create(config: BandObenConfig, options?: Partial<BandObenOptions>): { group: DrawGroup, width: number, height: number } {
const nordSued = options && options?.fromNorthToSouth ? true : false;
const boxStart = options && options?.trichterStart ? true : false;
const boxEnde = options && options?.trichterEnd ? true : false;
const band = this.createBand({ posX: 0, posY: 0, width: config.width, height: config.length, nordSued: nordSued, boxStart: boxStart, boxEnde: boxEnde });
return {
group: band.band,
width: band.width,
height: band.height
};
}
getObject(config: BandObenConfig, options?: Partial<BandObenOptions>): DrawDataDto {
const beldData = this.create(config,options)
const bedlWithHeader = this.createObjectWithHeader(beldData.group,beldData.width,beldData.height);
const xaml = bedlWithHeader.getChildString(true,0);
const svg = bedlWithHeader.getChildString(false, 0)
return {
name: "bandOben",
height: beldData.height,
width: beldData.width,
svg:[{state:'inactive',data:svg}],
xaml:[{state:'inactive',data:xaml}]
}
}
createObjectWithHeader(group:DrawGroup,width:number,height:number):DrawHeader{
const header = new DrawHeader({ lenght: width, height: height });
header.add(group);
return header;
}
}
@@ -0,0 +1,5 @@
import type { DrawDataDto } from '../../_dto/draw.dto';
export interface GraphicGenerator<TConfig, TOptions> {
getObject(config: TConfig, options?: Partial<TOptions>): DrawDataDto;
}
+13
View File
@@ -0,0 +1,13 @@
export interface BandObenOptions{
fromNorthToSouth:boolean,
trichterEnd:boolean,
trichterStart:boolean,
}
export interface BandObenConfig{
length:number,
width:number,
}
+1 -1
View File
@@ -72,7 +72,7 @@ export class DrawPath extends DrawElement {
}
commandToString(cmd: PathCommand, xaml?: boolean): string {
const prefix = cmd.relative && !xaml ? cmd.type.toLowerCase() : cmd.type;
const prefix = cmd.relative ? cmd.type.toLowerCase() : cmd.type;
const separator = xaml ? "," : " ";
switch (cmd.type) {
case "M":