// -------------------------------------------------------------------------------------------------------------------- // // http://helixtoolkit.codeplex.com, license: Ms-PL // // // Represents a set of line segments. The thickness of the lines is defined in screen space. // // -------------------------------------------------------------------------------------------------------------------- namespace HelixToolkit { using System.Windows; /// /// Represents a set of line segments. The thickness of the lines is defined in screen space. /// public class LinesVisual3D : ScreenSpaceVisual3D { #region Constants and Fields /// /// The thickness property. /// public static readonly DependencyProperty ThicknessProperty = DependencyProperty.Register( "Thickness", typeof(double), typeof(LinesVisual3D), new UIPropertyMetadata(1.0, GeometryChanged)); /// /// The builder. /// private readonly LineGeometryBuilder builder; #endregion #region Constructors and Destructors /// /// Initializes a new instance of the class. /// public LinesVisual3D() { this.builder = new LineGeometryBuilder(this); } #endregion #region Public Properties /// /// Gets or sets the thickness of the lines. /// /// /// The thickness. /// public double Thickness { get { return (double)this.GetValue(ThicknessProperty); } set { this.SetValue(ThicknessProperty, value); } } #endregion #region Methods /// /// Updates the geometry. /// protected override void UpdateGeometry() { this.mesh.Positions = null; int n = this.Points.Count; if (this.mesh.TriangleIndices.Count != n * 3) { this.mesh.TriangleIndices = this.builder.CreateIndices(n); } this.mesh.Positions = this.builder.CreatePositions(this.Points, this.Thickness, this.DepthOffset); } /// /// Updates the transforms. /// /// /// True if the transform is updated. /// protected override bool UpdateTransforms() { return this.builder.UpdateTransforms(); } #endregion } }