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

Move edge names when moving edges in network area diagram #77

Merged
merged 2 commits into from
Jun 19, 2024

Conversation

massimo-ferraro
Copy link
Contributor

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?
no

What kind of change does this PR introduce?
Bug fix

What is the current behavior?
In network area diagram, when moving an edge (due to the movement of a voltage level node) the edge name, if displayed, is not moved

What is the new behavior (if this is a feature change)?
When moving an edge (following the movement of a voltage level node) the edge name is correctly moved

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

Signed-off-by: massimo.ferraro <massimo.ferraro@soft.it>
Comment on lines 447 to 462
const nameElement: SVGGraphicsElement =
edgeNode.lastElementChild as SVGGraphicsElement;
if (
nameElement != null &&
nameElement.tagName == 'g' &&
(nameElement.id == null || nameElement.id.length == 0)
) {
// get DOM element containing name position
const namePositionElement: SVGGraphicsElement =
nameElement.lastElementChild as SVGGraphicsElement;
if (
namePositionElement != null &&
namePositionElement.tagName == 'g' &&
(namePositionElement.id == null ||
namePositionElement.id.length == 0)
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could avoid all this with a querySelector, it would be more robust

const edgeNamePositionElement: SVGGraphicsElement =
        edgeNode.querySelector(".nad-edge-label") as SVGGraphicsElement;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used querySelector for getting the element

Comment on lines 465 to 472
const nameAngleElement: SVGGraphicsElement =
namePositionElement.lastElementChild as SVGGraphicsElement;
if (
nameAngleElement != null &&
nameAngleElement.tagName == 'text'
) {
edgeNameAngleElement = nameAngleElement;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly

const edgeNameAngleElement: SVGGraphicsElement =
        edgeNamePositionElement.querySelector("text") as SVGGraphicsElement;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used querySelector for getting the element

anchorPoint: Point,
edgeStart: Point
) {
const edgeNameElements = DiagramUtils.getEdgeNameElements(edgeNode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as the content of DiagramUtils.getEdgeNameElements is very compact with querySelectors, I think you can remove it and call the querySelectors directly here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed DiagramUtils function and used querySelector for getting the elements in this method

Signed-off-by: massimo.ferraro <massimo.ferraro@soft.it>
@flo-dup flo-dup merged commit 8f32510 into integration/nad_interactive Jun 19, 2024
6 checks passed
@flo-dup flo-dup deleted the nad_move_edge_names branch June 19, 2024 08:31
flo-dup pushed a commit that referenced this pull request Jul 22, 2024
* Make single-bus voltage level nodes movable in network area diagram (#59)
* Move voltage level nodes with multiple buses in network area diagram (#65)
* Fix node moving when zooming out after node selection in network area diagram (#71)
* Move 3wt, dangling lines and voltage levels with unknown buses in nad viewer (#66)
* Move nodes of uncomplete networks in network area diagram SVG (#68)
* Update metadata and add callback for node moving in network area diagram (#73)
* Move edge names when moving edges in network area diagram (#77)
* Read SVG parameters from metadata in network area diagram (#79)
* Add flag for enabling node moving (#80)
* Add a transparent fill to unknown buses and three windings transformers in network area diagram (#81)

Signed-off-by: massimo.ferraro <massimo.ferraro@soft.it>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants