visualisierung
This commit is contained in:
1 parent
d0655f3638
commit
367c93c93e
84 files changed
+2265
-148
No files matched your search
@@ -5,7 +5,9 @@ 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 { DrawDataDto, DrawDto, DrawShapeOptionenDto } from "src/_dto/draw.dto";
|
||||
import type { GraphicGenerator } from './graphic-generator';
|
||||
import type { MotorConfig, MotorOptions } from './types';
|
||||
import { DrawHeader } from "../lib/drawHeader";
|
||||
|
||||
interface Para {
|
||||
@@ -14,7 +16,7 @@ interface Para {
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class DrawMotor {
|
||||
export class DrawMotor implements GraphicGenerator<MotorConfig, MotorOptions> {
|
||||
scale = 0;
|
||||
winkel = 0;
|
||||
raster = 4;
|
||||
@@ -35,9 +37,9 @@ export class DrawMotor {
|
||||
|
||||
|
||||
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 color = optionen?.colorInactive ?? this.normal;
|
||||
if (optionen && optionen.state == 'active') color = optionen.colorActive ?? this.green;
|
||||
if (optionen && optionen.state == 'error') color = optionen.colorError ?? this.red;
|
||||
|
||||
|
||||
let raster = 4.0;
|
||||
@@ -65,7 +67,10 @@ export class DrawMotor {
|
||||
|
||||
|
||||
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" });
|
||||
const z_text = new DrawText({
|
||||
x: 0, y: 0, text: "M",
|
||||
centeredBox: { width: obj_w, height: obj_h, fontSize: obj_h * 0.6 },
|
||||
});
|
||||
z_kreis.setAtrr({ fill: color })
|
||||
|
||||
|
||||
@@ -88,6 +93,23 @@ export class DrawMotor {
|
||||
|
||||
}
|
||||
|
||||
getObject(config: MotorConfig, options?: Partial<MotorOptions>): DrawDataDto {
|
||||
const width = 3 * config.raster * config.scale;
|
||||
const states = ['inactive', 'active', 'error'] as const;
|
||||
const graphics = states.map(state => {
|
||||
const group = this.create({ ...config, ...options, state });
|
||||
const header = new DrawHeader({ lenght: width, height: width });
|
||||
header.add(group);
|
||||
return { state, svg: header.getChildString(false, 0), xaml: header.getChildString(true, 0) };
|
||||
});
|
||||
return {
|
||||
name: 'motor',
|
||||
width,
|
||||
height: width,
|
||||
varianten: graphics.map(item => ({ ...item, xamlBase64: Buffer.from(item.xaml, 'utf8').toString('base64') })),
|
||||
};
|
||||
}
|
||||
|
||||
getDrawObject(optionen?: DrawShapeOptionenDto): DrawDto {
|
||||
const groupSvg = this.create(optionen)
|
||||
const svg = groupSvg.getChildString(false, 0)
|
||||
|
||||
Reference in new issue
Block a user