|
@@ -2,7 +2,6 @@ import 'dart:convert';
|
|
|
import 'dart:ui';
|
|
|
|
|
|
import 'package:fis_measure/interfaces/date_types/point.dart';
|
|
|
-import 'package:fis_measure/interfaces/process/items/measure_terms.dart';
|
|
|
import 'package:fis_measure/process/primitives/carotid_imt.dart';
|
|
|
import 'package:fis_measure/utils/js_utils.dart';
|
|
|
import 'package:vid/us/vid_us_unit.dart';
|
|
@@ -10,8 +9,8 @@ import 'package:vid/us/vid_us_unit.dart';
|
|
|
import 'calculator.dart';
|
|
|
|
|
|
class ShellCal extends Calculator<CarotidIMT, double> {
|
|
|
- ShellCal(CarotidIMT ref) : super(ref);
|
|
|
-
|
|
|
+ ShellCal(CarotidIMT ref, this.type) : super(ref);
|
|
|
+ String type = '';
|
|
|
@override
|
|
|
void calculate() {
|
|
|
if (ref.feature == null) return;
|
|
@@ -23,7 +22,7 @@ class ShellCal extends Calculator<CarotidIMT, double> {
|
|
|
//右下顶点
|
|
|
final rightBottomPoint =
|
|
|
DPoint(p1.x > p2.x ? p1.x : p2.x, p1.y > p2.y ? p1.y : p2.y);
|
|
|
- final outputItem = createOutput(MeasureTerms.Distance, 0.0, VidUsUnit.cm);
|
|
|
+ final outputItem = createOutput(type, 0.0, VidUsUnit.cm);
|
|
|
//图片尺寸
|
|
|
final imageSize = ref.application.carotid2DSize;
|
|
|
//画布尺寸
|
|
@@ -33,13 +32,17 @@ class ShellCal extends Calculator<CarotidIMT, double> {
|
|
|
//标准画布尺寸
|
|
|
final stdCanavsSize =
|
|
|
Size(canavsSize.width / imageScale, canavsSize.height / imageScale);
|
|
|
+ //Vid图像左上顶点的像素坐标
|
|
|
final imageLeftTopPoint = DPoint(
|
|
|
(stdCanavsSize.width - imageSize.width) / 2,
|
|
|
(stdCanavsSize.height - imageSize.height) / 2);
|
|
|
+ //Vid图像右下顶点的像素坐标
|
|
|
final imageRightBottomPoint = DPoint(imageLeftTopPoint.x + imageSize.width,
|
|
|
imageLeftTopPoint.y + imageSize.height);
|
|
|
+ //选区左上顶点的像素坐标
|
|
|
final rectLeftTopPoint = DPoint(stdCanavsSize.width * leftTopPoint.x,
|
|
|
stdCanavsSize.height * leftTopPoint.y);
|
|
|
+ //选区右下顶点的像素坐标
|
|
|
final rectRightBottomPoint = DPoint(
|
|
|
stdCanavsSize.width * rightBottomPoint.x,
|
|
|
stdCanavsSize.height * rightBottomPoint.y);
|
|
@@ -74,10 +77,28 @@ class ShellCal extends Calculator<CarotidIMT, double> {
|
|
|
final rectTop = (rectLeftTopPoint.y - imageLeftTopPoint.y).round();
|
|
|
final rectWidth = (rectRightBottomPoint.x - rectLeftTopPoint.x).round();
|
|
|
final rectHeight = (rectRightBottomPoint.y - rectLeftTopPoint.y).round();
|
|
|
+ String measureItemType = 'AntMeasureItem';
|
|
|
+ if (type == 'Ant.CCA IMT') {
|
|
|
+ measureItemType = 'AntMeasureItem';
|
|
|
+ } else if (type == 'Post.CCA IMT') {
|
|
|
+ measureItemType = 'PostMeasureItem';
|
|
|
+ } else if (type == 'Both.CCA IMT') {
|
|
|
+ measureItemType = 'AntAndPostMeasureItem';
|
|
|
+ }
|
|
|
final params =
|
|
|
- "{'MeasureItemType':'AntMeasureItem','IntimaRect':{'Left':$rectLeft,'Top':$rectTop,'Width':$rectWidth,'Height':$rectHeight}}";
|
|
|
+ "{'MeasureItemType':'$measureItemType','IntimaRect':{'Left':$rectLeft,'Top':$rectTop,'Width':$rectWidth,'Height':$rectHeight}}";
|
|
|
|
|
|
String description = "IMT\n Measuring";
|
|
|
+ List<Offset> getPointsFromStrList(List pointsStr) {
|
|
|
+ final points = <Offset>[];
|
|
|
+ for (var point in pointsStr) {
|
|
|
+ final xyStr = point.split(',');
|
|
|
+ points.add(Offset(
|
|
|
+ (double.parse(xyStr[0]) + imageLeftTopPoint.x) * imageScale,
|
|
|
+ (double.parse(xyStr[1]) + imageLeftTopPoint.y) * imageScale));
|
|
|
+ }
|
|
|
+ return points;
|
|
|
+ }
|
|
|
|
|
|
/// [Carotid] ✅在此处通知 Shell 计算,获取 description,touch/mouse finished 时绘制结果
|
|
|
try {
|
|
@@ -86,32 +107,39 @@ class ShellCal extends Calculator<CarotidIMT, double> {
|
|
|
[
|
|
|
(result) {
|
|
|
// print("getMeasureResult: $result");
|
|
|
+ if (result == 'error') {
|
|
|
+ outputs.add(outputItem);
|
|
|
+ outputs.last
|
|
|
+ .updateDescription(description: "$type\n Measure failed");
|
|
|
+ ref.application.updateRenderReady.emit(this, null);
|
|
|
+ return;
|
|
|
+ }
|
|
|
final res = jsonDecode(result);
|
|
|
- // print("getMeasureResult: $res");
|
|
|
- // print("getMeasureResult: ${res['ErrorCode']}");
|
|
|
if (res['ErrorCode'].toString() == "1000") {
|
|
|
- description =
|
|
|
- "Ant.CCA IMT\n Max: ${res['MaxThickness'].toStringAsFixed(2)}mm\n Min: ${res['MinThickness'].toStringAsFixed(2)}mm\n Avg: ${res['AverageThickness'].toStringAsFixed(2)}mm\n SD: ${res['SdThickness'].toStringAsFixed(2)}mm";
|
|
|
- List<Offset> lowerPoints = [];
|
|
|
- List<Offset> upperPoints = [];
|
|
|
- for (var i = 0; i < res['PointLower'].length; i++) {
|
|
|
- final xyStr = res['PointLower'][i].split(',');
|
|
|
- lowerPoints.add(Offset(
|
|
|
- (double.parse(xyStr[0]) + imageLeftTopPoint.x) * imageScale,
|
|
|
- (double.parse(xyStr[1]) + imageLeftTopPoint.y) *
|
|
|
- imageScale));
|
|
|
+ if (type != 'Both.CCA IMT') {
|
|
|
+ description =
|
|
|
+ "$type\n Max: ${res['MaxThickness'].toStringAsFixed(2)}mm\n Min: ${res['MinThickness'].toStringAsFixed(2)}mm\n Avg: ${res['AverageThickness'].toStringAsFixed(2)}mm\n SD: ${res['SdThickness'].toStringAsFixed(2)}mm";
|
|
|
+ } else {
|
|
|
+ description =
|
|
|
+ "$type\n Ant Max: ${res['LowerMeasureResult']['MaxThickness'].toStringAsFixed(2)}mm\n Ant.Min: ${res['LowerMeasureResult']['MinThickness'].toStringAsFixed(2)}mm\n Ant.Avg: ${res['LowerMeasureResult']['AverageThickness'].toStringAsFixed(2)}mm\n Ant.SD: ${res['LowerMeasureResult']['SdThickness'].toStringAsFixed(2)}mm\n Post.Max: ${res['UpperMeasureResult']['MaxThickness'].toStringAsFixed(2)}mm\n Post.Min: ${res['UpperMeasureResult']['MinThickness'].toStringAsFixed(2)}mm\n Post.Avg: ${res['UpperMeasureResult']['AverageThickness'].toStringAsFixed(2)}mm\n Post.SD: ${res['UpperMeasureResult']['SdThickness'].toStringAsFixed(2)}mm";
|
|
|
}
|
|
|
- for (var i = 0; i < res['PointUpper'].length; i++) {
|
|
|
- final xyStr = res['PointUpper'][i].split(',');
|
|
|
- upperPoints.add(Offset(
|
|
|
- (double.parse(xyStr[0]) + imageLeftTopPoint.x) * imageScale,
|
|
|
- (double.parse(xyStr[1]) + imageLeftTopPoint.y) *
|
|
|
- imageScale));
|
|
|
+ if (type != 'Both.CCA IMT') {
|
|
|
+ ref.feature!.offsetsList
|
|
|
+ .add(getPointsFromStrList(res['PointLower']));
|
|
|
+ ref.feature!.offsetsList
|
|
|
+ .add(getPointsFromStrList(res['PointUpper']));
|
|
|
+ } else {
|
|
|
+ ref.feature!.offsetsList.add(getPointsFromStrList(
|
|
|
+ res['LowerMeasureResult']['PointLower']));
|
|
|
+ ref.feature!.offsetsList.add(getPointsFromStrList(
|
|
|
+ res['LowerMeasureResult']['PointUpper']));
|
|
|
+ ref.feature!.offsetsList.add(getPointsFromStrList(
|
|
|
+ res['UpperMeasureResult']['PointLower']));
|
|
|
+ ref.feature!.offsetsList.add(getPointsFromStrList(
|
|
|
+ res['UpperMeasureResult']['PointUpper']));
|
|
|
}
|
|
|
- ref.feature!.offsetsList.add(lowerPoints);
|
|
|
- ref.feature!.offsetsList.add(upperPoints);
|
|
|
} else {
|
|
|
- description = "Ant.CCA IMT\n Measure failed";
|
|
|
+ description = "$type\n Measure failed";
|
|
|
}
|
|
|
outputs.add(outputItem);
|
|
|
outputs.last.updateDescription(description: description);
|
|
@@ -126,7 +154,7 @@ class ShellCal extends Calculator<CarotidIMT, double> {
|
|
|
outputs.add(outputItem);
|
|
|
outputs.last
|
|
|
.updateDescription(description: "Ant.CCA IMT\n Measure failed");
|
|
|
- print(e);
|
|
|
+ //
|
|
|
}
|
|
|
}
|
|
|
}
|