Exemplo n.º 1
0
        private void noTerminalCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            // If we previously had a terminal line, erase the terminal
            // position and unhighlight the arc.

            ISpatialDisplay draw = m_Cmd.ActiveDisplay;

            if (m_Line != null)
            {
                m_Cmd.ErasePainting();
            }

            m_Line = null;
            ParallelLineUI cmd = Command;

            // Draw the parallel point instead.
            if (m_IsLast)
            {
                m_Terminal = cmd.ParallelTwo;
            }
            else
            {
                m_Terminal = cmd.ParallelOne;
            }

            EditingController.Current.Style(Color.Yellow).Render(draw, m_Terminal);
        }
Exemplo n.º 2
0
        private void otherWayButton_Click(object sender, EventArgs e)
        {
            // Tell the command that's running this dialog.
            ParallelLineUI cmd = this.Command;

            cmd.ReverseArc();
        }
Exemplo n.º 3
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.º 4
0
        internal TerminalControl(ParallelLineUI cmd, bool isLast)
        {
            InitializeComponent();

            m_Cmd      = cmd;
            m_IsLast   = isLast;
            m_Line     = null;
            m_Terminal = null;
        }
Exemplo n.º 5
0
        internal ParallelControl(ParallelLineUI ui)
        {
            InitializeComponent();

            // Initialize everything.
            SetZeroValues();

            // Remember the command that's running the show (and the
            // line that's the reference line for the parallel).
            m_Cmd  = ui;
            m_Line = ui.ReferenceLine;
        }
Exemplo n.º 6
0
        bool Calculate()
        {
            // Ensure any previously defined end positions have been turfed.
            m_South = null;
            m_North = null;

            // Can't do nothing if the reference line is undefined.
            if (m_Line == null)
            {
                return(false);
            }

            // Calculate the parallel points, depending on what sort of
            // observation we've got.

            IPosition north = null;
            IPosition south = null;
            bool      ok    = false;

            // Ensure the correct sign is defined in case of an offset distance.

            if (m_Offset != null)
            {
                if (m_IsLeft)
                {
                    m_Offset.SetNegative();
                }
                else
                {
                    m_Offset.SetPositive();
                }

                ok = ParallelLineUI.Calculate(m_Line, m_Offset, out south, out north);
            }
            else if (m_Point != null)
            {
                ok = ParallelLineUI.Calculate(m_Line, m_Point, out south, out north);
            }

            // If the calculation succeeded, allocate vertices to
            // hold the results we got.

            if (ok)
            {
                m_South = south;
                m_North = north;
            }

            return(ok);
        }
Exemplo n.º 7
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.º 8
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.º 9
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();
        }
Exemplo n.º 10
0
        private void TerminalControl_Load(object sender, EventArgs e)
        {
            ISpatialDisplay view = m_Cmd.ActiveDisplay;

            // Get the "real" command that's running this dialog (not any update).
            ParallelLineUI cmd = Command;

            Debug.Assert(cmd != null);

            if (m_IsLast)
            {
                MyCaption     = "Terminal 2";
                okButton.Text = "&Finish";

                // If the reference line for the parallel isn't a circular
                // arc, disable and hide the "Other Way" button.
                if (!(cmd.ReferenceLine is ArcFeature))
                {
                    otherWayButton.Enabled = false;
                    otherWayButton.Visible = false;
                }
            }
            else
            {
                MyCaption     = "Terminal 1";
                okButton.Text = "&Next...";

                // Disable (and hide) the "Other Way" button.
                otherWayButton.Enabled = false;
                otherWayButton.Visible = false;
            }

            // If we are not updating a previously created parallel,
            // get a terminal position.
            int state = InitUpdate();

            if (state == 0 && !FindTerminal())
            {
                state = -1;
            }

            // Get out if that somehow failed.
            if (state < 0)
            {
                m_Cmd.DialAbort(this);
                return;
            }

            // Draw the terminal point in yellow.
            EditingController.Current.Style(Color.Yellow).Render(view, m_Terminal);

            // If we don't have a terminal line, alter the text that says
            // that it's highlighted! And make the "don't terminate" checkbox
            // invisible.
            if (m_Line == null)
            {
                messageLabel1.Visible      = false;
                messageLabel2.Text         = "If you want to terminate on a line, select it.";
                messageLabel3.Visible      = false;
                noTerminalCheckBox.Visible = false;
            }
        }