Ver Fonte

copy C# codes 2 dart from ultrasonic project 2

melon.yin há 2 anos atrás
pai
commit
c50e7c1e24

+ 66 - 0
lib/base_models/modes/mode.dart

@@ -0,0 +1,66 @@
+enum ModeTypeEnum {
+  undefined,
+
+  /// Modes like 2D, TNonL, 3D4D
+  tissue,
+
+  /// Modes like CF, PDI, TVI
+  flow,
+
+  /// Modes like PW, CW, TD
+  doppler,
+
+  /// Modes like MM, AMM
+  tissueTM
+}
+
+abstract class IMode {
+  // Data Members
+
+  /// Gets or sets whether the mode is active.
+  ///
+  /// The active mode can be the current most interesting working mode
+  ///
+  /// from user's point of view.
+  ///
+  /// e.g., If in 2D mode, user presses CF button, then CF mode is enabled and is activated.
+  ///
+  /// When user switch to B panel, then B mode is active mode.
+  ///
+  /// When set, the Active property of previous mode will be set to false.
+  bool get active;
+  set active(bool value);
+
+  /// Show or hide the mode. When mode is shown, usually it will create related native models and start to work.
+  /// This shall be the only way to make the mode work
+  bool get visible;
+  set visible(bool value);
+
+  /// Indicate whether the mode can be played in current visual state. In another word, the corresponding
+  ///  mode button can be clicked on hard keyboard.
+  ///
+  /// If the probe does not support one specific mode, then this flag is false
+  /// (Also the meta is not in the <see cref="IProbe.SupportedModes"/> list).
+  ///
+  /// Else this flag is false in Freezed state when the mode is invisible in live state.
+  ///
+  /// One sample: If CF + 2D is visible in live state, at this time, PW is Enabled but is not visible.
+  ///
+  /// When freezed, then PW is disabled, but 2D + CF are both Visible and Enabled.
+  ///
+  /// When user uncheck CF mode, then CF is invisible but is still Enabled.
+  ///
+  /// If user then unfreeze system, then both CF and PW are invisible and are enabled.
+  bool get enabled;
+  set enabled(bool value);
+
+  /// Gets the identifying name of the <see cref="IMode"/>.
+  /// B, CF, PDI, TVI, PW, CW, TD, M...
+  /// This name is hardcoded in every mode.
+  /// When doing compare, caller shall call like below:
+  /// if mode.Name == TwoDMode.ModeName
+
+  String get name;
+
+  ModeTypeEnum get modeType;
+}

+ 25 - 0
lib/base_models/view_port/image_boundary.dart

@@ -0,0 +1,25 @@
+import 'package:fis_measure/interfaces/date_types/point.dart';
+
+/// Describes the width, height, and point origin of a image area.
+abstract class IImageBoundary {
+  // Data Members
+  List<DPoint> get points;
+
+  /// Gets the position of the top-left corner of the Boundary.
+  DPoint get topLeft;
+
+  /// Gets the position of the bottom-right corner of the Boundary.
+  DPoint get bottomLeft;
+
+  /// Gets the position of the bottom-left corner of the Boundary.
+  DPoint get bottomRight;
+
+  /// Gets the position of the top-right corner of the Boundary.
+  DPoint get topRight;
+
+  /// Gets the width of the image.
+  double get width;
+
+  /// Gets the height of the image.
+  double get height;
+}

+ 50 - 0
lib/base_models/view_port/logical_coordinate.dart

@@ -0,0 +1,50 @@
+import 'package:fis_measure/interfaces/enums/uint.dart';
+
+import 'image_boundary.dart';
+import 'rect_region.dart';
+
+abstract class ILogicalCoordinate {
+  // Data Members
+
+  /// Gets a Boundary that specifies the desired region of valid image.
+  ///
+  /// Image boundary may outside the Region
+  IImageBoundary get imageBoundary;
+  set imageBoundary(IImageBoundary value);
+
+  /// Gets or sets a value indicating whether to flip the image horizontally.
+  bool get isFlipHorizontal;
+  set isFlipHorizontal(bool value);
+
+  /// Gets a value that indicates whether to flip the image vertically.
+  bool get isFlipVertical;
+  set isFlipVertical(bool value);
+
+  /// Gets a rect that specifies the axis-aligned bounding box of the rendered area.
+  ///
+  /// Region of rendered area is relevant to LayoutSchema.
+  ///
+  /// Region is match to the NormalizationCoordinate.Region
+  RectRegion get region;
+  set region(RectRegion value);
+
+  /// Gets the unit of X-axis(Horizontal),
+  ///
+  /// Tissue,Flow :XUnit=Units.cm YUnit=Units.cm
+  ///
+  /// TissueTimeMotion:XUnit=Units.s,YUnit=Units.cm
+  ///
+  /// DopplerTimeMotion:XUnit=Units.s,YUnit=Unit.cms
+  Unit get xUnit;
+  set xUnit(Unit value);
+
+  /// Gets the unit of Y-axis(Vertical),
+  ///
+  /// Tissue,Flow :XUnit=Units.cm YUnit=Units.cm
+  ///
+  /// TissueTimeMotion:XUnit=Units.s,YUnit=Units.cm
+  ///
+  /// DopplerTimeMotion:XUnit=Units.s,YUnit=Unit.cms
+  Unit get yUnit;
+  set yUnit(Unit value);
+}

