/// <summary> /// Gets the rectangle, with the first segment being the right segment of the base, and going into counter /// clockwise direction. /// </summary> /// <returns>The list of segments.</returns> private List <LineSegment> GetRectangle() { var coordSys = DataFetcher.GetSectionAlignedCoordsys(this.Component); var height = DataFetcher.GetBaseHeight(this.Component); var width = DataFetcher.GetBaseWidth(this.Component); var radius = DataFetcher.GetRadius(this.Component); var length = DataFetcher.GetSectionLength(this.Component); var geometry = new TransitionSectionGeometry(height, width, length, radius, coordSys.Origin, coordSys.AxisX.Cross(coordSys.AxisY)); return(geometry.RectangularSection.OfType <LineSegment>().ToList()); }
/// <summary> /// Gets the arc representing the circle at the top of the section. /// </summary> /// <returns>The arc.</returns> private Arc GetCircle() { var coordSys = DataFetcher.GetSectionAlignedCoordsys(this.Component); double sectionLength = DataFetcher.GetSectionLength(this.Component); var normal = coordSys.AxisX.Cross(coordSys.AxisY).GetNormal(); var centerPoint = coordSys.Origin + sectionLength * normal; double radius = DataFetcher.GetRadius(this.Component); return(new Arc(centerPoint, coordSys.AxisX, coordSys.AxisY, radius, 2 * Math.PI)); }
/// <summary> /// Called when any segment has ended a drag. /// </summary> /// <param name="sender">The sender.</param> /// <param name="eventArgs">Event args.</param> private void OnDragEnded(object sender, DragEventArgs eventArgs) { var centroid = DataFetcher.GetSectionAlignedCoordsys(this.Component).Origin; var height = 2.0 * Distance.PointToLine(centroid, new Line(this.topHeightHandle.Line)); var width = 2.0 * Distance.PointToLine(centroid, new Line(this.rightWidthHandle.Line)); this.Component.SetAttribute(TransitionSectionPluginPropertyNames.RectangleWidth, width); this.Component.SetAttribute(TransitionSectionPluginPropertyNames.RectangleHeight, height); this.Component.Modify(); new Model().CommitChanges(); }
/// <summary> /// Called when a height segment is being dragged. /// </summary> /// <param name="sender">The sender.</param> /// <param name="eventArgs">The event args.</param> private void OnHeightDragOngoing(object sender, DragEventArgs eventArgs) { if (!(sender is LineHandle lineHandle)) { return; } var segment = lineHandle.Line; var centroid = DataFetcher.GetSectionAlignedCoordsys(this.Component).Origin; var halfHeight = Distance.PointToLine(centroid, new Line(segment)); this.topHeightHandle.Line = PlaceAtDistanceFromPoint(this.topHeightHandle.Line, centroid, halfHeight); this.bottomHeightHandle.Line = PlaceAtDistanceFromPoint(this.bottomHeightHandle.Line, centroid, halfHeight); this.Graphics.Clear(); this.DrawRectangle(DataFetcher.GetBaseWidth(this.Component), 2.0 * halfHeight); }
/// <summary> /// Draws the preview of the base of the transition section. /// </summary> /// <param name="width">Width of the base.</param> /// <param name="height">Height of the base.</param> private void DrawRectangle(double width, double height) { var coordSys = DataFetcher.GetSectionAlignedCoordsys(this.Component); var radius = DataFetcher.GetRadius(this.Component); var length = DataFetcher.GetSectionLength(this.Component); var geometry = new TransitionSectionGeometry(height, width, length, radius, coordSys.Origin, coordSys.AxisX.Cross(coordSys.AxisY)); var rectangle = geometry.RectangularSection; foreach (var curve in rectangle) { if (curve is LineSegment segment) { this.Graphics.DrawLine(segment.StartPoint, segment.EndPoint); } else if (curve is Arc arc) { this.Graphics.DrawArc(arc); } } }