Index: src/Deltares.DSoilModel.Forms/DSoilModelGeometryEditor.cs =================================================================== diff -u -r225 -r238 --- src/Deltares.DSoilModel.Forms/DSoilModelGeometryEditor.cs (.../DSoilModelGeometryEditor.cs) (revision 225) +++ src/Deltares.DSoilModel.Forms/DSoilModelGeometryEditor.cs (.../DSoilModelGeometryEditor.cs) (revision 238) @@ -558,18 +558,51 @@ { return; } + + UndoRedoManager.Instance.BeginAction(); var profile = spatialEditor.EmptySelection.DataObject as SoilProfile2D; - UndoRedoManager.Instance.BeginAction(); - profile.Geometry.Clear(); - profile.Surfaces.Clear(); + ClearGeometryForSoilProfile2D(profile); + UndoRedoManager.Instance.EndAction(); - DataEventPublisher.DataListModified(profile.Geometry.Points); - DataEventPublisher.DataListModified(profile.Geometry.Curves); - DataEventPublisher.DataListModified(profile.Surfaces); + // in order to trigger refresh we select the 1st dummy object and then we reselect the "cleared" one + DataEventPublisher.SelectionChanged(new SoilProfile2D()); + DataEventPublisher.SelectionChanged(profile); } + private void ClearGeometryForSoilProfile2D(SoilProfile2D profile) + { + foreach (var lookup in Project.BoringLookup2Ds.Where(b => b.SoilProfile2D == profile).ToList()) + { + Project.BoringLookup2Ds.Remove(lookup); + boringLookup2Ds.Remove(lookup); + } + + foreach (var lookup in Project.CptLookup2Ds.Where(p => p.SoilProfile2D == profile).ToList()) + { + Project.CptLookup2Ds.Remove(lookup); + cptLookup2Ds.Remove(lookup); + } + + foreach (var location in Project.SpecificMechanismPointLocations.Where(l => l.SoilProfile2D == profile).ToList()) + { + Project.SpecificMechanismPointLocations.Remove(location); + specificMechanismPointLocations.Remove(location); + } + + foreach (var lookup in Project.Soilprofile1DLookup2Ds.Where(c => c.SoilProfile2D == profile).ToList()) + { + Project.Soilprofile1DLookup2Ds.Remove(lookup); + soilprofile1DLookup2Ds.Remove(lookup); + } + + profile.CenterCrestLocation = double.NaN; + profile.Geometry.Clear(); + profile.PreconsolidationStresses.Clear(); + profile.Surfaces.Clear(); + } + private void spatialEditor_ShapeRemoved(object sender, ShapeEventArgs e) { // if a CPT/Boring/Soilprofile Lookup is deleted, remove it from the project