2026_08_31
This commit is contained in:
commit
73015386e9
2320 files changed
+80291
No files matched your search
@@ -0,0 +1,173 @@
|
||||
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";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class DrawBand {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
|
||||
|
||||
constructor() {
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
|
||||
let color = this.normal;
|
||||
if (optionen && optionen.state == 'active') color = this.green;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 2.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
let winkel = 0.0;
|
||||
if (optionen && optionen.angle) winkel = optionen.angle;
|
||||
|
||||
|
||||
|
||||
let laenge = 40.0;
|
||||
if (optionen && optionen.width) laenge = optionen.width;
|
||||
|
||||
let hoehe = 2.0;
|
||||
if (optionen && optionen.height) hoehe = optionen.height;
|
||||
|
||||
const x0 = 0;
|
||||
const y0 = 0;
|
||||
|
||||
const l1 = laenge * raster * scale
|
||||
const h1 = hoehe * raster * scale
|
||||
|
||||
const r = h1 / 2;
|
||||
|
||||
const path_rumpf: PathCommand[] = [
|
||||
{ type: "M", x: r, y: y0 },
|
||||
{ type: "H", x: l1 - r }, // --
|
||||
{
|
||||
type: "A", rx: r, ry: r,
|
||||
xAxisRotation: 0,
|
||||
largeArcFlag: 0,
|
||||
sweepFlag: 1, x: l1 - r, y: h1
|
||||
}, // )
|
||||
|
||||
{ type: "H", x: x0 + r }, // --
|
||||
{
|
||||
type: "A", rx: r, ry: r,
|
||||
xAxisRotation: 0,
|
||||
largeArcFlag: 0,
|
||||
sweepFlag: 1, x: r, y: y0
|
||||
}, // (
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
const path_rect: PathCommand[] = [
|
||||
{ type: "M", x: 0, y: 0 },
|
||||
{ type: "H", x: 160 }, // --
|
||||
{ type: "V", y: 40 }, // --
|
||||
{ type: "H", x: 0 }, // --
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
const { height, width, offsetX, offsetY } = cal_rotation_dim(winkel, l1, h1);
|
||||
|
||||
const obj_h = height;
|
||||
const obj_w = width;
|
||||
|
||||
let cr = h1 / 2 - 0.8 * raster;
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
const group1 = new DrawGroup({});
|
||||
|
||||
if (winkel !== 0) {
|
||||
group1.setAtrr({ 'rotate_winkel': winkel })
|
||||
group1.setAtrr({ 'translate_x': offsetX })
|
||||
group1.setAtrr({ 'translate_y': offsetY })
|
||||
}
|
||||
const z_rumpf = new DrawPath(path_rumpf);
|
||||
z_rumpf.setAtrr({ fill: color })
|
||||
|
||||
const z_rect = new DrawPath(path_rect);
|
||||
z_rumpf.setAtrr({ fill: color })
|
||||
|
||||
const s1_rolle_vorne = new DrawEllipse({ cx: r, cy: r, rx: cr, ry: cr });
|
||||
const s1_rolle_hinten = new DrawEllipse({ cx: l1 - r, cy: r, rx: cr, ry: cr });
|
||||
const line = new DrawLine({ x1: 10, y1: 0, x2: 10, y2: 40 });
|
||||
|
||||
|
||||
this.scale = scale;
|
||||
this.height = hoehe;
|
||||
this.width = laenge;
|
||||
this.obj_height = obj_h //+ 30;
|
||||
this.obj_width = obj_w;
|
||||
this.offset_x = offsetX;
|
||||
this.offset_y = offsetY;
|
||||
|
||||
group1.add(s1_rolle_vorne);
|
||||
group1.add(s1_rolle_hinten);
|
||||
group1.add(z_rumpf);
|
||||
//group1.add(z_rect);
|
||||
groupInhalt.add(group1)
|
||||
|
||||
//groupInhalt.setAtrr({ translate_x: 10 })
|
||||
groupInhalt.setAtrr({ translate_y: 0 })
|
||||
return groupInhalt;
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const xaml = optionen && optionen.xaml ? true : false;
|
||||
const svg = groupSvg.getChildString(xaml, 0)
|
||||
return {
|
||||
name: "band",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: this.offset_x,
|
||||
offset_y: this.offset_y,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
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";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class DrawBehaelter {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
constructor() {
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
let color = this.normal;
|
||||
if (optionen && optionen.state == 'active') color = this.green;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 1.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
let laenge = 10.0;
|
||||
if (optionen && optionen.width) laenge = optionen.width;
|
||||
|
||||
let hoehe = 6.0;
|
||||
if (optionen && optionen.height) hoehe = optionen.height;
|
||||
|
||||
let pumpensumpf = optionen?.variant === 'pumpensumpf'
|
||||
let multi = optionen?.variant === 'multi'
|
||||
|
||||
const l = laenge;
|
||||
const h = hoehe;
|
||||
const diffUnten = 2;
|
||||
|
||||
let l1 = l * raster * scale;
|
||||
let x2e = (diffUnten) * raster * scale;
|
||||
let h1 = (h * raster * scale);
|
||||
let h2 = (h1 / 2);
|
||||
|
||||
|
||||
const obj_h = h1;
|
||||
const obj_w = l1;
|
||||
|
||||
|
||||
const b1_y = l1 / 10 * 3;
|
||||
const b2_y = l1 / 10 * 7;
|
||||
|
||||
|
||||
|
||||
const g1_path: PathCommand[] = [
|
||||
{ type: "M", x: 0, y: 0 },
|
||||
{ type: "H", x: l1 },
|
||||
{ type: "L", x: l1 - x2e, y: h1 },
|
||||
{ type: "H", x: x2e },
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
// Pumpensumpf oder B1
|
||||
const g2_path: PathCommand[] = [
|
||||
{ type: "M", x: 0, y: 0 },
|
||||
{ type: "H", x: l1 },
|
||||
{ type: "V", y: h2 },
|
||||
{ type: "L", x: l1 - x2e, y: h1 },
|
||||
{ type: "H", x: x2e },
|
||||
{ type: "L", x: 0, y: h2 },
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
|
||||
const z_g1 = new DrawPath(g1_path);
|
||||
z_g1.setAtrr({ fill: '#808080' })
|
||||
const z_g2 = new DrawPath(g2_path);
|
||||
z_g2.setAtrr({ fill: '#808080' })
|
||||
|
||||
|
||||
optionen?.variant === 'pumpensumpf' ? groupInhalt.add(z_g2) : groupInhalt.add(z_g1);
|
||||
|
||||
this.scale = scale;
|
||||
this.height = hoehe;
|
||||
this.width = laenge;
|
||||
this.obj_height = obj_h;
|
||||
this.obj_width = obj_w;
|
||||
|
||||
return groupInhalt;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
return {
|
||||
name: "behaelter",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: 0,
|
||||
offset_y: 0,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
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";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class DrawBehaelterMulti {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
constructor() {
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
let color = this.normal;
|
||||
if (optionen && optionen.state == 'active') color = this.green;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 1.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
let laenge = 30.0;
|
||||
if (optionen && optionen.width) laenge = optionen.width;
|
||||
|
||||
let hoehe = 6.0;
|
||||
if (optionen && optionen.height) hoehe = optionen.height;
|
||||
|
||||
let pumpensumpf = optionen?.variant === 'pumpensumpf'
|
||||
let multi = optionen?.variant === 'multi'
|
||||
|
||||
const l = laenge;
|
||||
const h = hoehe;
|
||||
const diffUnten = 1;
|
||||
|
||||
let l1 = l * raster * scale;
|
||||
let x2e = (diffUnten) * raster * scale;
|
||||
let h1 = (h * raster * scale);
|
||||
let h_m = (h1 / 2);
|
||||
|
||||
|
||||
|
||||
const b1_x = l1 / 10 * 4;
|
||||
const b2_x = l1 / 10 * 6;
|
||||
const b2_viertel = b2_x / 4;
|
||||
|
||||
let offset_b2_x = b1_x - x2e;
|
||||
|
||||
const obj_h = h1;
|
||||
const obj_w = offset_b2_x + b2_x;
|
||||
|
||||
|
||||
// B1
|
||||
const b1_path: PathCommand[] = [
|
||||
{ type: "M", x: 0, y: 0 },
|
||||
{ type: "H", x: b1_x },
|
||||
{ type: "V", y: h_m },
|
||||
{ type: "L", x: b1_x - x2e, y: h1 },
|
||||
{ type: "H", x: x2e },
|
||||
{ type: "L", x: 0, y: h_m },
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
// B2
|
||||
const b2_path: PathCommand[] = [
|
||||
{ type: "M", x: offset_b2_x, y: 0 },
|
||||
{ type: "H", x: offset_b2_x+b2_x },
|
||||
{ type: "V", y: h1 }, // v |
|
||||
{ type: "H", x: offset_b2_x + b2_x - 1 * b2_viertel + x2e }, // < -
|
||||
{ type: "L", x: offset_b2_x + b2_x - 1 * b2_viertel, y: h_m }, // ^ \
|
||||
{ type: "L", x: offset_b2_x + b2_x - 1 * b2_viertel - x2e, y: h1 }, // v /
|
||||
{ type: "H", x: offset_b2_x + b2_x - 3 * b2_viertel + x2e }, // < -
|
||||
{ type: "L", x: offset_b2_x + b2_x - 3 * b2_viertel, y: h_m }, // ^ \
|
||||
{ type: "L", x: offset_b2_x + b2_x - 3 * b2_viertel - x2e, y: h1 }, // v /
|
||||
{ type: "H", x: offset_b2_x + b2_x - 4 * b2_viertel }, // < -
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
// Linie Vertical bei b1
|
||||
const z_lineV = new DrawLine({ x1: b1_x/10*6, y1: 1, x2: b1_x/10*6, y2: h1/10*7 });
|
||||
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
|
||||
const z_b1 = new DrawPath(b1_path);
|
||||
z_b1.setAtrr({ fill: '#808080' })
|
||||
|
||||
const z_b2 = new DrawPath(b2_path);
|
||||
z_b2.setAtrr({ fill: '#808080' })
|
||||
|
||||
groupInhalt.add(z_lineV)
|
||||
groupInhalt.add(z_b1)
|
||||
groupInhalt.add(z_b2)
|
||||
|
||||
this.scale = scale;
|
||||
this.height = hoehe;
|
||||
this.width = laenge;
|
||||
this.obj_height = obj_h;
|
||||
this.obj_width = obj_w;
|
||||
|
||||
return groupInhalt;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
return {
|
||||
name: "behaelter",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: 0,
|
||||
offset_y: 0,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
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";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
p2
|
||||
| \
|
||||
/
|
||||
p1 p3
|
||||
|
||||
l1 l2
|
||||
|
||||
p5- p4
|
||||
|
||||
p2.1 p2.3
|
||||
|
||||
p2.2
|
||||
|
||||
|
||||
*/
|
||||
@Injectable()
|
||||
export class DrawBrecher {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
|
||||
constructor() {
|
||||
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
let color = this.normal;
|
||||
if (optionen && optionen.state == 'active') color = this.green;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 1.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
let laenge = 9.0;
|
||||
if (optionen && optionen.width) laenge = optionen.width;
|
||||
|
||||
let hoehe = 7.0;
|
||||
if (optionen && optionen.height) hoehe = optionen.height;
|
||||
|
||||
let faktor = scale * raster
|
||||
const l = laenge;
|
||||
const h = hoehe;
|
||||
|
||||
const y1 = 2 * faktor;
|
||||
const x1 = 5 * faktor;
|
||||
const x2 = l * faktor;
|
||||
const y2 = 4 * faktor;
|
||||
|
||||
let l1 = l * faktor;
|
||||
let h1 = (h * faktor);
|
||||
|
||||
let k1_radius = 3 * faktor
|
||||
const obj_h = h1 + faktor;
|
||||
const obj_w = l1;
|
||||
let offset_g1 = faktor;
|
||||
|
||||
|
||||
|
||||
|
||||
const g1: PathCommand[] = [
|
||||
{ type: "M", x: 0, y: offset_g1 + y1 },
|
||||
{ type: "L", x: x1, y: offset_g1 },
|
||||
{ type: "L", x: x2, y: offset_g1 + y2 },
|
||||
{ type: "V", y: offset_g1 + h1 },
|
||||
{ type: "H", x: 0 },
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
|
||||
// Gruppe
|
||||
const groupInhalt = new DrawGroup({});
|
||||
|
||||
// Main Hintergrund
|
||||
const z_g1 = new DrawPath(g1);
|
||||
z_g1.setAtrr({ fill: '#808080' })
|
||||
|
||||
// Schwungrad
|
||||
const z_kreis1 = new DrawEllipse({ cx: 5 * faktor, cy: offset_g1 + 2 * faktor, rx: k1_radius, ry: k1_radius });
|
||||
z_kreis1.setAtrr({ fill: color })
|
||||
|
||||
// Schwungrad innen
|
||||
const z_kreis2 = new DrawEllipse({ cx: 5 * faktor, cy: offset_g1 + 2 * faktor, rx: 2, ry: 2 });
|
||||
//z_kreis1.setAtrr({ fill: color })
|
||||
|
||||
// Brecher Linie fest
|
||||
const z_line1 = new DrawLine({ x1: raster, y1: offset_g1 + h1 - raster, x2: 1 * raster, y2: offset_g1 + y1 + raster });
|
||||
z_line1.setAtrr({ "dasharray": "5,5" });
|
||||
|
||||
// Brecher Linie beweglich
|
||||
const z_line2 = new DrawLine({ x1: 1 * faktor, y1: offset_g1 + h1 - faktor / 2, x2: 3 * faktor, y2: offset_g1 + y1 + raster });
|
||||
z_line1.setAtrr({ "dasharray": "5,5" });
|
||||
|
||||
|
||||
|
||||
groupInhalt.add(z_line1);
|
||||
groupInhalt.add(z_line2);
|
||||
groupInhalt.add(z_kreis2);
|
||||
groupInhalt.add(z_kreis1);
|
||||
groupInhalt.add(z_g1);
|
||||
|
||||
this.scale = scale;
|
||||
this.height = hoehe;
|
||||
this.width = laenge;
|
||||
this.obj_height = obj_h;
|
||||
this.obj_width = obj_w;
|
||||
|
||||
return groupInhalt;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
return {
|
||||
name: "brecher",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: 0,
|
||||
offset_y: 0,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
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";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class DrawFlex {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
|
||||
constructor() {
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
|
||||
//let raster = 4.0;
|
||||
//let scale = 2.0;
|
||||
//let winkel = 0.0;
|
||||
let laenge = 40.0;
|
||||
let hoehe = 2.0;
|
||||
|
||||
|
||||
const l1 = laenge
|
||||
const h1 = hoehe
|
||||
|
||||
const r = h1 / 2;
|
||||
|
||||
|
||||
const obj_h = h1;
|
||||
const obj_w = l1;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
|
||||
const z1 = new DrawLine({x1:0,y1:0,x2:l1,y2:0});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
this.height = hoehe;
|
||||
this.width = laenge;
|
||||
this.obj_height = obj_h;
|
||||
this.obj_width = obj_w;
|
||||
|
||||
|
||||
groupInhalt.add(z1);
|
||||
|
||||
return groupInhalt;
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const xaml = optionen && optionen.xaml ? true :false;
|
||||
const svg = groupSvg.getChildString(xaml, 0)
|
||||
return {
|
||||
name: "flex",
|
||||
height: this.obj_height,
|
||||
length: this.obj_width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: 0,
|
||||
offset_y: 0,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
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 { DrawHeader } from "../lib/drawHeader";
|
||||
|
||||
import { cal_rotation_dim } from '../lib/drawFunktions'
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { DrawDto, DrawShapeOptionenDto } from "src/_dto/draw.dto";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class DrawGurtfoerderer {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
|
||||
constructor() {
|
||||
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
let color = this.normal;
|
||||
if (optionen && optionen.state == 'active') color = this.green;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 1.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
|
||||
|
||||
const offset_g1_g2 = 2.0;
|
||||
const x0 = 0;
|
||||
const y0 = 0;
|
||||
const l1 = 8;
|
||||
const l2 = 8;
|
||||
const h = 45
|
||||
;
|
||||
const d = 1.5;
|
||||
const radius = 2
|
||||
const d_between = 2.0;
|
||||
const c_r = (d * 0.5 * raster * scale) / 2;
|
||||
const c1_y = (h - d / 2) * scale * raster;
|
||||
const c1_x = (x0 + d / 2 + offset_g1_g2) * scale * raster;
|
||||
|
||||
const c2_y = (y0 + d / 2) * scale * raster;
|
||||
const c2_x = (l1 + d + l2 + d_between - d / 2) * scale * raster;
|
||||
|
||||
const c3_y = (h + d_between - d / 2) * scale * raster;
|
||||
const c3_x = (x0 + d / 2) * scale * raster;
|
||||
|
||||
const c4_y = (y0 + d_between + d / 2) * scale * raster;
|
||||
const c4_x = (l1 + d + l2 + d_between - offset_g1_g2 - d / 2) * scale * raster;
|
||||
|
||||
let obj_h = (x0 + h + d_between + offset_g1_g2) * scale * raster + 1;
|
||||
let obj_w = (y0 + l1 + l2 + d + d_between) * scale * raster;
|
||||
|
||||
|
||||
|
||||
|
||||
const s_path1_config = {
|
||||
x: x0 + offset_g1_g2,
|
||||
y: y0, laenge1: l1 - offset_g1_g2,
|
||||
hoehe: h,
|
||||
laenge2: l2 + d_between,
|
||||
radiusUnten: radius,
|
||||
radiusOben: radius + d_between,
|
||||
distanz: d,
|
||||
raster: raster,
|
||||
scale: scale
|
||||
}
|
||||
|
||||
|
||||
|
||||
const s_path2_config = {
|
||||
x: x0,
|
||||
y: y0 + d_between,
|
||||
laenge1: l1 + d_between,
|
||||
hoehe: h,
|
||||
laenge2: l2 - offset_g1_g2,
|
||||
radiusUnten: radius + d_between,
|
||||
radiusOben: radius,
|
||||
distanz: d,
|
||||
raster: raster,
|
||||
scale: scale
|
||||
}
|
||||
|
||||
const s_path1 = this.getShape(s_path1_config);
|
||||
const s_path2 = this.getShape(s_path2_config);
|
||||
|
||||
|
||||
|
||||
|
||||
const shape_s1 = new DrawPath(s_path1);
|
||||
shape_s1.setAtrr({ fill: color })
|
||||
|
||||
const shape_s2 = new DrawPath(s_path2);
|
||||
shape_s2.setAtrr({ fill: color })
|
||||
|
||||
//Umlenkrolle Band 1 unten
|
||||
const s1_rolle_unten = new DrawEllipse({ cx: c1_x, cy: c1_y, rx: c_r, ry: c_r });
|
||||
const s1_rolle_oben = new DrawEllipse({ cx: c2_x, cy: c2_y, rx: c_r, ry: c_r });
|
||||
const s2_rolle_unten = new DrawEllipse({ cx: c3_x, cy: c3_y, rx: c_r, ry: c_r });
|
||||
const s2_rolle_oben = new DrawEllipse({ cx: c4_x, cy: c4_y, rx: c_r, ry: c_r });
|
||||
|
||||
const header = new DrawHeader({ lenght: obj_w, height: obj_h });
|
||||
const groupInhalt = new DrawGroup({});
|
||||
groupInhalt.add(s1_rolle_unten);
|
||||
groupInhalt.add(s1_rolle_oben);
|
||||
groupInhalt.add(s2_rolle_unten);
|
||||
groupInhalt.add(s2_rolle_oben);
|
||||
groupInhalt.add(shape_s1);
|
||||
groupInhalt.add(shape_s2);
|
||||
|
||||
this.scale = scale;
|
||||
this.height = 0;
|
||||
this.width = 0;
|
||||
this.obj_height = obj_h;
|
||||
this.obj_width = obj_w;
|
||||
|
||||
|
||||
|
||||
return groupInhalt;
|
||||
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
return {
|
||||
name: "brecher",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: 0,
|
||||
offset_y: 0,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
getShape(config:
|
||||
{
|
||||
x: number,
|
||||
y: number,
|
||||
laenge1: number,
|
||||
hoehe: number,
|
||||
laenge2: number,
|
||||
radiusOben: number,
|
||||
radiusUnten: number,
|
||||
distanz: number,
|
||||
raster: number,
|
||||
scale: number
|
||||
}) {
|
||||
|
||||
const { x, y, laenge1, hoehe, laenge2, radiusOben, radiusUnten, distanz, raster, scale } = config;
|
||||
|
||||
|
||||
const y0 = y * raster * scale;
|
||||
const x0 = x * raster * scale;
|
||||
const l1 = x0 + laenge1 * raster * scale
|
||||
const l2 = x0 + laenge2 * raster * scale
|
||||
const h1 = y0 + hoehe * raster * scale
|
||||
const d = distanz * raster * scale;
|
||||
const ru = radiusUnten * raster * scale;
|
||||
const ro = radiusOben * raster * scale;
|
||||
|
||||
const xe = l1 + l2 + d - x0; // x Ende
|
||||
|
||||
|
||||
const deck: PathCommand[] = [
|
||||
{ type: "M", x: xe - (d / 2), y: y0 },
|
||||
{ type: "H", x: l1 + ro + d },
|
||||
// Bogen oben oben
|
||||
{ type: "A", rx: ro + d, ry: ro + d, xAxisRotation: 0, largeArcFlag: 0, sweepFlag: 0, x: l1, y: y0 + ro + d },
|
||||
// Bogen unten oben
|
||||
{ type: "V", y: h1 - ru - d },
|
||||
{ type: "A", rx: ru, ry: ru, xAxisRotation: 0, largeArcFlag: 0, sweepFlag: 1, x: l1 - ru, y: h1 - d },
|
||||
{ type: "H", x: x0 + d / 2 },
|
||||
// Bogen Umkehr
|
||||
{ type: "A", rx: d / 2, ry: d / 2, x: x0 + d / 2, y: h1, xAxisRotation: 0, largeArcFlag: 0, sweepFlag: 0 },
|
||||
{ type: "H", x: l1 - ru },
|
||||
// Bogen unten unten
|
||||
{ type: "A", rx: ru + d, ry: ru + d, xAxisRotation: 0, largeArcFlag: 0, sweepFlag: 0, x: l1 + d, y: h1 - ru - d },
|
||||
//{ type: "L", x: d + l1, y: h1 - r - d },
|
||||
|
||||
{ type: "V", y: ro + d + y0 },
|
||||
// Bogen unten unten
|
||||
{ type: "A", rx: ro, ry: ro, xAxisRotation: 0, largeArcFlag: 0, sweepFlag: 1, x: l1 + ro + d, y: y0 + d },
|
||||
{ type: "H", x: xe - d / 2 },
|
||||
{ type: "A", rx: d / 2, ry: d / 2, x: xe - (d / 2), y: y0, xAxisRotation: 0, largeArcFlag: 0, sweepFlag: 0 },
|
||||
];
|
||||
|
||||
return deck;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
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";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class DrawHaspel {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
|
||||
constructor() {
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
let color = this.normal;
|
||||
if (optionen && optionen.state == 'active') color = this.green;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 2.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
|
||||
|
||||
const x0 = raster;
|
||||
const x1 = 4 * raster * scale; // länge Kasten
|
||||
const x_m = (x0 + x1) / 2; // mitte kasten
|
||||
const y0 = raster;
|
||||
const y1 = 4 * raster * scale; // höhe Kasten
|
||||
const y_m = (y0 + y1) / 2; //mitte kasten
|
||||
const radius = 1.0 * raster * scale;
|
||||
const radius2 = 0.5 * raster * scale;
|
||||
|
||||
const obj_h = y0 + y1 + 0 * raster;
|
||||
const obj_w = x0 + x1 + 0 * raster;
|
||||
const height = obj_h / scale / raster;
|
||||
const width = obj_w / scale / raster;
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
|
||||
const z_line_1 = new DrawLine({ x1: x0 + raster, y1: y0 + raster, x2: x1 - raster, y2: y1 - raster }); // \
|
||||
const z_line_2 = new DrawLine({ x1: x1 - raster, y1: y0 + raster, x2: x0 + raster, y2: y1 - raster }); // /
|
||||
const z_line_3 = new DrawLine({ x1: x_m, y1: y0, x2: x_m, y2: y1 }); // |
|
||||
const z_line_4 = new DrawLine({ x1: x0, y1: y_m, x2: x1, y2: y_m }); // -
|
||||
|
||||
const z_kreis = new DrawEllipse({ cx: x_m, cy: y_m, rx: radius, ry: radius });
|
||||
z_kreis.setAtrr({ fill: color })
|
||||
|
||||
const z_kreis2 = new DrawEllipse({ cx: x_m, cy: y_m, rx: radius2, ry: radius2 });
|
||||
|
||||
groupInhalt.add(z_kreis2);
|
||||
groupInhalt.add(z_kreis);
|
||||
groupInhalt.add(z_line_1);
|
||||
groupInhalt.add(z_line_2);
|
||||
groupInhalt.add(z_line_3);
|
||||
groupInhalt.add(z_line_4);
|
||||
|
||||
|
||||
|
||||
this.scale = scale;
|
||||
this.raster = raster;
|
||||
this.height = height;
|
||||
this.width = width;
|
||||
this.obj_height = obj_h;
|
||||
this.obj_width = obj_w;
|
||||
|
||||
return groupInhalt;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
return {
|
||||
name: "weiche",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: 0,
|
||||
offset_y: 0,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
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";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
<Grid>
|
||||
<Canvas>
|
||||
<Canvas.RenderTransform>
|
||||
<TransformGroup>
|
||||
<TranslateTransform X="200" Y="200" />
|
||||
</TransformGroup>
|
||||
</Canvas.RenderTransform>
|
||||
|
||||
<Path Data="M 200,0 v 195 h 10 v -195 z" Stroke="#000000" Fill="#50505f" />
|
||||
<Path Data="M 400,0 v 200 h 10 v -200 z" Stroke="#000000" Fill="#50505f" />
|
||||
<Path Data="M 600,0 v 200 h 10 v -200 z" Stroke="#000000" Fill="#50505f" />
|
||||
<Path Data="M 800,0 v 200 h 10 v -200 z" Stroke="#000000" Fill="#50505f" />
|
||||
<Path Data="M 0,0 v 200 h 1000 v -200 h -10 v 190 h -980 v -190 z" Stroke="#000000" Fill="#50505f" />
|
||||
<Line X1="0" X2="1000" Y1="70" Y2="70" Stroke="#000000" />
|
||||
<Line X1="0" X2="1000" Y1="130" Y2="130" Stroke="#000000" />
|
||||
</Canvas>
|
||||
|
||||
<Canvas>
|
||||
<Canvas.RenderTransform>
|
||||
<TransformGroup>
|
||||
<TranslateTransform X="280" Y="240" />
|
||||
</TransformGroup>
|
||||
</Canvas.RenderTransform>
|
||||
|
||||
|
||||
<Path Data="M 0,0 v 120 h 40 v -120 z" Stroke="#000000" Fill="#50505f" />
|
||||
|
||||
|
||||
</Canvas>
|
||||
|
||||
<Canvas>
|
||||
<Canvas.RenderTransform>
|
||||
<TransformGroup>
|
||||
<TranslateTransform X="300" Y="280" />
|
||||
</TransformGroup>
|
||||
</Canvas.RenderTransform>
|
||||
|
||||
<Path Data="M 0,0 v 40 h 400 v -40 z" Stroke="#000000" Fill="#50505f" />
|
||||
|
||||
|
||||
|
||||
</Canvas>
|
||||
|
||||
<Canvas>
|
||||
<Canvas.RenderTransform>
|
||||
<TransformGroup>
|
||||
<TranslateTransform X="300" Y="280" />
|
||||
</TransformGroup>
|
||||
</Canvas.RenderTransform>
|
||||
|
||||
<Path Data="M 0,0 v 40 h 400 v -40 z" Stroke="#000000" Fill="#50505f" />
|
||||
<Path Data="M 0,0 v 40 h 4 v -40 z" Stroke="#000000" Fill="#202020" />
|
||||
<Path Data="M 400,0 v 40 h -4 v -40 z" Stroke="#000000" Fill="#202020" />
|
||||
|
||||
|
||||
</Canvas>
|
||||
|
||||
</Grid>
|
||||
*/
|
||||
@Injectable()
|
||||
export class DrawHintergrund {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
|
||||
|
||||
constructor() {
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
|
||||
let color = this.normal;
|
||||
if (optionen && optionen.state == 'active') color = this.green;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 2.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
let winkel = 0.0;
|
||||
if (optionen && optionen.angle) winkel = optionen.angle;
|
||||
|
||||
|
||||
|
||||
let laenge = 40.0;
|
||||
if (optionen && optionen.width) laenge = optionen.width;
|
||||
|
||||
let hoehe = 2.0;
|
||||
if (optionen && optionen.height) hoehe = optionen.height;
|
||||
|
||||
const x0 = 0;
|
||||
const y0 = 0;
|
||||
|
||||
const l1 = laenge * raster * scale
|
||||
const h1 = hoehe * raster * scale
|
||||
|
||||
const r = h1 / 2;
|
||||
|
||||
const path_rumpf: PathCommand[] = [
|
||||
{ type: "M", x: r, y: y0 },
|
||||
{ type: "H", x: l1 - r }, // --
|
||||
{
|
||||
type: "A", rx: r, ry: r,
|
||||
xAxisRotation: 0,
|
||||
largeArcFlag: 0,
|
||||
sweepFlag: 1, x: l1 - r, y: h1
|
||||
}, // )
|
||||
|
||||
{ type: "H", x: x0 + r }, // --
|
||||
{
|
||||
type: "A", rx: r, ry: r,
|
||||
xAxisRotation: 0,
|
||||
largeArcFlag: 0,
|
||||
sweepFlag: 1, x: r, y: y0
|
||||
}, // (
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
const path_rect: PathCommand[] = [
|
||||
{ type: "M", x: 0, y: 0 },
|
||||
{ type: "H", x: 160 }, // --
|
||||
{ type: "V", y: 40 }, // --
|
||||
{ type: "H", x: 0 }, // --
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
const { height, width, offsetX, offsetY } = cal_rotation_dim(winkel, l1, h1);
|
||||
|
||||
const obj_h = height;
|
||||
const obj_w = width;
|
||||
|
||||
let cr = h1 / 2 - 0.8 * raster;
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
const group1 = new DrawGroup({});
|
||||
|
||||
if (winkel !== 0) {
|
||||
group1.setAtrr({ 'rotate_winkel': winkel })
|
||||
group1.setAtrr({ 'translate_x': offsetX })
|
||||
group1.setAtrr({ 'translate_y': offsetY })
|
||||
}
|
||||
const z_rumpf = new DrawPath(path_rumpf);
|
||||
z_rumpf.setAtrr({ fill: color })
|
||||
|
||||
const z_rect = new DrawPath(path_rect);
|
||||
z_rumpf.setAtrr({ fill: color })
|
||||
|
||||
const s1_rolle_vorne = new DrawEllipse({ cx: r, cy: r, rx: cr, ry: cr });
|
||||
const s1_rolle_hinten = new DrawEllipse({ cx: l1 - r, cy: r, rx: cr, ry: cr });
|
||||
const line = new DrawLine({ x1: 10, y1: 0, x2: 10, y2: 40 });
|
||||
|
||||
|
||||
this.scale = scale;
|
||||
this.height = hoehe;
|
||||
this.width = laenge;
|
||||
this.obj_height = obj_h //+ 30;
|
||||
this.obj_width = obj_w;
|
||||
this.offset_x = offsetX;
|
||||
this.offset_y = offsetY;
|
||||
|
||||
group1.add(s1_rolle_vorne);
|
||||
group1.add(s1_rolle_hinten);
|
||||
group1.add(z_rumpf);
|
||||
//group1.add(z_rect);
|
||||
groupInhalt.add(group1)
|
||||
|
||||
//groupInhalt.setAtrr({ translate_x: 10 })
|
||||
groupInhalt.setAtrr({ translate_y: 0 })
|
||||
return groupInhalt;
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const xaml = optionen && optionen.xaml ? true : false;
|
||||
const svg = groupSvg.getChildString(xaml, 0)
|
||||
return {
|
||||
name: "band",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: this.offset_x,
|
||||
offset_y: this.offset_y,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
import { PathCommand } from "../lib/types/path.types";
|
||||
import { DrawText } from '../lib/drawText'
|
||||
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";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class DrawMotor {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
|
||||
constructor() {
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
let color = this.normal;
|
||||
if (optionen && optionen.state == 'active') color = this.green;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
|
||||
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 2.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
|
||||
|
||||
const x0 = 0;
|
||||
const x1 = 3 * raster * scale; // länge
|
||||
const x_m = (x0 + x1) / 2; // mitte kasten
|
||||
const y0 = 0;
|
||||
const y1 = 3 * raster * scale; // höhe Kasten
|
||||
const y_m = (y0 + y1) / 2; //mitte kasten
|
||||
const radius = x1 / 2;
|
||||
|
||||
const obj_h = y0 + y1 + 0 * raster;
|
||||
const obj_w = x0 + x1 + 0 * raster;
|
||||
const height = obj_h / scale / raster;
|
||||
const width = obj_w / scale / raster;
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
|
||||
|
||||
const z_kreis = new DrawEllipse({ cx: x_m, cy: y_m, rx: radius, ry: radius });
|
||||
const z_text = new DrawText({ x: 5, y: 0, text:"M" });
|
||||
z_kreis.setAtrr({ fill: color })
|
||||
|
||||
|
||||
groupInhalt.add(z_text);
|
||||
groupInhalt.add(z_kreis);
|
||||
|
||||
|
||||
|
||||
this.scale = scale;
|
||||
this.raster = raster;
|
||||
this.height = height;
|
||||
this.width = width;
|
||||
this.obj_height = obj_h;
|
||||
this.obj_width = obj_w;
|
||||
|
||||
return groupInhalt;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
return {
|
||||
name: "motor",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: 0,
|
||||
offset_y: 0,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,270 @@
|
||||
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 { LineDto } from "src/_dto/visuElement.dto";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class DrawPfeil {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 1;
|
||||
width = 1;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
|
||||
red = "#f00000";
|
||||
normal = "#202020";
|
||||
green = "#00f000";
|
||||
green1 = "#0080ff";
|
||||
schlamm ="#CE6734"
|
||||
gemisch ="#E96B11"
|
||||
constructor() {
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(line: LineDto, optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
let raster = 4.0;
|
||||
let scale = 1.0;
|
||||
this.width = 0;
|
||||
this.height = 0;
|
||||
|
||||
let color = this.normal;
|
||||
if (optionen && optionen.state == 'active') color = this.gemisch;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
console.log(optionen)
|
||||
//if (optionen && optionen.colorActive && optionen.state == 'active') color = optionen.colorActive;
|
||||
if (optionen && optionen.colorInactive && optionen.state == 'inactive') color = optionen.colorInactive;
|
||||
if (optionen && optionen.colorError && optionen.state == 'error') color = optionen.colorError;
|
||||
console.log(color);
|
||||
const pfeil_h = 4;
|
||||
const pfeil_w = 4;
|
||||
const points = line.points;
|
||||
let lastPoint = { x: 0, y: 0 }
|
||||
const path_points: PathCommand[] = []
|
||||
let last_point_index = points.length - 1;
|
||||
|
||||
let index = 0;
|
||||
let direktion_down = false;
|
||||
let direktion_up = false;
|
||||
let direktion_left = false;
|
||||
let direktion_right = false;
|
||||
let no_pfeil = true;
|
||||
|
||||
let x_min = 0;
|
||||
let x_max = 0;
|
||||
let y_min = 0;
|
||||
let y_max = 0;
|
||||
|
||||
|
||||
for (let p of points) {
|
||||
|
||||
let x = p.x;
|
||||
let y = p.y;
|
||||
if (index == last_point_index) {
|
||||
direktion_down = lastPoint.y < y;
|
||||
direktion_up = lastPoint.y > y;
|
||||
direktion_left = lastPoint.x > x;
|
||||
direktion_right = lastPoint.x < x;
|
||||
if (direktion_down || direktion_up || direktion_left || direktion_right) no_pfeil = false;
|
||||
|
||||
if (direktion_down) y = y - pfeil_h;
|
||||
if (direktion_up) y = y + pfeil_h;
|
||||
if (direktion_right) x = x - pfeil_h;
|
||||
if (direktion_left) x = x + pfeil_h;
|
||||
}
|
||||
|
||||
index == 0 ? path_points.push({ type: "M", x, y }) : path_points.push({ type: "L", x, y })
|
||||
|
||||
if (p.y > y_max) y_max = p.y;
|
||||
if (p.y < y_min) y_min = p.y;
|
||||
if (p.x > x_max) x_max = p.x;
|
||||
if (p.x < x_min) x_min = p.x;
|
||||
|
||||
lastPoint = p;
|
||||
index++;
|
||||
}
|
||||
//console.log("direktion_down", direktion_down)
|
||||
//console.log("direktion_up", direktion_up)
|
||||
//console.log("direktion_left", direktion_left)
|
||||
//console.log("direktion_right", direktion_right)
|
||||
//console.log("no", no_pfeil)
|
||||
|
||||
let pfeil_start_x = 0;
|
||||
let pfeil_start_y = 0;
|
||||
let pfeil_end_x = 0;
|
||||
let pfeil_end_y = 0;
|
||||
let pfeil_p1_x = 0;
|
||||
let pfeil_p1_y = 0;
|
||||
let pfeil_p3_x = 0;
|
||||
let pfeil_p3_y = 0;
|
||||
let offset_w_x = 0;
|
||||
let offset_w_y = 0;
|
||||
|
||||
|
||||
if (direktion_down) {
|
||||
pfeil_start_x = lastPoint.x;
|
||||
pfeil_start_y = lastPoint.y - pfeil_h - 1;
|
||||
|
||||
pfeil_p1_x = pfeil_start_x + pfeil_h / 2;
|
||||
pfeil_p1_y = pfeil_start_y;
|
||||
|
||||
pfeil_end_x = lastPoint.x;
|
||||
pfeil_end_y = lastPoint.y - 1;
|
||||
|
||||
pfeil_p3_x = pfeil_start_x - pfeil_h / 2;
|
||||
pfeil_p3_y = pfeil_start_y;
|
||||
offset_w_x = 2;
|
||||
offset_w_x = x_max == 0 ? 4 : 2;
|
||||
}
|
||||
|
||||
if (direktion_up) {
|
||||
pfeil_start_x = lastPoint.x;
|
||||
pfeil_start_y = lastPoint.y + pfeil_h + 1;
|
||||
|
||||
pfeil_p1_x = pfeil_start_x - pfeil_h / 2;
|
||||
pfeil_p1_y = pfeil_start_y;
|
||||
|
||||
pfeil_end_x = lastPoint.x;
|
||||
pfeil_end_y = lastPoint.y + 1;
|
||||
|
||||
pfeil_p3_x = pfeil_start_x + pfeil_h / 2;
|
||||
pfeil_p3_y = pfeil_start_y;
|
||||
offset_w_x = x_max == 0 ? 4 : 2;
|
||||
}
|
||||
|
||||
if (direktion_right) {
|
||||
pfeil_start_x = lastPoint.x - pfeil_h - 1;
|
||||
pfeil_start_y = lastPoint.y;
|
||||
|
||||
pfeil_p1_x = pfeil_start_x;
|
||||
pfeil_p1_y = pfeil_start_y + pfeil_h / 2;
|
||||
|
||||
pfeil_end_x = lastPoint.x - 1;
|
||||
pfeil_end_y = lastPoint.y;
|
||||
|
||||
pfeil_p3_x = pfeil_start_x;
|
||||
pfeil_p3_y = pfeil_start_y - pfeil_h / 2;
|
||||
offset_w_y = y_max == 0 ? 4 : 2;
|
||||
|
||||
}
|
||||
|
||||
if (direktion_left) {
|
||||
pfeil_start_x = lastPoint.x + pfeil_h + 1;
|
||||
pfeil_start_y = lastPoint.y;
|
||||
|
||||
pfeil_p1_x = pfeil_start_x;
|
||||
pfeil_p1_y = pfeil_start_y - pfeil_h / 2;
|
||||
|
||||
pfeil_end_x = lastPoint.x + 1;
|
||||
pfeil_end_y = lastPoint.y;
|
||||
|
||||
pfeil_p3_x = pfeil_start_x;
|
||||
pfeil_p3_y = pfeil_start_y + pfeil_h / 2;
|
||||
offset_w_y = y_max == 0 ? 4 : 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const pfeil1: PathCommand[] = [
|
||||
{ type: "M", x: pfeil_start_x, y: pfeil_start_y },
|
||||
{ type: "L", x: pfeil_p1_x, y: pfeil_p1_y },
|
||||
{ type: "L", x: pfeil_end_x, y: pfeil_end_y },
|
||||
{ type: "L", x: pfeil_p3_x, y: pfeil_p3_y },
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
|
||||
const z_line = new DrawPath(path_points); // Line
|
||||
z_line.setAtrr({ stroke: color })
|
||||
z_line.setAtrr({ strokeWidth: 3 })
|
||||
|
||||
const z_pfeil = new DrawPath(pfeil1); // Pfeil
|
||||
z_pfeil.setAtrr({ fill: color })
|
||||
z_pfeil.setAtrr({ stroke: color })
|
||||
z_pfeil.setAtrr({ strokeWidth: 3 })
|
||||
|
||||
groupInhalt.add(z_pfeil);
|
||||
groupInhalt.add(z_line);
|
||||
|
||||
this.offset_x = 0;
|
||||
this.offset_y =0;
|
||||
if (x_min < 0){
|
||||
this.offset_x = Math.abs(x_min + offset_w_x);
|
||||
groupInhalt.setAtrr({ translate_x: Math.abs(x_min + offset_w_x) })
|
||||
}
|
||||
if (y_min < 0){
|
||||
this.offset_y = Math.abs(y_min + offset_w_y);
|
||||
groupInhalt.setAtrr({ translate_y: Math.abs(y_min + offset_w_y) })
|
||||
}
|
||||
|
||||
this.height = Math.abs(y_min) + y_max + offset_w_y;
|
||||
|
||||
this.width = Math.abs(x_min) + x_max + offset_w_x;
|
||||
this.obj_height = this.height;
|
||||
this.obj_width = this.width;
|
||||
if(this.obj_width<10) this.obj_width = 10; // Mindestgröße 10px
|
||||
if(this.obj_height<10) this.obj_height = 10; // Mindestgröße 10px
|
||||
|
||||
|
||||
|
||||
return groupInhalt;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(line: LineDto, optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(line,optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
return {
|
||||
name: "linie",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: this.offset_x, // translate Offset
|
||||
offset_y: this.offset_y,// translate Offset
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
getSvg(line: LineDto,optionen?: DrawShapeOptionenDto, xaml?: boolean): string {
|
||||
const drawXaml = xaml ? true : false;
|
||||
const groupSvg = this.create(line, optionen)
|
||||
|
||||
const header = new DrawHeader({ lenght: this.obj_width, height: this.obj_height });
|
||||
header.add(groupSvg);
|
||||
|
||||
return header.getChildString(drawXaml, 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
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";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class DrawPumpe {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
|
||||
constructor() {
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
let color = this.normal;
|
||||
if (optionen && optionen.state == 'active') color = this.green;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
|
||||
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 2.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
|
||||
|
||||
const x0 = 0;
|
||||
const x1 = 3 * raster * scale; // länge
|
||||
const x_m = (x0 + x1) / 2; // mitte kasten
|
||||
const y0 = 0;
|
||||
const y1 = 3 * raster * scale; // höhe Kasten
|
||||
const y_m = (y0 + y1) / 2; //mitte kasten
|
||||
const abstand_y = 4;
|
||||
const abstand_x = 4;
|
||||
const radius = x1 / 2;
|
||||
|
||||
const obj_h = y0 + y1 + 0 * raster;
|
||||
const obj_w = x0 + x1 + 0 * raster;
|
||||
const height = obj_h / scale / raster;
|
||||
const width = obj_w / scale / raster;
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
|
||||
const z_dreieck = new DrawPath([{ type: 'M', x: x_m, y: abstand_y }, { type: 'L', x: x1 - abstand_x, y: y_m + abstand_y }, { type: 'H', x: abstand_x }, { type: 'Z' }]); // \
|
||||
|
||||
const z_kreis = new DrawEllipse({ cx: x_m, cy: y_m, rx: radius, ry: radius });
|
||||
z_kreis.setAtrr({ fill: color })
|
||||
|
||||
|
||||
groupInhalt.add(z_dreieck);
|
||||
groupInhalt.add(z_kreis);
|
||||
|
||||
|
||||
|
||||
this.scale = scale;
|
||||
this.raster = raster;
|
||||
this.height = height;
|
||||
this.width = width;
|
||||
this.obj_height = obj_h;
|
||||
this.obj_width = obj_w;
|
||||
|
||||
return groupInhalt;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
return {
|
||||
name: "pumpe",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: 0,
|
||||
offset_y: 0,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
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";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
p2
|
||||
| \
|
||||
/
|
||||
p1 p3
|
||||
|
||||
l1 l2
|
||||
|
||||
p5- p4
|
||||
|
||||
p2.1 p2.3
|
||||
|
||||
p2.2
|
||||
|
||||
|
||||
*/
|
||||
@Injectable()
|
||||
export class DrawSetzmaschine {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
|
||||
constructor() {
|
||||
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
let color = this.normal;
|
||||
if (optionen && optionen.state == 'active') color = this.green;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
|
||||
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 1.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
const x0 = 0;
|
||||
const y0 = 0;
|
||||
|
||||
|
||||
const l1 = 1.5 * raster * scale
|
||||
const l2 = 11.5 * raster * scale
|
||||
const h1 = 5 * raster * scale
|
||||
const h2 = h1 + 1 * raster * scale
|
||||
|
||||
|
||||
const r_x0 = l1 + 1 * raster;
|
||||
const r_x1 = l2;
|
||||
const r_y0 = 0;
|
||||
const r_y1 = h1 - 1 * raster;
|
||||
|
||||
|
||||
|
||||
const l_x0 = r_x0;
|
||||
const l_y0 = r_y1 / 2;
|
||||
|
||||
const l_x1 = r_x1;
|
||||
const l_y1 = l_y0 + 1 * raster * scale;
|
||||
|
||||
const obj_h = h1 + h2 - 4;
|
||||
const obj_w = l2;
|
||||
|
||||
const height = obj_h / raster / scale;
|
||||
const width = obj_w / raster / scale;
|
||||
|
||||
//const { height, width, offsetX, offsetY } = cal_rotation_dim(0, obj_w, obj_h);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const deck: PathCommand[] = [
|
||||
{ type: "M", x: x0, y: y0 },
|
||||
{ type: "H", x: l1 },
|
||||
{ type: "V", y: h1 },
|
||||
{ type: "H", x: l2 },
|
||||
{ type: "V", y: h2 },
|
||||
{ type: "A", rx: (l2) / 2, ry: (l2 - 20) / 2, xAxisRotation: 0, largeArcFlag: 0, sweepFlag: 1, x: 0, y: h2 }, // u
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
const rechteck: PathCommand[] = [
|
||||
{ type: "M", x: r_x0, y: r_y0 },
|
||||
{ type: "H", x: r_x1 },
|
||||
{ type: "V", y: r_y1 },
|
||||
{ type: "H", x: r_x0 },
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
|
||||
|
||||
const z_deck = new DrawPath(deck);
|
||||
z_deck.setAtrr({ fill: '#808080' })
|
||||
|
||||
const z_rechteck = new DrawPath(rechteck);
|
||||
z_rechteck.setAtrr({ fill: color })
|
||||
|
||||
const z_line = new DrawLine({ x1: l_x0, y1: l_y0, x2: l_x1, y2: l_y1 });
|
||||
z_line.setAtrr({ "dasharray": "5,5" });
|
||||
|
||||
|
||||
const header = new DrawHeader({ lenght: obj_w, height: obj_h });
|
||||
groupInhalt.add(z_line);
|
||||
groupInhalt.add(z_rechteck);
|
||||
groupInhalt.add(z_deck);
|
||||
|
||||
this.scale = scale;
|
||||
this.height = height;
|
||||
this.width = width;
|
||||
this.obj_height = obj_h;
|
||||
this.obj_width = obj_w;
|
||||
|
||||
return groupInhalt;
|
||||
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
return {
|
||||
name: "setzmaschine",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: 0,
|
||||
offset_y: 0,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
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";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
p2
|
||||
| \
|
||||
/
|
||||
p1 p3
|
||||
|
||||
l1 l2
|
||||
|
||||
p5- p4
|
||||
|
||||
p2.1 p2.3
|
||||
|
||||
p2.2
|
||||
|
||||
|
||||
*/
|
||||
@Injectable()
|
||||
export class Sieb {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
|
||||
constructor() {
|
||||
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
let color = this.normal;
|
||||
if (optionen && optionen.state == 'active') color = this.green;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 2.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
const winkel = this.winkel;
|
||||
const height = 4;
|
||||
const width = 12
|
||||
const x0 = 0;
|
||||
const x1 = x0 + 9 * raster * scale; // Prozent
|
||||
const x2 = x0 + width * raster * scale; // 12 * raster
|
||||
const y0 = 0;
|
||||
const y1 = height / 2 * raster * scale;
|
||||
const y2 = height * raster * scale;
|
||||
|
||||
const y4 = 1 * raster * scale;
|
||||
const y5 = 3 * raster * scale;
|
||||
|
||||
|
||||
// Sammelbehälter unter Sieb
|
||||
const s_y0 = y2 + raster / 2;
|
||||
const s_y1 = s_y0 + (5 * raster);
|
||||
|
||||
|
||||
const obj_h = s_y1;
|
||||
const obj_w = x0 + x2;
|
||||
|
||||
//const { height, width, offsetX, offsetY } = cal_rotation_dim(winkel, obj_w, obj_h);
|
||||
|
||||
|
||||
|
||||
const deck: PathCommand[] = [
|
||||
{ type: "M", x: x0, y: y0 },
|
||||
{ type: "L", x: x2, y: y0 },
|
||||
{ type: "L", x: x2, y: y2 },
|
||||
{ type: "H", x: x0 },
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
const sammel: PathCommand[] = [
|
||||
{ type: "M", x: x0, y: s_y0 },
|
||||
{ type: "L", x: x0 + (x2 - x0) / 2, y: s_y1 },
|
||||
{ type: "L", x: x2, y: s_y0 },
|
||||
];
|
||||
|
||||
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
const groupTest = new DrawGroup({});
|
||||
|
||||
const z_deck = new DrawPath(deck);
|
||||
z_deck.setAtrr({ fill: color })
|
||||
const z_sammel = new DrawPath(sammel);
|
||||
|
||||
const z_line = new DrawLine({ x1: x0, y1: y4, x2: x2, y2: y4 });
|
||||
z_line.setAtrr({ "dasharray": "5,5" });
|
||||
|
||||
const z_line2 = new DrawLine({ x1: x0, y1: y5, x2: x2, y2: y5 });
|
||||
z_line2.setAtrr({ "dasharray": "5,5" });
|
||||
|
||||
groupTest.add(z_line);
|
||||
|
||||
groupInhalt.add(z_line);
|
||||
groupInhalt.add(z_line2);
|
||||
groupInhalt.add(z_sammel);
|
||||
groupInhalt.add(groupTest);
|
||||
|
||||
groupInhalt.add(z_deck);
|
||||
|
||||
this.scale = scale;
|
||||
this.height = height;
|
||||
this.width = width;
|
||||
this.obj_height = obj_h;
|
||||
this.obj_width = obj_w;
|
||||
|
||||
return groupInhalt;
|
||||
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
return {
|
||||
name: "sieb",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: 0,
|
||||
offset_y: 0,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
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";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class DrawSiebEntwaesserung {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
|
||||
constructor() {
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
let color = this.normal;
|
||||
if (optionen && optionen.state == 'active') color = this.green;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 1.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
|
||||
|
||||
const ohneTrichter = optionen?.variant === 'ohneTrichter' ? true : false;
|
||||
|
||||
const x0 = 0;
|
||||
const x1 = x0 + 9 * raster * scale; // Prozent
|
||||
const x2 = x0 + 12 * raster * scale; // 12 * raster
|
||||
const y0 = 0;
|
||||
const y1 = 2 * raster * scale;
|
||||
const y2 = 4 * raster * scale;
|
||||
|
||||
const y4 = 3 * raster * scale;
|
||||
|
||||
const sammel_y_offset = y2 + raster / 2;
|
||||
const sammel_y1 = sammel_y_offset + (5 * raster);
|
||||
|
||||
const sammel_p1 = { x: x0, y: sammel_y_offset };
|
||||
const sammel_p2 = { x: x2, y: sammel_y_offset };
|
||||
const sammel_p3 = { x: x0 + (x2 - x0) / 2, y: sammel_y1 };
|
||||
|
||||
const obj_h = ohneTrichter ? y2 : sammel_y1;
|
||||
const obj_w = x0 + x2;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const g2_path: PathCommand[] = [
|
||||
{ type: "M", x: x0, y: y1 },
|
||||
{ type: "L", x: x1, y: y0 },
|
||||
{ type: "L", x: x2, y: y1 },
|
||||
{ type: "V", y: y2 },
|
||||
{ type: "H", x: x0 },
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
const g3_path_trichter: PathCommand[] = [
|
||||
{ type: "M", x: sammel_p1.x, y: sammel_p1.y },
|
||||
{ type: "L", x: sammel_p3.x, y: sammel_p3.y },
|
||||
{ type: "L", x: sammel_p2.x, y: sammel_p2.y },
|
||||
];
|
||||
|
||||
const z_line = new DrawLine({ x1: x0, y1: y4, x2: x2, y2: y4 });
|
||||
z_line.setAtrr({ dasharray: "5,5" })
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
|
||||
|
||||
const z_g2 = new DrawPath(g2_path);
|
||||
z_g2.setAtrr({ fill: color })
|
||||
|
||||
const z_trichter = new DrawPath(g3_path_trichter);
|
||||
|
||||
groupInhalt.add(z_line);
|
||||
if(!ohneTrichter) groupInhalt.add(z_trichter);
|
||||
groupInhalt.add(z_g2);
|
||||
//groupInhalt.add(z_g1);
|
||||
|
||||
|
||||
this.scale = scale;
|
||||
this.height = obj_h / raster / scale;
|
||||
this.width = obj_w / raster / scale;
|
||||
this.obj_height = obj_h;
|
||||
this.obj_width = obj_w;
|
||||
|
||||
return groupInhalt;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
return {
|
||||
name: "siebentwaesserung",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: 0,
|
||||
offset_y: 0,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
import { PathCommand } from "../lib/types/path.types";
|
||||
import { DrawPath } from '../lib/drawPath'
|
||||
import { DrawGroup } from '../lib/drawGroup'
|
||||
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { DrawDto, DrawShapeOptionenDto } from "src/_dto/draw.dto";
|
||||
import { DrawHeader } from "../lib/drawHeader";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class DrawSilo {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
|
||||
constructor() {
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
let color = this.normal;
|
||||
if (optionen && optionen.state == 'active') color = this.green;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 2.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
let laenge = 24;
|
||||
if (optionen && optionen.width) laenge = optionen.width;
|
||||
|
||||
let hoehe = 16.0;
|
||||
if (optionen && optionen.height) hoehe = optionen.height;
|
||||
|
||||
|
||||
const x0 = raster;
|
||||
const x1 = laenge * raster * scale; // länge Kasten
|
||||
const x_m = x1 / 2; // mitte kasten
|
||||
const y0 = raster;
|
||||
const y1 = hoehe * raster * scale; // höhe Kasten
|
||||
const y_m = y1 / 2; //mitte kasten
|
||||
|
||||
const fuellung_y = (hoehe - 8) * raster * scale
|
||||
const spitze_y = (3) * raster * scale
|
||||
const wand_x = (2) * raster * scale
|
||||
|
||||
const obj_h = y0 + y1 + 0 * raster;
|
||||
const obj_w = x0 + x1 + 0 * raster;
|
||||
|
||||
//Kasten
|
||||
const g1_path: PathCommand[] = [
|
||||
{ type: "M", x: x0 + wand_x, y: y0 },
|
||||
{ type: "H", x: x0 },
|
||||
{ type: "V", y: y0 + y1 },
|
||||
{ type: "H", x: x0 + x1 },
|
||||
{ type: "V", y: y0 },
|
||||
{ type: "H", x: x0 + x1 - wand_x },
|
||||
];
|
||||
|
||||
//Füllung
|
||||
const g2_path: PathCommand[] = [
|
||||
{ type: "M", x: x0, y: y0 + fuellung_y },
|
||||
|
||||
{ type: "L", x: x0 + x_m, y: y0 + fuellung_y - spitze_y },
|
||||
{ type: "L", x: x0 + x1, y: y0 + fuellung_y },
|
||||
{ type: "V", y: y0 + y1 },
|
||||
{ type: "H", x: x0 },
|
||||
{ type: "Z" },
|
||||
];
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
|
||||
const z_g1 = new DrawPath(g1_path); // Kasten
|
||||
const z_g2 = new DrawPath(g2_path); // fuellung
|
||||
|
||||
z_g2.setAtrr({ fill: '#808080' })
|
||||
|
||||
groupInhalt.add(z_g2);
|
||||
groupInhalt.add(z_g1);
|
||||
|
||||
this.scale = scale;
|
||||
this.height = hoehe;
|
||||
this.width = laenge;
|
||||
this.obj_height = obj_h;
|
||||
this.obj_width = obj_w;
|
||||
|
||||
return groupInhalt;
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
return {
|
||||
name: "silo",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: 0,
|
||||
offset_y: 0,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
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";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class DrawTurbowascher {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
|
||||
constructor() {
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
anker(x: number, y: number, direction: boolean, faktor: number) {
|
||||
const a_h = 2.5 * faktor;
|
||||
const a_l = 0.3 * faktor;
|
||||
const a_d = 0.2 * faktor;
|
||||
|
||||
let di = 1;
|
||||
if (direction) di = -1;
|
||||
|
||||
let path: PathCommand[] = [
|
||||
{ type: 'M', x: x, y: y },
|
||||
{ type: 'V', y: y + a_h * di },
|
||||
{ type: 'H', x: x + a_l },
|
||||
{ type: 'V', y: y + ((a_h - a_d) * di) },
|
||||
{ type: 'H', x: x + a_d },
|
||||
{ type: 'V', y: y },
|
||||
{ type: 'Z' },
|
||||
|
||||
]
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
let color = this.normal;
|
||||
if (optionen && optionen.state == 'active') color = this.green;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 2.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
|
||||
const faktor = raster * scale;
|
||||
|
||||
const x0 = 0 * faktor;
|
||||
const y0 = 0 * faktor;
|
||||
const l1 = 14 * faktor;
|
||||
const l2 = 12 * faktor;
|
||||
const h = 6 * faktor;
|
||||
const d = 0.4 * faktor;
|
||||
|
||||
const d_between = 2.5;
|
||||
|
||||
let obj_h = (x0 + h);
|
||||
let obj_w = (y0 + l1 + 1 * raster);
|
||||
let laenge = obj_w / raster / scale;
|
||||
let hoehe = obj_h / raster / scale;
|
||||
|
||||
|
||||
const groupAnker = new DrawGroup({});
|
||||
let anker_pos_x = 1 * faktor;
|
||||
let step = 1.5 * faktor;
|
||||
let anz = 9;
|
||||
let di = false;
|
||||
|
||||
for (let i = 0; i < anz; i++) {
|
||||
const path = this.anker(anker_pos_x, h / 2, di, faktor);
|
||||
const z_anker = new DrawPath(path); // Kasten
|
||||
groupAnker.add(z_anker);
|
||||
di = !di;
|
||||
anker_pos_x += step;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Kasten
|
||||
const g1_path: PathCommand[] = [
|
||||
{ type: 'M', x: x0, y: y0 },
|
||||
{ type: 'H', x: l1 },
|
||||
{ type: 'V', y: h },
|
||||
{ type: 'H', x: x0 },
|
||||
{ type: 'Z' }
|
||||
];
|
||||
|
||||
// Kasten Hinten
|
||||
const g2_path: PathCommand[] = [
|
||||
{ type: 'M', x: x0 + l1, y: y0 },
|
||||
{ type: 'H', x: x0 + l1 + 1 * raster },
|
||||
{ type: 'V', y: h },
|
||||
{ type: 'H', x: x0 + l1 },
|
||||
{ type: 'Z' }
|
||||
];
|
||||
|
||||
const g3_path: PathCommand[] = [
|
||||
{ type: 'M', x: x0, y: h / 2 - d / 2 },
|
||||
{ type: 'H', x: l1 + raster },
|
||||
{ type: 'V', y: h / 2 + d / 2 },
|
||||
{ type: 'H', x: x0 },
|
||||
{ type: 'Z' }
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
|
||||
const z_g1 = new DrawPath(g1_path); // Kasten
|
||||
z_g1.setAtrr({ fill: color })
|
||||
|
||||
const z_g2 = new DrawPath(g2_path); // Kasten
|
||||
z_g2.setAtrr({ fill: '#808080' })
|
||||
|
||||
const z_g3 = new DrawPath(g3_path); // Kasten
|
||||
z_g3.setAtrr({ fill: '#808080' })
|
||||
|
||||
groupInhalt.add(z_g2);
|
||||
groupInhalt.add(z_g3);
|
||||
groupInhalt.add(groupAnker);
|
||||
groupInhalt.add(z_g1);
|
||||
|
||||
|
||||
|
||||
this.obj_height = obj_h;
|
||||
this.obj_width = obj_w;
|
||||
this.scale = scale;
|
||||
this.raster = raster;
|
||||
this.height = hoehe;
|
||||
this.width = laenge;
|
||||
|
||||
return groupInhalt;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
return {
|
||||
name: "turbowasher",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: 0,
|
||||
offset_y: 0,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
import { PathCommand } from "../lib/types/path.types";
|
||||
import { DrawPath } from '../lib/drawPath'
|
||||
import { DrawGroup } from '../lib/drawGroup'
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { DrawDto, DrawShapeOptionenDto } from "src/_dto/draw.dto";
|
||||
import { DrawHeader } from "../lib/drawHeader";
|
||||
|
||||
@Injectable()
|
||||
export class DrawVentil {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
|
||||
constructor() {
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
let color = this.normal;
|
||||
if (optionen && optionen.state == 'active') color = this.green;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 1.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
let vertical = optionen?.variant === 'vertical'
|
||||
|
||||
const faktor = raster * scale
|
||||
const x0 = 0;
|
||||
const x1 = vertical ? x0 + 6 * faktor : x0 + 4 * faktor; // länge Kasten
|
||||
const y0 = 0;
|
||||
const y1 = vertical ? y0 + 4 * faktor : y0 + 6 * faktor; // höhe Kasten
|
||||
|
||||
|
||||
const obj_h = y0 + y1;
|
||||
const obj_w = x0 + x1;
|
||||
|
||||
let laenge = obj_w / faktor;
|
||||
let hoehe = obj_h / faktor;
|
||||
|
||||
//Ventil Horizontal
|
||||
const g1_horizontal: PathCommand[] = [
|
||||
{ type: "M", x: x0, y: y0 },
|
||||
{ type: "H", x: x0 + x1 },
|
||||
{ type: "L", x: x0, y: y0 + y1 },
|
||||
{ type: "H", x: x0 + x1 },
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
//Ventil Vertikal
|
||||
const g2_vertical: PathCommand[] = [
|
||||
{ type: "M", x: x0, y: y0 },
|
||||
{ type: "V", y: y0 + y1 },
|
||||
{ type: "L", x: x1, y: y0 },
|
||||
{ type: "V", y: y0 + y1 },
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
|
||||
let p1_path = vertical ? g2_vertical : g1_horizontal;
|
||||
const z_p1 = new DrawPath(p1_path); // Kasten
|
||||
z_p1.setAtrr({ fill: color })
|
||||
|
||||
groupInhalt.add(z_p1);
|
||||
|
||||
this.scale = scale;
|
||||
this.height = hoehe;
|
||||
this.width = laenge;
|
||||
this.obj_height = obj_h;
|
||||
this.obj_width = obj_w;
|
||||
|
||||
return groupInhalt;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
return {
|
||||
name: "ventil",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: 0,
|
||||
offset_y: 0,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
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";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class DrawWasserZufuhr {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
blue = "#0000ff"
|
||||
constructor() {
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
let color = this.blue;
|
||||
if (optionen && optionen.state == 'active') color = this.green;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
|
||||
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 1.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
|
||||
|
||||
const x0 = 0;
|
||||
const x1 = 2 * raster * scale; // länge
|
||||
const x_m = (x0 + x1) / 2; // mitte kasten
|
||||
const y0 = 0;
|
||||
const y1 = 4 * raster * scale; // höhe Kasten
|
||||
|
||||
const radius = 1 * raster * scale;
|
||||
const y_k = (y0 + radius); //mitte kasten
|
||||
|
||||
const obj_h = y0 + y1;
|
||||
const obj_w = x0 + x1;
|
||||
const height = obj_h / scale / raster;
|
||||
const width = obj_w / scale / raster;
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
|
||||
let line:PathCommand[] = [{ type: 'M', x: x_m, y: 2*radius }, { type: 'V', y: y1 }]
|
||||
let posKreis:{x:number,y:number} = {x:x_m,y:y_k}
|
||||
const z_line = new DrawPath(line); // \
|
||||
z_line.setAtrr({ stroke: color })
|
||||
|
||||
const z_kreis = new DrawEllipse({ cx: posKreis.x, cy: posKreis.y, rx: radius, ry: radius });
|
||||
z_kreis.setAtrr({ stroke: color })
|
||||
z_kreis.setAtrr({ fill: color })
|
||||
|
||||
|
||||
groupInhalt.add(z_kreis);
|
||||
groupInhalt.add(z_line);
|
||||
|
||||
|
||||
|
||||
this.scale = scale;
|
||||
this.raster = raster;
|
||||
this.height = height;
|
||||
this.width = width;
|
||||
this.obj_height = obj_h;
|
||||
this.obj_width = obj_w;
|
||||
|
||||
return groupInhalt;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
return {
|
||||
name: "pumpe",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: 0,
|
||||
offset_y: 0,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
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";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class DrawWeiche {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
|
||||
constructor() {
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
let color = this.normal;
|
||||
if (optionen && optionen.state == 'active') color = this.green;
|
||||
if (optionen && optionen.state == 'error') color = this.red;
|
||||
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 1.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
|
||||
const faktor = raster * scale
|
||||
const x0 = 0;
|
||||
const x1 = x0 + 8 * raster * scale; // länge Kasten
|
||||
const x2 = x1 / 2; // mitte kasten
|
||||
const y0 = 0;
|
||||
const y1 = y0 + 8 * raster * scale; // höhe Kasten
|
||||
const y2 = y1 / 2; //mitte kasten
|
||||
|
||||
const pfeil_h = 1 * raster * scale;
|
||||
const pfeil_w = 1 * raster * scale;
|
||||
const pfeil1_mitte_x = x0 + x2;
|
||||
const pfeil1_mitte_start_y = y0 + y1 - pfeil_h - 1;
|
||||
const pfeil1_mitte_endpunkt_y2 = y0 + y1 - 1;
|
||||
|
||||
const pfeil2_mitte_y = y0 + y2;
|
||||
const pfeil2_mitte_start_x = x0 + pfeil_h + 1;
|
||||
const pfeil2_mitte_endpunkt_x = x0 + 1;
|
||||
|
||||
const obj_h = y1 + 0 * raster;
|
||||
const obj_w = x1 + 0 * raster;
|
||||
|
||||
let laenge = obj_w / raster / scale;
|
||||
let hoehe = obj_h / raster / scale;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const pfeil1: PathCommand[] = [
|
||||
{ type: "M", x: pfeil1_mitte_x, y: pfeil1_mitte_start_y },
|
||||
{ type: "H", x: pfeil1_mitte_x + pfeil_w / 2 },
|
||||
{ type: "L", x: pfeil1_mitte_x, y: pfeil1_mitte_endpunkt_y2 },
|
||||
{ type: "L", x: pfeil1_mitte_x - pfeil_w / 2, y: pfeil1_mitte_start_y },
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
const pfeil2: PathCommand[] = [
|
||||
{ type: "M", x: pfeil2_mitte_start_x, y: pfeil2_mitte_y },
|
||||
{ type: "V", y: pfeil2_mitte_y + pfeil_w / 2 },
|
||||
{ type: "L", x: pfeil2_mitte_endpunkt_x, y: pfeil2_mitte_y },
|
||||
{ type: "L", x: pfeil2_mitte_start_x, y: pfeil2_mitte_y - pfeil_w / 2 },
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
//Kasten
|
||||
const g1_path: PathCommand[] = [
|
||||
{ type: "M", x: x0, y: y0 },
|
||||
{ type: "H", x: x0 + x1 },
|
||||
{ type: "V", y: y0 + y1 },
|
||||
{ type: "H", x: x0 },
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
|
||||
const z_g1 = new DrawPath(g1_path); // Kasten
|
||||
const z_pfeil1 = new DrawPath(pfeil1); // Pfeilspitze V
|
||||
z_pfeil1.setAtrr({ fill: '#000000' })
|
||||
const z_pfeil2 = new DrawPath(pfeil2); // Pfeilspitze <
|
||||
z_pfeil2.setAtrr({ fill: '#000000' })
|
||||
const z_line_V = new DrawLine({ x1: x0 + x2, y1: y0, x2: x0 + x2, y2: y0 + y1 - pfeil_h });
|
||||
const z_line_H = new DrawLine({ x1: x0 + x2, y1: y0 + y2, x2: x0 + pfeil_h, y2: y0 + y2 });
|
||||
const z_kreis1 = new DrawEllipse({ cx: x0 + x2, cy: y0 + y2, rx: scale * raster / 2, ry: scale * raster / 2 });
|
||||
z_kreis1.setAtrr({ fill: '#000000' })
|
||||
|
||||
|
||||
|
||||
groupInhalt.add(z_kreis1);
|
||||
groupInhalt.add(z_pfeil1);
|
||||
groupInhalt.add(z_pfeil2);
|
||||
groupInhalt.add(z_line_H);
|
||||
groupInhalt.add(z_line_V);
|
||||
groupInhalt.add(z_g1);
|
||||
|
||||
|
||||
|
||||
this.scale = scale;
|
||||
this.height = hoehe;
|
||||
this.width = laenge;
|
||||
this.obj_height = obj_h;
|
||||
this.obj_width = obj_w;
|
||||
|
||||
return groupInhalt;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
return {
|
||||
name: "weiche",
|
||||
height: this.height,
|
||||
length: this.width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: 0,
|
||||
offset_y: 0,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
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";
|
||||
|
||||
interface Para {
|
||||
scale?: number,
|
||||
}
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class DrawZyklon {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
obj_height = 0;
|
||||
obj_width = 0;
|
||||
height = 0;
|
||||
width = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
|
||||
red = "#f00000";
|
||||
normal = "#808080";
|
||||
green = "#00f000";
|
||||
|
||||
constructor() {
|
||||
this.scale = 2.0;
|
||||
}
|
||||
|
||||
|
||||
create(optionen?: DrawShapeOptionenDto): DrawGroup {
|
||||
let raster = 4.0;
|
||||
if (optionen && optionen.raster) raster = optionen.raster;
|
||||
|
||||
let scale = 1.0;
|
||||
if (optionen && optionen.scale) scale = optionen.scale;
|
||||
|
||||
let laenge = 10.0;
|
||||
if (optionen && optionen.width) laenge = optionen.width;
|
||||
|
||||
let hoehe = 6.0;
|
||||
if (optionen && optionen.height) hoehe = optionen.height;
|
||||
|
||||
const faktor = raster * scale
|
||||
const x0 = raster;
|
||||
const x1 = x0 + 6 * raster * scale; // länge Kasten
|
||||
const x_m = x1 / 2; // mitte kasten
|
||||
const y0 = raster;
|
||||
const y1 = y0 + 20 * raster * scale; // höhe Kasten
|
||||
const y_m = y1 / 2; //mitte kasten
|
||||
|
||||
const einlass_oben_b = 2 * raster * scale;
|
||||
const einlass_oben_h = 1 * raster * scale;
|
||||
|
||||
|
||||
const einlass_seite_b = 1 * raster * scale;
|
||||
const einlass_seite_h = 3 * raster * scale;
|
||||
const einlass_seite_pos_y = 3 * raster * scale;
|
||||
|
||||
const trichter_pos_y = y0 + 14 * raster * scale;
|
||||
const trichter_unten_b = 2 * raster * scale;
|
||||
|
||||
const obj_h = y0 + y1 + 0 * raster + einlass_oben_h;
|
||||
const obj_w = x0 + x1 + 0 * raster + einlass_seite_b;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Kasten
|
||||
const g1_path: PathCommand[] = [
|
||||
{ type: "M", x: x0, y: y0 + einlass_oben_h },
|
||||
{ type: "H", x: x0 + (x1 / 2) - (einlass_oben_b / 2) }, // Linie zu Einlass oben
|
||||
{ type: "V", y: y0 }, // Einlass oben L1 hoch
|
||||
{ type: "H", x: x0 + (x1 / 2) + (einlass_oben_b / 2) }, // Einlass oben L2 rüber
|
||||
{ type: "V", y: y0 + einlass_oben_h }, // Einlass oben L3 runter
|
||||
{ type: "H", x: x0 + x1 }, // Ecke oben
|
||||
{ type: "V", y: y0 + einlass_seite_pos_y },
|
||||
{ type: "H", x: x0 + x1 + einlass_seite_b },
|
||||
{ type: "V", y: y0 + einlass_seite_pos_y + einlass_seite_h },
|
||||
{ type: "H", x: x0 + x1 },
|
||||
{ type: "V", y: y0 + trichter_pos_y },
|
||||
{ type: "L", x: x0 + (x1 / 2) + trichter_unten_b / 2, y: y1 },
|
||||
{ type: "H", x: x0 + (x1 / 2) - trichter_unten_b / 2 }, // H Line trichter unten
|
||||
{ type: "L", x: x0, y: y0 + trichter_pos_y },
|
||||
|
||||
{ type: "Z" }
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const groupInhalt = new DrawGroup({});
|
||||
|
||||
const z_g1 = new DrawPath(g1_path); // Kasten
|
||||
z_g1.setAtrr({ fill: '#808080' })
|
||||
|
||||
const z_line_1 = new DrawLine({ x1: x0, y1: y0 + einlass_seite_pos_y, x2: x0 + x1, y2: y0 + einlass_seite_pos_y });
|
||||
const z_line_2 = new DrawLine({ x1: x0, y1: y0 + einlass_seite_pos_y + einlass_seite_h, x2: x0 + x1, y2: y0 + einlass_seite_pos_y + einlass_seite_h });
|
||||
|
||||
|
||||
|
||||
groupInhalt.add(z_line_1);
|
||||
groupInhalt.add(z_line_2);
|
||||
groupInhalt.add(z_g1);
|
||||
|
||||
|
||||
|
||||
this.scale = scale;
|
||||
this.height = hoehe;
|
||||
this.width = laenge;
|
||||
this.obj_height = obj_h;
|
||||
this.obj_width = obj_w;
|
||||
this.offset_x = 0;
|
||||
this.offset_y = 0;
|
||||
return groupInhalt;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
return {
|
||||
name: "zyklon",
|
||||
height: this.obj_height,
|
||||
length: this.obj_width,
|
||||
px_height: this.obj_height,
|
||||
px_width: this.obj_width,
|
||||
raster: this.raster,
|
||||
scale: this.scale,
|
||||
offset_x: 0,
|
||||
offset_y: 0,
|
||||
svg
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
|
||||
export abstract class DrawContainer {
|
||||
elements = new Map<number, DrawContainer | DrawElement>();
|
||||
|
||||
add(item: DrawContainer | DrawElement) {
|
||||
const elNr = this.elements.size
|
||||
this.elements.set(elNr, item);
|
||||
}
|
||||
|
||||
getElements() {
|
||||
return this.elements;
|
||||
}
|
||||
|
||||
abstract getChildString(xaml: boolean,deph:number):string;
|
||||
}
|
||||
|
||||
class Translate {
|
||||
dataXaml = new Map<string, {svg:string,xaml:string}>()
|
||||
constructor(private xaml?:boolean) {
|
||||
if(!xaml) this.xaml = false;
|
||||
this.dataXaml.set('color', {svg:'Color',xaml:'Color'});
|
||||
this.dataXaml.set('strokeWidth', {svg:'stroke-width',xaml:'StrokeThickness'});
|
||||
this.dataXaml.set('stroke', {svg:'stroke',xaml:'Stroke'});
|
||||
this.dataXaml.set('dasharray', {svg:'stroke-dasharray',xaml:'StrokeDashArray'});
|
||||
this.dataXaml.set('stroke-dasharray', {svg:'stroke-dasharray',xaml:'StrokeDashArray'});
|
||||
this.dataXaml.set('fill', {svg:'fill',xaml:'Fill'});
|
||||
this.dataXaml.set('opacity', {svg:'opacity',xaml:'opacity'});
|
||||
}
|
||||
|
||||
getAttribute(key: string, value: string | number): { key: string, value: string | number } {
|
||||
let t_key = this.dataXaml.get(key);
|
||||
|
||||
if(this.xaml && key==='fill' && value==='none') return {key:'ignore',value:''};
|
||||
//console.log(key,t_key)
|
||||
if (t_key && !this.xaml) return { key: t_key.svg, value: value };
|
||||
if (t_key && this.xaml) return { key: t_key.xaml, value: value };
|
||||
else return { key: key, value: value };
|
||||
}
|
||||
|
||||
setXaml(){
|
||||
this.xaml = true;
|
||||
}
|
||||
|
||||
setSvg(){
|
||||
this.xaml = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export abstract class DrawElement {
|
||||
attributes = new Map<string, string | number>();
|
||||
|
||||
constructor() { }
|
||||
|
||||
convertAttributesToString(values:Map<string, string|number>,xaml?: boolean, translate?: Translate) {
|
||||
translate = new Translate(xaml);
|
||||
|
||||
let str = '';
|
||||
let sep = ' ';
|
||||
for (const [key, paraValue] of values) {
|
||||
let attr = {key,value: paraValue};
|
||||
if (translate) attr = translate.getAttribute(attr.key, attr.value);
|
||||
|
||||
if(attr.key!=='ignore'){
|
||||
str += `${attr.key}="${attr.value}"${sep}`
|
||||
sep = ' ';
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
abstract drawSvg():string;
|
||||
abstract drawXaml():string;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
interface ElypI {
|
||||
x: number,
|
||||
y: number
|
||||
}
|
||||
|
||||
class Elipse extends DrawElement {
|
||||
constructor(name: string) {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
|
||||
getAttString(): string {
|
||||
return "att1=1";
|
||||
}
|
||||
|
||||
setAtrr(att: Partial<ElypI>) {
|
||||
Object.entries(att).forEach(([key, value]) => {
|
||||
this.attributes.set(key, value);
|
||||
});
|
||||
}
|
||||
|
||||
drawSvg(): string {
|
||||
return 'not Supportet jet'
|
||||
}
|
||||
|
||||
|
||||
|
||||
drawXaml(): string {
|
||||
return 'not Supportet jet'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
import { DrawElement } from "./draw"
|
||||
|
||||
interface PropEllipse {
|
||||
cx: number
|
||||
cy: number
|
||||
rx: number
|
||||
ry: number
|
||||
}
|
||||
|
||||
interface SvgOptions {
|
||||
color?: string
|
||||
storkWidth?: number,
|
||||
stroke?:string,
|
||||
dasharray?: string,
|
||||
fill?: string,
|
||||
opacity?: number
|
||||
}
|
||||
|
||||
|
||||
export class DrawEllipse extends DrawElement {
|
||||
|
||||
|
||||
|
||||
constructor(private posAndSize: PropEllipse) {
|
||||
super();
|
||||
|
||||
// Default Attribute
|
||||
this.attributes.set('strokeWidth', 1);
|
||||
this.attributes.set('stroke', "#000000");
|
||||
this.attributes.set('fill', 'none');
|
||||
}
|
||||
|
||||
|
||||
setAtrr(att: Partial<SvgOptions>) {
|
||||
Object.entries(att).forEach(([key, value]) => {
|
||||
this.attributes.set(key, value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
drawSvg() {
|
||||
const paraStr = this.convertAttributesToString(this.attributes);
|
||||
const posSvg = this.getSvgPositions(this.posAndSize)
|
||||
const posStr = this.convertAttributesToString(posSvg);
|
||||
|
||||
const shape = this.drawElementSvg(posStr, paraStr);
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
drawXaml(): string {
|
||||
const paraStr = this.convertAttributesToString(this.attributes, true);
|
||||
const posXaml = this.getXamlPositions(this.posAndSize)
|
||||
const posStr = this.convertAttributesToString(posXaml, true);
|
||||
|
||||
const shape = this.drawElementXaml(posStr, paraStr);
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
drawElementSvg(position: string, options: string) {
|
||||
return `<ellipse ${position} ${options}></ellipse>`
|
||||
}
|
||||
|
||||
drawElementXaml(position: string, options: string) {
|
||||
|
||||
return `<Ellipse ${position} ${options}></Ellipse>`
|
||||
|
||||
}
|
||||
|
||||
getSvgPositions(dim: PropEllipse) {
|
||||
|
||||
let retValue = new Map<string, number>();
|
||||
|
||||
retValue.set('cx', dim.cx);
|
||||
retValue.set('cy', dim.cy);
|
||||
retValue.set('rx', dim.rx);
|
||||
retValue.set('ry', dim.ry);
|
||||
|
||||
return retValue;
|
||||
|
||||
}
|
||||
|
||||
getXamlPositions(dim: PropEllipse) {
|
||||
|
||||
let retValue = new Map<string, number>();
|
||||
|
||||
retValue.set('Canvas.Left', dim.cx - dim.rx);
|
||||
retValue.set('Canvas.Top', dim.cy - dim.ry);
|
||||
retValue.set('Width', dim.rx * 2);
|
||||
retValue.set('Height', dim.ry * 2);
|
||||
|
||||
return retValue;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
export function cal_rotation_dim(winkel: number, laenge: number, hoehe: number) {
|
||||
|
||||
let h = (Math.sin(Math.abs(winkel) * Math.PI / 180) * laenge) + (Math.cos(Math.abs(winkel) * Math.PI / 180) * hoehe);
|
||||
let w = ((Math.cos(Math.abs(winkel) * Math.PI / 180) * laenge) + (Math.sin(Math.abs(winkel) * Math.PI / 180) * hoehe));
|
||||
let d = Math.cos(Math.abs(winkel) * Math.PI / 180) * hoehe;
|
||||
let dw = Math.sin(Math.abs(winkel) * Math.PI / 180) * hoehe;
|
||||
|
||||
let offsetX = 0;
|
||||
let offsetY = h - d;
|
||||
if (winkel > 0) {
|
||||
offsetX = dw;
|
||||
offsetY = 0;
|
||||
}
|
||||
return { height: h, width: w, offsetX, offsetY };
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
import { DrawContainer, DrawElement } from "./draw"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
interface PropDimGroup {
|
||||
x?: number,
|
||||
y?: number,
|
||||
rotate?: number
|
||||
}
|
||||
|
||||
|
||||
interface SvgOptionsGroup {
|
||||
rotate_winkel?: number
|
||||
rotate_posX?: number
|
||||
rotate_posY?: number
|
||||
translate_x?: number
|
||||
translate_y?: number
|
||||
}
|
||||
|
||||
|
||||
export class DrawGroup extends DrawContainer {
|
||||
|
||||
attributes = new Map<string, string | number>();
|
||||
|
||||
constructor(private posDim: PropDimGroup) {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
setAtrr(att: Partial<SvgOptionsGroup>) {
|
||||
Object.entries(att).forEach(([key, value]) => {
|
||||
this.attributes.set(key, value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
getRotatetOption(): { winkel: number, posX: number, posY: number } | undefined {
|
||||
let winkel = this.attributes.get('rotate_winkel') as number;
|
||||
|
||||
let posX = this.attributes.get('rotate_posX') as number;
|
||||
let posY = this.attributes.get('rotate_posY') as number;
|
||||
if (!winkel) return undefined;
|
||||
let obj = {
|
||||
winkel: winkel,
|
||||
posX: posX ? posX : 0,
|
||||
posY: posY ? posY : 0
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
drawElementSvg(options?: string): { start: string, end: string } {
|
||||
// Check if Rotatate option set
|
||||
let rotate = this.getRotatetOption()
|
||||
let translate_x = this.attributes.get('translate_x') as number;
|
||||
let translate_y = this.attributes.get('translate_y') as number;
|
||||
let transformStr = ""
|
||||
if (translate_x || translate_y) {
|
||||
let x = translate_x ? translate_x : 0;
|
||||
let y = translate_y ? translate_y : 0;
|
||||
transformStr = `translate(${x} ${y}) `
|
||||
}
|
||||
|
||||
let rotateString = "";
|
||||
if (rotate) {
|
||||
rotateString = `transform="${transformStr}rotate(${rotate.winkel} ${rotate.posX} ${rotate.posY})"`
|
||||
}
|
||||
|
||||
return { start: `<g ${rotateString}>`, end: '</g>' }
|
||||
}
|
||||
|
||||
drawElementXaml(options?: string): { start: string, end: string } {
|
||||
let rotate = this.getRotatetOption()
|
||||
let translate_x = this.attributes.get('translate_x') as number;
|
||||
let translate_y = this.attributes.get('translate_y') as number;
|
||||
|
||||
let transformStr = "";
|
||||
if (rotate!=undefined || translate_x!=undefined || translate_y!=undefined) {
|
||||
let renderStart =
|
||||
` <Canvas.RenderTransformOrigin>0.5,0.5</Canvas.RenderTransformOrigin>
|
||||
<Canvas.RenderTransform><TransformGroup>`
|
||||
let renderEnd = `</TransformGroup></Canvas.RenderTransform>`
|
||||
|
||||
let rotateStr = rotate!=undefined ? `<RotateTransform Angle="${rotate.winkel}"/>`:""
|
||||
let translateXStr = translate_x!=undefined ? `X="${translate_x}"` : "";
|
||||
let translateYStr = translate_y!=undefined ? `Y="${translate_y}"` : "";
|
||||
let translateStr = translate_x!=undefined || translate_y != undefined ? ` <TranslateTransform ${translateXStr} ${translateYStr}/>`:"";
|
||||
transformStr = renderStart + rotateStr + translateStr + renderEnd;
|
||||
}
|
||||
/*
|
||||
` <Canvas.RenderTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="30"/>
|
||||
<TranslateTransform X="100" Y="50"/>
|
||||
</TransformGroup>
|
||||
</Canvas.RenderTransform>`
|
||||
*/
|
||||
return { start: `<Canvas> ${transformStr}`, end: '</Canvas>' }
|
||||
|
||||
}
|
||||
|
||||
getChildString(xaml: boolean, deph: number): string {
|
||||
|
||||
deph = deph + 1;
|
||||
|
||||
const reversedElements = Array.from(this.elements).reverse();
|
||||
let containerData = ''
|
||||
|
||||
for (const [key, value] of reversedElements) {
|
||||
let svgOfNextElement = ''
|
||||
|
||||
if (value instanceof DrawContainer) {
|
||||
svgOfNextElement = value.getChildString(xaml, deph)
|
||||
} else {
|
||||
const content = xaml ? value.drawXaml() : value.drawSvg();
|
||||
svgOfNextElement = "\t".repeat(deph) + content + '\n';
|
||||
}
|
||||
containerData += svgOfNextElement;
|
||||
}
|
||||
|
||||
const { start, end } = xaml ? this.drawElementXaml() : this.drawElementSvg();
|
||||
const group = "\t".repeat(deph - 1) + start + '\n' + containerData + "\t".repeat(deph - 1) + end + '\n'
|
||||
|
||||
return group;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
const group = (svg: string, options?: { x?: number, y?: number, rotate?: number }, xaml?: boolean) => {
|
||||
if (!options) options = { x: 0, y: 0, rotate: 0 };
|
||||
if (!options.x) options.x = 0;
|
||||
if (!options.y) options.y = 0;
|
||||
if (!options.rotate) options.rotate = 0;
|
||||
|
||||
let transform = '';
|
||||
let translate = '';
|
||||
let rotate = ''
|
||||
if (options.x > 0 || options.y > 0) translate = `translate(${options.x},${options.y})`
|
||||
if (options.rotate != 0) rotate = `rotate(${options.rotate} ${0} ${0})`
|
||||
if (options.x > 0 || options.y > 0 || options.rotate != 0) transform = `transform="${translate} ${rotate}"`
|
||||
|
||||
// XAML
|
||||
let x_left = `Left="${options.x}"`;
|
||||
let x_top = `Top="${options.y}"`;
|
||||
let x_rotate = '';
|
||||
if (options.rotate != 0) x_rotate =
|
||||
`
|
||||
<Canvas.RenderTransform>
|
||||
<RotateTransform Angle="${options.rotate}" CenterX="${0}" CenterY="${0}" />
|
||||
</Canvas.RenderTransform>`
|
||||
if (options.x > 0) x_left = ''
|
||||
|
||||
let group =
|
||||
`<g ${transform}>
|
||||
${svg}
|
||||
</g>`
|
||||
|
||||
let xgroup =
|
||||
`<Canvas ${x_left} ${x_top}>
|
||||
${svg} ${x_rotate}
|
||||
</Canvas>`
|
||||
|
||||
|
||||
if (xaml) return xgroup;
|
||||
return group;
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
import { DrawContainer, DrawElement } from "./draw"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
interface PropDimHeader {
|
||||
lenght: number,
|
||||
height: number,
|
||||
}
|
||||
|
||||
|
||||
interface SvgOptionsGroup {
|
||||
dummy: number
|
||||
}
|
||||
|
||||
|
||||
export class DrawHeader extends DrawContainer {
|
||||
|
||||
attributes = new Map<string,string|number>();
|
||||
length: number;
|
||||
height: number;
|
||||
constructor(dim: PropDimHeader) {
|
||||
super();
|
||||
this.length = dim.lenght;
|
||||
this.height = dim.height;
|
||||
}
|
||||
|
||||
|
||||
setAtrr(att: Partial<SvgOptionsGroup>) {
|
||||
Object.entries(att).forEach(([key, value]) => {
|
||||
this.attributes.set(key, value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
drawElementSvg(options?: string):{start:string,end:string} {
|
||||
const optionString = this.getSvgOptions(this.length,this.height);
|
||||
const start_z1 = `<?xml version="1.0" ?>\n`
|
||||
const start_z2 = `<svg xmlns="http://www.w3.org/2000/svg"\n`
|
||||
const start_z3 = `${optionString} >\n`
|
||||
return {start:start_z1+start_z2+start_z3, end:'</svg>'}
|
||||
}
|
||||
|
||||
drawElementXaml(options?: string):{start:string,end:string} {
|
||||
const optionString = this.getXamlOptions(this.length,this.height);
|
||||
const z1 = `<?xml version="1.0" ?>\n`
|
||||
const z2 =`<Viewbox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">\n` // Stretch="Fill"
|
||||
const z3 =`<Canvas ${optionString}>\n`
|
||||
|
||||
return {start:z1+z2+z3,end:'</Canvas>\n</Viewbox>'}
|
||||
|
||||
}
|
||||
|
||||
getChildString(xaml: boolean,deph:number):string {
|
||||
|
||||
deph = deph +1;
|
||||
|
||||
const reversedElements = Array.from(this.elements).reverse();
|
||||
let containerData = ''
|
||||
|
||||
for (const [key, value] of reversedElements) {
|
||||
let svgOfNextElement = ''
|
||||
|
||||
if( value instanceof DrawContainer){
|
||||
svgOfNextElement = value.getChildString(xaml,deph)
|
||||
} else{
|
||||
const content = xaml?value.drawXaml():value.drawSvg();
|
||||
svgOfNextElement = "\t".repeat(deph) + content + '\n';
|
||||
}
|
||||
containerData += svgOfNextElement;
|
||||
}
|
||||
|
||||
const {start,end} = xaml ? this.drawElementXaml() : this.drawElementSvg();
|
||||
const group = "\t".repeat(deph-1) +start +'\n'+containerData+"\t".repeat(deph-1) + end + '\n'
|
||||
|
||||
return group;
|
||||
|
||||
}
|
||||
|
||||
getXamlOptions(length:number,height:number){
|
||||
return `Width="${length}" Height="${height}"`
|
||||
}
|
||||
|
||||
getSvgOptions(length:number,height:number){
|
||||
return `viewBox="0 0 ${length} ${height}"`
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
import { DrawElement } from "./draw"
|
||||
|
||||
/*
|
||||
const line = (data: PropLine, options?: SvgOptions, xaml?: boolean) => {
|
||||
let opt = { color: "#000000", storkWidth: 1, fill: 'none', dasharray: '' };
|
||||
if (options) opt = { ...opt, ...options };
|
||||
if (options && options.dasharray && !xaml) opt.dasharray = 'stroke-dasharray="' + options.dasharray + '"'
|
||||
if (options && options.dasharray && xaml) opt.dasharray = 'StrokeDashArray="' + options.dasharray + '"'.replace(',', ' ');
|
||||
|
||||
|
||||
|
||||
if(xaml) return xl;
|
||||
return l;
|
||||
}
|
||||
*/
|
||||
interface PropLine {
|
||||
x1: number,
|
||||
y1: number,
|
||||
x2: number,
|
||||
y2: number,
|
||||
}
|
||||
|
||||
interface SvgOptions {
|
||||
color?: string
|
||||
storkWidth?: number,
|
||||
dasharray?: string,
|
||||
fill?: string,
|
||||
opacity?: number
|
||||
}
|
||||
|
||||
|
||||
export class DrawLine extends DrawElement {
|
||||
|
||||
|
||||
|
||||
constructor(private posAndSize: PropLine) {
|
||||
super();
|
||||
|
||||
// Default Attribute
|
||||
this.attributes.set('strokeWidth', 1);
|
||||
this.attributes.set('stroke', "#000000");
|
||||
this.attributes.set('fill', 'none');
|
||||
}
|
||||
|
||||
|
||||
setAtrr(att: Partial<SvgOptions>) {
|
||||
Object.entries(att).forEach(([key, value]) => {
|
||||
this.attributes.set(key, value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
drawSvg() {
|
||||
const paraStr = this.convertAttributesToString(this.attributes);
|
||||
const posSvg = this.getSvgPositions(this.posAndSize)
|
||||
const posStr = this.convertAttributesToString(posSvg);
|
||||
|
||||
const shape = this.drawElementSvg(posStr, paraStr);
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
drawXaml(): string {
|
||||
const paraStr = this.convertAttributesToString(this.attributes, true);
|
||||
const posXaml = this.getXamlPositions(this.posAndSize)
|
||||
const posStr = this.convertAttributesToString(posXaml, true);
|
||||
|
||||
const shape = this.drawElementXaml(posStr, paraStr);
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
drawElementSvg(position: string, options: string) {
|
||||
return `<line ${position} ${options}></line>`
|
||||
}
|
||||
|
||||
drawElementXaml(position: string, options: string) {
|
||||
|
||||
return `<Line ${position} ${options}></Line>`
|
||||
|
||||
}
|
||||
|
||||
getSvgPositions(dim: PropLine) {
|
||||
|
||||
let retValue = new Map<string, number>();
|
||||
|
||||
retValue.set('x1', dim.x1);
|
||||
retValue.set('y1', dim.y1);
|
||||
retValue.set('x2', dim.x2);
|
||||
retValue.set('y2', dim.y2);
|
||||
|
||||
return retValue;
|
||||
|
||||
}
|
||||
|
||||
getXamlPositions(dim: PropLine) {
|
||||
let retValue = new Map<string, number>();
|
||||
|
||||
retValue.set('X1', dim.x1);
|
||||
retValue.set('Y1', dim.y1);
|
||||
retValue.set('X2', dim.x2);
|
||||
retValue.set('Y2', dim.y2);
|
||||
|
||||
return retValue;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
import { DrawElement } from "./draw"
|
||||
import {PathCommand,} from './types/path.types';
|
||||
|
||||
interface SvgOptions {
|
||||
color?: string
|
||||
storkWidth?: number,
|
||||
dasharray?: string,
|
||||
fill?: string,
|
||||
opacity?: number,
|
||||
stroke?:string,
|
||||
strokeWidth?:number
|
||||
}
|
||||
|
||||
|
||||
|
||||
export class DrawPath extends DrawElement {
|
||||
|
||||
|
||||
|
||||
constructor(private pathCommands: PathCommand[]) {
|
||||
super();
|
||||
|
||||
// Default Attribute
|
||||
this.attributes.set('strokeWidth', 2);
|
||||
this.attributes.set('stroke', "#202020");
|
||||
this.attributes.set('fill', 'none');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
setAtrr(att: Partial<SvgOptions>) {
|
||||
Object.entries(att).forEach(([key, value]) => {
|
||||
this.attributes.set(key, value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
drawSvg() {
|
||||
const paraStr = this.convertAttributesToString(this.attributes);
|
||||
const path = this.getCmdString(false)
|
||||
|
||||
|
||||
const shape = this.drawElementSvg(path, paraStr);
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
drawXaml(): string {
|
||||
const paraStr = this.convertAttributesToString(this.attributes, true);
|
||||
const path = this.getCmdString(true);
|
||||
const shape = this.drawElementXaml(path, paraStr);
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
drawElementSvg(pathCmd: string, options: string) {
|
||||
return `<path d="${pathCmd}" ${options}></path>`
|
||||
}
|
||||
|
||||
drawElementXaml(pathCmd: string, options: string) {
|
||||
|
||||
return `<Path Data="${pathCmd}" ${options}></Path>`
|
||||
|
||||
}
|
||||
|
||||
getCmdString(xaml: boolean = false) {
|
||||
const pathCmd = this.pathCommands.map(d => this.commandToString(d, xaml)).join(" ")
|
||||
|
||||
return pathCmd;
|
||||
|
||||
}
|
||||
|
||||
commandToString(cmd: PathCommand, xaml?: boolean): string {
|
||||
const prefix = cmd.relative && !xaml ? cmd.type.toLowerCase() : cmd.type;
|
||||
const separator = xaml ? "," : " ";
|
||||
switch (cmd.type) {
|
||||
case "M":
|
||||
case "L":
|
||||
return `${prefix} ${cmd.x}${separator}${cmd.y}`;
|
||||
|
||||
case "H":
|
||||
return `${prefix} ${cmd.x}`;
|
||||
|
||||
case "V":
|
||||
return `${prefix} ${cmd.y}`;
|
||||
|
||||
case "C":
|
||||
return `${prefix} ${cmd.x1}${separator}${cmd.y1} ${cmd.x2} ${cmd.y2} ${cmd.x}${separator}${cmd.y}`;
|
||||
|
||||
case "S":
|
||||
return `${prefix} ${cmd.x2} ${cmd.y2} ${cmd.x} ${cmd.y}`;
|
||||
|
||||
case "Q":
|
||||
return `${prefix} ${cmd.x1} ${cmd.y1} ${cmd.x} ${cmd.y}`;
|
||||
|
||||
case "T":
|
||||
return `${prefix} ${cmd.x} ${cmd.y}`;
|
||||
|
||||
case "A":
|
||||
return `${prefix} ${cmd.rx}${separator}${cmd.ry} ${cmd.xAxisRotation} ${cmd.largeArcFlag} ${cmd.sweepFlag} ${cmd.x}${separator}${cmd.y}`;
|
||||
|
||||
case "Z":
|
||||
return `${prefix}`;
|
||||
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
import { DrawElement } from "./draw"
|
||||
|
||||
|
||||
interface PropText {
|
||||
x: number,
|
||||
y: number,
|
||||
text:string
|
||||
}
|
||||
|
||||
interface SvgOptions {
|
||||
color?: string
|
||||
storkWidth?: number,
|
||||
dasharray?: string,
|
||||
fill?: string,
|
||||
opacity?: number
|
||||
}
|
||||
|
||||
|
||||
export class DrawText extends DrawElement {
|
||||
|
||||
|
||||
|
||||
constructor(private posAndText: PropText) {
|
||||
super();
|
||||
|
||||
// Default Attribute
|
||||
this.attributes.set('stroke', "#000000");
|
||||
|
||||
}
|
||||
|
||||
|
||||
setAtrr(att: Partial<SvgOptions>) {
|
||||
Object.entries(att).forEach(([key, value]) => {
|
||||
this.attributes.set(key, value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
drawSvg() {
|
||||
const paraStr = this.convertAttributesToString(this.attributes);
|
||||
const posSvg = this.getSvgPositions(this.posAndText)
|
||||
const posStr = this.convertAttributesToString(posSvg);
|
||||
|
||||
const shape = this.drawElementSvg(posStr,this.posAndText.text, paraStr);
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
drawXaml(): string {
|
||||
const paraStr = this.convertAttributesToString(this.attributes, true);
|
||||
//const posXaml = this.getXamlPositions(this.posAndText)
|
||||
//const posStr = this.convertAttributesToString(posXaml, true);
|
||||
|
||||
|
||||
const shape = this.drawElementXaml(this.posAndText.x,this.posAndText.y,this.posAndText.text, paraStr);
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
drawElementSvg(position: string,text:string, options: string) {
|
||||
return `<text ${position} ${options}>${text}</text>`
|
||||
}
|
||||
|
||||
drawElementXaml(posX:number,posY:number,text:string, options: string) {
|
||||
|
||||
return `<TextBlock Canvas.Left="${posX}"
|
||||
Canvas.Top="${posY}"
|
||||
Foreground="#000000"
|
||||
Text="${text}"
|
||||
FontSize="16"
|
||||
FontWeight="Bold"/>`
|
||||
|
||||
}
|
||||
|
||||
getSvgPositions(dim: PropText) {
|
||||
|
||||
let retValue = new Map<string, number>();
|
||||
|
||||
retValue.set('x', dim.x);
|
||||
retValue.set('y', dim.y);
|
||||
|
||||
|
||||
return retValue;
|
||||
|
||||
}
|
||||
|
||||
getXamlPositions(dim: PropText) {
|
||||
let retValue = new Map<string, number>();
|
||||
|
||||
retValue.set('X', dim.x);
|
||||
retValue.set('Y', dim.y);
|
||||
|
||||
|
||||
return retValue;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Whitespace-only changes.
@@ -0,0 +1,104 @@
|
||||
|
||||
|
||||
/** Basis-Typ: alle Commands haben ein Flag ob relativ oder absolut */
|
||||
export interface PathBaseCommand {
|
||||
/** true = relativer Befehl (kleiner Buchstabe), false/undefined = absolut */
|
||||
relative?: boolean;
|
||||
}
|
||||
|
||||
/** Move-To */
|
||||
export interface MoveToCommand extends PathBaseCommand {
|
||||
type: "M";
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
/** Line-To */
|
||||
export interface LineToCommand extends PathBaseCommand {
|
||||
type: "L";
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
/** Horizontal Line-To */
|
||||
export interface HorizontalLineToCommand extends PathBaseCommand {
|
||||
type: "H";
|
||||
x: number;
|
||||
}
|
||||
|
||||
/** Vertical Line-To */
|
||||
export interface VerticalLineToCommand extends PathBaseCommand {
|
||||
type: "V";
|
||||
y: number;
|
||||
}
|
||||
|
||||
/** Cubic Bézier Curve */
|
||||
export interface CubicBezierCommand extends PathBaseCommand {
|
||||
type: "C";
|
||||
x1: number; y1: number;
|
||||
x2: number; y2: number;
|
||||
x: number; y: number;
|
||||
}
|
||||
|
||||
/** Smooth Cubic Bézier Curve */
|
||||
export interface SmoothCubicBezierCommand extends PathBaseCommand {
|
||||
type: "S";
|
||||
x2: number; y2: number;
|
||||
x: number; y: number;
|
||||
}
|
||||
|
||||
/** Quadratic Bézier Curve */
|
||||
export interface QuadraticBezierCommand extends PathBaseCommand {
|
||||
type: "Q";
|
||||
x1: number; y1: number;
|
||||
x: number; y: number;
|
||||
}
|
||||
|
||||
/** Smooth Quadratic Bézier Curve */
|
||||
export interface SmoothQuadraticBezierCommand extends PathBaseCommand {
|
||||
type: "T";
|
||||
x: number; y: number;
|
||||
}
|
||||
|
||||
/** Elliptical Arc */
|
||||
export interface ArcCommand extends PathBaseCommand {
|
||||
type: "A";
|
||||
rx: number;
|
||||
ry: number;
|
||||
xAxisRotation: number;
|
||||
largeArcFlag: 0 | 1;
|
||||
sweepFlag: 0 | 1;
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
/** Close Path */
|
||||
export interface ClosePathCommand extends PathBaseCommand {
|
||||
type: "Z";
|
||||
}
|
||||
|
||||
/** Union aller Path-Kommandos */
|
||||
export type PathCommand =
|
||||
| MoveToCommand
|
||||
| LineToCommand
|
||||
| HorizontalLineToCommand
|
||||
| VerticalLineToCommand
|
||||
| CubicBezierCommand
|
||||
| SmoothCubicBezierCommand
|
||||
| QuadraticBezierCommand
|
||||
| SmoothQuadraticBezierCommand
|
||||
| ArcCommand
|
||||
| ClosePathCommand;
|
||||
|
||||
/** Ein ganzer Pfad ist einfach eine Liste von Kommandos */
|
||||
export type SvgPath = PathCommand[];
|
||||
|
||||
|
||||
|
||||
|
||||
interface PropDimPath {
|
||||
cx: number
|
||||
cy: number
|
||||
rx: number
|
||||
ry: number
|
||||
}
|
||||
Reference in new issue
Block a user