|
@@ -60,9 +60,63 @@ class Ellipse extends AreaItemAbstract {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ bool isFirstPointMove = true;
|
|
|
+ DPoint touchStartPosition = DPoint(0, 0); // 相对位移起始触摸点
|
|
|
+ DPoint currPointLastPosition = DPoint(0, 0); // 当前操作的点之前所在位置
|
|
|
+
|
|
|
@override
|
|
|
bool onExecuteTouch(PointInfo args) {
|
|
|
- return true;
|
|
|
+ if (state == ItemStates.finished) {
|
|
|
+ if (args.pointType == PointInfoType.touchDown) {
|
|
|
+ state = ItemStates.waiting;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (state == ItemStates.waiting) {
|
|
|
+ if (args.pointType == PointInfoType.touchDown) {
|
|
|
+ isFirstPointMove = true;
|
|
|
+ handleTouchDownWhileWaiting(args);
|
|
|
+ }
|
|
|
+ } else if (state == ItemStates.running) {
|
|
|
+ if (feature == null) return false;
|
|
|
+ final f = feature! as EllipseFeature;
|
|
|
+ if (args.pointType == PointInfoType.touchDown) {
|
|
|
+ touchStartPosition = args;
|
|
|
+ currPointLastPosition = f.innerPoints[f.activeIndex];
|
|
|
+ }
|
|
|
+ if (args.pointType == PointInfoType.touchMove) {
|
|
|
+ if (isFirstPointMove) {
|
|
|
+ DPoint newStartPoint = args;
|
|
|
+ newStartPoint.addOffset(0, -0.2);
|
|
|
+ for (var element in f.innerPoints) {
|
|
|
+ element.update(newStartPoint);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ DPoint newPoint = currPointLastPosition
|
|
|
+ .clone()
|
|
|
+ .addVector(args - touchStartPosition);
|
|
|
+ f.innerPoints[f.activeIndex] = newPoint;
|
|
|
+ f.adjustPoints(newPoint);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (args.pointType == PointInfoType.touchUp) {
|
|
|
+ if (isFirstPointMove) {
|
|
|
+ isFirstPointMove = false;
|
|
|
+ f.activeIndex = 1;
|
|
|
+ }
|
|
|
+ if (f.activeIndex == 1) {
|
|
|
+ if (f.xAxisEnd != f.xAxisStart) {
|
|
|
+ f.adjustPoints(args);
|
|
|
+ f.activeIndex = 2;
|
|
|
+ }
|
|
|
+ } else if (f.activeIndex == 2) {
|
|
|
+ doFeatureFinish();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ doCalculate();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
void handleMouseDownWhileWaiting(PointInfo args) {
|
|
@@ -77,6 +131,18 @@ class Ellipse extends AreaItemAbstract {
|
|
|
state = ItemStates.running;
|
|
|
}
|
|
|
|
|
|
+ void handleTouchDownWhileWaiting(PointInfo args) {
|
|
|
+ // TODO: 判断是否当前area
|
|
|
+ // 转换为Area逻辑位置
|
|
|
+ final point = args.toAreaLogicPoint();
|
|
|
+ feature = EllipseFeature(this, point);
|
|
|
+ if (args.hostVisualArea != null) {
|
|
|
+ feature!.hostVisualArea = args.hostVisualArea;
|
|
|
+ }
|
|
|
+ feature!.activeIndex = 0;
|
|
|
+ state = ItemStates.running;
|
|
|
+ }
|
|
|
+
|
|
|
static Ellipse createAreaPerimeter(ItemMeta meta, [IMeasureItem? parent]) {
|
|
|
final ellipse = Ellipse(meta, parent);
|
|
|
ellipse.calculator = AreaPerimeterEllipseCal(ellipse);
|