public static void AddPointToDrawing(ref PCad.Model model, Action saveToHistory) { CoordinateCreation.BakePosition(model.InteractionState.focusPosition); model.Sketch.coordinateSystem.SetAnchorPosition(MouseInput.RaycastPosition); switch (model.Tool.CurrentGeometryType) { case GeometryType.Point: model.Sketch.geometries.Add(PointCreation.NewPoint(model.InteractionState.focusPosition)); saveToHistory(); break; case GeometryType.Line: if (!(model.InteractionState.incompleteGeometry is LineModel)) { model.InteractionState.incompleteGeometry = LineCreation.StartNewLine(model.InteractionState.focusPosition); model.Sketch.geometries.Add(model.InteractionState.incompleteGeometry); } else { LineCreation.CompleteLine(model.InteractionState.incompleteGeometry as LineModel, model.InteractionState.focusPosition); model.InteractionState.incompleteGeometry = null; saveToHistory(); } break; case GeometryType.Rectangle: if (!(model.InteractionState.incompleteGeometry is RectangleModel)) { model.InteractionState.incompleteGeometry = RectangleCreation.StartNewRectangle(model.InteractionState.focusPosition, model.Tool.CurrentGeometryColor); model.Sketch.geometries.Add(model.InteractionState.incompleteGeometry); } else { RectangleCreation.CompleteRectangle(model.InteractionState.incompleteGeometry as RectangleModel, model.InteractionState.focusPosition); model.InteractionState.incompleteGeometry = null; saveToHistory(); } break; default: throw new ArgumentOutOfRangeException(); } // reset input model.InteractionState.keyboardInputModel = new NumpadInput.Model(); }
private static void UpdateGeometry(ref GeometryModel incompleteGeometry, Vec <Coordinate> focusPosition) { switch (incompleteGeometry) { case RectangleModel rectangleModel: RectangleCreation.UpdateRectangle(rectangleModel, focusPosition); break; case LineModel lineModel: LineCreation.UpdateLine(lineModel, focusPosition); break; } }