Added isolations end markers

+Added isolation end markers rendering on the Isolations layer
*Renamed the “Isolations IDs” layer to “Isolations”
This commit is contained in:
izawartka 2025-07-11 01:28:41 +02:00
parent 2d5c0baba6
commit dfe90bfd2d
3 changed files with 46 additions and 11 deletions

View File

@ -32,6 +32,11 @@
fill: #ffa;
}
.map svg path.isolation-end-marker {
stroke: #ffa;
stroke-width: 0.5px;
}
.map svg g.track-object circle {
fill: #eee;
}

View File

@ -1,4 +1,6 @@
import { useMemo } from "react";
import SimpleLabelText from "../text/SimpleLabelText";
import { TrackConnectionType } from "../../../model/track-connection";
export default function IsolationIdRenderer(props) {
const { object } = props;
@ -6,16 +8,43 @@ export default function IsolationIdRenderer(props) {
const [x, y] = pos.toSVGCoords();
const text = object.id_isolation ?? '';
if (object.hide_isolation || !text) {
return null;
}
const showText = (!object.hide_isolation && !!text);
return <SimpleLabelText
text={text}
x={x}
y={y}
textProps={{
className: "isolation-id"
}}
/>
return (<>
{showText && <SimpleLabelText
text={text}
x={x}
y={y}
textProps={{
className: "isolation-id"
}}
/>}
<IsolationEndMarker object={object} isStart={true} />
<IsolationEndMarker object={object} />
</>);
}
function IsolationEndMarker(props) {
const { object, isStart = false } = props;
const isShown = useMemo(() => {
return object.connections.some(conn =>
(isStart ? conn.type === TrackConnectionType.START : conn.type === TrackConnectionType.END) &&
conn.otherTrack.id_isolation !== object.id_isolation
);
}, [object, isStart]);
if (!isShown) return null;
const pos = isStart ? object.points.start : object.points.end;
const [x, y] = pos.toSVGCoords();
const angle = isStart ? object.getStartAngleXZ() : object.getEndAngleXZ();
const cos = Math.cos(angle);
const sin = Math.sin(angle);
return <path
className="isolation-end-marker"
d={`M ${x - 1.5 * cos} ${y - 1.5 * sin} L ${x + 1.5 * cos} ${y + 1.5 * sin}`}
/>
}

View File

@ -76,6 +76,7 @@ const Constants = {
{
id: 'isolations-ids',
name: 'Isolations IDs',
name: 'Isolations',
default: false,
},
{