Skip to content

Commit

Permalink
Read layout parameters from metadata in network area diagram viewer (#95
Browse files Browse the repository at this point in the history
)

Signed-off-by: Massimo Ferraro <massimo.ferraro@soft.it>
  • Loading branch information
massimo-ferraro authored and flo-dup committed Nov 4, 2024
1 parent 127275b commit d046ef4
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 53 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions demo/src/diagram-viewers/data/nad-four-substations.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions demo/src/diagram-viewers/data/nad-ieee14cdf-solved.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion demo/src/diagram-viewers/data/nad-ieee300cdf-VL9006.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions demo/src/diagram-viewers/data/nad-ieee9-zeroimpedance-cdf.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions demo/src/diagram-viewers/data/nad-scada.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions src/components/network-area-diagram-viewer/diagram-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,3 +507,23 @@ export function getTextNodeMoves(
{ xOrig: connXOrig, yOrig: connYOrig, xNew: connXNew, yNew: connYNew },
];
}

// get number parameter from metadata element
export function getNumberParameter(
parametersMetadataElement: SVGGraphicsElement | null,
parameterName: string,
parameterDefault: number
): number {
const parameter = parametersMetadataElement?.getAttribute(parameterName);
return parameter !== undefined && parameter !== null ? +parameter : parameterDefault;
}

// get boolean parameter from metadata element
export function getBooleanParameter(
parametersMetadataElement: SVGGraphicsElement | null,
parameterName: string,
parameterDefault: boolean
): boolean {
const parameter = parametersMetadataElement?.getAttribute(parameterName);
return parameter !== undefined && parameter !== null ? parameter === 'true' : parameterDefault;
}
Loading

0 comments on commit d046ef4

Please sign in to comment.