Example #1
0
        /// <summary>
        /// Obtains the geometry for spans along this leg.
        /// </summary>
        /// <param name="pos">The position for the start of the leg.
        /// <param name="bearing">The bearing of the leg.</param>
        /// <param name="sfac">Scale factor to apply to distances.</param>
        /// <param name="spans">Information for the spans coinciding with this leg.</param>
        /// <returns>The sections along this leg</returns>
        internal override ILineGeometry[] GetSpanSections(IPosition pos, double bearing, double sfac, SpanInfo[] spans)
        {
            var result = new ILineGeometry[spans.Length];

            // A leg with just one span, but no observed distance is due to the fact that the Leg constructor
            // that accepts a span count will always produce an array with at least one span (this covers cul-de-sacs
            // defined only with a central angle). May be better to handle it there.
            if (spans.Length == 1 && spans[0].ObservedDistance == null)
            {
                result[0] = new LineSegmentGeometry(pos, pos);
                return(result);
            }

            double sinBearing = Math.Sin(bearing);
            double cosBearing = Math.Cos(bearing);

            IPosition sPos = pos;
            IPosition ePos = null;

            double edist = 0.0;

            for (int i = 0; i < result.Length; i++, sPos = ePos)
            {
                edist    += (spans[i].ObservedDistance.Meters * sfac);
                ePos      = new Position(pos.X + (edist * sinBearing), pos.Y + (edist * cosBearing));
                result[i] = new LineSegmentGeometry(sPos, ePos);
            }

            return(result);
        }
        /// <summary>
        /// Gets the position that is a specific distance from the start of this line.
        /// </summary>
        /// <param name="dist">The distance from the start of the line.</param>
        /// <param name="result">The position found</param>
        /// <returns>True if the distance is somewhere ON the line. False if the distance
        /// was less than zero, or more than the line length (in that case, the position
        /// found corresponds to the corresponding terminal point).</returns>
        internal override bool GetPosition(ILength distance, out IPosition result)
        {
            IPosition[] data = m_Data;

            if (data.Length == 2)
            {
                return(LineSegmentGeometry.GetPosition(data[0], data[1], distance.Meters, out result));
            }
            else
            {
                return(GetPosition(data, distance.Meters, out result));
            }
        }
