Exemple #1
0
        /// <summary>
        /// Occurs when this tool is clicked
        /// </summary>
        public override void OnClick()
        {
            IEnumFeature pEnumFeature = m_MapControl.Map.FeatureSelection as IEnumFeature;

            if (pEnumFeature == null || m_MapControl.Map.SelectionCount != 1)
            {
                return;
            }
            pEnumFeature.Reset();
            IFeature pFeature = pEnumFeature.Next();

            if (pFeature == null)
            {
                return;
            }

            //画出图形各节点
            if (MoData.v_bVertexSelectionTracker == true)
            {
                ModPublic.DrawEditSymbol(pFeature.Shape, m_MapControl.ActiveView);
            }

            //设置点选容差
            ISelectionEnvironment pSelectEnv = new SelectionEnvironmentClass();

            m_dblTolearance = ModPublic.ConvertPixelsToMapUnits(m_hookHelper.ActiveView, pSelectEnv.SearchTolerance);

            m_pFeature = pFeature;
        }
Exemple #2
0
        private void GetSelctionSet(IFeatureLayer pFeatureLayer, IGeometry pGeometry, bool bjustone, int Shift)
        {
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
            //没开启编辑的不可选择
            IDataset       pDataset       = pFeatureClass as IDataset;
            IWorkspaceEdit pWorkspaceEdit = pDataset.Workspace as IWorkspaceEdit;

            if (!pWorkspaceEdit.IsBeingEdited())
            {
                return;
            }
            switch (Shift)
            {
            case 1:       //增加选择结果集
                ModPublic.GetSelctionSet(pFeatureLayer, pGeometry, pFeatureClass, esriSelectionResultEnum.esriSelectionResultAdd, bjustone);
                break;

            case 4:       //减少选择结果集
                ModPublic.GetSelctionSet(pFeatureLayer, pGeometry, pFeatureClass, esriSelectionResultEnum.esriSelectionResultSubtract, bjustone);
                break;

            case 2:
                ModPublic.GetSelctionSet(pFeatureLayer, pGeometry, pFeatureClass, esriSelectionResultEnum.esriSelectionResultXOR, bjustone);
                break;

            default:       //新建选择结果集
                ModPublic.GetSelctionSet(pFeatureLayer, pGeometry, pFeatureClass, esriSelectionResultEnum.esriSelectionResultNew, bjustone);
                break;
            }
        }
Exemple #3
0
        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            if (m_pFeature == null)
            {
                return;
            }
            IPoint pPnt = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            //鼠标在选择集的范围外为选择功能
            if (ModPublic.MouseOnSelection(pPnt, m_hookHelper.ActiveView) == false && m_bMouseDown == false)
            {//若光标不在选择的对象上,为选择功能
                ControlsEditSelFeature clsSelectFeature = new ControlsEditSelFeature();
                clsSelectFeature.OnCreate(m_hookHelper.Hook);
                clsSelectFeature.OnClick();
                m_MapControl.CurrentTool = clsSelectFeature as ITool;
                return;
            }
            //范围内为移动要素功能且不在要素节点上
            else if (ModPublic.MouseOnFeatureVertex(pPnt, m_pFeature, m_hookHelper.ActiveView) == false && m_bMouseDown == false)
            {
                ControlsMoveSelFeature pControlsMoveSelFeature = new ControlsMoveSelFeature();
                pControlsMoveSelFeature.OnCreate(m_hookHelper.Hook);
                pControlsMoveSelFeature.OnClick();
                m_MapControl.CurrentTool = pControlsMoveSelFeature as ITool;
                return;
            }


            if (m_pVertexFeed == null)
            {
                return;
            }
            //捕捉节点
            if (MoData.v_bSnapStart)
            {
                m_pSnapPoint = ModPublic.SnapPoint(pPnt, m_hookHelper.ActiveView);
            }

            IHitTest pHitTest           = m_pFeature.Shape as IHitTest;
            IPoint   pHitPoint          = new PointClass();
            double   dblHitDistance     = 0;
            int      lPart              = 0;
            int      intHitSegmentIndex = 0;
            bool     bRight             = false;
            bool     bHitTest           = pHitTest.HitTest(pPnt, m_dblTolearance, esriGeometryHitPartType.esriGeometryPartVertex, pHitPoint, ref dblHitDistance, ref lPart, ref intHitSegmentIndex, ref bRight);

            if (m_pSnapPoint != null && MoData.v_bSnapStart)
            {
                m_pVertexFeed.MoveTo(m_pSnapPoint);
            }
            else
            {
                m_pVertexFeed.MoveTo(pPnt);
            }
        }
