|
@@ -3,12 +3,14 @@ import 'dart:typed_data';
|
|
|
import 'package:fis_jsonrpc/rpc.dart';
|
|
|
import 'package:fis_measure/interfaces/enums/annotation.dart';
|
|
|
import 'package:fis_measure/interfaces/process/items/item.dart';
|
|
|
+import 'package:fis_measure/interfaces/process/items/item_metas.dart';
|
|
|
import 'package:fis_measure/interfaces/process/items/types.dart';
|
|
|
import 'package:fis_measure/interfaces/process/player/play_controller.dart';
|
|
|
import 'package:fis_measure/interfaces/process/standard_line/calibration.dart';
|
|
|
import 'package:fis_measure/interfaces/process/workspace/application.dart';
|
|
|
import 'package:fis_measure/interfaces/process/workspace/exam_info.dart';
|
|
|
import 'package:fis_measure/interfaces/process/workspace/measure_controller.dart';
|
|
|
+import 'package:fis_measure/process/items/item_meta_convert.dart';
|
|
|
import 'package:fis_measure/process/workspace/measure_3d_view_controller.dart';
|
|
|
import 'package:fis_measure/process/workspace/measure_controller.dart';
|
|
|
import 'package:fis_measure/process/workspace/measure_data_controller.dart';
|
|
@@ -16,6 +18,7 @@ import 'package:fis_measure/view/measure/measure_main_view.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
|
+import 'item_create_test.dart';
|
|
|
import 'process/workspace/measure_handler.dart';
|
|
|
|
|
|
class MeasureDataTester {
|
|
@@ -81,6 +84,9 @@ class MeasureDataTester {
|
|
|
class MeasureTestPage extends StatefulWidget {
|
|
|
const MeasureTestPage({Key? key}) : super(key: key);
|
|
|
|
|
|
+ // ignore: non_constant_identifier_names
|
|
|
+ static List<dynamic> MetaDTOList = [];
|
|
|
+
|
|
|
@override
|
|
|
State<StatefulWidget> createState() => _MeasureTestPageState();
|
|
|
}
|
|
@@ -344,14 +350,22 @@ class _MeasureLeftBoardState extends State<_MeasureLeftBoard> {
|
|
|
MeasureTypes.AreaPerimeterPolyline,
|
|
|
];
|
|
|
|
|
|
+ late final List<String> passeItems;
|
|
|
+
|
|
|
final scrollController = ScrollController();
|
|
|
final application = Get.find<IApplication>();
|
|
|
|
|
|
int activeIndex = 0;
|
|
|
|
|
|
+ late final List<ItemMeta> workingItems;
|
|
|
+
|
|
|
@override
|
|
|
void initState() {
|
|
|
- application.switchItemByName(C_SUPPORTED_ITEMS[0]);
|
|
|
+ // passeItems = C_SUPPORTED_ITEMS;
|
|
|
+ passeItems = TestItems.C_DISTANCE_ITEMS;
|
|
|
+ loadItems();
|
|
|
+ // application.switchItemByName(C_SUPPORTED_ITEMS[0]);
|
|
|
+ // changeItemByMeta(0);
|
|
|
application.canMeasureChanged.addListener(_onCanMeasureChanged);
|
|
|
super.initState();
|
|
|
}
|
|
@@ -364,7 +378,18 @@ class _MeasureLeftBoardState extends State<_MeasureLeftBoard> {
|
|
|
|
|
|
_onCanMeasureChanged(Object sender, bool e) {
|
|
|
if (e && mounted) {
|
|
|
- changeItem(0);
|
|
|
+ changeItemByMeta(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void loadItems() {
|
|
|
+ workingItems = [];
|
|
|
+ final workingItemDtos = MeasureTestPage.MetaDTOList.where(
|
|
|
+ (e) => passeItems.contains(e['Name']));
|
|
|
+ for (var map in workingItemDtos) {
|
|
|
+ final dto = ItemMetaDTO.fromJson(map);
|
|
|
+ final item = ItemMetaConverter(dto).output();
|
|
|
+ workingItems.add(item);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -378,20 +403,27 @@ class _MeasureLeftBoardState extends State<_MeasureLeftBoard> {
|
|
|
isAlwaysShown: true,
|
|
|
child: ListView.separated(
|
|
|
controller: scrollController,
|
|
|
- itemCount: C_SUPPORTED_ITEMS.length,
|
|
|
+ // itemCount: C_SUPPORTED_ITEMS.length,
|
|
|
+ itemCount: workingItems.length,
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
- final name = C_SUPPORTED_ITEMS[index];
|
|
|
+ // final name = C_SUPPORTED_ITEMS[index];
|
|
|
+ final item = workingItems[index];
|
|
|
+ final name = item.name;
|
|
|
final active = index == activeIndex;
|
|
|
return active
|
|
|
? ElevatedButton(
|
|
|
- onPressed: () => changeItem(index),
|
|
|
+ // onPressed: () => changeItem(index),
|
|
|
+ onPressed: () {
|
|
|
+ changeItemByMeta(index);
|
|
|
+ },
|
|
|
child: Text(name),
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
fixedSize: const Size.fromHeight(50),
|
|
|
),
|
|
|
)
|
|
|
: OutlinedButton(
|
|
|
- onPressed: () => changeItem(index),
|
|
|
+ // onPressed: () => changeItem(index),
|
|
|
+ onPressed: () => changeItemByMeta(index),
|
|
|
child: Text(name),
|
|
|
style: OutlinedButton.styleFrom(
|
|
|
fixedSize: const Size.fromHeight(50),
|
|
@@ -406,31 +438,19 @@ class _MeasureLeftBoardState extends State<_MeasureLeftBoard> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- void buildItems() {
|
|
|
- final count = C_SUPPORTED_ITEMS.length;
|
|
|
- final children = <Widget>[];
|
|
|
- for (var i = 0; i < count; i++) {
|
|
|
- final name = C_SUPPORTED_ITEMS[i];
|
|
|
- final active = i == activeIndex;
|
|
|
- final widget = active
|
|
|
- ? ElevatedButton(
|
|
|
- onPressed: () => changeItem(i),
|
|
|
- child: Text(name),
|
|
|
- style: ElevatedButton.styleFrom(
|
|
|
- fixedSize: const Size.fromHeight(50),
|
|
|
- ),
|
|
|
- )
|
|
|
- : OutlinedButton(
|
|
|
- onPressed: () => changeItem(i),
|
|
|
- child: Text(name),
|
|
|
- style: OutlinedButton.styleFrom(
|
|
|
- fixedSize: const Size.fromHeight(50),
|
|
|
- ),
|
|
|
- );
|
|
|
- if (i > 0) {
|
|
|
- children.add(const SizedBox(height: 8));
|
|
|
+ void changeItemByMeta(int index) {
|
|
|
+ setState(() {
|
|
|
+ activeIndex = index;
|
|
|
+ });
|
|
|
+ final meta = workingItems[index];
|
|
|
+ application.switchItem(meta);
|
|
|
+ print(application.activeMeasureItem?.meta.name);
|
|
|
+ // handle combo item
|
|
|
+ if (application.activeMeasureItem != null) {
|
|
|
+ final item = application.activeMeasureItem!;
|
|
|
+ if (item is ITopMeasureItem) {
|
|
|
+ item.switchChild(0);
|
|
|
}
|
|
|
- children.add(widget);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -438,12 +458,14 @@ class _MeasureLeftBoardState extends State<_MeasureLeftBoard> {
|
|
|
setState(() {
|
|
|
activeIndex = index;
|
|
|
});
|
|
|
- final name = C_SUPPORTED_ITEMS[index];
|
|
|
+ final name = passeItems[index];
|
|
|
application.switchItemByName(name);
|
|
|
// handle combo item
|
|
|
- final item = application.activeMeasureItem!;
|
|
|
- if (item is ITopMeasureItem) {
|
|
|
- item.switchChild(0);
|
|
|
+ if (application.activeMeasureItem != null) {
|
|
|
+ final item = application.activeMeasureItem!;
|
|
|
+ if (item is ITopMeasureItem) {
|
|
|
+ item.switchChild(0);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|