+ 35 - 0
lib/base_models/view_port/physical_coordinate.dart

@@ -0,0 +1,35 @@
+import 'package:fis_measure/base_models/visuals/visual_area.dart';
+import 'package:fis_measure/interfaces/date_types/point.dart';
+
+import 'image_boundary.dart';
+import 'logical_coordinate.dart';
+
+abstract class IPhysicalCoordinate {
+  /// <summary>
+  /// Synchronize interesting data from native and refreshes the logicalCoordinate.
+  /// </summary>
+  ///<returns>A return value indicates result of download operation.</returns>
+  bool download(IVisualArea area, ILogicalCoordinate logicalCoordinate);
+
+  /// <summary>
+  /// Transforms the specified point in relative coordinate and returns a point in current coordinate.
+  /// </summary>
+  /// <returns></returns>
+  DPoint convert(DPoint point);
+
+  /// <summary>
+  /// Transforms the specified point in current coordinate and returns a point in relative coordinate.
+  /// </summary>
+  /// <param name="point"></param>
+  /// <returns></returns>
+  DPoint convertBack(DPoint point);
+
+  /// <summary>
+  /// Check if the boundary if match the coordinate.
+  /// </summary>
+  /// <param name="boundary"></param>
+  /// <returns></returns>
+  bool checkBoundary(IImageBoundary boundary);
+
+  void reset();
+}

+ 1 - 0
lib/base_models/view_port/rect_region.dart

@@ -0,0 +1 @@
+class RectRegion {}

+ 54 - 0
lib/base_models/view_port/view_port.dart

@@ -0,0 +1,54 @@
+import 'package:fis_common/event/event_type.dart';
+import 'package:fis_measure/interfaces/enums/uint.dart';
+
+import 'image_boundary.dart';
+import 'physical_coordinate.dart';
+import 'rect_region.dart';
+
+abstract class IViewPort {
+  bool get physicalCoordinateReady;
+
+  /// Gets a coordinate system in Physical  which contains physical relative data for a visual area.
+  IPhysicalCoordinate get physical;
+
+  /// Gets a Boundary that specifies the desired region of valid image.
+  ///
+  /// remarks: Image boundary may outside the Region </remarks>
+  IImageBoundary get imageBoundary;
+
+  /// Gets a value indicating whether to flip the image horizontally.
+  bool get isFlipHorizontal;
+
+  /// Gets a value that indicates whether to flip the image vertically.
+  bool get isFlipVertical;
+
+  /// Gets a rect that specifies the axis-aligned bounding box of the rendered area.
+  ///
+  /// IsFlipHorizontal or IsFlipVertical wouldn't affect this value.
+  ///
+  /// Region of rendered area is relevant to LayoutSchema.
+  ///
+  /// Region is match to the NormalizationCoordinate.Region
+  RectRegion get region;
+
+  /// Gets the unit of X-axis(Horizontal),
+  ///
+  /// Tissue,Flow :XUnit=Units.cm YUnit=Units.cm
+  ///
+  /// TissueTimeMotion:XUnit=Units.s,YUnit=Units.cm
+  ///
+  /// DopplerTimeMotion:XUnit=Units.s,YUnit=Unit.cms
+  Unit get xUnit;
+
+  /// Gets the unit of Y-axis(Vertical),
+  ///
+  /// Tissue,Flow :XUnit=Units.cm YUnit=Units.cm
+  ///
+  /// TissueTimeMotion:XUnit=Units.s,YUnit=Units.cm
+  ///
+  /// DopplerTimeMotion:XUnit=Units.s,YUnit=Unit.cms
+  Unit get yUnit;
+
+  /// Occurs when the value of the properties changes on this accessory.
+  late final FEventHandler updated;
+}

