Skip to content

Commit

Permalink
SY-1217 schematic edges incorrectly positioned (#829)
Browse files Browse the repository at this point in the history
* [console] - fixed incorrectly positioned items on layout laod

* [console] - fixed schematic endpoints positioned incorrectly

* [console] - removed commented out code and added documentation for an unintuitive section

* [console] - removed commented out code and added documentation for an unintuitive section

* [console] - adjusted tank handle offset slightly

---------

Co-authored-by: Elham Islam <elham@synnaxlabs.com>
  • Loading branch information
emilbon99 and Lham42 authored Sep 16, 2024
1 parent 6956983 commit 3c6a44d
Show file tree
Hide file tree
Showing 6 changed files with 6,973 additions and 6 deletions.
6,964 changes: 6,964 additions & 0 deletions console/src-tauri/gen/schemas/windows-schema.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion console/src/schematic/Schematic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,10 @@ export const Loaded: Layout.Renderer = ({ layoutKey }) => {
onViewportChange={handleViewportChange}
edges={schematic.edges}
nodes={schematic.nodes}
viewport={schematic.viewport}
// Turns out that setting the zoom value to 1 here doesn't have any negative
// effects on teh schematic sizing and ensures that we position all the lines
// in the correct place.
viewport={{ ...schematic.viewport, zoom: 1 }}
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

0 comments on commit 3c6a44d

Please sign in to comment.