123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- import 'dart:ui';
- import 'package:fis_measure/interfaces/date_types/point.dart';
- import 'package:fis_measure/interfaces/enums/items.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/workspace/point_info.dart';
- import 'package:fis_measure/process/calcuators/depth.dart';
- import 'package:fis_measure/process/calcuators/depth2baseline.dart';
- import 'package:fis_measure/process/items/item.dart';
- import 'package:fis_measure/process/items/item_feature.dart';
- import 'package:fis_measure/process/items/top_item.dart';
- import 'package:fis_measure/process/items/top_item_feature.dart';
- import 'package:fis_measure/process/primitives/location.dart';
- import 'package:fis_measure/process/primitives/ray.dart';
- class DepthToBaseLine extends TopMeasureItem<DepthToBaseLineFeature> {
- late final Ray baseline;
- late final Location depth;
- DepthToBaseLine(ItemMeta meta) : super(meta) {
- final metaBaseLine = meta.getChildByType(MeasureTypes.Ray)!;
- final metaDepth = meta.getChildByType(MeasureTypes.Distance)!;
- baseline = Ray.createRay(metaBaseLine, this);
- depth = _Depth.createDepth(metaDepth, this);
- childItems.add(baseline);
- childItems.add(depth);
- }
- @override
- bool onExecuteMouse(PointInfo args) {
- if (feature == null) {
- feature = DepthToBaseLineFeature(this);
- listenChildrenUpdate();
- }
- if (args.pointType == PointInfoType.mouseDown) {
- if (childrenAllDone) {
- workingChild.clear();
- }
- }
- feature?.hostVisualArea = args.hostVisualArea;
- final result = workingChild.execute(args);
- doCalculate();
- return result;
- }
- @override
- bool onExecuteTouch(PointInfo args) {
- return workingChild.execute(args);
- }
- static DepthToBaseLine createDepthToBaseLine(ItemMeta meta,
- [IMeasureItem? parent]) {
- if (meta.measureType != MeasureTypes.DepthToBaseLine) {
- throw ArgumentError();
- }
- var location = DepthToBaseLine(meta);
- location.calculator = DistanceToRayCal(location);
- return location;
- }
- }
- class DepthToBaseLineFeature extends TopMeasureItemFeature {
- DepthToBaseLineFeature(
- DepthToBaseLine refItem,
- ) : super(refItem);
- }
- class _Depth extends Location {
- _Depth(ItemMeta meta, DepthToBaseLine parent) : super(meta, parent);
- @override
- bool onExecuteMouse(PointInfo args) {
- if (state == ItemStates.finished || state == ItemStates.waiting) {
- if (args.pointType == PointInfoType.mouseMove) {
- if (feature == null && measuredFeatures.isEmpty) {
- _createFeature(args);
- return true;
- }
- } else if (args.pointType == PointInfoType.mouseDown) {
- _createFeature(args);
- return true;
- }
- return false;
- }
- if (state == ItemStates.running) {
- if (args.pointType == PointInfoType.mouseUp) return false;
- feature?.point = args;
- doCalculate();
- if (args.pointType == PointInfoType.mouseDown) {
- doFeatureFinish();
- }
- }
- return true;
- }
- void _createFeature(PointInfo args) {
- measuredFeatures.clear();
- feature ??= _DepthFeature(this, args);
- if (args.hostVisualArea != null) {
- feature!.hostVisualArea = args.hostVisualArea;
- }
- doCalculate();
- state = ItemStates.running;
- }
- static _Depth createDepth(ItemMeta meta, DepthToBaseLine parent) {
- final depth = _Depth(meta, parent);
- depth.calculator = TissueDepthCal(depth);
- return depth;
- }
- }
- class _DepthFeature extends LocationFeature {
- _DepthFeature(IMeasureItem refItem, DPoint point) : super(refItem, point);
- @override
- void paint(Canvas canvas, Size size) {
- drawId(canvas, size);
- final viewPoint = convert2ViewPoint(size, point).toOffset();
- drawVertex(canvas, viewPoint);
- }
- }
|