DXF-Import: TEXT/MTEXT -> editierbarer Plan-Text (Drawing2D text-Primitiv, SVG-Render)
This commit is contained in:
+35
-1
@@ -15,7 +15,7 @@
|
||||
//
|
||||
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
|
||||
|
||||
import type { Contour, ContourSet, Drawing2D, Drawing2DGeom } from "../model/types";
|
||||
import type { Contour, ContourSet, Drawing2D, Drawing2DGeom, ImportedText } from "../model/types";
|
||||
|
||||
/** Wie DXF-Layer auf Kategorien abgebildet werden. */
|
||||
export type CategoryMode = "active" | "byLayer";
|
||||
@@ -66,6 +66,40 @@ export function contoursToDrawings(
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wandelt importierte Texte in Drawing2D-`text`-Elemente um — analog
|
||||
* `contoursToDrawings` (gleiche Layer→Kategorie-Zuordnung). Winkel/Höhe kommen
|
||||
* 1:1 aus `ImportedText` (Höhe in Modell-Metern, Winkel in Radiant).
|
||||
*/
|
||||
export function textsToDrawings(
|
||||
texts: ImportedText[],
|
||||
levelId: string,
|
||||
categoryMode: CategoryMode,
|
||||
fallbackCode: string,
|
||||
layerToCode: (layerName: string) => string,
|
||||
): Drawing2D[] {
|
||||
const out: Drawing2D[] = [];
|
||||
for (const it of texts) {
|
||||
const layerName = it.layer ?? "";
|
||||
const categoryCode =
|
||||
categoryMode === "byLayer" && layerName ? layerToCode(layerName) : fallbackCode;
|
||||
out.push({
|
||||
id: nextId(),
|
||||
type: "drawing2d",
|
||||
levelId,
|
||||
categoryCode,
|
||||
geom: {
|
||||
shape: "text",
|
||||
at: { ...it.at },
|
||||
text: it.text,
|
||||
height: it.height,
|
||||
angle: it.angle,
|
||||
},
|
||||
});
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Eine Kontur → 2D-Geometrie (line bei 2 offenen Punkten, sonst polyline). */
|
||||
function contourGeom(contour: Contour): Drawing2DGeom | null {
|
||||
const pts = contour.pts;
|
||||
|
||||
Reference in New Issue
Block a user