+ 1 - 0
lib/base_models/visuals/adorner.dart

@@ -0,0 +1 @@
+abstract class IAdorner {}

+ 41 - 0
lib/base_models/visuals/visual_area.dart

@@ -0,0 +1,41 @@
+import 'package:fis_common/event/event_type.dart';
+import 'package:fis_measure/base_models/modes/mode.dart';
+import 'package:fis_measure/base_models/view_port/view_port.dart';
+import 'package:fis_measure/interfaces/collections/changed_args.dart';
+import 'package:fis_measure/interfaces/enums/visual_area_type.dart';
+
+import 'adorner.dart';
+
+abstract class IVisualArea {
+  bool get detailView;
+  set detailView(bool value);
+
+  /// Identify this visual area when it is serialized while saving visual.
+  /// when unserialize, adorners(measure lines/comments...) found the target visual area by this.
+  String get id;
+
+  /// If this is true, then this area and adorners will be saved when save visual, otherwise not.
+  bool get needSerialize;
+
+  List<IAdorner> get adorners;
+
+  VisualAreaTypeEnum get visualAreaType;
+
+  IMode get mode;
+
+  /// Gets a value indicating whether correspondent mode is not null.
+  /// If a visual area is visible, the Mode is not null, otherwise Mode is null.
+  bool get isVisible;
+
+  /// Gets a ViewPort object that represents the view port info of this area.
+  IViewPort get viewPort;
+
+  bool get isZoomArea;
+
+  late final FEventHandler<CollectionChangedArgs<IAdorner>>
+      adornerCollectionChanged;
+
+  late final FEventHandler isVisibleChanged;
+  late final FEventHandler modeChanged;
+  late final FEventHandler viewModeChanged;
+}

+ 12 - 0
lib/interfaces/collections/changed_args.dart

@@ -0,0 +1,12 @@
+class CollectionChangedArgs<T> {
+  late final List<T> _removedItems;
+  late final List<T> _addedItems;
+
+  List<T> get removedItems => _removedItems;
+  List<T> get addedItems => _addedItems;
+
+  CollectionChangedArgs(List<T>? removed, List<T>? added) {
+    _removedItems = removed ?? <T>[];
+    _addedItems = added ?? <T>[];
+  }
+}

+ 1 - 3
lib/interfaces/date_types/matrix.dart

