/// <summary> /// Event handler for the <see cref="PickingTool.PreviewRequested"/> event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="eventArgs">The <see cref="ToleratedObjectEventArgs"/> instance containing the event data.</param> private void OnPreviewRequested(object sender, ToleratedObjectEventArgs eventArgs) { this.Graphics.Clear(); if (this.pickedPoints.Count < 1) { return; } var centroid = this.pickedPoints.Last(); var sectionLength = Distance.PointToPoint(eventArgs.HitPoint, centroid); var distances = new[] { this.heightValueBox.Value, this.widthValueBox.Value, this.radiusValueBox.Value, sectionLength }; if (distances.Any(x => x < GeometryConstants.DISTANCE_EPSILON)) { return; } var normal = new Vector(eventArgs.HitPoint - centroid); var transitionSection = new TransitionSectionGeometry( this.heightValueBox.Value, this.widthValueBox.Value, sectionLength, this.radiusValueBox.Value, centroid, normal); this.DrawTransitionSection(transitionSection); }
/// <summary> /// Event handler for the <see cref="PickingTool.ObjectPicked"/> event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="eventArgs">The <see cref="ToleratedObjectEventArgs"/> instance containing the event data.</param> private void OnObjectPicked(object sender, ToleratedObjectEventArgs eventArgs) { if (!eventArgs.IsValid) { return; } this.pickedPoints.Add(eventArgs.HitPoint); }
/// <summary> /// Event handler for the <see cref="PickingTool.PreviewRequested"/> event. /// </summary> /// <param name="sender">The sender object.</param> /// <param name="eventArgs">The event argument for the handler.</param> private void OnPreviewRequested(object sender, ToleratedObjectEventArgs eventArgs) { this.Graphics.Clear(); this.currentAppliedValues = this.Component.GetAppliedAttributes(); var profile = BasicPlugin.BeamPlugin.DefaultProfileName; var lengthFactor = 2.0; if (this.currentAppliedValues.TryGetValue("Profile", out var profileValue)) { profile = profileValue.ToString(); } if (this.currentAppliedValues.TryGetValue("LengthFactor", out var lengthFactorValue)) { double.TryParse(lengthFactorValue.ToString(), out lengthFactor); } if (this.pickedPoints.Any()) { var lengthVector = new Vector(eventArgs.HitPoint - this.pickedPoints.Last()) * lengthFactor; this.Graphics.DrawProfile(profile, new LineSegment(this.pickedPoints.Last(), lengthVector + this.pickedPoints.Last()), new Vector(0, 0, -150), rotationInDegrees: 90); } }