Exemple #4
0
        public void GetLayers()
        {
            _ComboBoxLayer.Items.Clear();
            List <ILayer> plistLay = ModPublic.LoadAllEditLyr(myHook.MapControl.Map);

            if (plistLay.Count != 0)
            {
                _ComboBoxLayer.Tag = plistLay;
                for (int i = 0; i < plistLay.Count; i++)
                {
                    _ComboBoxLayer.Items.Add(plistLay[i].Name);
                }
                _ComboBoxLayer.SelectedIndex = 0;
            }
        }
Exemple #5
0
        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            //鼠标在选择集的范围外为选择功能
            IPoint pPnt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            if (ModPublic.MouseOnSelection(pPnt, m_hookHelper.ActiveView) == false && m_bMouseDown == false)
            {//若光标不在选择的对象上,为选择功能
                ControlsEditSelFeature clsSelectFeature = new ControlsEditSelFeature();
                clsSelectFeature.OnCreate(m_hookHelper.Hook);
                clsSelectFeature.OnClick();
                m_MapControl.CurrentTool = clsSelectFeature as ITool;
                return;
            }

            //鼠标在选择要素节点上时为节点移动功能
            if (m_MapControl.Map.SelectionCount == 1)
            {
                IEnumFeature pEnumFeature = m_MapControl.Map.FeatureSelection as IEnumFeature;
                pEnumFeature.Reset();
                IFeature pFeature = pEnumFeature.Next();
                if (ModPublic.MouseOnFeatureVertex(pPnt, pFeature, m_hookHelper.ActiveView) == true && MoData.v_bVertexSelectionTracker == true)
                {
                    ControlsMoveVertex pControlsMoveVertex = new ControlsMoveVertex();
                    pControlsMoveVertex.OnCreate(m_hookHelper.Hook);
                    pControlsMoveVertex.OnClick();
                    m_MapControl.CurrentTool = pControlsMoveVertex as ITool;
                    return;
                }
            }

            //捕捉节点
            if (MoData.v_bSnapStart)
            {
                ModPublic.SnapPoint(pPnt, m_hookHelper.ActiveView);
            }

            if (Button != 1)
            {
                return;
            }
            //进行移动
            if (m_MapControl.Map.SelectionCount > 0 && m_pMoveGeometryFeedback != null && m_pNewLineFeedback != null)
            {
                m_pMoveGeometryFeedback.MoveTo(pPnt);
                m_pNewLineFeedback.MoveTo(pPnt);
            }
        }
Exemple #6
0
        public override void OnDblClick()
        {
            IEnumFeature pEnumFeature = m_MapControl.Map.FeatureSelection as IEnumFeature;

            if (pEnumFeature == null)
            {
                return;
            }
            pEnumFeature.Reset();
            IFeature pFeature = pEnumFeature.Next();

            if (pFeature == null)
            {
                return;
            }

            ModPublic.DrawEditSymbol(pFeature.Shape, m_hookHelper.ActiveView);
            MoData.v_bVertexSelectionTracker = true;
        }
Exemple #7
0
        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            //鼠标在选择集的范围内则TOOL置为移动工具
            IPoint pPnt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            if (ModPublic.MouseOnSelection(pPnt, m_hookHelper.ActiveView) == true)
            {
                if (m_pControlsMoveSelFeature == null)
                {
                    m_pControlsMoveSelFeature = new ControlsMoveSelFeature();
                    m_pControlsMoveSelFeature.OnCreate(m_hookHelper.Hook);
                    m_MapControl.CurrentTool = m_pControlsMoveSelFeature as ITool;
                }
                else
                {
                    m_MapControl.CurrentTool = m_pControlsMoveSelFeature as ITool;
                }
            }
            else
            {
                m_MapControl.CurrentTool = this as ITool;
            }
        }
