예제 #1
0
        //--------------------------------------------------------------------------------------------------

        public override bool OnMouseUp(MouseEventData data, bool shiftSelected)
        {
            if (_MoveMode != MoveMode.None)
            {
                _MoveMode = MoveMode.None;
                WorkspaceController.HudManager?.SetCursor(null);

                _AxisHintLine?.Remove();

                WorkspaceController.HudManager?.RemoveElement(_Coord3dHudElement);
                _Coord3dHudElement = null;
                WorkspaceController.HudManager?.RemoveElement(_Delta3DHudElement);
                _Delta3DHudElement = null;

                if (_Delta.SquareMagnitude() > 0)
                {
                    // Commit
                    Stop();
                    IsFinished = true;
                }

                WorkspaceController.Invalidate();
                return(true);
            }
            return(base.OnMouseUp(data, shiftSelected));
        }
예제 #2
0
        //--------------------------------------------------------------------------------------------------

        public override bool OnMouseMove(MouseEventData data)
        {
            if (_MoveMode != MoveMode.None)
            {
                if ((_MoveMode & MoveMode.Axis) != 0)
                {
                    var axisDelta = _ProcessMouseInputForAxis(data) - _MoveStartValue.X;
                    if (!axisDelta.HasValue)
                    {
                        return(false);
                    }

                    _Delta = Vec.Zero;

                    switch (_MoveMode)
                    {
                    case MoveMode.AxisX:
                        _Delta.X = axisDelta.Value;
                        break;

                    case MoveMode.AxisY:
                        _Delta.Y = axisDelta.Value;
                        break;

                    case MoveMode.AxisZ:
                        _Delta.Z = axisDelta.Value;
                        break;
                    }
                }
                else if ((_MoveMode & MoveMode.Plane) != 0)
                {
                    Pnt resultPnt;
                    if (!WorkspaceController.ActiveViewport.ScreenToPoint(_MovePlane, (int)data.ScreenPoint.X, (int)data.ScreenPoint.Y, out resultPnt))
                    {
                        return(false);
                    }

                    _Delta = Vec.Zero;

                    var planeDelta = ProjLib.Project(_MovePlane, resultPnt).Translated(_MoveStartValue, Pnt2d.Origin);
                    switch (_MoveMode)
                    {
                    case MoveMode.PlaneYZ:
                        _Delta.Z = planeDelta.X;
                        _Delta.Y = -planeDelta.Y;
                        break;

                    case MoveMode.PlaneXZ:
                        _Delta.Z = planeDelta.X;
                        _Delta.X = planeDelta.Y;
                        break;

                    case MoveMode.PlaneXY:
                        _Delta.X = planeDelta.X;
                        _Delta.Y = planeDelta.Y;
                        break;
                    }
                }

                // Transform into unrotated frame
                //Debug.WriteLine(">> {0}  {1}  {2}", Delta.x, Delta.y, Delta.z);
                _Delta.Transform(_InverseRotation);
                //Debug.WriteLine("<< {0}  {1}  {2}", Delta.x, Delta.y, Delta.z);

                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    _Delta.X = Maths.RoundToNearest(_Delta.X, WorkspaceController.Workspace.GridStep);
                    _Delta.Y = Maths.RoundToNearest(_Delta.Y, WorkspaceController.Workspace.GridStep);
                    _Delta.Z = Maths.RoundToNearest(_Delta.Z, WorkspaceController.Workspace.GridStep);
                }

                UpdateGizmo();
                data.ForceReDetection = true;

                if (_Coord3dHudElement == null)
                {
                    _Coord3dHudElement = WorkspaceController.HudManager?.CreateElement <Coord3dHudElement>(this);
                    _Delta3DHudElement = WorkspaceController.HudManager?.CreateElement <Delta3DHudElement>(this);
                }

                if (_Coord3dHudElement != null)
                {
                    var coord = _CoordinateSystem.Location.Translated(_Delta);
                    _Coord3dHudElement.CoordinateX = coord.X;
                    _Coord3dHudElement.CoordinateY = coord.Y;
                    _Coord3dHudElement.CoordinateZ = coord.Z;
                }

                if (_Delta3DHudElement != null)
                {
                    _Delta3DHudElement.DeltaX = Delta.X;
                    _Delta3DHudElement.DeltaY = Delta.Y;
                    _Delta3DHudElement.DeltaZ = Delta.Z;
                }

                return(base.OnMouseMove(data));
            }
            return(false);
        }