Exemplo n.º 1
0
        /// <summary>
        /// Executes this operation.
        /// </summary>
        /// <param name="sub">The polygon subdivision information.</param>
        internal void Execute(PolygonSub sub)
        {
            int numLine = sub.NumLink;

            if (numLine == 0)
            {
                throw new Exception("PolygonSubdivisionOperation.Execute - Nothing to add");
            }

            // If the polygon contains just one label, de-activate it. This covers a "well-behaved" situation,
            // where the label inside the polygon is likely to be redundant after the subdivision (it also
            // conforms to logic used in the past). In a situation where the polygon contains multiple labels,
            // it's less clear whether the labels become redundant or not, so we keep them all.
            Polygon pol = sub.Polygon;

            if (pol.LabelCount == 1)
            {
                m_Label = pol.Label;
                if (m_Label != null)
                {
                    m_Label.IsInactive = true;
                }
            }

            // Mark the polygon for deletion
            pol.IsDeleted = true;

            // Get the default entity type for lines.
            CadastralMapModel map = MapModel;
            IEntity           ent = map.DefaultLineType;

            // Allocate array to point to the lines we will be creating.
            m_Lines = new LineFeature[numLine];

            // Add lines for each link
            PointFeature start, end;

            for (int i = 0; sub.GetLink(i, out start, out end); i++)
            {
                m_Lines[i] = map.AddLine(start, end, ent, this);
            }

            // Peform standard completion steps
            Complete();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles a mouse down event
        /// </summary>
        /// <param name="p">The position where the click occurred</param>
        /// <returns>True if the command handled the mouse down. False if it did nothing.</returns>
        internal override bool LButtonDown(IPosition p)
        {
            // Find out what polygon we need to subdivide
            IPointGeometry pg    = PointGeometry.Create(p);
            ISpatialIndex  index = CadastralMapModel.Current.Index;
            Polygon        pol   = new FindPointContainerQuery(index, pg).Result;

            if (pol == null)
            {
                MessageBox.Show("Specified position does not fall inside any polygon.");
                return(false);
            }


            PolygonSubdivisionOperation op = null;

            try
            {
                // Form the links. Return if we didn't find any links.
                PolygonSub   sub = new PolygonSub(pol);
                PointFeature start, end;
                if (!sub.GetLink(0, out start, out end))
                {
                    MessageBox.Show("Cannot locate any points to connect.");
                    return(true);
                }

                op = new PolygonSubdivisionOperation();
                op.Execute(sub);
                FinishCommand();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace, ex.Message);
                AbortCommand();
            }

            return(true);
        }
        /// <summary>
        /// Handles a mouse down event
        /// </summary>
        /// <param name="p">The position where the click occurred</param>
        /// <returns>True if the command handled the mouse down. False if it did nothing.</returns>
        internal override bool LButtonDown(IPosition p)
        {
            // Find out what polygon we need to subdivide
            IPointGeometry pg = PointGeometry.Create(p);
            ISpatialIndex index = CadastralMapModel.Current.Index;
            Polygon pol = new FindPointContainerQuery(index, pg).Result;
            if (pol==null)
            {
                MessageBox.Show("Specified position does not fall inside any polygon.");
                return false;
            }

            PolygonSubdivisionOperation op = null;

            try
            {
                // Form the links. Return if we didn't find any links.
                PolygonSub sub = new PolygonSub(pol);
                PointFeature start, end;
                if (!sub.GetLink(0, out start, out end))
                {
                    MessageBox.Show("Cannot locate any points to connect.");
                    return true;
                }

                op = new PolygonSubdivisionOperation();
                op.Execute(sub);
                FinishCommand();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace, ex.Message);
                AbortCommand();
            }

            return true;
        }
        /// <summary>
        /// Executes this operation.
        /// </summary>
        /// <param name="sub">The polygon subdivision information.</param>
        internal void Execute(PolygonSub sub)
        {
            int numLine = sub.NumLink;
            if (numLine==0)
                throw new Exception("PolygonSubdivisionOperation.Execute - Nothing to add");

            // If the polygon contains just one label, de-activate it. This covers a "well-behaved" situation,
            // where the label inside the polygon is likely to be redundant after the subdivision (it also
            // conforms to logic used in the past). In a situation where the polygon contains multiple labels,
            // it's less clear whether the labels become redundant or not, so we keep them all.
            Polygon pol = sub.Polygon;
            if (pol.LabelCount == 1)
            {
                m_Label = pol.Label;
                if (m_Label!=null)
                    m_Label.IsInactive = true;
            }

            // Mark the polygon for deletion
            pol.IsDeleted = true;

            // Get the default entity type for lines.
            CadastralMapModel map = MapModel;
            IEntity ent = map.DefaultLineType;

            // Allocate array to point to the lines we will be creating.
            m_Lines = new LineFeature[numLine];

            // Add lines for each link
            PointFeature start, end;
            for (int i=0; sub.GetLink(i, out start, out end); i++)
            {
                m_Lines[i] = map.AddLine(start, end, ent, this);
            }

            // Peform standard completion steps
            Complete();
        }