Exemple #8
0
        private void ArcGisMapControl_OnAfterScreenDraw(object sender, IMapControlEvents2_OnAfterScreenDrawEvent e)
        {
            //判断节点编辑中的选择节点,用于刷新画节点
            if (MoData.v_bVertexSelectionTracker == false)
            {
                return;
            }

            IEnumFeature pEnumFeature = m_Hook.MapControl.Map.FeatureSelection as IEnumFeature;

            if (pEnumFeature == null || m_Hook.MapControl.Map.SelectionCount != 1)
            {
                return;
            }
            pEnumFeature.Reset();
            IFeature pFeature = pEnumFeature.Next();

            if (pFeature == null)
            {
                return;
            }

            ModPublic.DrawEditSymbol(pFeature.Shape, m_Hook.MapControl.ActiveView);
        }
Exemple #9
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }

            //设置点选择容差
            ISelectionEnvironment pSelectEnv = new SelectionEnvironmentClass();
            double Length = ModPublic.ConvertPixelsToMapUnits(m_hookHelper.ActiveView, pSelectEnv.SearchTolerance);

            IPoint               pPoint    = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            IGeometry            pGeometry = pPoint as IGeometry;
            ITopologicalOperator pTopo     = pGeometry as ITopologicalOperator;
            IGeometry            pBuffer   = pTopo.Buffer(Length);

            //仅与框架别界相交地物会被选取
            pGeometry = m_MapControl.TrackRectangle() as IGeometry;
            bool bjustone = true;

            if (pGeometry != null)
            {
                if (pGeometry.IsEmpty)
                {
                    pGeometry = pBuffer;
                }
                else
                {
                    bjustone = false;
                }
            }
            else
            {
                pGeometry = pBuffer;
            }

            UID pUID = new UIDClass();

            pUID.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";   //UID for IFeatureLayer
            IEnumLayer pEnumLayer = m_MapControl.Map.get_Layers(pUID, true);

            pEnumLayer.Reset();
            ILayer pLayer = pEnumLayer.Next();

            while (pLayer != null)
            {
                if (pLayer.Visible == false)
                {
                    pLayer = pEnumLayer.Next();
                    continue;
                }
                IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                if (pFeatureLayer.Selectable == false)
                {
                    pLayer = pEnumLayer.Next();
                    continue;
                }

                GetSelctionSet(pFeatureLayer, pGeometry, bjustone, Shift);

                pLayer = pEnumLayer.Next();
            }

            //触发Map选择发生变化事件
            ISelectionEvents pSelectionEvents = m_hookHelper.FocusMap as ISelectionEvents;

            pSelectionEvents.SelectionChanged();

            //刷新
            m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, m_hookHelper.ActiveView.Extent);
            AttributeShow();
        }
Exemple #10
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }
            //设置点选择容差
            ISelectionEnvironment pSelectEnv = new SelectionEnvironmentClass();
            double Length = ModPublic.ConvertPixelsToMapUnits(m_hookHelper.ActiveView, pSelectEnv.SearchTolerance);

            IPoint               pPoint    = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            IGeometry            pGeometry = pPoint as IGeometry;
            ITopologicalOperator pTopo     = pGeometry as ITopologicalOperator;
            IGeometry            pBuffer   = pTopo.Buffer(Length);

            //仅与框架别界相交地物会被选取
            pGeometry = m_MapControl.TrackRectangle() as IGeometry;
            bool bjustone = true;

            if (pGeometry != null)
            {
                if (pGeometry.IsEmpty)
                {
                    pGeometry = pBuffer;
                }
                else
                {
                    bjustone = false;
                }
            }
            else
            {
                pGeometry = pBuffer;
            }

            UID pUID = new UIDClass();

            pUID.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";   //UID for IFeatureLayer
            IEnumLayer pEnumLayer = m_MapControl.Map.get_Layers(pUID, true);

            pEnumLayer.Reset();
            ILayer pLayer = pEnumLayer.Next();

            while (pLayer != null)
            {
                IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;

                if (pFeatureClass.ObjectClassID != ControlsAttribute.m_CurFeatCls.ObjectClassID)
                {
                    pLayer = pEnumLayer.Next();
                    continue;
                }

                switch (Shift)
                {
                case 1:       //增加选择结果集
                    ModPublic.GetSelctionSet(pFeatureLayer, pGeometry, pFeatureClass, esriSelectionResultEnum.esriSelectionResultAdd, bjustone);
                    break;

                case 4:       //减少选择结果集
                    ModPublic.GetSelctionSet(pFeatureLayer, pGeometry, pFeatureClass, esriSelectionResultEnum.esriSelectionResultSubtract, bjustone);
                    break;

                case 2:
                    ModPublic.GetSelctionSet(pFeatureLayer, pGeometry, pFeatureClass, esriSelectionResultEnum.esriSelectionResultXOR, bjustone);
                    break;

                default:       //新建选择结果集
                    ModPublic.GetSelctionSet(pFeatureLayer, pGeometry, pFeatureClass, esriSelectionResultEnum.esriSelectionResultNew, bjustone);
                    break;
                }

                pLayer = pEnumLayer.Next();
            }

            //刷新
            m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, m_hookHelper.ActiveView.Extent);
        }
