|
@@ -24,6 +24,8 @@ class Spline extends AreaItemAbstract with AutoSnapMixin {
|
|
|
static Spline createAreaPerimeter(ItemMeta meta, [IMeasureItem? parent]) {
|
|
|
Spline spline = Spline(meta, parent);
|
|
|
spline.calculator = _AreaPerimeterCalc(spline);
|
|
|
+ spline.isClosed = false;
|
|
|
+ spline.splineTension = 0.5;
|
|
|
return spline;
|
|
|
}
|
|
|
|
|
@@ -33,6 +35,8 @@ class Spline extends AreaItemAbstract with AutoSnapMixin {
|
|
|
]) {
|
|
|
Spline spline = Spline(meta, parent);
|
|
|
spline.calculator = CurveLengthCal(spline);
|
|
|
+ spline.isClosed = false;
|
|
|
+ spline.splineTension = 0.5;
|
|
|
return spline;
|
|
|
}
|
|
|
|
|
@@ -61,7 +65,7 @@ class Spline extends AreaItemAbstract with AutoSnapMixin {
|
|
|
}
|
|
|
doCalculate();
|
|
|
|
|
|
- f.isClosed = checkAutoFinish(args);
|
|
|
+ checkAutoSnap(args);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -84,20 +88,18 @@ class Spline extends AreaItemAbstract with AutoSnapMixin {
|
|
|
}
|
|
|
|
|
|
class SplineFeature extends AreaItemFeatureAbstract {
|
|
|
- static const double _splineTension = 0.5;
|
|
|
static const double _splineTolerance = 0.05;
|
|
|
|
|
|
- SplineFeature(AreaItemAbstract refItem, DPoint point) : super(refItem) {
|
|
|
+ SplineFeature(Spline refItem, DPoint point) : super(refItem) {
|
|
|
innerPoints.add(point.clone());
|
|
|
innerPoints.add(point.clone());
|
|
|
- splineTension = _splineTension;
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
void paint(Canvas canvas, Size size) {
|
|
|
if (innerPoints.isEmpty) return;
|
|
|
final paintPoints = innerPoints;
|
|
|
- if (isClosed) {
|
|
|
+ if ((refItem as AutoSnapMixin).snapState) {
|
|
|
paintPoints.removeLast();
|
|
|
}
|
|
|
drawId(canvas, size);
|
|
@@ -155,15 +157,17 @@ class SplineFeature extends AreaItemFeatureAbstract {
|
|
|
|
|
|
static void addSegment(List<DPoint> polyLineSegment, List<DPoint> points,
|
|
|
List<int> pointIndex, double tension, double tolerance) {
|
|
|
+ if (points.length < 2) return;
|
|
|
segment(
|
|
|
- polyLineSegment,
|
|
|
- points[pointIndex[0]],
|
|
|
- points[pointIndex[1]],
|
|
|
- points[pointIndex[2]],
|
|
|
- points[pointIndex[3]],
|
|
|
- tension,
|
|
|
- tension,
|
|
|
- tolerance);
|
|
|
+ polyLineSegment,
|
|
|
+ points[pointIndex[0]],
|
|
|
+ points[pointIndex[1]],
|
|
|
+ points[pointIndex[2]],
|
|
|
+ points[pointIndex[3]],
|
|
|
+ tension,
|
|
|
+ tension,
|
|
|
+ tolerance,
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
static double segment(List<DPoint> points, DPoint pt0, DPoint pt1, DPoint pt2,
|
|
@@ -303,7 +307,7 @@ class _AreaPerimeterCalc extends Calculator<Spline, double> {
|
|
|
points[i + 1], points[i + 2], tension, tension, tolerance);
|
|
|
}
|
|
|
}
|
|
|
- print("面积计算拟合点数 ${polyLineSegment.length}");
|
|
|
+
|
|
|
final area = calcArea(polyLineSegment);
|
|
|
return [perimeter, area];
|
|
|
}
|