powsybl / powsybl-diagram-viewer

Other
2 stars 1 forks source link

[nad-viewer] Make voltage level nodes movable #41

Closed flo-dup closed 2 months ago

flo-dup commented 7 months ago

Describe the current behavior

The typescript network-area diagram viewer is static: https://github.com/powsybl/powsybl-diagram-viewer/blob/main/src/network-area-diagram-viewer.ts

Describe the expected behavior

The typescript network-area diagram viewer allows to move nodes

Describe the motivation

use case: the users want to rearrange the positions calculated from powsybl-network-area-diagram layout.

Extra Information

A proof-of-concept has been done in powsybl/powsybl-dev-tools#59. The corresponding javascript is available here. This promising POC was not redrawing anything but only adding geometrical transformation to modified objects, using the metadata which is inside the SVG. This POC has nonetheless limitations listed below, which forces us to recompute ("redraw") some part of the SVG.

This javascript can be used as a starting point for developing the feature. Note that it should be first translated into typescript.

The limitations of that POC are:

  1. it's not feasible to move properly the concentric annuli (circles) with any transformation, as the holes in the circles are completely different: this needs to be redrawn using typescript transcription of the corresponding java code.
    • Note that the metadata which is now in the svg is missing informations to be able to redraw the node. A pull request would be needed on powsybl-diagram side to add this information to metadata.
    • Note that the neighbouring nodes of the moved node might need to be redrawn

Before moving: beforemoving After moving: aftermoving

  1. the parallel lines are stretched when moving the node, and as a consequence arrows on the lines (which are at fixed distance) might not be on the lines anymore: this also needs to be redrawn by recomputing the positions of the half-line 3 corresponding points using typescript transcription of the corresponding java code. Note that if current metadata is not enough to redraw the line, the needed metadata should be listed and added on powsybl-diagram side.

Before moving: beforemoving After moving: aftermoving

  1. the half-lines are not stretched properly when the node is moved closer to its neighbour. This problem also justifies the need to redraw lines.

Before moving: beforemoving After moving: aftermoving

flo-dup commented 7 months ago

Note that the POC was also using the classes of SVG objects to move them. With glued / stretchable classes, see powsybl/powsybl-diagram#459, which allows to identify the part which should remain at fixed distance of the moved node / of its neighbours. This mechanism seems to me more complex than redrawing, at least for the 2 or 3 points of the half-lines. As we plan here to redraw lines, it could therefore be removed, both from powsybl-diagram and from the javascript.