Exemple #11
0
        //========================================================================================
        //陈胜鹏  2009-08-19  添加
        /// <summary>
        /// 融合选择集中的要素
        /// </summary>
        /// <param name="pSelectionSet">选择集对象,从中取出需要融合的要素</param>
        /// <param name="pMergeLayer">发生融合的要素所在图层</param>
        /// <param name="OID">被保留的要素OID</param>
        private void MergeSelectedFeature(ISelectionSet pSelectionSet, IFeatureLayer pMergeLayer, int OID)
        {
            //判断是否满足融合条件
            bool CanMerge = JudgeCondition();

            //OID = 0;
            //如果满足融合的判定条件才能开始进行融合(这里主要分几何条件和属性条件)
            if (CanMerge)
            {
                IEnumIDs pEnumIDs;                                                         //枚举要素变量
                Dictionary <int, IFeature> pDicFeature = new Dictionary <int, IFeature>(); //存储多个需要融合的要素的字典
                int                  FtID     = 0;                                         //要素OID
                IGeometry            pGeoTemp = null;                                      //存储融合后的要素图形
                ITopologicalOperator pTopoOperator;
                IFeature             pFt         = null;
                int                  pTempFeatID = 0;

                IFeatureClass pFeatCls = pMergeLayer.FeatureClass;

                pEnumIDs = pSelectionSet.IDs;
                FtID     = pEnumIDs.Next();

                //初始化临时要素图形
                pTempFeatID = FtID;
                pGeoTemp    = pFeatCls.GetFeature(pTempFeatID).Shape;
                pDicFeature.Add(FtID, pFeatCls.GetFeature(pTempFeatID));  //记录遍历到的要素ID

                FtID = pEnumIDs.Next();
                while (FtID != -1)
                {
                    //获得需要融合的第二个要素
                    pFt = pFeatCls.GetFeature(FtID);
                    pDicFeature.Add(FtID, pFt);  //记录遍历到的要素ID

                    //融合要素的图形
                    pTopoOperator = pGeoTemp as ITopologicalOperator;
                    pGeoTemp      = pTopoOperator.Union(pFt.ShapeCopy);

                    //临时图形进行简单化
                    pTopoOperator = pGeoTemp as ITopologicalOperator;
                    pTopoOperator.Simplify();

                    //下一个要素
                    FtID = pEnumIDs.Next();
                }

                //获取第一个保留的要素,赋给它融合后的图形,并保存
                pFt       = pFeatCls.GetFeature(OID);
                pFt.Shape = pGeoTemp;

                //处理设置FID、state不一致问题 wjj 20090903
                IDisplayRelationshipClass pDisResCls = pMergeLayer as IDisplayRelationshipClass;
                if (pDisResCls.RelationshipClass != null)     //是否与日志记录表做了联表查询
                {
                    //获取图幅结合表
                    IFeatureLayer pFeatLay = ModPublic.GetLayerOfGroupLayer(myHook.MapControl, "范围", "图幅范围") as IFeatureLayer;
                    if (pFeatLay != null)
                    {
                        ChangeFeatureState(pDisResCls.RelationshipClass, pFt, pDicFeature, pFeatLay.FeatureClass);
                    }
                }

                pFt.Store();

                //删除被融合的要素
                foreach (KeyValuePair <int, IFeature> var in pDicFeature)
                {
                    if (var.Key != OID)
                    {
                        pFt = pFeatCls.GetFeature(var.Key);
                        pFt.Delete();
                    }
                }

                pDicFeature = null;
            }
        }