Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SY-1217 schematic edges incorrectly positioned #829

Merged
merged 7 commits into from
Sep 16, 2024
6,964 changes: 6,964 additions & 0 deletions console/src-tauri/gen/schemas/windows-schema.json
emilbon99 marked this conversation as resolved.
Show resolved Hide resolved
emilbon99 marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion console/src/schematic/Schematic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ export const Loaded: Layout.Renderer = ({ layoutKey }) => {
onViewportChange={handleViewportChange}
edges={schematic.edges}
nodes={schematic.nodes}
viewport={schematic.viewport}
viewport={{ ...schematic.viewport, zoom: 1 }}
// viewport={schematic.viewport}
emilbon99 marked this conversation as resolved.
Show resolved Hide resolved
onEdgesChange={handleEdgesChange}
onNodesChange={handleNodesChange}
onEditableChange={handleEditableChange}
Expand Down
1 change: 1 addition & 0 deletions pluto/src/vis/diagram/aether/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export const translateNodesForward = (nodes: Node[]): rf.Node[] =>
...node,
id: node.key,
type: "custom",
zIndex: 8,
data: {},
}));

Expand Down
2 changes: 0 additions & 2 deletions pluto/src/vis/diagram/edge/Edge.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
}
}


.react-flow__edge {
z-index: 6;

}

.react-flow__edge.selected {
Expand Down
5 changes: 3 additions & 2 deletions pluto/src/vis/diagram/edge/connector/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,16 @@ export const segmentsToPoints = (
firstSeg.length,
);
const firstMag = orientationMagnitude(firstSegOrientation);
const zoomMultiplier = 4 * (2 - zoom ** 0.5);
points[0] = xy.translate(points[0], {
[firstSeg.direction]: -1 * firstMag * 4 * zoom,
[firstSeg.direction]: -1 * firstMag * zoomMultiplier,
[direction.swap(firstSeg.direction)]: 0,
} as const as xy.XY);
const lastSeg = segments[segments.length - 1];
const lastSegOrientation = orientationFromLength(lastSeg.direction, lastSeg.length);
const lastMag = orientationMagnitude(lastSegOrientation);
points[points.length - 1] = xy.translate(points[points.length - 1], {
[lastSeg.direction]: lastMag * 4 * zoom,
[lastSeg.direction]: lastMag * zoomMultiplier,
[direction.swap(lastSeg.direction)]: 0,
} as const as xy.XY);

Expand Down
2 changes: 1 addition & 1 deletion pluto/src/vis/diagram/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const selectNodeBox = (flow: ReactFlowInstance, key: string): box.Box =>
const n = selectNode(key);
const flowN = flow.getNodes().find((n) => n.id === key);
if (flowN == null) throw new Error(`[diagram] - cannot find node with key: ${key}`);
return box.construct(flowN.position, box.dims(box.construct(n)));
return box.construct(flowN.position, xy.scale(box.dims(box.construct(n)), 1 / flow.getZoom()));
};

export const selectNodeLayout = (key: string, flow: ReactFlowInstance): NodeLayout => {
Expand Down
2 changes: 1 addition & 1 deletion pluto/src/vis/schematic/primitives/Primitives.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ export const Tank = ({
{...props}
>
<HandleBoundary>
<Handle location="top" orientation="left" left={50} top={0} id="1" />
<Handle location="top" orientation="left" left={50} top={-1} id="1" />
emilbon99 marked this conversation as resolved.
Show resolved Hide resolved
{hasCornerBoundaries && (
<>
<Handle
Expand Down
Loading