6
6
import type { Ray3d } from "@itwin/core-geometry" ;
7
7
import { Point3d , PolygonOps } from "@itwin/core-geometry" ;
8
8
import type { DecorateContext , GraphicBuilder } from "@itwin/core-frontend" ;
9
- import { IModelApp , QuantityType } from "@itwin/core-frontend" ;
9
+ import { IModelApp } from "@itwin/core-frontend" ;
10
10
import { StyleSet , WellKnownGraphicStyleType , WellKnownTextStyleType } from "./GraphicStyle.js" ;
11
11
import type { TextEntry } from "./TextMarker.js" ;
12
12
import { TextMarker } from "./TextMarker.js" ;
13
+ import type { MeasurementFormattingProps } from "./MeasurementProps.js" ;
13
14
14
15
export class Polygon {
15
16
public isSelected : boolean ;
@@ -25,6 +26,8 @@ export class Polygon {
25
26
private _overrideText ?: string [ ] | TextEntry [ ] ;
26
27
private _textMarker : TextMarker ;
27
28
private _styleSet : StyleSet ;
29
+ private _areaKoQ : string ;
30
+ private _areaPersistenceUnitName : string ;
28
31
29
32
public get points ( ) : Point3d [ ] {
30
33
return this . _points ;
@@ -76,7 +79,27 @@ export class Polygon {
76
79
return this . _worldScale ?? 1.0 ;
77
80
}
78
81
79
- constructor ( points : Point3d [ ] , copyPoints : boolean = true , styleSet ?: StyleSet , worldScale ?: number ) {
82
+ public get areaKoQ ( ) : string {
83
+ return this . _areaKoQ ;
84
+ }
85
+
86
+ public set areaKoQ ( value : string ) {
87
+ this . _areaKoQ = value ;
88
+ this . recomputeFromPoints ( ) ;
89
+ }
90
+
91
+ public get areaPersistenceUnitName ( ) : string {
92
+ return this . _areaPersistenceUnitName ;
93
+ }
94
+
95
+ public set areaPersistenceUnitName ( value : string ) {
96
+ this . _areaPersistenceUnitName = value ;
97
+ this . recomputeFromPoints ( ) ;
98
+ }
99
+
100
+ constructor ( points : Point3d [ ] , copyPoints : boolean = true , styleSet ?: StyleSet , worldScale ?: number , formatting ?: MeasurementFormattingProps ) {
101
+ this . _areaKoQ = formatting ?. koqName ?? "AecUnits.AREA" ;
102
+ this . _areaPersistenceUnitName = formatting ?. persistenceUnitName ?? "Units.SQ_M" ;
80
103
this . _styleSet = ( styleSet !== undefined ) ? styleSet : StyleSet . default ;
81
104
this . drawMarker = true ;
82
105
this . drawFillArea = true ;
@@ -117,12 +140,12 @@ export class Polygon {
117
140
this . recomputeFromPoints ( ) ;
118
141
}
119
142
120
- private setTextToMarker ( ) {
143
+ private async setTextToMarker ( ) {
121
144
if ( this . _overrideText ) {
122
145
this . _textMarker . textLines = this . _overrideText ;
123
146
} else {
124
147
const lines : string [ ] = [ ] ;
125
- const areaFormatter = IModelApp . quantityFormatter . findFormatterSpecByQuantityType ( QuantityType . Area ) ;
148
+ const areaFormatter = IModelApp . quantityFormatter . getSpecsByName ( this . _areaKoQ ) ?. formatterSpec ;
126
149
if ( undefined !== areaFormatter )
127
150
lines . push ( IModelApp . quantityFormatter . formatQuantity ( this . worldScale * this . worldScale * this . area , areaFormatter ) ) ;
128
151
0 commit comments