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:
parent
2d5c0baba6
commit
dfe90bfd2d
@ -32,6 +32,11 @@
|
|||||||
fill: #ffa;
|
fill: #ffa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.map svg path.isolation-end-marker {
|
||||||
|
stroke: #ffa;
|
||||||
|
stroke-width: 0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
.map svg g.track-object circle {
|
.map svg g.track-object circle {
|
||||||
fill: #eee;
|
fill: #eee;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
|
import { useMemo } from "react";
|
||||||
import SimpleLabelText from "../text/SimpleLabelText";
|
import SimpleLabelText from "../text/SimpleLabelText";
|
||||||
|
import { TrackConnectionType } from "../../../model/track-connection";
|
||||||
|
|
||||||
export default function IsolationIdRenderer(props) {
|
export default function IsolationIdRenderer(props) {
|
||||||
const { object } = props;
|
const { object } = props;
|
||||||
@ -6,16 +8,43 @@ export default function IsolationIdRenderer(props) {
|
|||||||
const [x, y] = pos.toSVGCoords();
|
const [x, y] = pos.toSVGCoords();
|
||||||
const text = object.id_isolation ?? '';
|
const text = object.id_isolation ?? '';
|
||||||
|
|
||||||
if (object.hide_isolation || !text) {
|
const showText = (!object.hide_isolation && !!text);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <SimpleLabelText
|
return (<>
|
||||||
text={text}
|
{showText && <SimpleLabelText
|
||||||
x={x}
|
text={text}
|
||||||
y={y}
|
x={x}
|
||||||
textProps={{
|
y={y}
|
||||||
className: "isolation-id"
|
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}`}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,6 +76,7 @@ const Constants = {
|
|||||||
{
|
{
|
||||||
id: 'isolations-ids',
|
id: 'isolations-ids',
|
||||||
name: 'Isolations IDs',
|
name: 'Isolations IDs',
|
||||||
|
name: 'Isolations',
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user