startDrawing method
Implementation
void startDrawing(Offset point, {Map<String, dynamic>? properties}) {
debugPrint('DrawingToolManager.startDrawing: $_currentToolType at $point');
if (_currentToolType == null) return;
_finishCurrentDrawing();
final id = _generateId();
switch (_currentToolType!) {
case DrawingToolType.trendLine:
_currentDrawingTool = TrendLineTool(
id: id,
startPoint: point,
color: properties?['color'] ?? const Color(0xFFFFD700),
strokeWidth: properties?['strokeWidth'] ?? 2.0,
);
break;
case DrawingToolType.trendAngle:
_currentDrawingTool = TrendAngleTool(
id: id,
startPoint: point,
color: properties?['color'] ?? const Color(0xFFFFD700),
strokeWidth: properties?['strokeWidth'] ?? 2.0,
);
break;
case DrawingToolType.arrow:
_currentDrawingTool = ArrowTool(
id: id,
startPoint: point,
color: properties?['color'] ?? const Color(0xFFFF6B6B),
strokeWidth: properties?['strokeWidth'] ?? 2.0,
);
break;
case DrawingToolType.verticalLine:
_currentDrawingTool = VerticalLineTool(
id: id,
xPosition: point.dx,
color: properties?['color'] ?? const Color(0xFF00BFFF),
strokeWidth: properties?['strokeWidth'] ?? 2.0,
);
// 垂直线工具创建后立即完成
_currentDrawingTool!.state = DrawingToolState.none;
_tools.add(_currentDrawingTool!);
_currentDrawingTool = null;
_notifyToolsChanged();
return;
case DrawingToolType.horizontalLine:
_currentDrawingTool = HorizontalLineTool(
id: id,
yPosition: point.dy,
color: properties?['color'] ?? const Color(0xFF00BFFF),
strokeWidth: properties?['strokeWidth'] ?? 2.0,
);
// 水平线工具创建后立即完成
_currentDrawingTool!.state = DrawingToolState.none;
_tools.add(_currentDrawingTool!);
_currentDrawingTool = null;
_notifyToolsChanged();
return;
case DrawingToolType.horizontalRay:
_currentDrawingTool = HorizontalRayTool(
id: id,
startPoint: point,
color: properties?['color'] ?? const Color(0xFF00BFFF),
strokeWidth: properties?['strokeWidth'] ?? 2.0,
);
break;
case DrawingToolType.ray:
_currentDrawingTool = RayTool(
id: id,
startPoint: point,
color: properties?['color'] ?? const Color(0xFF00BFFF),
strokeWidth: properties?['strokeWidth'] ?? 2.0,
);
break;
case DrawingToolType.crossLine:
_currentDrawingTool = CrossLineTool(
id: id,
centerPoint: point,
color: properties?['color'] ?? const Color(0xFF00BFFF),
strokeWidth: properties?['strokeWidth'] ?? 2.0,
);
// 十字线工具创建后立即完成
_currentDrawingTool!.state = DrawingToolState.none;
_tools.add(_currentDrawingTool!);
_currentDrawingTool = null;
_notifyToolsChanged();
return;
}
if (_currentDrawingTool != null) {
_currentDrawingTool!.state = DrawingToolState.drawing;
_notifyToolsChanged();
}
}