Example #3
0
        internal void Draw() // was Paint
        {
            // Nothing to do if parallel points undefined.
            if (m_South == null || m_North == null)
            {
                return;
            }

            Debug.Assert(m_Line != null);
            ISpatialDisplay draw        = m_Cmd.ActiveDisplay;
            IDrawStyle      solidStyle  = EditingController.Current.Style(Color.Magenta);
            IDrawStyle      dottedStyle = new DottedStyle();

            ArcFeature arc = m_Line.GetArcBase();

            if (arc != null)
            {
                // The parallel portion is solid, while the remaining portion of the circle is dotted.
                CircularArcGeometry cg = new CircularArcGeometry(arc.Circle.Center, m_South, m_North, arc.IsClockwise);
                solidStyle.Render(draw, cg);
                cg.IsClockwise = !cg.IsClockwise;
                dottedStyle.Render(draw, cg);
            }
            else
            {
                // What's the bearing from the start to the end of the parallel?
                double bearing = Geom.BearingInRadians(m_South, m_North);

                // What's the max length of a diagonal crossing the entire screen?
                double maxdiag = m_Cmd.MaxDiagonal;

                // Project to a point below the southern end of the parallel, as
                // well as a point above the northern end.
                IPosition below = Geom.Polar(m_South, bearing + Constants.PI, maxdiag);
                IPosition above = Geom.Polar(m_North, bearing, maxdiag);

                LineSegmentGeometry.Render(below, m_South, draw, dottedStyle);
                LineSegmentGeometry.Render(m_South, m_North, draw, solidStyle);
                LineSegmentGeometry.Render(m_North, above, draw, dottedStyle);

                // If we have an offset point, draw it in green.
                if (m_Point != null)
                {
                    m_Point.Draw(draw, Color.Green);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Checks whether this closed shape intersects (overlaps) a line.
        /// This assumes that a window-window overlap has already been checked for.
        /// </summary>
        /// <param name="line">The line to compare with the shape</param>
        /// <returns>True if intersection found.</returns>
        bool IsIntersect(LineGeometry line)
        {
            //IntersectionResult xres = new IntersectionResult(line);
            //return (xres.IntersectMultiSegment(this) > 0);

            IntersectionResult xres = new IntersectionResult(line);

            // Intersect each segment of this shape with the line.
            IPointGeometry[] data = this.Data;
            for (int i = 1; i < data.Length; i++)
            {
                LineSegmentGeometry thisSeg = new LineSegmentGeometry(data[i - 1], data[i]);
                if (xres.IntersectSegment(thisSeg) > 0)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #5
0
        /// <summary>
        /// Draws the current state of the edit
        /// </summary>
        internal void Draw()
        {
            Debug.Assert(m_Line != null);
            ISpatialDisplay view = ActiveDisplay;

            // Figure out the positions for the ends of the parallel line (if any) ...

            // Assume we already know both terminals.
            IPosition start = m_Term1;
            IPosition end   = m_Term2;

            // If either one is undefined, but a dialog for it is active,
            // try to get the terminal from there instead.
            if (m_TermDial1 != null && start == null)
            {
                start = m_TermDial1.TerminalPosition;
            }

            if (m_TermDial2 != null && end == null)
            {
                end = m_TermDial2.TerminalPosition;
            }

            // If they weren't actually defined, use the parallel points instead.
            if (start == null)
            {
                start = m_Par1;
            }

            if (end == null)
            {
                end = m_Par2;
            }

            // If those weren't defined either, try to calculate them now.
            if (end == null && Calculate())
            {
                start = m_Par1;
                end   = m_Par2;
            }

            // Any offset point
            if (m_OffsetPoint != null)
            {
                m_OffsetPoint.Draw(view, Color.Green);
            }

            // Everything else should draw in usual command-style colour.
            IDrawStyle style       = EditingController.Current.Style(Color.Magenta);
            IDrawStyle dottedStyle = new DottedStyle();

            // If the reference line is a curve, get the curve info.
            ArcFeature arc = m_Line.GetArcBase();

            if (arc != null)
            {
                bool iscw = arc.IsClockwise;

                // Reverse the direction if necessary.
                if (m_IsReversed)
                {
                    iscw = !iscw;
                }

                // Draw the parallel line (the rest of the circle being dotted).
                if (start != null)
                {
                    CircularArcGeometry parArc = new CircularArcGeometry(arc.Circle, start, end, iscw);
                    style.Render(view, parArc);

                    parArc.IsClockwise = !parArc.IsClockwise;
                    dottedStyle.Render(view, parArc);
                }
            }
            else
            {
                // PARALLEL IS STRAIGHT

                // If we've got something, figure out positions for dotted portion.
                if (start != null)
                {
                    // What's the max length of a diagonal crossing the entire screen?
                    double maxdiag = this.MaxDiagonal;

                    // What's the bearing from the start to the end of the parallel?
                    double bearing = Geom.BearingInRadians(start, end);

                    // Project to a point before the start end of the parallel, as
                    // well as a point after the end.
                    IPosition before = Geom.Polar(start, bearing + Constants.PI, maxdiag);
                    IPosition after  = Geom.Polar(end, bearing, maxdiag);

                    LineSegmentGeometry.Render(before, start, view, dottedStyle);
                    LineSegmentGeometry.Render(start, end, view, style);
                    LineSegmentGeometry.Render(end, after, view, dottedStyle);
                }
            }

            // Draw terminal positions (if defined).

            if (m_Term1 != null)
            {
                style.Render(view, m_Term1);
            }

            if (m_Term2 != null)
            {
                style.Render(view, m_Term2);
            }

            // The terminal lines.

            if (m_TermLine1 != null)
            {
                m_TermLine1.Render(view, style);
            }

            if (m_TermLine2 != null)
            {
                m_TermLine2.Render(view, style);
            }

            // Do the active dialog last so their stuff draws on top.
            if (m_ParDial != null)
            {
                m_ParDial.Draw();
            }

            if (m_TermDial1 != null)
            {
                m_TermDial1.Draw();
            }

            if (m_TermDial2 != null)
            {
                m_TermDial2.Draw();
            }
        }
        internal void Draw()
        {
            ISpatialDisplay display = m_Cmd.ActiveDisplay;

            // Draw the line we're extending in a special colour (any highlighting it
            // originally had should have been removed during LineExtensionControl_Load)
            if (m_ExtendLine != null)
            {
                m_ExtendLine.Draw(display, Color.DarkBlue);
            }

            // If we're doing an update, draw the original extension in grey.
            LineExtensionOperation pop = UpdateOp;

            if (pop != null)
            {
                LineFeature origLine = pop.NewLine;
                if (origLine != null)
                {
                    origLine.Draw(display, Color.Gray);
                }

                PointFeature origPoint = pop.NewPoint;
                if (origPoint != null)
                {
                    origPoint.Draw(display, Color.Gray);
                }
            }

            // Calculate the start and end points of the extension, initially
            // assuming that it's a straight line extension.
            IPosition start, end;

            if (LineExtensionUI.Calculate(m_ExtendLine, m_IsExtendFromEnd, m_Length, out start, out end))
            {
                // Draw the straight extension line
                IDrawStyle          style = (m_WantLine ? new DrawStyle(Color.Magenta) : new DottedStyle(Color.Magenta));
                LineSegmentGeometry seg   = new LineSegmentGeometry(start, end);
                seg.Render(display, style);
            }
            else
            {
                // Perhaps it's a circular arc ...

                IPosition center;
                bool      iscw;

                if (LineExtensionUI.Calculate(m_ExtendLine, m_IsExtendFromEnd, m_Length,
                                              out start, out end, out center, out iscw))
                {
                    // And draw the curve.
                    IDrawStyle          style = (m_WantLine ? new DrawStyle(Color.Magenta) : new DottedStyle(Color.Magenta));
                    IPointGeometry      c     = PointGeometry.Create(center);
                    CircularArcGeometry arc   = new CircularArcGeometry(c, start, end, iscw);
                    arc.Render(display, style);
                }
                else if (m_ExtendLine != null)
                {
                    // Get the position we're extending from.
                    end = (m_IsExtendFromEnd ? m_ExtendLine.EndPoint : m_ExtendLine.StartPoint);
                }
            }

            // If we actually got something, draw the end point.
            if (end != null)
            {
                IDrawStyle style = m_Cmd.Controller.DrawStyle;
                style.FillColor = Color.Magenta;
                style.Render(display, end);
            }
        }
Example #7
0
        // Segment
        internal uint Intersect(IPointGeometry start, IPointGeometry end)
        {
            ILineSegmentGeometry seg = new LineSegmentGeometry(start, end);

            return(m_IntersectedObject.LineGeometry.IntersectSegment(this, seg));
        }
Example #8
0
 internal override bool GetPosition(ILength dist, out IPosition pos)
 {
     return(LineSegmentGeometry.GetPosition(this, dist.Meters, out pos));
 }
Example #9
0
 public override ILength Distance(IPosition point)
 {
     return(LineSegmentGeometry.GetDistance(this, point));
 }
Example #10
0
 internal override void Render(ISpatialDisplay display, IDrawStyle style)
 {
     LineSegmentGeometry.Render(this, display, style);
 }