|
@@ -12,6 +12,8 @@ import 'package:fis_ui/index.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
|
+import 'converter.dart';
|
|
|
+
|
|
|
class MeasureResultPanel extends StatefulWidget {
|
|
|
const MeasureResultPanel({this.resultFontSize = 16.0, Key? key})
|
|
|
: super(key: key);
|
|
@@ -175,7 +177,7 @@ class _MeasureResultPanelState extends State<MeasureResultPanel> {
|
|
|
}
|
|
|
final idLength = features.length.toString().length;
|
|
|
for (var feature in features) {
|
|
|
- final strList = _FeatureDescConverter(feature).generate(idLength);
|
|
|
+ final strList = FeatureValueDescConverter(feature).generate(idLength);
|
|
|
lines.addAll(strList);
|
|
|
}
|
|
|
}
|
|
@@ -189,108 +191,3 @@ class _MeasureResultPanelState extends State<MeasureResultPanel> {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-class _FeatureDescConverter {
|
|
|
- final IMeasureItemFeature feature;
|
|
|
- _FeatureDescConverter(this.feature);
|
|
|
-
|
|
|
- String idPlaceStr = ' ';
|
|
|
- String idStr = ' ';
|
|
|
-
|
|
|
- List<String> generate(int idLength) {
|
|
|
- idPlaceStr = ' '.padRight(idLength, ' ');
|
|
|
- idStr = feature.id.toString().padRight(idLength, ' ');
|
|
|
-
|
|
|
- final List<String> arr = [];
|
|
|
- final mainLines = _findFeatureLines(feature);
|
|
|
- arr.addAll(mainLines);
|
|
|
-
|
|
|
- final ref = feature.refItem;
|
|
|
- if (ref is ITopMeasureItem) {
|
|
|
- for (var child in ref.childItems) {
|
|
|
- for (var feature in child.measuredFeatures) {
|
|
|
- final str = _findChildLine(feature);
|
|
|
- if (str != null && str.isNotEmpty) {
|
|
|
- arr.add(str);
|
|
|
- }
|
|
|
- }
|
|
|
- if (child.feature != null) {
|
|
|
- final str = _findChildLine(child.feature!);
|
|
|
- if (str != null && str.isNotEmpty) {
|
|
|
- arr.add(str);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return arr;
|
|
|
- }
|
|
|
-
|
|
|
- String? _findChildLine(IMeasureItemFeature feature) {
|
|
|
- if (feature.value == null) return null;
|
|
|
-
|
|
|
- final value = feature.value!;
|
|
|
- final valueStr = _pickValueStr(value);
|
|
|
-
|
|
|
- final name = feature.refItem.description;
|
|
|
- final unitStr = UnitDescriptionMap.getDesc(value.meta.unit);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return ' $idPlaceStr $name: $valueStr$unitStr';
|
|
|
- }
|
|
|
-
|
|
|
- List<String> _findFeatureLines(IMeasureItemFeature feature) {
|
|
|
- final count = feature.values.length;
|
|
|
- if (count == 0) {
|
|
|
- final output = feature.refItem.meta.outputs.first;
|
|
|
- final name =
|
|
|
- _findDisplayName(output.description, output.briefAnnotation, false);
|
|
|
- return ['$idStr $name'];
|
|
|
- }
|
|
|
-
|
|
|
- List<String> arr = [];
|
|
|
- for (var i = 0; i < count; i++) {
|
|
|
- final val = feature.values[i];
|
|
|
- final meta = val.meta;
|
|
|
- final valueStr = _pickValueStr(val);
|
|
|
- final name =
|
|
|
- _findDisplayName(meta.description, meta.briefAnnotation, false);
|
|
|
- final unitStr = UnitDescriptionMap.getDesc(meta.unit);
|
|
|
-
|
|
|
- if (i == 0) {
|
|
|
- arr.add('$idStr $name: $valueStr$unitStr');
|
|
|
- } else {
|
|
|
- arr.add('$idPlaceStr $name: $valueStr$unitStr');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return arr;
|
|
|
- }
|
|
|
-
|
|
|
- String _pickValueStr(ValueBase value) {
|
|
|
- if (value is FloatValue) {
|
|
|
- return _roundDouble(value.value!, value.meta.fractionalDigits).toString();
|
|
|
- } else if (value is StringValue) {
|
|
|
- return value.value!;
|
|
|
- }
|
|
|
- return '';
|
|
|
- }
|
|
|
-
|
|
|
- String _findDisplayName(String description, String? briefAnnotation,
|
|
|
- [bool showAnnotation = false]) {
|
|
|
- if (showAnnotation) {
|
|
|
- if (briefAnnotation != null && briefAnnotation.isNotEmpty) {
|
|
|
- return briefAnnotation;
|
|
|
- }
|
|
|
- }
|
|
|
- return description;
|
|
|
- }
|
|
|
-
|
|
|
- double _roundDouble(double value, [int digits = 2]) {
|
|
|
- final digitsStr = value.toStringAsFixed(digits);
|
|
|
- final result = double.parse(digitsStr);
|
|
|
- return result;
|
|
|
- }
|
|
|
-}
|