Exemple #1
0
        internal override void MouseMove(IPosition p)
        {
            // The following is pretty much the same as what the controller would do to
            // cover auto-select...

            // The ground tolerance is 1mm at the draw scale.
            ISpatialDisplay draw = ActiveDisplay;
            ILength         tol  = new Length(0.001 * draw.MapScale);

            // Just return if we previously selected something, and the
            // search point lies within tolerance.
            if (m_Line != null)
            {
                ILength dist = m_Line.Distance(p);
                if (dist.Meters < tol.Meters)
                {
                    return;
                }

                // Ensure the previously select line gets un-highlighted
                m_Line = null;
                ErasePainting();
            }

            // Ask the map to find the closest line (if any)
            ISpatialIndex index = CadastralMapModel.Current.Index;

            m_Line = (index.QueryClosest(p, tol, SpatialType.Line) as LineFeature);
            Highlight(m_Line);
        }
Exemple #2
0
        /// <summary>
        /// Sees whether the orientation of the new text should be altered. This
        /// occurs if the auto-orient capability is enabled, and the specified
        /// position is close to any visible lne.
        /// </summary>
        /// <param name="posn">The position to use for making the check.</param>
        /// <returns></returns>
        LineFeature GetOrientation(IPointGeometry posn)
        {
            // The ground tolerance is 2mm at the draw scale.
            ISpatialDisplay display = ActiveDisplay;
            double          tol     = 0.002 * display.MapScale;

            // If we previously selected something, see if the search point
            // lies within tolerance. If so, there's no change.
            if (m_Orient != null)
            {
                double dist = m_Orient.Distance(posn).Meters;
                if (dist < tol)
                {
                    return(m_Orient);
                }
            }

            // Get the map to find the closest line
            CadastralMapModel map   = CadastralMapModel.Current;
            ISpatialIndex     index = map.Index;

            return(index.QueryClosest(posn, new Length(tol), SpatialType.Line) as LineFeature);
        }