updateDrawing method
void
updateDrawing(
- Offset point
)
Implementation
void updateDrawing(Offset point) {
if (_currentDrawingTool == null) return;
switch (_currentDrawingTool!.type) {
case DrawingToolType.trendLine:
final tool = _currentDrawingTool as TrendLineTool;
tool.endPoint = point;
break;
case DrawingToolType.trendAngle:
final tool = _currentDrawingTool as TrendAngleTool;
tool.endPoint = point;
// 计算角度
if (tool.startPoint != null && tool.endPoint != null) {
final dx = tool.endPoint!.dx - tool.startPoint!.dx;
final dy = tool.endPoint!.dy - tool.startPoint!.dy;
tool.angle = (atan2(dy, dx) * 180 / pi).abs();
}
break;
case DrawingToolType.arrow:
final tool = _currentDrawingTool as ArrowTool;
tool.endPoint = point;
break;
case DrawingToolType.verticalLine:
final tool = _currentDrawingTool as VerticalLineTool;
tool.xPosition = point.dx;
break;
case DrawingToolType.horizontalLine:
final tool = _currentDrawingTool as HorizontalLineTool;
tool.yPosition = point.dy;
break;
case DrawingToolType.horizontalRay:
final tool = _currentDrawingTool as HorizontalRayTool;
if (tool.direction == null) {
tool.direction = point.dx > tool.startPoint!.dx ? 1.0 : -1.0;
}
break;
case DrawingToolType.ray:
final tool = _currentDrawingTool as RayTool;
tool.directionPoint = point;
break;
case DrawingToolType.crossLine:
final tool = _currentDrawingTool as CrossLineTool;
tool.centerPoint = point;
break;
}
_notifyToolsChanged();
}