Пример #1
0
        public static void Update(ref PCad.Model model, CoordinateSystemUI coordinateSystemUI,
                                  bool isMouseOnDrawArea, Action saveToHistory)
        {
            model.InteractionState.hoveredCoordinate =
                CoordinateManipulation.TryGetCoordinateAtPosition(coordinateSystemUI);

            NumpadInput.UpdateNumpadInput(ref model.InteractionState.keyboardInputModel,
                                          model.Sketch.coordinateSystem.GetAllParameters()
                                          );

            model.InteractionState.focusPosition = CoordinateCreation.UpdateCursorPosition(
                model.InteractionState.focusPosition,
                model.Sketch.coordinateSystem,
                model.InteractionState.keyboardInputModel
                );

            if (model.InteractionState.focusPosition == null)
            {
                Debug.LogError($"Focus Position should always be != null if state == DrawRectangles");
                return;
            }

            switch (model.InteractionState.CurrentMouseState)
            {
            case MouseInput.MouseState.None:
            case MouseInput.MouseState.PrimaryHold:
            case MouseInput.MouseState.PrimaryUp:
                break;

            case MouseInput.MouseState.PrimaryDown:
                if (isMouseOnDrawArea || Input.GetKeyDown(KeyCode.Return))
                {
                    AddPointToDrawing(ref model, saveToHistory);
                }

                break;

            case MouseInput.MouseState.SetAnchorDown:
                var mousePosition = MouseInput.RaycastPosition;
                model.Sketch.coordinateSystem.SetAnchorPosition(mousePosition);
                break;

            case MouseInput.MouseState.DeleteDown:
                CoordinateCreation.DeletePositionAtMousePosition(model.Sketch.coordinateSystem);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            UpdateGeometry(ref model.InteractionState.incompleteGeometry, model.InteractionState.focusPosition);
        }
Пример #2
0
 public void Initialize(Vec <float> mousePositionAsOrigin)
 {
     Sketch.coordinateSystem             = new CoordinateSystem(mousePositionAsOrigin);
     Sketch.geometries                   = new List <GeometryModel>();
     InteractionState.keyboardInputModel = new NumpadInput.Model();
     Tool = new ToolConfiguration()
     {
         ActiveTool           = ToolConfiguration.Tool.Drawing,
         CurrentGeometryType  = GeometryType.Rectangle,
         CurrentGeometryColor = GeometryStyleAsset.GeometryColor.White,
     };
     InteractionState.focusPosition = CoordinateCreation.UpdateCursorPosition(
         InteractionState.focusPosition,
         Sketch.coordinateSystem,
         InteractionState.keyboardInputModel
         );
 }