From cefbc3c9be7ffb6252f43d229dcd30b966bfb5d4 Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 1 Aug 2023 15:54:47 +1000 Subject: [PATCH] Support for rounded rectangles --- .../drawing/drawings/rect/rect.component.html | 2 ++ .../helpers/svg-to-drawing-converter/rect-converter.ts | 10 ++++++++++ src/app/cartography/models/drawings/rect-element.ts | 2 ++ src/app/cartography/widgets/drawings/rect-drawing.ts | 4 +++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/app/cartography/components/experimental-map/drawing/drawings/rect/rect.component.html b/src/app/cartography/components/experimental-map/drawing/drawings/rect/rect.component.html index ed00003c8..c334f32ae 100644 --- a/src/app/cartography/components/experimental-map/drawing/drawings/rect/rect.component.html +++ b/src/app/cartography/components/experimental-map/drawing/drawings/rect/rect.component.html @@ -7,4 +7,6 @@ [attr.stroke-dasharray]="stroke_dasharray" [attr.width]="rect.width" [attr.height]="rect.height" + [attr.rx]="rect.rx" + [attr.ry]="rect.ry" /> diff --git a/src/app/cartography/helpers/svg-to-drawing-converter/rect-converter.ts b/src/app/cartography/helpers/svg-to-drawing-converter/rect-converter.ts index a5b98d248..fd88b2476 100644 --- a/src/app/cartography/helpers/svg-to-drawing-converter/rect-converter.ts +++ b/src/app/cartography/helpers/svg-to-drawing-converter/rect-converter.ts @@ -40,6 +40,16 @@ export class RectConverter implements SvgConverter { drawing.height = parseInt(height.value, 10); } + const rx = element.attributes.getNamedItem('rx'); + if (rx) { + drawing.rx = parseInt(rx.value, 0); + } + + const ry = element.attributes.getNamedItem('ry'); + if (ry) { + drawing.ry = parseInt(ry.value, 0); + } + return drawing; } } diff --git a/src/app/cartography/models/drawings/rect-element.ts b/src/app/cartography/models/drawings/rect-element.ts index 661e5ea41..a410e852a 100644 --- a/src/app/cartography/models/drawings/rect-element.ts +++ b/src/app/cartography/models/drawings/rect-element.ts @@ -8,4 +8,6 @@ export class RectElement implements DrawingElement { stroke: string; stroke_width: number; stroke_dasharray: string; + rx: number; + ry: number; } diff --git a/src/app/cartography/widgets/drawings/rect-drawing.ts b/src/app/cartography/widgets/drawings/rect-drawing.ts index de6a31d2f..e7b90352e 100644 --- a/src/app/cartography/widgets/drawings/rect-drawing.ts +++ b/src/app/cartography/widgets/drawings/rect-drawing.ts @@ -33,7 +33,9 @@ export class RectDrawingWidget implements DrawingShapeWidget { .attr('stroke-width', (rect) => rect.stroke_width) .attr('stroke-dasharray', (rect) => this.qtDasharrayFixer.fix(rect.stroke_dasharray)) .attr('width', (rect) => rect.width) - .attr('height', (rect) => rect.height); + .attr('height', (rect) => rect.height) + .attr('rx', (rect) => rect.rx) + .attr('ry', (rect) => rect.ry); drawing.exit().remove(); }