Exemplo n.º 1
0
        /// <summary>
        /// Tries to find a terminal line to end the parallel on.
        /// </summary>
        /// <returns>False if parallel positions are not available. True
        /// otherwise (that does not mean that a terminal was actually found).
        /// </returns>
        bool FindTerminal()
        {
            // Get the position of the parallel point.
            ParallelLineUI cmd = this.Command;
            IPosition      parpos;

            if (m_IsLast)
            {
                parpos = cmd.ParallelTwo;
            }
            else
            {
                parpos = cmd.ParallelOne;
            }

            // The parallel point HAS to be known.
            if (parpos == null)
            {
                MessageBox.Show("Parallel point has not been calculated");
                return(false);
            }

            // Treat the parallel point as the initial terminal.
            m_Terminal = parpos;

            // Get the offset to the parallel.
            double offset = cmd.GetPlanarOffset();

            // Figure out a search radius (the smaller of half the offset,
            // or half a centimetre at the current draw scale).
            double  scale = cmd.ActiveDisplay.MapScale;
            ILength tol   = new Length(Math.Min(offset * 0.5, scale * 0.005));

            // Search for the line closest to the parallel point, and
            // within the search radius. The line has to be visible
            // and selectable.
            CadastralMapModel map = CadastralMapModel.Current;

            //m_Line = map.FindClosestLine(parpos, tol, true);
            m_Line = (map.Index.QueryClosest(parpos, tol, SpatialType.Line) as LineFeature);

            // If we found something, highlight it (after confirming that
            // it really does intersect the parallel).
            if (m_Line != null)
            {
                IPosition xsect = cmd.GetIntersect(m_Line, m_IsLast);
                if (xsect == null)
                {
                    m_Line = null;
                }
                else
                {
                    //pView->UnHighlight(m_pArc);
                    //pView->Highlight(*m_pArc);
                    m_Terminal = xsect;
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculates the terminal positions for the parallel.
        /// </summary>
        /// <param name="refLine">The reference line.</param>
        /// <param name="offset">The observed offset (either a <c>Distance</c>
        /// or an <c>OffsetPoint</c>).</param>
        /// <param name="term1">A line that the parallel should start on (may be null).</param>
        /// <param name="term2">A line that the parallel should end on (may be null).</param>
        /// <param name="spar">The start of the parallel.</param>
        /// <param name="epar">The end of the parallel.</param>
        /// <returns>True if calculated ok.</returns>
        bool Calculate(LineFeature refLine
                       , Observation offset
                       , LineFeature term1
                       , LineFeature term2
                       , out IPosition spar
                       , out IPosition epar)
        {
            spar = epar = null;

            if (!ParallelLineUI.Calculate(refLine, offset, out spar, out epar))
            {
                return(false);
            }

            // If the start of the parallel should begin on a specific
            // line, get the closest intersection.

            if (term1 != null)
            {
                spar = ParallelLineUI.GetIntersect(refLine, spar, term1);
                if (spar == null)
                {
                    throw new Exception("Parallel does not intersect terminal line.");
                }
            }

            // And similarly for the end of the parallel.

            if (term2 != null)
            {
                IPosition tpar = ParallelLineUI.GetIntersect(refLine, epar, term2);
                if (tpar == null)
                //epar = ParallelLineUI.GetIntersect(refLine, epar, term2);
                //if (epar == null)
                {
                    epar = ParallelLineUI.GetIntersect(refLine, epar, term2);
                    throw new Exception("Parallel does not intersect terminal line.");
                }
                else
                {
                    epar = tpar;
                }
            }

            return(true);
        }
Exemplo n.º 3
0
        int InitUpdate()
        {
            // Get the creating op.
            ParallelLineOperation op = UpdateOp;

            if (op == null)
            {
                return(0);
            }

            ISpatialDisplay view = m_Cmd.ActiveDisplay;
            ParallelLineUI  cmd  = Command;

            // The originally produced parallel may have been
            // changed to have a different offset.

            // Get the line that the parallel originally terminated on (if any).
            if (m_IsLast)
            {
                m_Line = op.Terminal2;
            }
            else
            {
                m_Line = op.Terminal1;
            }

            // If we didn't terminate on any particular line, that's
            // the way it will remain, Otherwise confirm that the
            // parallel continues to intersect it. In the event that
            // the parallel no longer intersects, get another
            // terminal position (and maybe a different terminal line).
            if (m_Line != null)
            {
                m_Terminal = cmd.GetIntersect(m_Line, m_IsLast);
                if (m_Terminal != null)
                {
                    // The parallel still intersects the terminal line that was originally specified,
                    // so highlight the terminal line (having de-selected and unhighlighted
                    // anything that was previously highlighted).

                    m_Line.Render(view, new HighlightStyle());
                }
                else
                {
                    // Get a new terminal position (preferably coincident with some other line).

                    // DON'T try to find a new terminal if the op is being corrected due to a
                    // problem in rollforward preview. In that case, we want the user to see
                    // where the old terminal was ... well, leave that nicety for now.

                    if (!FindTerminal())
                    {
                        return(-1);
                    }
                }
            }
            else
            {
                // Parallel did not terminate on a line, so grab the start or end of the parallel line
                LineFeature parLine = op.ParallelLine;
                if (m_IsLast)
                {
                    m_Terminal = parLine.EndPoint;
                }
                else
                {
                    m_Terminal = parLine.StartPoint;
                }
            }

            return(1);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Reacts to the selection of a line feature.
        /// </summary>
        /// <param name="line">The line (if any) that has been selected.</param>
        internal void SelectLine(LineFeature line)
        {
            ISpatialDisplay view  = m_Cmd.ActiveDisplay;
            IPosition       xsect = null;
            ParallelLineUI  cmd   = Command;

            // Confirm that the line actually intersects the parallel.
            if (line != null)
            {
                xsect = cmd.GetIntersect(line, m_IsLast);
                if (xsect == null)
                {
                    MessageBox.Show("Selected line does not intersect the parallel");

                    // De-select the line the user picked
                    EditingController.Current.ClearSelection();

                    // Re-highlight the arc if had originally (if any).
                    if (m_Line != null)
                    {
                        EditingController.Current.Select(m_Line);
                    }

                    return;
                }
            }

            // Ensure everything is erased.
            m_Cmd.ErasePainting();

            // Hold on to new terminal position.
            if (xsect != null)
            {
                m_Terminal = xsect;
            }
            else if (m_IsLast)
            {
                m_Terminal = cmd.ParallelTwo;
            }
            else
            {
                m_Terminal = cmd.ParallelOne;
            }

            // If we previously had an arc selected (and it's not the
            // newly selected line), ensure that it's been unhighlighted.
            //if (m_pArc && m_pArc != pArc) m_pArc->UnHighlight();

            // Hold on to the new terminal arc (if any).
            m_Line = line;

            // If it's defined, ensure the "don't use terminal" check
            // box is clear. And change the static text that tells the
            // user what to do.
            if (m_Line != null)
            {
                noTerminalCheckBox.Checked = false;
                messageLabel2.Text         = "If you want to terminate on a different line, select it.";
            }

            // Ensure everything is drawn as expected.
            cmd.Draw();

            // Resume focus on the Next/Finish button.
            okButton.Focus();
        }