|
@@ -2,15 +2,17 @@
|
|
|
|
|
|
import 'dart:typed_data';
|
|
|
|
|
|
+import 'package:fis_common/event/event_type.dart';
|
|
|
import 'package:fis_vid_ext/vid_extended_data.dart';
|
|
|
import 'package:fis_vid_ext/vid_tag.dart';
|
|
|
import 'package:fis_vid_ext/vid_value.dart';
|
|
|
|
|
|
import 'pixel_space.dart';
|
|
|
|
|
|
+/// 参考线
|
|
|
class StandardLine {
|
|
|
- /// Default Standard Line Physical Length (unit mm)
|
|
|
- static const double DefaultPhysicsLength = 40;
|
|
|
+ /// Default Standard Line Physical Length (unit cm)
|
|
|
+ static const double DefaultPhysicsLength = 4.0;
|
|
|
|
|
|
/// 0028,0030 PixelSpacing from dicom
|
|
|
static final VidTag DicomTagPixelSpacing = VidTag("0028", "0030");
|
|
@@ -27,27 +29,43 @@ class StandardLine {
|
|
|
/// 0018, 6026 Physical Units Y
|
|
|
static final VidTag DicomTagPhysicalUnitsY = VidTag("0018", "6026");
|
|
|
|
|
|
- PixelSpacing? _currentPixelSpacing;
|
|
|
+ PixelSpacing _currentPixelSpacing = PixelSpacing();
|
|
|
double _physicsLength = DefaultPhysicsLength;
|
|
|
+ double _pixelLength = 0.0;
|
|
|
+ double _perPixelPhysicalLength = 0.0;
|
|
|
|
|
|
+ /// 参考线物理长度(cm)
|
|
|
double get physicsLength => _physicsLength;
|
|
|
set physicsLength(double val) {
|
|
|
if (val != _physicsLength) {
|
|
|
_physicsLength = val;
|
|
|
+ _onLineLengthChanged();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// 参考线像素长度
|
|
|
+ double get pixelLength => _pixelLength;
|
|
|
+ set pixelLength(double val) {
|
|
|
+ if (val != _pixelLength) {
|
|
|
+ _pixelLength = val;
|
|
|
+ _onLineLengthChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 单位像素物理长度(cm)
|
|
|
+ double get perPixelPhysicalLength => _perPixelPhysicalLength;
|
|
|
+
|
|
|
/// 当前像素距离尺
|
|
|
- PixelSpacing? get currentPixelSpacing => _currentPixelSpacing;
|
|
|
- set currentPixelSpacing(PixelSpacing? val) {
|
|
|
+ PixelSpacing get currentPixelSpacing => _currentPixelSpacing;
|
|
|
+ set currentPixelSpacing(PixelSpacing val) {
|
|
|
if (val != _currentPixelSpacing) {
|
|
|
_currentPixelSpacing = val;
|
|
|
_onPixelSpacingChanged();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// 是否需要设置像素距离尺
|
|
|
- bool get needSetPixelSpacing => currentPixelSpacing == null;
|
|
|
+ /// 像素距离尺变化事件
|
|
|
+ final pixelSpacingChanged = FEventHandler<PixelSpacing?>();
|
|
|
|
|
|
/// 通过vid扩展信息加载像素距离信息
|
|
|
void loadFromVidExtData(Uint8List bytes) {
|
|
@@ -86,8 +104,23 @@ class StandardLine {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ void _onLineLengthChanged() {
|
|
|
+ final physicalDeltaX = physicsLength * 10 / pixelLength;
|
|
|
+ final physicalDeltaY = physicalDeltaX;
|
|
|
+ currentPixelSpacing = PixelSpacing.fill(physicalDeltaX, physicalDeltaY);
|
|
|
+ }
|
|
|
+
|
|
|
void _onPixelSpacingChanged() {
|
|
|
-// _physicsLength
|
|
|
+ _perPixelPhysicalLength =
|
|
|
+ _getPixelLengthWithUnit(currentPixelSpacing.physicalDeltaX);
|
|
|
+ }
|
|
|
+
|
|
|
+ double _getPixelLengthWithUnit(double length) {
|
|
|
+ // if (_mearsureUnit == MearsureUnit.cm)
|
|
|
+ // {
|
|
|
+ length = length / 10;
|
|
|
+ // }
|
|
|
+ return length;
|
|
|
}
|
|
|
|
|
|
IVidValue? _getVidValueByTag(VidTag vidTag, VidExtendedData extendedData) {
|