Esempio n. 1
0
        //--------------------------------------------------------------------------------------------------

        public override bool OnMouseUp(MouseEventData data, bool shiftSelected)
        {
            if (_Moving)
            {
                _Moving = false;

                if (MoveDelta != Vec2d.Zero)
                {
                    // Commit
                    RaiseFinished();
                    MoveDelta = Vec2d.Zero;

                    // Set new center
                    UpdateTrihedron();
                }

                WorkspaceController.HudManager?.RemoveElement(_Coord2DHudElement);
                _Coord2DHudElement = null;
                WorkspaceController.HudManager?.RemoveElement(_Delta2DHudElement);
                _Coord2DHudElement = null;

                _MergePreviewMarkers.ForEach(m => m.Remove());
                _MergePreviewMarkers.Clear();

                return(true);
            }
            return(base.OnMouseUp(data, shiftSelected));
        }
Esempio n. 2
0
        //--------------------------------------------------------------------------------------------------

        public override bool OnMouseMove(MouseEventData data)
        {
            if (_Moving)
            {
                // Get new point from parameters
                double u = 0, v = 0;
                ElSLib.Parameters(_Sketch.Plane, data.PointOnPlane, ref u, ref v);
                var newPoint = new Pnt2d(u, v);

                // Calc delta
                MoveDelta = new Vec2d(newPoint.Coord.Subtracted(_MoveStartPoint.Coord));

                // Apply constraints
                ApplyConstraints();
                Snap();
                ApplyConstraints();

                // Calc new 3D center
                var newPos3D = ElSLib.Value(_Center2D.X + MoveDelta.X, _Center2D.Y + MoveDelta.Y, _Sketch.Plane);
                _GizmoPlane.SetLocation(newPos3D);
                Gizmo.SetComponent(_GizmoPlane);

                // Check for point merge candidates
                _MergePreviewMarkers.ForEach(m => m.Remove());
                _MergePreviewMarkers.Clear();
                foreach (var candidate in CheckMergePoints(MoveDelta))
                {
                    var point     = _Sketch.Points[candidate.Value];
                    var geomPoint = new Geom_CartesianPoint(point.X, point.Y, 0);
                    geomPoint.Transform(_Sketch.GetTransformation());
                    var marker = new Marker(WorkspaceController, Marker.Styles.Bitmap | Marker.Styles.Topmost, Marker.RingImage);
                    marker.Set(geomPoint);
                    marker.SetColor(Colors.Highlight);
                    _MergePreviewMarkers.Add(marker);
                }

                data.ForceReDetection = true;

                if (_Coord2DHudElement == null)
                {
                    _Coord2DHudElement = WorkspaceController.HudManager?.CreateElement <Coord2DHudElement>(this);
                    _Delta2DHudElement = WorkspaceController.HudManager?.CreateElement <Delta2DHudElement>(this);
                }
                if (_Coord2DHudElement != null)
                {
                    _Coord2DHudElement.CoordinateX = _Center2D.X + MoveDelta.X;
                    _Coord2DHudElement.CoordinateY = _Center2D.Y + MoveDelta.Y;
                }
                if (_Delta2DHudElement != null)
                {
                    _Delta2DHudElement.DeltaX = MoveDelta.X;
                    _Delta2DHudElement.DeltaY = MoveDelta.Y;
                }
            }

            return(base.OnMouseMove(data));
        }
Esempio n. 3
0
        //--------------------------------------------------------------------------------------------------

        public override void Stop()
        {
            Gizmo?.Remove();

            WorkspaceController.HudManager?.RemoveElement(_Coord2DHudElement);
            _Coord2DHudElement = null;
            WorkspaceController.HudManager?.RemoveElement(_Delta2DHudElement);
            _Coord2DHudElement = null;

            _MergePreviewMarkers.ForEach(m => m.Remove());
            _MergePreviewMarkers.Clear();

            if (_Sketch != null)
            {
                _Sketch.ElementsChanged -= Sketch_ElementsChanged;
            }

            base.Stop();
        }