2026_08_31

This commit is contained in:
marco committed 2026-08-31 16:19:06 +02:00
commit 73015386e9
2320 files changed
+80291

No files matched your search

+270
View File
@@ -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);
}
}