@@ -549,9 +549,7 @@ class DMatrix {
       }
 
       if ((_offsetX != 0.0) || (_offsetY != 0.0)) {
-        var typeIdx = _type.index;
-        typeIdx |= MatrixTypes.transformIsTranslation.index;
-        _type = MatrixTypes.values[typeIdx];
+        _type |= MatrixTypes.transformIsTranslation;
       }
       if ((_type.index &
               (MatrixTypes.transformIsScaling.index |

+ 60 - 0
lib/interfaces/enums/uint.dart

@@ -0,0 +1,60 @@
+enum Unit {
+  none,
+  percent,
+  fraction,
+  //
+  placeholder3,
+  placeholder4,
+  placeholder5,
+  placeholder6,
+  placeholder7,
+  placeholder8,
+  placeholder9,
+  // Length
+  cm,
+  mm,
+  inch,
+  ft,
+  // Time
+  s,
+  minute,
+  hour,
+  day,
+  week,
+  weekDay,
+  tick,
+  msec,
+  //
+  placeholder28,
+  placeholder29,
+  // Angle
+  degree,
+  radian,
+  //
+  placeholder32,
+  placeholder33,
+  placeholder34,
+  placeholder35,
+  placeholder36,
+  placeholder37,
+  placeholder38,
+  placeholder39,
+  // Weight
+  g,
+  mg,
+  ng,
+  kg,
+  oz,
+  lb,
+  lbOz,
+  //
+  placeholder47,
+  placeholder48,
+  placeholder49,
+  //Area
+  cm2,
+  mm2,
+  m3,
+  //
+  placeholder53,
+}

+ 28 - 0
lib/interfaces/enums/visual_area_type.dart

@@ -0,0 +1,28 @@
+enum VisualAreaTypeEnum {
+  /// Tissue area
+  tissue,
+
+  /// Flow area
+  ///
+  /// Layout logic equals to Tissue
+  flow,
+
+  /// Timemotion area, e.g. M/PW mode.
+  timeMotion,
+
+  /// Doppler area
+  doppler,
+
+  /// Tissue time motion area, e.g., M mode
+  tissueTimeMotion,
+
+  /// Trace area, e.g., ECG
+  trace,
+
+  /// Colorbar definition
+  colorbar,
+
+  tissue3D,
+
+  sweiReliableColorBar,
+}

+ 11 - 0
lib/interfaces/mode_names.dart

@@ -0,0 +1,11 @@
+// ignore_for_file: constant_identifier_names
+
+class ModeNames {
+  static const B = "B";
+  static const TM = "TM";
+  static const Doppler = "Doppler";
+  static const Trace = "Trace";
+  static const P_ColorBar = "pColorBar";
+  static const FourD = "4D";
+  static const P_SweiReliableColorBar = "pSweiReliableColorBar";
+}

+ 46 - 2
lib/interfaces/process/layout/configuration.dart

@@ -1,5 +1,8 @@
 import 'package:fis_common/logger/logger.dart';
+import 'package:fis_measure/interfaces/date_types/rect.dart';
 import 'package:fis_measure/interfaces/enums/display_mode.dart';
+import 'package:fis_measure/interfaces/enums/visual_area_type.dart';
+import 'package:fis_measure/interfaces/mode_names.dart';
 
 import 'section.dart';
 import 'view_port.dart';
@@ -13,7 +16,7 @@ class LayoutConfiguration {
   }
 
   bool _loaded = false;
-  List<LayoutSection> _layoutSections = [];
+  final List<LayoutSection> _layoutSections = [];
 
   bool get loaded => _loaded;
 
@@ -31,6 +34,47 @@ class LayoutConfiguration {
     _loaded = true;
   }
 
+  DRect getRect(
+    String section,
+    VisualAreaTypeEnum areaType,
+    DisplayModeEnum displayFormat,
+  ) {
+    String mode;
+    switch (areaType) {
+      case VisualAreaTypeEnum.tissue:
+      case VisualAreaTypeEnum.flow:
+        mode = ModeNames.B;
+        break;
+      case VisualAreaTypeEnum.timeMotion:
+      case VisualAreaTypeEnum.tissueTimeMotion:
+        mode = ModeNames.TM;
+        break;
+      case VisualAreaTypeEnum.doppler:
+        mode = ModeNames.Doppler;
+        break;
+      case VisualAreaTypeEnum.trace:
+        mode = ModeNames.Trace;
+        break;
+      case VisualAreaTypeEnum.colorbar:
+        mode = ModeNames.P_ColorBar;
+        break;
+      case VisualAreaTypeEnum.tissue3D:
+        mode = ModeNames.FourD;
+        break;
+      case VisualAreaTypeEnum.sweiReliableColorBar:
+        mode = ModeNames.P_SweiReliableColorBar;
+        break;
+    }
+
+    final viewPort = _matchViewPort(section, mode, displayFormat);
+    final rect = DRect(
+        viewPort.left / 100,
+        viewPort.top / 100,
+        (viewPort.right - viewPort.left) / 100,
+        (viewPort.bottom - viewPort.top) / 100);
+    return rect;
+  }
+
   LayoutViewPort _matchViewPort(
     String name,
     String layoutKey,
@@ -40,7 +84,7 @@ class LayoutConfiguration {
     LayoutViewPort viewPort = LayoutViewPort();
     List<LayoutSection> sections = [];
 
-    var sectionIdx = _layoutSections.indexWhere((x) => x.key == name);
+    final sectionIdx = _layoutSections.indexWhere((x) => x.key == name);
     if (sectionIdx > -1) {
       sections.add(_layoutSections[sectionIdx]);
     }

+ 6 - 6
pubspec.yaml

@@ -53,12 +53,12 @@ dependencies:
   path_provider: ^2.0.2
   image: 3.1.3
 
-# dependency_overrides:
-#   fis_common:
-#     git:
-#       url: http://git.ius.plus:88/Project-Wing/fis_lib_common.git
-#       ref: 1.0.7+1
-#     # path: ../fis_lib_common
+dependency_overrides:
+  fis_common:
+    git:
+      url: http://git.ius.plus:88/Project-Wing/fis_lib_common.git
+      ref: 1.0.7+1
+    # path: ../fis_lib_common
 
 dev_dependencies:
   flutter_test: