diff --git a/Elements/src/EdgeDisplaySettings.cs b/Elements/src/EdgeDisplaySettings.cs index 94300b1ee..ec11b9241 100644 --- a/Elements/src/EdgeDisplaySettings.cs +++ b/Elements/src/EdgeDisplaySettings.cs @@ -14,6 +14,21 @@ public class EdgeDisplaySettings /// How the Width should be interpreted. If set to Screen Units, Width is interpreted as a constant pixel width (and rounded to the nearest integer). If set to World Units, Width is interpreted as a constant meter width. /// public EdgeDisplayWidthMode WidthMode { get; set; } = EdgeDisplayWidthMode.ScreenUnits; + + /// + /// Whether and how to display dashes along the line. + /// + public EdgeDisplayDashMode DashMode { get; set; } = EdgeDisplayDashMode.None; + + /// + /// The size of the dash. If Mode is set to None, this value will be ignored. Note that the units for this value (screen vs world) are affected by the choice of Dash Mode. + /// + public double DashSize { get; set; } = 1; + + /// + /// The size of the gaps between dashes. If Mode is set to None, this value will be ignored. If this value is set to null, DashSize will be used. Note that the units for this value (screen vs world) are affected by the choice of Dash Mode. + /// + public double? GapSize { get; set; } = 1; } /// @@ -30,4 +45,23 @@ public enum EdgeDisplayWidthMode /// WorldUnits = 1, } + + /// + /// Different ways to interpret the Width property of a EdgeDisplaySettings. + /// + public enum EdgeDisplayDashMode + { + /// + /// Dashed display is not enabled. Dash size is ignored. + /// + None = 0, + /// + /// Dash sizes are specified in pixels, and maintain a constant size when zooming. + /// + ScreenUnits = 1, + /// + /// Dash sizes are specified in meters, and maintain a constant size relative to the model. + /// + WorldUnits = 2, + } } \ No newline at end of file diff --git a/Elements/src/Serialization/glTF/GltfExtensions.cs b/Elements/src/Serialization/glTF/GltfExtensions.cs index 9cd0b6c8e..11cc68c25 100644 --- a/Elements/src/Serialization/glTF/GltfExtensions.cs +++ b/Elements/src/Serialization/glTF/GltfExtensions.cs @@ -232,6 +232,8 @@ internal static Dictionary AddMaterials(this Gltf gltf, AddExtension(gltf, gltfMaterial, "HYPAR_materials_edge_settings", new Dictionary{ {"lineWidth", material.EdgeDisplaySettings.LineWidth}, {"widthMode", (int)material.EdgeDisplaySettings.WidthMode}, + {"dashMode", (int)material.EdgeDisplaySettings.DashMode}, + {"dashSize", material.EdgeDisplaySettings.DashSize} }); } diff --git a/Elements/test/ModelCurveTests.cs b/Elements/test/ModelCurveTests.cs index 88ba4e4d3..aa9faba3e 100644 --- a/Elements/test/ModelCurveTests.cs +++ b/Elements/test/ModelCurveTests.cs @@ -71,9 +71,9 @@ public void ModelCurveWithLineWeights() var ctrlPts = new List { a, b, c, d, e, f }; var bezier = new Bezier(ctrlPts); - var lineModelCurve = new ModelCurve(line, new Material("Red", Colors.Red) { EdgeDisplaySettings = new EdgeDisplaySettings { LineWidth = 5 } }); + var lineModelCurve = new ModelCurve(line, new Material("Red", Colors.Red) { EdgeDisplaySettings = new EdgeDisplaySettings { LineWidth = 5, DashMode = EdgeDisplayDashMode.WorldUnits, DashSize = 0.1 } }); var arcModelCurve = new ModelCurve(arc, new Material("Orange", Colors.Orange) { EdgeDisplaySettings = new EdgeDisplaySettings { LineWidth = 0.1, WidthMode = EdgeDisplayWidthMode.WorldUnits } }, new Transform(5, 0, 0)); - var plineModelCurve = new ModelCurve(pline, new Material("Purple", Colors.Purple) { EdgeDisplaySettings = new EdgeDisplaySettings { LineWidth = 10, WidthMode = EdgeDisplayWidthMode.ScreenUnits } }, new Transform(10, 0, 0)); + var plineModelCurve = new ModelCurve(pline, new Material("Purple", Colors.Purple) { EdgeDisplaySettings = new EdgeDisplaySettings { LineWidth = 10, WidthMode = EdgeDisplayWidthMode.ScreenUnits, DashMode = EdgeDisplayDashMode.ScreenUnits, DashSize = 10, GapSize = 4 } }, new Transform(10, 0, 0)); var bezierModelCurve = new ModelCurve(bezier, new Material("Green", Colors.Green) { EdgeDisplaySettings = new EdgeDisplaySettings { LineWidth = 1, WidthMode = EdgeDisplayWidthMode.WorldUnits } }, new Transform(15, 0, 0)); //