measure_configuation_page.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. import 'package:fis_i18n/i18n.dart';
  2. import 'package:fis_jsonrpc/rpc.dart';
  3. import 'package:fis_measure/interfaces/process/items/terms.dart';
  4. import 'package:fis_measure/interfaces/process/player/play_controller.dart';
  5. import 'package:fis_measure/interfaces/process/workspace/application.dart';
  6. import 'package:fis_measure/process/language/measure_language.dart';
  7. import 'package:fis_measure/process/workspace/measure_data_controller.dart';
  8. import 'package:fis_measure/process/workspace/measure_handler.dart';
  9. import 'package:fis_measure/view/measure/measure_config/widgets/measurement_tool_selection.dart';
  10. import 'package:fis_measure/view/measure/measure_view_controller.dart';
  11. import 'package:fis_measure/view/player/controller.dart';
  12. import 'package:fis_theme/theme.dart';
  13. import 'package:fis_ui/index.dart';
  14. import 'package:flutter/material.dart';
  15. import 'package:get/get.dart';
  16. ///条目元数据组
  17. class ItemMetaGroup {
  18. ItemMetaGroup(
  19. this.itemMetaGroupTitle,
  20. this.itemMeta,
  21. this.isExpend,
  22. );
  23. /// 当前测量组的名称
  24. final String itemMetaGroupTitle;
  25. /// 当前测量组的测量数组
  26. final List<ItemMetaDTO> itemMeta;
  27. /// 是否展开
  28. bool? isExpend;
  29. }
  30. /// 测量工具配置
  31. class MeasureConfigurationPage extends StatelessWidget {
  32. const MeasureConfigurationPage({Key? key}) : super(key: key);
  33. @override
  34. FWidget build(BuildContext context) {
  35. return const _MeasureConfigurationDialog();
  36. }
  37. }
  38. ///测量配置对话框
  39. class _MeasureConfigurationDialog extends StatefulWidget implements FWidget {
  40. const _MeasureConfigurationDialog({
  41. Key? key,
  42. }) : super(key: key);
  43. @override
  44. State<_MeasureConfigurationDialog> createState() =>
  45. _MeasureConfigurationDialogState();
  46. }
  47. class _MeasureConfigurationDialogState
  48. extends State<_MeasureConfigurationDialog> {
  49. int measureToolsTab = 0;
  50. /// 切换标签栏
  51. void changeTab(int index) {
  52. measureToolsTab = index;
  53. setState(() {});
  54. }
  55. late final application = Get.find<IApplication>();
  56. late final measureHandler = Get.find<MeasureHandler>();
  57. final playerController = Get.find<IPlayerController>() as VidPlayerController;
  58. /// 数据
  59. final measureData = Get.find<MeasureDataController>();
  60. /// 测量项控制器
  61. final measureMetaController = Get.find<MeasureMetaController>();
  62. /// 选中的测量项
  63. List<String> chooseMeasureList = [];
  64. List<ItemMetaGroup> itemMetaListGroup = [];
  65. String activeName = '';
  66. /// 打开已选测量工具设置
  67. ///
  68. /// [name] 测量的名字 后期改版后应该是一个测量对象
  69. void openHasSelectedSettingDialog(String name) {
  70. // state.childItemMeta = state.allItemMeta.firstWhere(
  71. // (element) => element.name == name,
  72. // );
  73. // router.dialog(() => HasSelectedSettingDialog(name: name));
  74. }
  75. Future<void> getName() async {
  76. List<String> getModes = [];
  77. for (var element in playerController.currentFrame?.visuals[0].modes ?? []) {
  78. getModes.add(element.type.toString().split('.')[1]);
  79. }
  80. var measureModeSelection = MeasureModeSelection(
  81. application.applicationName,
  82. application.categoryName,
  83. application.isThirdPart ? ['TPPTissue'] : getModes,
  84. );
  85. measureHandler.measureModeChanged = measureModeSelection;
  86. measureData.getMeasureApplicationList = [];
  87. var measureApplicationDTO =
  88. await measureData.getMeasureApplication.call(measureModeSelection);
  89. if (measureApplicationDTO != null) {
  90. /// 模式版本
  91. measureData.measureApplicationVersion =
  92. measureApplicationDTO.version ?? '';
  93. measureData.availableModes = measureApplicationDTO.availableModes ?? [];
  94. measureMetaController.setAvailableModes(measureData.currentMode);
  95. activeName = measureData.curItemMetaList[0].name;
  96. }
  97. }
  98. void submit() async {
  99. var measureModeSubmitChanged = MeasureModeSubmit(
  100. measureData.measureApplicationVersion,
  101. application.applicationName,
  102. application.categoryName,
  103. UserDefinedMeasureModeDTO(
  104. modeName: measureData.currentMode,
  105. workingGroups: [
  106. UserDefinedMeasureGroupDTO(
  107. name: 'General',
  108. folders: [
  109. UserDefinedMeasureFolderDTO(
  110. name: 'General',
  111. workingItemNames: chooseMeasureList,
  112. ),
  113. ],
  114. ),
  115. ],
  116. ),
  117. );
  118. measureHandler.measureModeSubmitChanged = measureModeSubmitChanged;
  119. await measureData.saveUserDefinedMeasureApplicationAsync
  120. .call(measureModeSubmitChanged);
  121. getName();
  122. measureMetaController.setAvailableModes(measureData.currentMode);
  123. }
  124. @override
  125. void initState() {
  126. super.initState();
  127. List<String> chooseMeasure = [];
  128. measureMetaController.measureConfig();
  129. itemMetaListGroup = measureData.itemMetaListGroup;
  130. chooseMeasure = measureData.getMeasureApplicationList
  131. .where((element) => !MeasureUnsupportedTerms.items.contains(element))
  132. .toList();
  133. chooseMeasureList = chooseMeasure.toSet().toList();
  134. }
  135. @override
  136. void dispose() {
  137. super.dispose();
  138. }
  139. @override
  140. FWidget build(BuildContext context) {
  141. return FSimpleDialog(
  142. title: FText(
  143. i18nBook.measure.config.t,
  144. style: const TextStyle(
  145. color: Colors.white,
  146. fontSize: 18,
  147. ),
  148. ),
  149. cancelString: i18nBook.common.cancel.t,
  150. okString: i18nBook.common.confirm.t,
  151. isDefault: true,
  152. onOk: () {
  153. submit();
  154. },
  155. onCancel: () {
  156. chooseMeasureList = measureData.getMeasureApplicationList;
  157. Get.back();
  158. setState(() {});
  159. },
  160. children: [
  161. FContainer(
  162. width: 830,
  163. height: 500,
  164. child: _buildMeasureconfiguration(),
  165. ),
  166. ],
  167. );
  168. }
  169. FWidget _buildMeasureconfiguration() {
  170. return FContainer(
  171. padding: const EdgeInsets.symmetric(horizontal: 15),
  172. child: FRow(
  173. crossAxisAlignment: CrossAxisAlignment.start,
  174. children: [
  175. FContainer(
  176. width: 170,
  177. decoration: const BoxDecoration(
  178. border: Border(
  179. right: BorderSide(
  180. color: Color.fromRGBO(235, 235, 235, 1),
  181. width: 1,
  182. ),
  183. ),
  184. ),
  185. child: FColumn(
  186. crossAxisAlignment: CrossAxisAlignment.end,
  187. children: [
  188. const FSizedBox(
  189. height: 10,
  190. ),
  191. FContainer(
  192. width: 160,
  193. child: FInkWell(
  194. onTap: () {
  195. changeTab(0);
  196. },
  197. child: FContainer(
  198. padding: const EdgeInsets.symmetric(
  199. vertical: 10,
  200. horizontal: 5,
  201. ),
  202. child: FText(
  203. i18nBook.measure.measureToolSelect.t,
  204. style: measureToolsTab == 0
  205. ? TextStyle(
  206. color: FTheme.ins.colorScheme.primary,
  207. )
  208. : const TextStyle(),
  209. textAlign: TextAlign.end,
  210. ),
  211. ),
  212. ),
  213. ),
  214. FContainer(
  215. width: 160,
  216. child: FInkWell(
  217. onTap: () {
  218. changeTab(1);
  219. },
  220. child: FContainer(
  221. padding: const EdgeInsets.symmetric(
  222. vertical: 10,
  223. horizontal: 5,
  224. ),
  225. child: FText(
  226. i18nBook.measure.selectedMeasureTool.t,
  227. style: measureToolsTab == 1
  228. ? TextStyle(
  229. color: FTheme.ins.colorScheme.primary,
  230. )
  231. : const TextStyle(),
  232. textAlign: TextAlign.end,
  233. ),
  234. ),
  235. ),
  236. ),
  237. ],
  238. ),
  239. ),
  240. measureToolsTab == 0
  241. ? FExpanded(
  242. child: FSingleChildScrollView(
  243. child: SelectModulePage(
  244. itemMetaListGroup: itemMetaListGroup,
  245. chooseMeasureList: chooseMeasureList,
  246. ),
  247. ),
  248. )
  249. : FExpanded(
  250. child: _HasSelectedModulePage(
  251. chooseMeasureList: chooseMeasureList,
  252. ),
  253. ),
  254. ],
  255. ),
  256. );
  257. }
  258. }
  259. class _HasSelectedModulePage extends StatelessWidget implements FWidget {
  260. final List<String> chooseMeasureList;
  261. /// 数据
  262. final measureData = Get.find<MeasureDataController>();
  263. /// 测量语言包
  264. final measureLanguage = MeasureLanguage();
  265. _HasSelectedModulePage({
  266. required this.chooseMeasureList,
  267. });
  268. @override
  269. FWidget build(BuildContext context) {
  270. return FListView(
  271. shrinkWrap: true,
  272. children: [
  273. FColumn(
  274. crossAxisAlignment: CrossAxisAlignment.start,
  275. children: [
  276. FContainer(
  277. padding: const EdgeInsets.only(left: 15, top: 15, bottom: 15),
  278. child: FWrap(
  279. spacing: 16.0, // 主轴(水平)方向间距
  280. runSpacing: 8.0, // 纵轴(垂直)方向间距
  281. direction: Axis.horizontal,
  282. crossAlignment: WrapCrossAlignment.center,
  283. alignment: WrapAlignment.start,
  284. children: List<FWidget>.generate(
  285. chooseMeasureList.length,
  286. (index) {
  287. return FContainer(
  288. width: 180,
  289. height: 60,
  290. decoration: BoxDecoration(
  291. border: Border.all(
  292. width: 0.5,
  293. color: FTheme.ins.colorScheme.primary,
  294. ),
  295. ),
  296. child: FColumn(
  297. mainAxisAlignment: MainAxisAlignment.center,
  298. children: [
  299. FText(
  300. chooseMeasureList[index].toString(),
  301. style: const TextStyle(
  302. color: Colors.black,
  303. ),
  304. ),
  305. FText(
  306. measureLanguage.t(
  307. 'measure',
  308. chooseMeasureList[index].toString(),
  309. ),
  310. style: const TextStyle(
  311. color: Colors.black,
  312. ),
  313. ),
  314. ],
  315. ),
  316. // ),
  317. );
  318. },
  319. ),
  320. ),
  321. ),
  322. ],
  323. ),
  324. ],
  325. );
  326. }
  327. }