// Copyright (C) Stichting Deltares 2025. 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; using System.Drawing; using System.Drawing.Drawing2D; using Deltares.Dam.Data.Sensors; using Deltares.Geometry.Forms; using Deltares.Mathematics; using Deltares.Standard.Forms; namespace Deltares.Dam.Forms { public class SensorDrawingObject : DrawingObject { private Sensor sensor; private Point2D point; /// /// Initializes a new instance of the class. /// public SensorDrawingObject() { Layer = -50; } /// /// Gets or sets the color. /// /// /// The color. /// public Color Color { get; set; } = Color.Coral; /// /// Sets the data object. /// /// The data object. public override void SetDataObject(object dataObject) { sensor = (Sensor) dataObject; } /// /// Gets the data object. /// /// public override object GetDataObject() { return sensor; } /// /// Render this object in 3D space. /// /// Rendering target information. public override void Draw3D(GraphicsInfo info) { DrawingSupport.SetIEPDraw3D(info.Graphics); DrawingSupport.Pen3D(DashStyle.Solid, 3, Color); if (sensor != null) { var calculatedPoint = new Point3D(); var sensorPoint = new Point3D(sensor.RelativeLocation, 0.0, sensor.Depth); GetScaled3DPoint(info.Projection, new Point3D(sensorPoint.X, sensorPoint.Y, sensorPoint.Z), ref calculatedPoint); DrawingSupport.Cross_Symbol3D(calculatedPoint.X, calculatedPoint.Z, 10); point = new Point2D(calculatedPoint.X, calculatedPoint.Z); } } /// /// Determines whether the screenpoint is on the location of the sensor (to support showing tooltip) /// /// The projection. /// The screen point. /// public override bool ContainsPoint(IProjection projection, Point screenPoint) { var screenPoint2D = new Point2D(screenPoint.X, screenPoint.Y); if (point != null) { if (Routines2D.DetermineIfPointsCoincide(point, screenPoint2D, 3)) { return true; } } return false; } /// /// Renders a label or tooltip to provide some information in text for this object. /// /// Rendering target information. public override void DrawLabel(GraphicsInfo info) { var realPoint = new Point(Convert.ToInt32(point.X), Convert.ToInt32(point.Y)); var screenPoint = new Point(realPoint.X + 20, realPoint.Y - 20); DrawingSupport.DrawLabelAtPoint(info, realPoint, screenPoint, sensor.Name, Brushes.Black, Brushes.LemonChiffon, Brushes.DarkSlateGray); } } }