Exemplo n.º 1
0
        /// <summary>
        /// Calculates the position of the extension point.
        /// </summary>
        /// <returns>The calculated position</returns>
        IPosition Calculate()
        {
            // Figure out the new position for the extension point, depending
            // on whether the line we extended is a circular arc or a straight.

            IPosition start;            // Start of the extension
            IPosition end;              // End of the extension
            bool      ok;               // Did calculation work ok?

            if (m_ExtendLine is ArcFeature)
            {
                IPosition center;       // The center of the circle
                bool      iscw;         // Is the curve clockwise?

                ok = LineExtensionUI.Calculate(m_ExtendLine, m_IsExtendFromEnd, m_Length,
                                               out start, out end, out center, out iscw);
            }
            else
            {
                ok = LineExtensionUI.Calculate(m_ExtendLine, m_IsExtendFromEnd, m_Length,
                                               out start, out end);
            }

            return(ok ? end : null);
        }
Exemplo n.º 2
0
        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);
            }
        }