QuantityFormatter
The QuantityFormatter is a class that formats quantity values. This class is used on the front-end to format quantities for interactive tools, such as the different measure tools. The Quantity Formatter is not used to format properties stored in the iModel as that is work is done on the back-end via the Presentation layer. The QuantityFormatter can be set to formatted values in the same PresentationUnitSystem as that being used by the back-end.
QuantityType
There are nine built-in quantity types, see QuantityType. The QuantityFormatter defines default formatting specification for each of these types per PresentationUnitSystem
. Custom quantity types that implement the CustomQuantityTypeDefinition interface may also be registered with the QuantityFormatter, see method registerQuantityType
.
Overriding Default Formats
The QuantityFormat
provides the method setOverrideFormats
to allow the default format to be overridden. A class the implements the UnitFormattingSettingsProvider interface can be set with the QuantityFormatter to persist the overrides set. This provider can then monitor the current session to load the overrides when necessary. The class LocalUnitFormatProvider can be set using the following to register to store settings to local storage and to maintain overrides by iModel.
This allows both the Presentation Unit System and the format overrides, set by the user, to stay in sync as the user opens different iModels.
Measure Tools
Below are a list of a few of the delivered Measure Tools and the QuantityTypes they use.
MeasureDistanceTool
- Length - QuantityType.Length
- Coordinates - QuantityType.Coordinate
MeasureLocationTool
- Coordinates - QuantityType.Coordinate
- Spatial Coordinates - QuantityType.LatLong
- Height - QuantityType.Coordinate
MeasureAreaByPointsTool
- Perimeter - QuantityType.Length
- Coordinates - QuantityType.Coordinate
- Area - QuantityType.Area
MeasureElementTool
- Accumulated Length - QuantityType.Length
- Accumulated Area - QuantityType.Area
- Volume - QuantityType.Volume
- Centroid - QuantityType.Coordinate
Last Updated: 11 June, 2024