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

        void _Sketch_ElementsChanged(Sketch sketch, Sketch.ElementType types)
        {
            if (sketch != Sketch)
            {
                return;
            }

            // Check for new ones
            if (types.HasFlag(Sketch.ElementType.Point))
            {
                // Take over new points
                _TempPoints = new Dictionary <int, Pnt2d>(Sketch.Points);
            }

            Elements.OnSketchChanged(Sketch, types);
            _UpdateSelections();
        }
Esempio n. 2
0
        //--------------------------------------------------------------------------------------------------

        void Sketch_ElementsChanged(Sketch sketch, Sketch.ElementType types)
        {
            if (types.HasFlag(Sketch.ElementType.Point))
            {
                // Check for lost points
                var lostPoints = Points.Where(i => !_Sketch.Points.ContainsKey(i)).ToArray();
                foreach (var lostPoint in lostPoints)
                {
                    Points.Remove(lostPoint);
                }

                if (!Points.Any())
                {
                    RaiseFinished();
                }

                UpdateTrihedron();
            }
        }
        //--------------------------------------------------------------------------------------------------

        internal void OnSketchChanged(Sketch sketch, Sketch.ElementType types)
        {
            if (sketch == _SketchEditorTool.Sketch)
            {
                if (types.HasFlag(Sketch.ElementType.Point))
                {
                    // Check for lost points
                    var lostPoints = PointElements.Where(pc => !sketch.Points.ContainsKey(pc.PointIndex)).ToArray();
                    foreach (var lostPoint in lostPoints)
                    {
                        lostPoint.Remove();
                        PointElements.Remove(lostPoint);
                    }
                }
                if (types.HasFlag(Sketch.ElementType.Segment))
                {
                    // Check for lost segments
                    var lostSegs = SegmentElements.Where(sc => !sketch.Segments.ContainsValue(sc.Segment)).ToArray();
                    foreach (var lostSeg in lostSegs)
                    {
                        lostSeg.Remove();
                        SegmentElements.Remove(lostSeg);
                    }
                }
                if (types.HasFlag(Sketch.ElementType.Constraint))
                {
                    // Check for lost constraints
                    var lostCons = ConstraintElements.Where(cc => !sketch.Constraints.Contains(cc.Constraint)).ToArray();
                    foreach (var lostCon in lostCons)
                    {
                        lostCon.Remove();
                        ConstraintElements.Remove(lostCon);
                    }
                }

                // Check for new ones
                if (types.HasFlag(Sketch.ElementType.Point))
                {
                    // Check for new points
                    var newPoints = sketch.Points.Where(kvp => !PointElements.Exists(pc => pc.PointIndex == kvp.Key));
                    foreach (var pointKvp in newPoints)
                    {
                        var element = new SketchEditorPointElement(_SketchEditorTool, pointKvp.Key, pointKvp.Value, _SketchEditorTool.Transform, sketch.Plane);
                        element.UpdateVisual();
                        element.Activate(true);
                        PointElements.Add(element);
                    }
                }
                if (types.HasFlag(Sketch.ElementType.Segment))
                {
                    // Check for new segments
                    var newSegs = sketch.Segments.Where(seg => !SegmentElements.Exists(sc => sc.Segment == seg.Value));
                    foreach (var segmentKvp in newSegs)
                    {
                        var element = new SketchEditorSegmentElement(_SketchEditorTool, segmentKvp.Key, segmentKvp.Value, _SketchEditorTool.Transform, sketch.Plane);
                        element.OnPointsChanged(sketch.Points, sketch.Segments, _MarkerCounts);
                        element.UpdateVisual();
                        element.Activate(true);
                        SegmentElements.Add(element);
                    }
                }
                if (types.HasFlag(Sketch.ElementType.Constraint))
                {
                    // Check for new constraints
                    var newCons = sketch.Constraints.Where(con => !ConstraintElements.Exists(cc => cc.Constraint == con));
                    foreach (var sketchConstraint in newCons)
                    {
                        var element = new SketchEditorConstraintElement(_SketchEditorTool, sketchConstraint, _SketchEditorTool.Transform, sketch.Plane);
                        element.OnPointsChanged(sketch.Points, sketch.Segments, _MarkerCounts);
                        element.UpdateVisual();
                        element.Activate(true);
                        ConstraintElements.Add(element);
                    }
                }

                // Update elements
                _UpdateElementList();

                if (types.HasFlag(Sketch.ElementType.Point))
                {
                    OnPointsChanged(sketch.Points, sketch.Segments);
                }

                _SketchEditorTool.WorkspaceController.Invalidate();
            }
        }