// Copyright (C) Stichting Deltares 2024. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System.Drawing; using System.Drawing.Drawing2D; using Deltares.Dam.Data; using Deltares.Geometry.Forms; using Deltares.Mathematics; using Deltares.Standard.Forms; namespace Deltares.Dam.Forms { public class SlipCircleDrawingObject : DrawingObject { private StabilityResultSlices slipcircle; /// /// Initializes a new instance of the class. /// public SlipCircleDrawingObject() { Layer = -60; } /// /// Gets or sets the color. /// /// /// The color. /// public Color Color { get; set; } = Color.Salmon; /// /// Sets the data object. /// /// The data object. public override void SetDataObject(object aDataObject) { slipcircle = (StabilityResultSlices) aDataObject; } /// /// Gets the data object. /// /// public override object GetDataObject() { return slipcircle; } /// /// override The Draw3D() Method /// /// public override void Draw3D(GraphicsInfo info) { DrawingSupport.SetIEPDraw3D(info.Graphics); DrawingSupport.ColorMaterial3D(Color.CornflowerBlue); DrawingSupport.Brush3D(Color.Black); DrawingSupport.Pen3D(DashStyle.Solid, 3, Color); DrawSlices(info); Point3D activeCenterPoint; var topLeftPoint = new Point3D { X = slipcircle.StabilityResultSlice[0].BottomLeftPoint.X, Y = 0, Z = slipcircle.StabilityResultSlice[0].BottomLeftPoint.Y }; GetScaled3DPoint(info.Projection, topLeftPoint, ref topLeftPoint); int sliceIndex = slipcircle.StabilityResultSlice.Count - 1; var topRightPointSlice = new Point3D { X = slipcircle.StabilityResultSlice[sliceIndex].TopRightPoint.X, Y = 0, Z = slipcircle.StabilityResultSlice[sliceIndex].TopRightPoint.Y }; GetScaled3DPoint(info.Projection, topRightPointSlice, ref topRightPointSlice); if (slipcircle.ActiveCenterPoint != null) { activeCenterPoint = new Point3D { X = slipcircle.ActiveCenterPoint.X, Y = 0, Z = slipcircle.ActiveCenterPoint.Y }; GetScaled3DPoint(info.Projection, activeCenterPoint, ref activeCenterPoint); DrawingSupport.Cross_Symbol3D(activeCenterPoint.X, activeCenterPoint.Z, 10); DrawingSupport.Pen3D(DashStyle.Solid, 1, Color); DrawingSupport.Line3D(topLeftPoint, activeCenterPoint); if (slipcircle.PassiveCenterPoint != null) { var passiveCenterPoint = new Point3D { X = slipcircle.PassiveCenterPoint.X, Y = 0, Z = slipcircle.PassiveCenterPoint.Y }; GetScaled3DPoint(info.Projection, passiveCenterPoint, ref passiveCenterPoint); DrawingSupport.Cross_Symbol3D(passiveCenterPoint.X, passiveCenterPoint.Z, 10); DrawingSupport.Pen3D(DashStyle.Solid, 1, Color); DrawingSupport.Line3D(topRightPointSlice, passiveCenterPoint); } else { DrawingSupport.Pen3D(DashStyle.Solid, 1, Color); DrawingSupport.Line3D(topRightPointSlice, activeCenterPoint); } } } private void DrawSlices(GraphicsInfo info) { for (var i = 0; i < slipcircle.StabilityResultSlice.Count; i++) { StabilityResultSlice stabilityResultSlice = slipcircle.StabilityResultSlice[i]; var bottomLeftPoint = new Point3D { X = stabilityResultSlice.BottomLeftPoint.X, Y = 0, Z = stabilityResultSlice.BottomLeftPoint.Y }; var bottomRightPoint = new Point3D { X = stabilityResultSlice.BottomRightPoint.X, Y = 0, Z = stabilityResultSlice.BottomRightPoint.Y }; var topLeftPoint = new Point3D { X = stabilityResultSlice.TopLeftPoint.X, Y = 0, Z = stabilityResultSlice.TopLeftPoint.Y }; var topRightPoint = new Point3D { X = stabilityResultSlice.TopRightPoint.X, Y = 0, Z = stabilityResultSlice.TopRightPoint.Y }; GetScaled3DPoint(info.Projection, bottomLeftPoint, ref bottomLeftPoint); GetScaled3DPoint(info.Projection, bottomRightPoint, ref bottomRightPoint); GetScaled3DPoint(info.Projection, topLeftPoint, ref topLeftPoint); GetScaled3DPoint(info.Projection, topRightPoint, ref topRightPoint); DrawingSupport.Line3D(bottomLeftPoint, bottomRightPoint); DrawingSupport.Line3D(bottomRightPoint, topRightPoint); DrawingSupport.Line3D(topRightPoint, topLeftPoint); DrawingSupport.Line3D(topLeftPoint, bottomLeftPoint); } } } }