From 5bee5deb22e7ec09342e0e64a2cb325eee53232a Mon Sep 17 00:00:00 2001 From: Rajnikant Lodhi Date: Wed, 24 Aug 2022 16:03:50 +0530 Subject: [PATCH] convert the qt value into the stroke dasharray --- .../cartography/helpers/qt-dasharray-fixer.ts | 2 ++ .../style-editor/style-editor.component.ts | 35 +++++++++++++------ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/app/cartography/helpers/qt-dasharray-fixer.ts b/src/app/cartography/helpers/qt-dasharray-fixer.ts index e7aade66..127887ef 100644 --- a/src/app/cartography/helpers/qt-dasharray-fixer.ts +++ b/src/app/cartography/helpers/qt-dasharray-fixer.ts @@ -14,9 +14,11 @@ export class QtDasharrayFixer { }; public fix(dasharray: string): string { + if(dasharray || dasharray == '' ){ if (dasharray in QtDasharrayFixer.MAPPING) { return QtDasharrayFixer.MAPPING[dasharray]; } return dasharray; } } +} diff --git a/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.ts b/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.ts index 1097b9c1..5633f3a0 100644 --- a/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.ts +++ b/src/app/components/project-map/drawings-editors/style-editor/style-editor.component.ts @@ -4,6 +4,7 @@ import { MatDialogRef } from '@angular/material/dialog'; import { DrawingToMapDrawingConverter } from '../../../../cartography/converters/map/drawing-to-map-drawing-converter'; import { MapDrawingToSvgConverter } from '../../../../cartography/converters/map/map-drawing-to-svg-converter'; import { DrawingsDataSource } from '../../../../cartography/datasources/drawings-datasource'; +import { QtDasharrayFixer } from '../../../../cartography/helpers/qt-dasharray-fixer'; import { Drawing } from '../../../../cartography/models/drawing'; import { EllipseElement } from '../../../../cartography/models/drawings/ellipse-element'; import { LineElement } from '../../../../cartography/models/drawings/line-element'; @@ -27,12 +28,12 @@ export class StyleEditorDialogComponent implements OnInit { element: ElementData; formGroup: FormGroup; borderTypes = [ - { value: 'none', name: 'Solid' }, - { value: '15 3', name: 'Dash' }, - { value: '5', name: 'Dot' }, - { value: '15 2 7 2', name: 'Dash Dot' }, - { value: '15 2 7 2 7 2', name: 'Dash Dot Dot' }, - { value: '', name: 'No border' }, + {qt:'none', value: 'none', name: 'Solid' }, + {qt:'10, 2', value: '25, 25', name: 'Dash' }, + {qt:'4, 2', value: '5, 25', name: 'Dot' }, + {qt:'5, 5, 1, 5', value: '5, 25, 25', name: 'Dash Dot' }, + {qt:'5, 2, 5, 2, 5', value: '25, 25, 5, 25, 5', name: 'Dash Dot Dot' }, + {qt:'', value: '', name: 'No border' }, ]; constructor( @@ -44,7 +45,8 @@ export class StyleEditorDialogComponent implements OnInit { private formBuilder: FormBuilder, private toasterService: ToasterService, private nonNegativeValidator: NonNegativeValidator, - private rotationValidator: RotationValidator + private rotationValidator: RotationValidator, + private qtDasharrayFixer: QtDasharrayFixer ) { this.formGroup = this.formBuilder.group({ borderWidth: new FormControl('', [Validators.required, nonNegativeValidator.get]), @@ -53,15 +55,28 @@ export class StyleEditorDialogComponent implements OnInit { } ngOnInit() { + let dasharray_find_value; this.element = new ElementData(); if (this.drawing.element instanceof RectElement || this.drawing.element instanceof EllipseElement) { this.element.fill = this.drawing.element.fill; this.element.stroke = this.drawing.element.stroke; - this.element.stroke_dasharray = this.drawing.element.stroke_dasharray ?? 'none'; + let dasharray_value = this.drawing.element.stroke_dasharray; + this.borderTypes.map((_) => { + if (_.qt == dasharray_value) { + dasharray_find_value = _.value; + } + }); + this.element.stroke_dasharray = dasharray_find_value ?? 'none'; this.element.stroke_width = this.drawing.element.stroke_width; } else if (this.drawing.element instanceof LineElement) { this.element.stroke = this.drawing.element.stroke; - this.element.stroke_dasharray = this.drawing.element.stroke_dasharray ?? 'none'; + let dasharray_value = this.drawing.element.stroke_dasharray; + this.borderTypes.map((_) => { + if (_.qt == dasharray_value) { + dasharray_find_value = _.value; + } + }); + this.element.stroke_dasharray = dasharray_find_value ?? 'none'; this.element.stroke_width = this.drawing.element.stroke_width; } @@ -87,7 +102,7 @@ export class StyleEditorDialogComponent implements OnInit { if (this.drawing.element instanceof RectElement || this.drawing.element instanceof EllipseElement) { this.drawing.element.fill = this.element.fill; this.drawing.element.stroke = this.element.stroke; - this.drawing.element.stroke_dasharray = this.element.stroke_dasharray; + this.drawing.element.stroke_dasharray = this.qtDasharrayFixer.fix(this.element.stroke_dasharray); this.drawing.element.stroke_width = this.element.stroke_width; } else if (this.drawing.element instanceof LineElement) { this.drawing.element.stroke = this.element.stroke;