From 4a02a6113f561d36bf93c88cad841128be1da6d0 Mon Sep 17 00:00:00 2001 From: jamal-khey Date: Thu, 12 Dec 2024 16:41:10 +0100 Subject: [PATCH 1/2] fix zoom in NAD (#134) Signed-off-by: jamal-khey --- .../network-area-diagram-viewer/network-area-diagram-viewer.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/network-area-diagram-viewer/network-area-diagram-viewer.ts b/src/components/network-area-diagram-viewer/network-area-diagram-viewer.ts index ff17b69f..00830257 100644 --- a/src/components/network-area-diagram-viewer/network-area-diagram-viewer.ts +++ b/src/components/network-area-diagram-viewer/network-area-diagram-viewer.ts @@ -335,7 +335,6 @@ export class NetworkAreaDiagramViewer { zoomMin: 0.5 / this.ratio, // maximum zoom OUT ratio (0.5 = at best, the displayed area is twice the SVG's size) zoomMax: 20 * this.ratio, // maximum zoom IN ratio (20 = at best, the displayed area is only 1/20th of the SVG's size) zoomFactor: 0.2, - margins: { top: 0, left: 0, right: 0, bottom: 0 }, }); } From 936ab02ba6eb321bf68f7c61570e30a51273ea31 Mon Sep 17 00:00:00 2001 From: Massimo Ferraro Date: Fri, 20 Dec 2024 15:25:46 +0100 Subject: [PATCH 2/2] Fix moving of fictitious voltage level nodes in NAD viewer (#141) Signed-off-by: massimo.ferraro --- .../data/nad-ieee14cdf-solved.svg | 56 +++++++++---------- .../data/nad-ieee14cdf-solved_metadata.json | 6 +- .../diagram-metadata.ts | 2 + .../diagram-utils.test.ts | 20 +++++++ .../diagram-utils.ts | 5 ++ .../network-area-diagram-viewer.ts | 20 ++++--- .../svg-parameters.ts | 8 +++ 7 files changed, 79 insertions(+), 38 deletions(-) diff --git a/demo/src/diagram-viewers/data/nad-ieee14cdf-solved.svg b/demo/src/diagram-viewers/data/nad-ieee14cdf-solved.svg index dc731adb..4c59d10c 100644 --- a/demo/src/diagram-viewers/data/nad-ieee14cdf-solved.svg +++ b/demo/src/diagram-viewers/data/nad-ieee14cdf-solved.svg @@ -120,7 +120,7 @@ path.nad-arrow-in:not(.nad-state-in .nad-arrow-in) {visibility: hidden} - + @@ -129,15 +129,15 @@ path.nad-arrow-in:not(.nad-state-in .nad-arrow-in) {visibility: hidden} - + - - - + + + @@ -150,7 +150,7 @@ path.nad-arrow-in:not(.nad-state-in .nad-arrow-in) {visibility: hidden} - + @@ -162,8 +162,8 @@ path.nad-arrow-in:not(.nad-state-in .nad-arrow-in) {visibility: hidden} - - + + @@ -280,7 +280,7 @@ path.nad-arrow-in:not(.nad-state-in .nad-arrow-in) {visibility: hidden} - + @@ -292,8 +292,8 @@ path.nad-arrow-in:not(.nad-state-in .nad-arrow-in) {visibility: hidden} - - + + @@ -306,8 +306,8 @@ path.nad-arrow-in:not(.nad-state-in .nad-arrow-in) {visibility: hidden} - - + + @@ -318,7 +318,7 @@ path.nad-arrow-in:not(.nad-state-in .nad-arrow-in) {visibility: hidden} - + @@ -410,8 +410,8 @@ path.nad-arrow-in:not(.nad-state-in .nad-arrow-in) {visibility: hidden} - - + + @@ -422,7 +422,7 @@ path.nad-arrow-in:not(.nad-state-in .nad-arrow-in) {visibility: hidden} - + @@ -436,8 +436,8 @@ path.nad-arrow-in:not(.nad-state-in .nad-arrow-in) {visibility: hidden} - - + + @@ -448,7 +448,7 @@ path.nad-arrow-in:not(.nad-state-in .nad-arrow-in) {visibility: hidden} - + @@ -462,8 +462,8 @@ path.nad-arrow-in:not(.nad-state-in .nad-arrow-in) {visibility: hidden} - - + + @@ -474,7 +474,7 @@ path.nad-arrow-in:not(.nad-state-in .nad-arrow-in) {visibility: hidden} - + @@ -685,10 +685,10 @@ path.nad-arrow-in:not(.nad-state-in .nad-arrow-in) {visibility: hidden} - + - + @@ -805,19 +805,19 @@ path.nad-arrow-in:not(.nad-state-in .nad-arrow-in) {visibility: hidden} diff --git a/demo/src/diagram-viewers/data/nad-ieee14cdf-solved_metadata.json b/demo/src/diagram-viewers/data/nad-ieee14cdf-solved_metadata.json index 1c35fabb..9ac0d2df 100644 --- a/demo/src/diagram-viewers/data/nad-ieee14cdf-solved_metadata.json +++ b/demo/src/diagram-viewers/data/nad-ieee14cdf-solved_metadata.json @@ -159,7 +159,8 @@ "svgId" : "6", "equipmentId" : "VL12", "x" : 694.18, - "y" : 76.12 + "y" : 76.12, + "fictitious" : true }, { "svgId" : "8", "equipmentId" : "VL13", @@ -174,7 +175,8 @@ "svgId" : "12", "equipmentId" : "VL2", "x" : 62.4, - "y" : -384.58 + "y" : -384.58, + "fictitious" : true }, { "svgId" : "14", "equipmentId" : "VL3", diff --git a/src/components/network-area-diagram-viewer/diagram-metadata.ts b/src/components/network-area-diagram-viewer/diagram-metadata.ts index 1725af08..306d3d26 100644 --- a/src/components/network-area-diagram-viewer/diagram-metadata.ts +++ b/src/components/network-area-diagram-viewer/diagram-metadata.ts @@ -31,6 +31,7 @@ export interface SvgParametersMetadata { nodeHollowWidth: number; unknownBusNodeExtraRadius: number; edgeNameDisplayed: boolean; + fictitiousVoltageLevelCircleRadius: number; } export interface BusNodeMetadata { @@ -46,6 +47,7 @@ export interface NodeMetadata { equipmentId: string; x: number; y: number; + fictitious?: boolean; } export interface EdgeMetadata { diff --git a/src/components/network-area-diagram-viewer/diagram-utils.test.ts b/src/components/network-area-diagram-viewer/diagram-utils.test.ts index eb14acfe..1801acfb 100644 --- a/src/components/network-area-diagram-viewer/diagram-utils.test.ts +++ b/src/components/network-area-diagram-viewer/diagram-utils.test.ts @@ -344,6 +344,26 @@ test('getTextNodeMoves', () => { expect(textNodeMove[1].yNew).toBe(-53.76); }); +test('isVlNodeFictitious', () => { + const nodes: NodeMetadata[] = [ + { + svgId: '0', + equipmentId: 'vl', + x: 189.53, + y: 123.47, + }, + { + svgId: '2', + equipmentId: 'vl2', + x: -171.8, + y: 131.88, + fictitious: true, + }, + ]; + expect(DiagramUtils.isVlNodeFictitious('0', nodes)).toBe(false); + expect(DiagramUtils.isVlNodeFictitious('2', nodes)).toBe(true); +}); + function getSvgNode(): SVGGraphicsElement { const nodeSvg = '' + diff --git a/src/components/network-area-diagram-viewer/diagram-utils.ts b/src/components/network-area-diagram-viewer/diagram-utils.ts index 50a2f10a..37aebced 100644 --- a/src/components/network-area-diagram-viewer/diagram-utils.ts +++ b/src/components/network-area-diagram-viewer/diagram-utils.ts @@ -521,3 +521,8 @@ export function getTextNodeMoves( { xOrig: textNode.connectionShiftX, yOrig: textNode.connectionShiftY, xNew: connXNew, yNew: connYNew }, ]; } + +export function isVlNodeFictitious(vlNodeId: string, nodes: NodeMetadata[] | undefined): boolean { + const node: NodeMetadata | undefined = nodes?.find((node) => node.svgId == vlNodeId); + return node?.fictitious ?? false; +} diff --git a/src/components/network-area-diagram-viewer/network-area-diagram-viewer.ts b/src/components/network-area-diagram-viewer/network-area-diagram-viewer.ts index 00830257..966a2532 100644 --- a/src/components/network-area-diagram-viewer/network-area-diagram-viewer.ts +++ b/src/components/network-area-diagram-viewer/network-area-diagram-viewer.ts @@ -551,7 +551,9 @@ export class NetworkAreaDiagramViewer { const nbNeighbours = busNodes !== undefined && busNodes.length > 1 ? busNodes.length - 1 : 0; const voltageLevelCircleRadius = DiagramUtils.getVoltageLevelCircleRadius( nbNeighbours, - this.svgParameters.getVoltageLevelCircleRadius() + DiagramUtils.isVlNodeFictitious(vlNode.id, this.diagramMetadata?.nodes) + ? this.svgParameters.getFictitiousVoltageLevelCircleRadius() + : this.svgParameters.getVoltageLevelCircleRadius() ); // compute text edge start and end const vlNodePosition = DiagramUtils.getPosition(vlNode); @@ -655,13 +657,15 @@ export class NetworkAreaDiagramViewer { return edgeNodes[0]?.id == this.draggedElement?.id ? edgeNodes[1] : edgeNodes[0]; } - private getNodeRadius(busNodeId: string): [number, number, number] { + private getNodeRadius(busNodeId: string, vlNodeId: string): [number, number, number] { const busNode: BusNodeMetadata | undefined = this.diagramMetadata?.busNodes.find( (busNode) => busNode.svgId == busNodeId ); return DiagramUtils.getNodeRadius( busNode?.nbNeighbours ?? 0, - this.svgParameters.getVoltageLevelCircleRadius(), + DiagramUtils.isVlNodeFictitious(vlNodeId, this.diagramMetadata?.nodes) + ? this.svgParameters.getFictitiousVoltageLevelCircleRadius() + : this.svgParameters.getVoltageLevelCircleRadius(), busNode?.index ?? 0, this.svgParameters.getInterAnnulusSpace() ); @@ -714,7 +718,7 @@ export class NetworkAreaDiagramViewer { angleFork2 ); const unknownBusNode1 = edge.busNode1 != null && edge.busNode1.length == 0; - const nodeRadius1 = this.getNodeRadius(edge.busNode1 != null ? edge.busNode1 : '-1'); + const nodeRadius1 = this.getNodeRadius(edge.busNode1 ?? '-1', edge.node1 ?? '-1'); const edgeStart1 = DiagramUtils.getPointAtDistance( DiagramUtils.getPosition(edgeNodes[0]), edgeFork1, @@ -723,7 +727,7 @@ export class NetworkAreaDiagramViewer { : nodeRadius1[1] ); const unknownBusNode2 = edge.busNode2 != null && edge.busNode2.length == 0; - const nodeRadius2 = this.getNodeRadius(edge.busNode2 != null ? edge.busNode2 : '-1'); + const nodeRadius2 = this.getNodeRadius(edge.busNode2 ?? '-1', edge.node2 ?? '-1'); const edgeStart2 = DiagramUtils.getPointAtDistance( DiagramUtils.getPosition(edgeNodes[1]), edgeFork2, @@ -775,9 +779,9 @@ export class NetworkAreaDiagramViewer { return; } // compute moved edge data: polyline points - const nodeRadius1 = this.getNodeRadius(edge.busNode1 != null ? edge.busNode1 : '-1'); + const nodeRadius1 = this.getNodeRadius(edge.busNode1 ?? '-1', edge.node1 ?? '-1'); const edgeStart1 = this.getEdgeStart(edge.busNode1, nodeRadius1[1], edgeNodes[0], edgeNodes[1]); - const nodeRadius2 = this.getNodeRadius(edge.busNode2 != null ? edge.busNode2 : '-1'); + const nodeRadius2 = this.getNodeRadius(edge.busNode2 ?? '-1', edge.node2 ?? '-1'); const edgeStart2 = this.getEdgeStart(edge.busNode2, nodeRadius2[1], edgeNodes[1], edgeNodes[0]); const edgeMiddle = DiagramUtils.getMidPosition(edgeStart1, edgeStart2); // move edge @@ -1172,7 +1176,7 @@ export class NetworkAreaDiagramViewer { // compute polyline points const edgeNodes = this.getEdgeNodes(edge); const threeWtMoved = edgeNodes[1]?.id == this.draggedElement?.id; - const nodeRadius1 = this.getNodeRadius(edge.busNode1 != null ? edge.busNode1 : '-1'); + const nodeRadius1 = this.getNodeRadius(edge.busNode1 ?? '-1', edge.node1 ?? '-1'); const edgeStart = this.getEdgeStart(edge.busNode1, nodeRadius1[1], edgeNodes[0], edgeNodes[1]); const translation = this.getTranslation(mousePosition); const edgeEnd = threeWtMoved diff --git a/src/components/network-area-diagram-viewer/svg-parameters.ts b/src/components/network-area-diagram-viewer/svg-parameters.ts index e904d1b9..fec65530 100644 --- a/src/components/network-area-diagram-viewer/svg-parameters.ts +++ b/src/components/network-area-diagram-viewer/svg-parameters.ts @@ -20,6 +20,7 @@ export class SvgParameters { static readonly NODE_HOLLOW_WIDTH_DEFAULT = 15.0; static readonly UNKNOWN_BUS_NODE_EXTRA_RADIUS_DEFAULT = 10.0; static readonly EDGE_NAME_DISPLAYED_DEFAULT = true; + static readonly FICTITIOUS_VOLTAGE_LEVEL_CIRCLE_RADIUS_DEFAULT = 15.0; svgParametersMetadata: SvgParametersMetadata | undefined; @@ -74,4 +75,11 @@ export class SvgParameters { public getEdgeNameDisplayed(): boolean { return this.svgParametersMetadata?.edgeNameDisplayed ?? SvgParameters.EDGE_NAME_DISPLAYED_DEFAULT; } + + public getFictitiousVoltageLevelCircleRadius(): number { + return ( + this.svgParametersMetadata?.fictitiousVoltageLevelCircleRadius ?? + SvgParameters.FICTITIOUS_VOLTAGE_LEVEL_CIRCLE_RADIUS_DEFAULT + ); + } }
-
+
1.1 kV / -13.4°
-
+
1.1 kV / -14.9°
-
+
1.0 kV / -10.3°