|
@@ -21,6 +21,14 @@ import 'package:get/get.dart';
|
|
|
import 'package:vid/us/vid_us_unit.dart';
|
|
|
import 'package:vid/us/vid_us_visual_area_type.dart';
|
|
|
|
|
|
+class MobileBaseMeasureItemBtn {
|
|
|
+ ItemMeta itemMeta;
|
|
|
+ String displayName;
|
|
|
+ IconData icon;
|
|
|
+ MobileBaseMeasureItemBtn(
|
|
|
+ {required this.itemMeta, required this.displayName, required this.icon});
|
|
|
+}
|
|
|
+
|
|
|
/// 移动端测量项选择器(继承自 测量项页面)
|
|
|
class MobileMeasureSelector extends FStatefulWidget {
|
|
|
const MobileMeasureSelector({Key? key}) : super(key: key);
|
|
@@ -29,6 +37,16 @@ class MobileMeasureSelector extends FStatefulWidget {
|
|
|
FState<MobileMeasureSelector> createState() => _MobileMeasureSelector();
|
|
|
}
|
|
|
|
|
|
+class MobileMoreMeasureItemModesModel {
|
|
|
+ String modeName;
|
|
|
+ String displayName;
|
|
|
+ List<MeasureItemModel> availableItems;
|
|
|
+ MobileMoreMeasureItemModesModel(
|
|
|
+ {required this.modeName,
|
|
|
+ required this.displayName,
|
|
|
+ required this.availableItems});
|
|
|
+}
|
|
|
+
|
|
|
class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
|
|
|
late final application = Get.find<IApplication>();
|
|
|
|
|
@@ -109,10 +127,6 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
|
|
|
VidUsVisualAreaType.Flow,
|
|
|
];
|
|
|
|
|
|
- /// 是否允许使用基础测量项
|
|
|
- bool get _isEnableBaseMeasureItems =>
|
|
|
- _supportBasicMeasureAreaTypes.contains(_currentAreaType);
|
|
|
-
|
|
|
/// 是否已初始化完成所有测量项数据
|
|
|
bool _isInitAllMeasureItems = false;
|
|
|
|
|
@@ -125,6 +139,27 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
|
|
|
/// 判断是否为特殊测量项
|
|
|
bool get isSpecial => MeasurespecialsupportedTerms.items.contains(activeName);
|
|
|
|
|
|
+ /// 是否允许使用基础测量项
|
|
|
+ bool get _isEnableBaseMeasureItems =>
|
|
|
+ _supportBasicMeasureAreaTypes.contains(_currentAreaType);
|
|
|
+
|
|
|
+ @override
|
|
|
+ FWidget build(BuildContext context) {
|
|
|
+ return FSizedBox(
|
|
|
+ width: 100,
|
|
|
+ child: showMore
|
|
|
+ ? _buildExtraMeasureItemPanel()
|
|
|
+ : _buildBaseMeasureItemPanel(),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 切换子测量项
|
|
|
+ void changeChildItem(int index) {
|
|
|
+ if (isCombo && topMeasureItem != null) {
|
|
|
+ topMeasureItem!.switchChild(index);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// 切换测量项
|
|
|
bool changeItem(ItemMeta itemMeta) {
|
|
|
if (mounted) {
|
|
@@ -141,80 +176,6 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
|
|
|
return success;
|
|
|
}
|
|
|
|
|
|
- /// 切换子测量项
|
|
|
- void changeChildItem(int index) {
|
|
|
- if (isCombo && topMeasureItem != null) {
|
|
|
- topMeasureItem!.switchChild(index);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /// 子测量项变化事件监听
|
|
|
- void _onWorkingChildChanged(sender, int e) {
|
|
|
- setState(() {
|
|
|
- activeChildItemIndex = e;
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /// 测量项变化事件监听
|
|
|
- /// 需要重新绑定子测量项
|
|
|
- void _onActiveMeasureItemChanged(sender, IMeasureItem? e) {
|
|
|
- if (e != null) {
|
|
|
- final item = application.activeMeasureItem!;
|
|
|
- if (item is ITopMeasureItem) {
|
|
|
- topMeasureItem = item;
|
|
|
- isCombo = true;
|
|
|
- item.switchChild(0);
|
|
|
- activeChildItemIndex = 0;
|
|
|
- item.workingChildChanged.addListener(_onWorkingChildChanged);
|
|
|
- childItemLabels = item.childItems.map((e) => (e.description)).toList();
|
|
|
- } else {
|
|
|
- isCombo = false;
|
|
|
- }
|
|
|
- if (mounted) {
|
|
|
- setState(() {});
|
|
|
- }
|
|
|
- } else {
|
|
|
- /// 如果为空测量项
|
|
|
- isCombo = false;
|
|
|
- activeChildItemIndex = 0;
|
|
|
- showMore = false;
|
|
|
- activeName = "";
|
|
|
- if (mounted) {
|
|
|
- setState(() {});
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- void _visualAreaChanged(sender, IVisualArea e) {
|
|
|
- _cancelCurrSelect();
|
|
|
- _currentAreaType = e.visualAreaType;
|
|
|
- }
|
|
|
-
|
|
|
- @override
|
|
|
- FWidget build(BuildContext context) {
|
|
|
- return FSizedBox(
|
|
|
- width: 100,
|
|
|
- child: showMore
|
|
|
- ? _buildExtraMeasureItemPanel()
|
|
|
- : _buildBaseMeasureItemPanel(),
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- @override
|
|
|
- void initState() {
|
|
|
- super.initState();
|
|
|
- _cancelCurrSelect();
|
|
|
- application.activeMeasureItemChanged
|
|
|
- .addListener(_onActiveMeasureItemChanged);
|
|
|
- application.visualAreaChanged.addListener(_visualAreaChanged);
|
|
|
- _currentAreaType = application.currentVisualArea.visualAreaType;
|
|
|
- _initMeasureItemsListAsync();
|
|
|
- }
|
|
|
-
|
|
|
- void _initMeasureItemsListAsync() async {
|
|
|
- _availableModes = await _initMeasureItemsList();
|
|
|
- }
|
|
|
-
|
|
|
@override
|
|
|
void dispose() {
|
|
|
super.dispose();
|
|
@@ -227,68 +188,15 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// 构建基础测量项面板
|
|
|
- FWidget _buildBaseMeasureItemPanel() {
|
|
|
- return FColumn(
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
- mainAxisSize: MainAxisSize.max,
|
|
|
- children: [
|
|
|
- ..._mobileBasicMeasureItemsList.map((e) {
|
|
|
- return _buildBaseMeasureBtn(
|
|
|
- e.itemMeta, e.itemMeta.name == activeName, e.displayName, e.icon);
|
|
|
- }).toList(),
|
|
|
- if (!application.isThirdPart) _buildChangeMoreMeasureItem(),
|
|
|
- ],
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- /// 构建更多测量项面板
|
|
|
- FWidget _buildExtraMeasureItemPanel() {
|
|
|
- return FColumn(
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
- mainAxisSize: MainAxisSize.max,
|
|
|
- children: [
|
|
|
- const FSizedBox(
|
|
|
- height: 50,
|
|
|
- ),
|
|
|
- ..._buildCurrentMeasureItem(),
|
|
|
- const FSizedBox(
|
|
|
- height: 10,
|
|
|
- ),
|
|
|
- FExpanded(child: _buildChildItemBtns()),
|
|
|
- _buildCancelCurrMeasureItemBtn(),
|
|
|
- _buildChangeMoreMeasureItem(),
|
|
|
- ],
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- List<FWidget> _buildCurrentMeasureItem() {
|
|
|
- final measureLanguage = MeasureLanguage();
|
|
|
- final displayName = measureLanguage.t('measure', activeName);
|
|
|
- return [
|
|
|
- FText(
|
|
|
- i18nBook.measure.currentMeasureTool.t,
|
|
|
- textAlign: TextAlign.center,
|
|
|
- style: const TextStyle(color: Colors.grey, fontSize: 14),
|
|
|
- ),
|
|
|
- const FSizedBox(
|
|
|
- height: 10,
|
|
|
- ),
|
|
|
- FText(
|
|
|
- activeName,
|
|
|
- textAlign: TextAlign.center,
|
|
|
- style: const TextStyle(color: Colors.white),
|
|
|
- ),
|
|
|
- const FSizedBox(
|
|
|
- height: 5,
|
|
|
- ),
|
|
|
- if (i18nBook.isCurrentChinese)
|
|
|
- FText(
|
|
|
- displayName,
|
|
|
- textAlign: TextAlign.center,
|
|
|
- style: const TextStyle(color: Colors.grey, fontSize: 12),
|
|
|
- ),
|
|
|
- ];
|
|
|
+ @override
|
|
|
+ void initState() {
|
|
|
+ super.initState();
|
|
|
+ _cancelCurrSelect();
|
|
|
+ application.activeMeasureItemChanged
|
|
|
+ .addListener(_onActiveMeasureItemChanged);
|
|
|
+ application.visualAreaChanged.addListener(_visualAreaChanged);
|
|
|
+ _currentAreaType = application.currentVisualArea.visualAreaType;
|
|
|
+ _initMeasureItemsListAsync();
|
|
|
}
|
|
|
|
|
|
/// 构建基础测量项按钮
|
|
@@ -340,12 +248,30 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- /// 构建打开更多测量项按钮
|
|
|
- FWidget _buildChangeMoreMeasureItem() {
|
|
|
+ /// 构建基础测量项面板
|
|
|
+ FWidget _buildBaseMeasureItemPanel() {
|
|
|
+ return FColumn(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ mainAxisSize: MainAxisSize.max,
|
|
|
+ children: [
|
|
|
+ ..._mobileBasicMeasureItemsList.map((e) {
|
|
|
+ return _buildBaseMeasureBtn(
|
|
|
+ e.itemMeta, e.itemMeta.name == activeName, e.displayName, e.icon);
|
|
|
+ }).toList(),
|
|
|
+ if (!application.isThirdPart) _buildChangeMoreMeasureItem(),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 构建取消当前测量项按钮
|
|
|
+ FWidget _buildCancelCurrMeasureItemBtn() {
|
|
|
return FInkWell(
|
|
|
- onTap: () async {
|
|
|
+ onTap: () {
|
|
|
+ _cancelCurrSelect();
|
|
|
+ setState(() {
|
|
|
+ showMore = false;
|
|
|
+ });
|
|
|
HapticFeedback.mediumImpact();
|
|
|
- await _openMoreMeasureItemDialog();
|
|
|
},
|
|
|
child: Container(
|
|
|
margin: const EdgeInsets.fromLTRB(0, 10, 10, 10),
|
|
@@ -358,11 +284,11 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
|
|
|
child: FColumn(
|
|
|
children: [
|
|
|
const FIcon(
|
|
|
- Icons.format_list_bulleted,
|
|
|
+ Icons.cancel_outlined,
|
|
|
color: Colors.grey,
|
|
|
),
|
|
|
FText(
|
|
|
- i18nBook.measure.expandGroup.t,
|
|
|
+ i18nBook.common.cancel.t,
|
|
|
style: const TextStyle(
|
|
|
color: Colors.grey,
|
|
|
),
|
|
@@ -373,15 +299,12 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- /// 构建取消当前测量项按钮
|
|
|
- FWidget _buildCancelCurrMeasureItemBtn() {
|
|
|
+ /// 构建打开更多测量项按钮
|
|
|
+ FWidget _buildChangeMoreMeasureItem() {
|
|
|
return FInkWell(
|
|
|
- onTap: () {
|
|
|
- _cancelCurrSelect();
|
|
|
- setState(() {
|
|
|
- showMore = false;
|
|
|
- });
|
|
|
+ onTap: () async {
|
|
|
HapticFeedback.mediumImpact();
|
|
|
+ await _openMoreMeasureItemDialog();
|
|
|
},
|
|
|
child: Container(
|
|
|
margin: const EdgeInsets.fromLTRB(0, 10, 10, 10),
|
|
@@ -394,11 +317,11 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
|
|
|
child: FColumn(
|
|
|
children: [
|
|
|
const FIcon(
|
|
|
- Icons.cancel_outlined,
|
|
|
+ Icons.format_list_bulleted,
|
|
|
color: Colors.grey,
|
|
|
),
|
|
|
FText(
|
|
|
- i18nBook.common.cancel.t,
|
|
|
+ i18nBook.measure.expandGroup.t,
|
|
|
style: const TextStyle(
|
|
|
color: Colors.grey,
|
|
|
),
|
|
@@ -409,21 +332,6 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- /// 构建子测量项选择器
|
|
|
- FWidget _buildChildItemBtns() {
|
|
|
- if (isSpecial) {
|
|
|
- //是否为特殊组合测量项
|
|
|
- return const SpecialItemHR();
|
|
|
- }
|
|
|
- if (!isCombo) return const FSizedBox();
|
|
|
- return FListView(
|
|
|
- children: List.generate(
|
|
|
- childItemLabels.length,
|
|
|
- (index) => _buildChildItemBtn(index, childItemLabels[index]),
|
|
|
- ),
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
/// 构建子测量项按钮
|
|
|
FWidget _buildChildItemBtn(int index, String displayName) {
|
|
|
final bool isActive = index == activeChildItemIndex;
|
|
@@ -451,56 +359,68 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- /// 打开更多测量项选择器
|
|
|
- Future<void> _openMoreMeasureItemDialog() async {
|
|
|
- List<MobileMoreMeasureItemModesModel> modes = [];
|
|
|
- if (_isInitAllMeasureItems) {
|
|
|
- modes = _availableModes;
|
|
|
- } else {
|
|
|
- modes = await _initMeasureItemsList();
|
|
|
- _availableModes = modes;
|
|
|
+ /// 构建子测量项选择器
|
|
|
+ FWidget _buildChildItemBtns() {
|
|
|
+ if (isSpecial) {
|
|
|
+ //是否为特殊组合测量项
|
|
|
+ return const SpecialItemHR();
|
|
|
}
|
|
|
- final List<String> _currModes =
|
|
|
- _findModesByCurrArea(application.currentVisualArea);
|
|
|
-
|
|
|
- final List<MobileMoreMeasureItemModesModel> activeModes = modes
|
|
|
- .where((element) => _currModes.contains(element.modeName))
|
|
|
- .toList();
|
|
|
+ if (!isCombo) return const FSizedBox();
|
|
|
+ return FListView(
|
|
|
+ children: List.generate(
|
|
|
+ childItemLabels.length,
|
|
|
+ (index) => _buildChildItemBtn(index, childItemLabels[index]),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
- final MoreMeasureBackResult? result =
|
|
|
- await Get.dialog<MoreMeasureBackResult>(MobileMoreMeasureItemDialog(
|
|
|
- measureModeList: activeModes,
|
|
|
- activeItemName: activeName,
|
|
|
- initModeIndex: showMore ? moreMeasureBackResult?.currModeIndex : null,
|
|
|
- initScrollOffset:
|
|
|
- showMore ? moreMeasureBackResult?.currScrollOffset : null,
|
|
|
- ));
|
|
|
- if (result != null) {
|
|
|
- moreMeasureBackResult = result;
|
|
|
- bool success = changeItem(result.selectedMeasureItemMeta);
|
|
|
- if (success) {
|
|
|
- setState(() {
|
|
|
- showMore = true;
|
|
|
- });
|
|
|
- } else {
|
|
|
- PromptBox.toast(i18nBook.measure.temporarilyUnsupportedMeasurement.t);
|
|
|
- }
|
|
|
- }
|
|
|
+ List<FWidget> _buildCurrentMeasureItem() {
|
|
|
+ final measureLanguage = MeasureLanguage();
|
|
|
+ final displayName = measureLanguage.t('measure', activeName);
|
|
|
+ return [
|
|
|
+ FText(
|
|
|
+ i18nBook.measure.currentMeasureTool.t,
|
|
|
+ textAlign: TextAlign.center,
|
|
|
+ style: const TextStyle(color: Colors.grey, fontSize: 14),
|
|
|
+ ),
|
|
|
+ const FSizedBox(
|
|
|
+ height: 10,
|
|
|
+ ),
|
|
|
+ FText(
|
|
|
+ activeName,
|
|
|
+ textAlign: TextAlign.center,
|
|
|
+ style: const TextStyle(color: Colors.white),
|
|
|
+ ),
|
|
|
+ const FSizedBox(
|
|
|
+ height: 5,
|
|
|
+ ),
|
|
|
+ if (i18nBook.isCurrentChinese)
|
|
|
+ FText(
|
|
|
+ displayName,
|
|
|
+ textAlign: TextAlign.center,
|
|
|
+ style: const TextStyle(color: Colors.grey, fontSize: 12),
|
|
|
+ ),
|
|
|
+ ];
|
|
|
}
|
|
|
|
|
|
- /// 可能有些区域会重叠,无法手动区分,所以需要根据当前的区域来查找可以使用的测量项
|
|
|
- List<String> _findModesByCurrArea(IVisualArea currArea) {
|
|
|
- List<String> modes = [];
|
|
|
- List<IVisualArea> visualAreas = application.visuals[0].visualAreas;
|
|
|
- if (visualAreas.isEmpty) {
|
|
|
- return modes;
|
|
|
- }
|
|
|
- for (IVisualArea element in visualAreas) {
|
|
|
- if (element.displayRegion == currArea.displayRegion) {
|
|
|
- modes.add(element.mode.modeType.toString().split('.')[1]);
|
|
|
- }
|
|
|
- }
|
|
|
- return modes;
|
|
|
+ /// 构建更多测量项面板
|
|
|
+ FWidget _buildExtraMeasureItemPanel() {
|
|
|
+ return FColumn(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ mainAxisSize: MainAxisSize.max,
|
|
|
+ children: [
|
|
|
+ const FSizedBox(
|
|
|
+ height: 50,
|
|
|
+ ),
|
|
|
+ ..._buildCurrentMeasureItem(),
|
|
|
+ const FSizedBox(
|
|
|
+ height: 10,
|
|
|
+ ),
|
|
|
+ FExpanded(child: _buildChildItemBtns()),
|
|
|
+ _buildCancelCurrMeasureItemBtn(),
|
|
|
+ _buildChangeMoreMeasureItem(),
|
|
|
+ ],
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/// 取消当前选中的测量项
|
|
@@ -517,73 +437,6 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- /// 获取当前帧信息来初始化当前测量项
|
|
|
- Future<List<MobileMoreMeasureItemModesModel>> _initMeasureItemsList() async {
|
|
|
- final vidImage = playerController.currentFrame;
|
|
|
- if (vidImage == null) return [];
|
|
|
- List<String> getModes = [];
|
|
|
- List<String> displayModeNames = [];
|
|
|
- for (var element in vidImage.visuals[0].modes) {
|
|
|
- getModes.add(element.type.toString().split('.')[1]);
|
|
|
- displayModeNames.add(element.displayName);
|
|
|
- }
|
|
|
- measureData.applicationModes = vidImage.visuals[0].modes;
|
|
|
- measureData.currentMode = vidImage.visuals[0].modes.first.type.name;
|
|
|
- var measureModeSelection = MeasureModeSelection(
|
|
|
- application.applicationName,
|
|
|
- application.categoryName,
|
|
|
- application.isThirdPart ? ['TPPTissue'] : getModes,
|
|
|
- );
|
|
|
-
|
|
|
- /// 请求数据
|
|
|
- final MeasureApplicationDTO? measureApplicationDTO =
|
|
|
- await measureData.getMeasureApplication.call(measureModeSelection);
|
|
|
- if (measureApplicationDTO == null ||
|
|
|
- measureApplicationDTO.availableModes == null) return [];
|
|
|
-
|
|
|
- /// 遍历 measureApplicationDTO.availableModes 拼装出新的 supportedModes
|
|
|
- List<MobileMoreMeasureItemModesModel> supportedModes = [];
|
|
|
- for (int i = 0; i < measureApplicationDTO.availableModes!.length; i++) {
|
|
|
- MeasureModeDTO mode = measureApplicationDTO.availableModes![i];
|
|
|
- List<ItemMetaDTO> supportedItems = _currSupportedItemFilter(mode);
|
|
|
- String displayName =
|
|
|
- displayModeNames.length > i ? displayModeNames[i] : '';
|
|
|
- MobileMoreMeasureItemModesModel modeModel =
|
|
|
- MobileMoreMeasureItemModesModel(
|
|
|
- modeName: mode.modeName ?? '',
|
|
|
- displayName: displayName,
|
|
|
- availableItems: _itemConverter(supportedItems));
|
|
|
- supportedModes.add(modeModel);
|
|
|
- }
|
|
|
- if (supportedModes.isNotEmpty) {
|
|
|
- _isInitAllMeasureItems = true;
|
|
|
- }
|
|
|
- return supportedModes;
|
|
|
- }
|
|
|
-
|
|
|
- List<MeasureItemModel> _itemConverter(List<ItemMetaDTO> items) {
|
|
|
- if (i18nBook.isCurrentChinese) {
|
|
|
- return items.map((e) {
|
|
|
- final cName = measureLanguage.t('measure', e.description ?? '');
|
|
|
- return MeasureItemModel(
|
|
|
- displayName: cName,
|
|
|
- itemMeta: e,
|
|
|
- category: e.categories?.first ?? '',
|
|
|
- searchKey: "${e.name?.toLowerCase()}$cName",
|
|
|
- );
|
|
|
- }).toList();
|
|
|
- } else {
|
|
|
- return items.map((e) {
|
|
|
- return MeasureItemModel(
|
|
|
- displayName: e.name ?? '',
|
|
|
- itemMeta: e,
|
|
|
- category: e.categories?.first ?? '',
|
|
|
- searchKey: "${e.name?.toLowerCase()}",
|
|
|
- );
|
|
|
- }).toList();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/// 过滤出当前支持的所有测量项
|
|
|
List<ItemMetaDTO> _currSupportedItemFilter(MeasureModeDTO mode) {
|
|
|
final supportedMeasureTypeName = [
|
|
@@ -645,7 +498,6 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// 筛选支持的组合测量项
|
|
|
if (items.methodChildItems != null &&
|
|
|
items.methodChildItems!.isNotEmpty) {
|
|
|
bool isAdd = true;
|
|
@@ -659,6 +511,11 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// 排除不支持的项
|
|
|
+ if (MeasureUnsupportedTerms.items.contains(items.name)) {
|
|
|
+ isSupported = false;
|
|
|
+ }
|
|
|
+
|
|
|
// final cName = measureLanguage.t('measure', items.description ?? '');
|
|
|
if (isSupported) {
|
|
|
_supportedItems.add(items);
|
|
@@ -671,25 +528,172 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- print("${mode.modeName} 模式下过滤出 ${_supportedItems.length} 项");
|
|
|
+ // print("${mode.modeName} 模式下过滤出 ${_supportedItems.length} 项");
|
|
|
return _supportedItems;
|
|
|
}
|
|
|
-}
|
|
|
|
|
|
-class MobileBaseMeasureItemBtn {
|
|
|
- ItemMeta itemMeta;
|
|
|
- String displayName;
|
|
|
- IconData icon;
|
|
|
- MobileBaseMeasureItemBtn(
|
|
|
- {required this.itemMeta, required this.displayName, required this.icon});
|
|
|
-}
|
|
|
+ /// 可能有些区域会重叠,无法手动区分,所以需要根据当前的区域来查找可以使用的测量项
|
|
|
+ List<String> _findModesByCurrArea(IVisualArea currArea) {
|
|
|
+ List<String> modes = [];
|
|
|
+ List<IVisualArea> visualAreas = application.visuals[0].visualAreas;
|
|
|
+ if (visualAreas.isEmpty) {
|
|
|
+ return modes;
|
|
|
+ }
|
|
|
+ for (IVisualArea element in visualAreas) {
|
|
|
+ if (element.displayRegion == currArea.displayRegion) {
|
|
|
+ modes.add(element.mode.modeType.toString().split('.')[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return modes;
|
|
|
+ }
|
|
|
|
|
|
-class MobileMoreMeasureItemModesModel {
|
|
|
- String modeName;
|
|
|
- String displayName;
|
|
|
- List<MeasureItemModel> availableItems;
|
|
|
- MobileMoreMeasureItemModesModel(
|
|
|
- {required this.modeName,
|
|
|
- required this.displayName,
|
|
|
- required this.availableItems});
|
|
|
+ /// 获取当前帧信息来初始化当前测量项
|
|
|
+ Future<List<MobileMoreMeasureItemModesModel>> _initMeasureItemsList() async {
|
|
|
+ final vidImage = playerController.currentFrame;
|
|
|
+ if (vidImage == null) return [];
|
|
|
+ List<String> getModes = [];
|
|
|
+ List<String> displayModeNames = [];
|
|
|
+ for (var element in vidImage.visuals[0].modes) {
|
|
|
+ getModes.add(element.type.toString().split('.')[1]);
|
|
|
+ displayModeNames.add(element.displayName);
|
|
|
+ }
|
|
|
+ measureData.applicationModes = vidImage.visuals[0].modes;
|
|
|
+ measureData.currentMode = vidImage.visuals[0].modes.first.type.name;
|
|
|
+ var measureModeSelection = MeasureModeSelection(
|
|
|
+ application.applicationName,
|
|
|
+ application.categoryName,
|
|
|
+ application.isThirdPart ? ['TPPTissue'] : getModes,
|
|
|
+ );
|
|
|
+
|
|
|
+ /// 请求数据
|
|
|
+ final MeasureApplicationDTO? measureApplicationDTO =
|
|
|
+ await measureData.getMeasureApplication.call(measureModeSelection);
|
|
|
+ if (measureApplicationDTO == null ||
|
|
|
+ measureApplicationDTO.availableModes == null) return [];
|
|
|
+
|
|
|
+ /// 遍历 measureApplicationDTO.availableModes 拼装出新的 supportedModes
|
|
|
+ List<MobileMoreMeasureItemModesModel> supportedModes = [];
|
|
|
+ for (int i = 0; i < measureApplicationDTO.availableModes!.length; i++) {
|
|
|
+ MeasureModeDTO mode = measureApplicationDTO.availableModes![i];
|
|
|
+ List<ItemMetaDTO> supportedItems = _currSupportedItemFilter(mode);
|
|
|
+ String displayName =
|
|
|
+ displayModeNames.length > i ? displayModeNames[i] : '';
|
|
|
+ MobileMoreMeasureItemModesModel modeModel =
|
|
|
+ MobileMoreMeasureItemModesModel(
|
|
|
+ modeName: mode.modeName ?? '',
|
|
|
+ displayName: displayName,
|
|
|
+ availableItems: _itemConverter(supportedItems));
|
|
|
+ supportedModes.add(modeModel);
|
|
|
+ }
|
|
|
+ if (supportedModes.isNotEmpty) {
|
|
|
+ _isInitAllMeasureItems = true;
|
|
|
+ }
|
|
|
+ return supportedModes;
|
|
|
+ }
|
|
|
+
|
|
|
+ void _initMeasureItemsListAsync() async {
|
|
|
+ _availableModes = await _initMeasureItemsList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<MeasureItemModel> _itemConverter(List<ItemMetaDTO> items) {
|
|
|
+ if (i18nBook.isCurrentChinese) {
|
|
|
+ return items.map((e) {
|
|
|
+ final cName = measureLanguage.t('measure', e.description ?? '');
|
|
|
+ return MeasureItemModel(
|
|
|
+ displayName: cName,
|
|
|
+ itemMeta: e,
|
|
|
+ category: e.categories?.first ?? '',
|
|
|
+ searchKey: "${e.name?.toLowerCase()}$cName",
|
|
|
+ );
|
|
|
+ }).toList();
|
|
|
+ } else {
|
|
|
+ return items.map((e) {
|
|
|
+ return MeasureItemModel(
|
|
|
+ displayName: e.name ?? '',
|
|
|
+ itemMeta: e,
|
|
|
+ category: e.categories?.first ?? '',
|
|
|
+ searchKey: "${e.name?.toLowerCase()}",
|
|
|
+ );
|
|
|
+ }).toList();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 测量项变化事件监听
|
|
|
+ /// 需要重新绑定子测量项
|
|
|
+ void _onActiveMeasureItemChanged(sender, IMeasureItem? e) {
|
|
|
+ if (e != null) {
|
|
|
+ final item = application.activeMeasureItem!;
|
|
|
+ if (item is ITopMeasureItem) {
|
|
|
+ topMeasureItem = item;
|
|
|
+ isCombo = true;
|
|
|
+ item.switchChild(0);
|
|
|
+ activeChildItemIndex = 0;
|
|
|
+ item.workingChildChanged.addListener(_onWorkingChildChanged);
|
|
|
+ childItemLabels = item.childItems.map((e) => (e.description)).toList();
|
|
|
+ } else {
|
|
|
+ isCombo = false;
|
|
|
+ }
|
|
|
+ if (mounted) {
|
|
|
+ setState(() {});
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ /// 如果为空测量项
|
|
|
+ isCombo = false;
|
|
|
+ activeChildItemIndex = 0;
|
|
|
+ showMore = false;
|
|
|
+ activeName = "";
|
|
|
+ if (mounted) {
|
|
|
+ setState(() {});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 子测量项变化事件监听
|
|
|
+ void _onWorkingChildChanged(sender, int e) {
|
|
|
+ setState(() {
|
|
|
+ activeChildItemIndex = e;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 打开更多测量项选择器
|
|
|
+ Future<void> _openMoreMeasureItemDialog() async {
|
|
|
+ List<MobileMoreMeasureItemModesModel> modes = [];
|
|
|
+ if (_isInitAllMeasureItems) {
|
|
|
+ modes = _availableModes;
|
|
|
+ } else {
|
|
|
+ modes = await _initMeasureItemsList();
|
|
|
+ _availableModes = modes;
|
|
|
+ }
|
|
|
+ final List<String> _currModes =
|
|
|
+ _findModesByCurrArea(application.currentVisualArea);
|
|
|
+
|
|
|
+ final List<MobileMoreMeasureItemModesModel> activeModes = modes
|
|
|
+ .where((element) => _currModes.contains(element.modeName))
|
|
|
+ .toList();
|
|
|
+
|
|
|
+ final MoreMeasureBackResult? result =
|
|
|
+ await Get.dialog<MoreMeasureBackResult>(MobileMoreMeasureItemDialog(
|
|
|
+ measureModeList: activeModes,
|
|
|
+ activeItemName: activeName,
|
|
|
+ initModeIndex: showMore ? moreMeasureBackResult?.currModeIndex : null,
|
|
|
+ initScrollOffset:
|
|
|
+ showMore ? moreMeasureBackResult?.currScrollOffset : null,
|
|
|
+ ));
|
|
|
+ if (result != null) {
|
|
|
+ moreMeasureBackResult = result;
|
|
|
+ bool success = changeItem(result.selectedMeasureItemMeta);
|
|
|
+ if (success) {
|
|
|
+ setState(() {
|
|
|
+ showMore = true;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ PromptBox.toast(i18nBook.measure.temporarilyUnsupportedMeasurement.t);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void _visualAreaChanged(sender, IVisualArea e) {
|
|
|
+ _cancelCurrSelect();
|
|
|
+ _currentAreaType = e.visualAreaType;
|
|
|
+ }
|
|
|
}
|