public override void OnClick(object sender, EventArgs args)
 {
     _context.SetCurrentTool(this);
     _pointSnapper = new PointSnapper();
     (_pointSnapper as PointSnapper).Map = _context.FocusMap;
     _tolerance = _context.Config.EngineSnapEnvironment.SnapTolerance;
 }
Beispiel #2
0
        public override void OnClick(object sender, EventArgs args)
        {
            if (_plugin.CurrentLayer == null)
            {
                MessageBox.Show(@"未设置当前编辑图层!");
                _context.ClearCurrentTool();
                return;
            }
            IBasicLayerInfo pointLayerInfo = _plugin.CurrentLayer.Layers.FirstOrDefault(c => c.DataType == enumPipelineDataType.Point);

            if (pointLayerInfo != null)
            {
                _pointFeatureLayer = CommonHelper.GetLayerByName(_context.FocusMap, pointLayerInfo.AliasName, true) as IFeatureLayer;
            }
            IBasicLayerInfo lineLayerInfo = _plugin.CurrentLayer.Layers.FirstOrDefault(c => c.DataType == enumPipelineDataType.Line);

            if (lineLayerInfo != null)
            {
                _lineFeatureLayer = CommonHelper.GetLayerByName(_context.FocusMap, lineLayerInfo.AliasName, true) as IFeatureLayer;
            }
            if (_pointFeatureLayer == null || _lineFeatureLayer == null)
            {
                MessageBox.Show(@"点图层或线图层未设置!");
                _context.ClearCurrentTool();
                return;
            }


            _context.SetCurrentTool(this);
            _pointSnapper = new PointSnapper();
            (_pointSnapper as PointSnapper).Map = _context.FocusMap;
        }
        protected override void OnActivate()
        {
            //Get the snap environment and initialize the feedback
            UID snapUID = new UID();

            this.Cursor = Cursors.Cross;

            snapUID.Value = "{E07B4C52-C894-4558-B8D4-D4050018D1DA}";

            if (ArcMap.Application != null)
            {
                m_SnappingEnv = ArcMap.Application.FindExtensionByCLSID(snapUID) as ISnappingEnvironment;
            }

            if (m_SnappingEnv != null)
            {
                m_Snapper = m_SnappingEnv.PointSnapper;
            }

            m_SnappingFeedback = new SnappingFeedbackClass();
            m_SnappingFeedback.Initialize(ArcMap.Application, m_SnappingEnv, true);

            Mediator.NotifyColleagues(VisibilityLibrary.Constants.MAP_POINT_TOOL_ACTIVATED, true);

            // Also notify what the previous tool was so it can be set back
            Mediator.NotifyColleagues(VisibilityLibrary.Constants.MAP_TOOL_CHANGED, lastActiveToolGuid);
        }
        protected override void OnActivate()
        {
            //Get the snap environment and initialize the feedback
            UID snapUID = new UID();

            this.Cursor        = Cursors.Cross;
            snapUID.Value      = "{E07B4C52-C894-4558-B8D4-D4050018D1DA}";
            m_SnappingEnv      = ArcMap.Application.FindExtensionByCLSID(snapUID) as ISnappingEnvironment;
            m_Snapper          = m_SnappingEnv.PointSnapper;
            m_SnappingFeedback = new SnappingFeedbackClass();
            m_SnappingFeedback.Initialize(ArcMap.Application, m_SnappingEnv, true);
        }
Beispiel #5
0
 //设置捕捉环境
 public static void StartSnappingEnv()
 {
     if (m_bStartSnap)
     {
         m_SnappingEnv = DataEditCommon.GetSnapEnvironment(m_hookHelper, snappingType);
         if (m_SnappingEnv != null)
         {
             m_Snapper          = m_SnappingEnv.PointSnapper;
             m_SnappingFeedback = new SnappingFeedbackClass();
             m_SnappingFeedback.Initialize(m_hookHelper.Hook, m_SnappingEnv);
         }
     }
 }
Beispiel #6
0
 public override void OnClick(object sender, EventArgs args)
 {
     if (_cheQiConfig.FlagLayer == null)
     {
         MessageBox.Show(@"未选择扯旗图层!", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (string.IsNullOrWhiteSpace(_cheQiConfig.Expression))
     {
         MessageBox.Show(@"扯旗表达式为空!", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     _geoFeatureLayer = _cheQiConfig.FlagLayer as IGeoFeatureLayer;
     _context.SetCurrentTool(this);
     _pointSnapper = new PointSnapper();
     (_pointSnapper as PointSnapper).Map = _context.FocusMap;
     _tolerance = _context.Config.EngineSnapEnvironment.SnapTolerance;
 }
Beispiel #7
0
        public void Initialize(IEditor pEditor)
        {
            // Initialize the constructor
            m_editor   = pEditor as IEditor;
            m_edSketch = pEditor as IEditSketch3;

            //Get the snap environment
            m_snappingEnv      = m_editor.Parent.FindExtensionByName("ESRI Snapping") as ISnappingEnvironment;
            m_snapper          = m_snappingEnv.PointSnapper;
            m_snappingFeedback = new SnappingFeedbackClass();
            m_snappingFeedback.Initialize(m_editor.Parent, m_snappingEnv, true);

            m_firstPoint  = new PointClass();
            m_secondPoint = new PointClass();
            m_activePoint = new PointClass();

            // Set the phase to inactive so we start at the beginning
            m_etoolPhase = ToolPhase.Inactive;
        }
Beispiel #8
0
 private static void old_acctor_mc()
 {
     SketchToolAssist.m_LastPartGeometry = null;
     SketchToolAssist.IsCreateParrel     = false;
     SketchToolAssist.m_offset           = 1;
     SketchToolAssist.ConstructOffset    = 5;
     SketchToolAssist.m_Feedback         = null;
     SketchToolAssist.m_pUnDoPoint       = null;
     SketchToolAssist.m_pLastPoint1      = null;
     SketchToolAssist.m_pEndPoint1       = null;
     SketchToolAssist.m_bShowVlaue       = true;
     SketchToolAssist.m_totalLength      = 0;
     SketchToolAssist.m_pPointColn       = null;
     SketchToolAssist.m_pAP = null;
     SketchToolAssist.m_pPointCollection = null;
     SketchToolAssist.m_PointCount       = 0;
     SketchToolAssist.m_bInUse           = false;
     SketchToolAssist.m_pSym             = new SimpleMarkerSymbol();
     SketchToolAssist.m_psnaper          = new PointSnapper();
     SketchToolAssist.Init();
 }
Beispiel #9
0
        public override void OnClick(object sender, EventArgs args)
        {
            if (_plugin.CurrentLayer == null)
            {
                MessageBox.Show(@"未设置当前编辑图层!");
                _context.ClearCurrentTool();
                return;
            }
            IBasicLayerInfo pointLayerInfo =
                _plugin.CurrentLayer.Layers.FirstOrDefault(c => c.DataType == enumPipelineDataType.Point);

            if (pointLayerInfo != null)
            {
                _gdbhFieldName     = pointLayerInfo.GetFieldName(PipeConfigWordHelper.PointWords.GDBH);
                _pointFeatureLayer = CommonHelper.GetLayerByName(_context.FocusMap, pointLayerInfo.AliasName, true) as IFeatureLayer;
            }
            IBasicLayerInfo lineLayerInfo =
                _plugin.CurrentLayer.Layers.FirstOrDefault(c => c.DataType == enumPipelineDataType.Line);

            if (lineLayerInfo != null)
            {
                _qdbhFieldName    = lineLayerInfo.GetFieldName(PipeConfigWordHelper.LineWords.QDBH);
                _zdbhFieldName    = lineLayerInfo.GetFieldName(PipeConfigWordHelper.LineWords.ZDBH);
                _lineFeatureLayer = CommonHelper.GetLayerByName(_context.FocusMap, lineLayerInfo.AliasName, true) as IFeatureLayer;
            }
            if (_pointFeatureLayer == null || _lineFeatureLayer == null)
            {
                MessageBox.Show(@"点图层或线图层未设置!");
                _context.ClearCurrentTool();
                return;
            }

            _context.SetCurrentTool(this);
            _pointSnapper = new PointSnapper();
            (_pointSnapper as PointSnapper).Map = _context.FocusMap;
            _tolerance = _context.Config.EngineSnapEnvironment.SnapTolerance;
        }
Beispiel #10
0
 private static void old_acctor_mc()
 {
     SketchShareEx.m_psnaper            = new PointSnapper();
     SketchShareEx.m_CurrentStep        = 0;
     SketchShareEx.m_SysGrants          = new SysGrants(AppConfigInfo.UserID);
     SketchShareEx.m_pSketchCommandFolw = new SketchCommandFlow();
     SketchShareEx.IsFixLength          = false;
     SketchShareEx.IsFixDirection       = false;
     SketchShareEx.FixLength            = 0;
     SketchShareEx.FixDirection         = 0;
     SketchShareEx.StartPoint           = null;
     SketchShareEx.LastPoint            = null;
     SketchShareEx.IsCreateParrel       = false;
     SketchShareEx.m_offset             = 1;
     SketchShareEx.ConstructOffset      = 5;
     SketchShareEx.PointCount           = 0;
     SketchShareEx.m_pAnchorPoint       = null;
     SketchShareEx.m_bInUse             = false;
     SketchShareEx.m_pPointCollection   = null;
     SketchShareEx.m_pLastPoint1        = null;
     SketchShareEx.m_pEndPoint1         = null;
     SketchShareEx.m_bShowVlaue         = true;
     SketchShareEx.m_totalLength        = 0;
     SketchShareEx.m_bSnapSuccessful    = false;
     SketchShareEx.m_pSym             = new SimpleMarkerSymbol();
     SketchShareEx.m_pPoint           = null;
     SketchShareEx.m_HasLicense       = false;
     SketchShareEx.m_LastPartGeometry = null;
     SketchShareEx.m_bInStreaming     = false;
     SketchShareEx.m_MinDis           = 0;
     SketchShareEx.m_HasLicense       = EditorLicenseProviderCheck.Check();
     SketchShareEx.m_pSym.Style       = esriSimpleMarkerStyle.esriSMSCircle;
     SketchShareEx.m_pSym.Size        = 8;
     SketchShareEx.m_pSym.Outline     = true;
     SketchShareEx.m_pSym.Color       = ColorManage.GetRGBColor(0, 255, 255);
 }
Beispiel #11
0
        public void OnMouseDown(int button, int shift, int x, int y)
        {
            this._bMouse = true;
            IPoint point = this._hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);

            this._tool.OnMouseDown(1, shift, x, y);
            if (this._bFinished)
            {
                this._bFinished = false;
            }
            else
            {
                try
                {
                    if (this._snappingEnv == null)
                    {
                        return;
                    }
                    IPointSnapper     pointSnapper = this._snappingEnv.PointSnapper;
                    ISnappingResult   result       = pointSnapper.Snap(point);
                    IEngineEditSketch engineEditor = Editor.UniqueInstance.EngineEditor as IEngineEditSketch;
                    IPointCollection  points       = engineEditor.Geometry as IPointCollection;
                    if (!this._bStarted)
                    {
                        this.CreateFeed();
                        if (result != null)
                        {
                            this._lineFeedback.Start(result.Location);
                        }
                        this._bStarted = true;
                        return;
                    }
                    IGeometry geometry = engineEditor.Geometry;
                    if (geometry == null)
                    {
                        return;
                    }
                    IPointCollection points2  = geometry as IPointCollection;
                    IPolyline        polyline = this._lineFeedback.Stop();
                    int index = 0;
                    if (engineEditor.GeometryType == esriGeometryType.esriGeometryPolygon)
                    {
                        index = points.PointCount - 2;
                    }
                    else
                    {
                        index = points.PointCount - 1;
                    }
                    if (polyline != null)
                    {
                        IPointCollection points3 = (IPointCollection)polyline;
                        for (int i = 1; i < (points3.PointCount - 1); i++)
                        {
                            IPoint point2    = points3.get_Point(i);
                            IPoint newPoints = (point2 as IClone).Clone() as IPoint;
                            if (pointSnapper.Snap(point2).Type == esriSnappingType.esriSnappingTypeVertex)
                            {
                                points2.InsertPoints(index, 1, ref newPoints);
                                index++;
                            }
                        }
                    }
                    int hDC = this._hookHelper.ActiveView.ScreenDisplay.hDC;
                    this._lineFeedback.Stop();
                    this._lineFeedback.Refresh(hDC);
                    if (result != null)
                    {
                        this._lineFeedback.Start(result.Location);
                    }
                    if (button == 2)
                    {
                        this.OnDblClick();
                    }
                    engineEditor.RefreshSketch();
                }
                catch (Exception exception)
                {
                    this.mErrOpt.ErrorOperate(this.mSubSysName, "ShapeEdit.SnapEx", "OnMouseUp", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
                }
                this._bMouse = false;
            }
        }
Beispiel #12
0
        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolNewDisplacement.OnMouseMove implementation


            IMapControl3 m_MapControl = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl3;

            m_snappingFeed.Refresh(m_MapControl.ActiveView.ScreenDisplay.hDC);
            m_snappingFeed.UnInitialize();
            m_snappingFeed.Initialize(m_MapControl.Object, m_SnappingEnvironment, true);
            m_snappingFeed.Refresh(m_MapControl.ActiveView.ScreenDisplay.hDC);
            m_SnappingEnvironment.SnappingType = esriSnappingType.esriSnappingTypePoint;


            //起始点
            if (bFlag == true)
            {
                IPoint          point      = TransformToMapPoint(X, Y);
                IPointSnapper   ptSnapper  = m_SnappingEnvironment.PointSnapper;
                ISnappingResult snapresult = ptSnapper.Snap(point);
                if (snapresult != null)
                {
                    //   IEngineEditProperties2 ep2 = env as IEngineEditProperties2;
                    //if (ep2.SnapTips == true)
                    {
                        if (m_snappingFeed != null)
                        {
                            if (snapresult.Description == pIMULayer.Name + ": Point")
                            {
                                m_snappingFeed.Update(snapresult, m_MapControl.ActiveView.ScreenDisplay.hDC);
                            }
                        }
                    }
                }
                else
                {
                    m_snappingFeed.Update(null, m_MapControl.ActiveView.ScreenDisplay.hDC);
                }
            }
            // 结束点
            if (bFlag == false)
            {
                IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;
                if (pMapCtr != null)
                {
                    IPoint mapPoint = pMapCtr.ToMapPoint(X, Y);
                    m_NewLineFeedback.MoveTo(mapPoint);

                    IPoint          point      = TransformToMapPoint(X, Y);
                    IPointSnapper   ptSnapper  = m_SnappingEnvironment.PointSnapper;
                    ISnappingResult snapresult = ptSnapper.Snap(point);
                    if (snapresult != null)
                    {
                        //   IEngineEditProperties2 ep2 = env as IEngineEditProperties2;
                        //if (ep2.SnapTips == true)
                        {
                            if (m_snappingFeed != null)
                            {
                                if (snapresult.Description == pCenterlinePointLayer.Name + ": Point")
                                {
                                    m_snappingFeed.Update(snapresult, m_MapControl.ActiveView.ScreenDisplay.hDC);
                                }
                            }
                        }
                    }
                    else
                    {
                        m_snappingFeed.Update(null, m_MapControl.ActiveView.ScreenDisplay.hDC);
                    }
                }
            }
        }
Beispiel #13
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolNewDisplacement.OnMouseDown implementation
            if (!DataReady())
            {
                MessageBox.Show("内检测、中线图层设置不正确");
                return;
            }

            object       Miss         = Type.Missing;
            IMapControl2 pMapCtr      = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;
            IMapControl3 m_MapControl = pMapCtr as IMapControl3;

            if (pMapCtr != null)
            {
                //IGeoReference pGR = pRasterLayer as IGeoReference;
                IPoint mapPoint = pMapCtr.ToMapPoint(X, Y);
                m_NewLineFeedback.Display = pMapCtr.ActiveView.ScreenDisplay;
                if (bFlag == true)//起始点
                {
                    IPoint          point      = TransformToMapPoint(X, Y);
                    IPointSnapper   ptSnapper  = m_SnappingEnvironment.PointSnapper;
                    ISnappingResult snapresult = ptSnapper.Snap(point);
                    if (snapresult != null)
                    {
                        m_snappingFeed.UnInitialize();
                        m_snappingFeed.Initialize(m_MapControl.Object, m_SnappingEnvironment, true);
                        m_snappingFeed.Refresh(m_MapControl.ActiveView.ScreenDisplay.hDC);
                        m_SnappingEnvironment.SnappingType = esriSnappingType.esriSnappingTypePoint;
                        ISpatialFilter pSF    = new SpatialFilterClass();
                        IPoint         ProjPt = snapresult.Location;
                        ProjPt.Project(((IGeoDataset)(pIMULayer.FeatureClass)).SpatialReference);
                        pSF.Geometry      = ProjPt;
                        pSF.GeometryField = pIMULayer.FeatureClass.ShapeFieldName;
                        pSF.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
                        IFeatureCursor pCursor  = pIMULayer.FeatureClass.Search(pSF, false);
                        IFeature       pFeature = pCursor.NextFeature();
                        if (pFeature != null)
                        {
                            IMUFeature = pFeature;
                            m_NewLineFeedback.Start(mapPoint);

                            bFlag = false;
                        }
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor);
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(pSF);
                    }
                }
                else//目标点
                {
                    IPoint          point      = TransformToMapPoint(X, Y);
                    IPointSnapper   ptSnapper  = m_SnappingEnvironment.PointSnapper;
                    ISnappingResult snapresult = ptSnapper.Snap(point);
                    if (snapresult != null)
                    {
                        //m_snappingFeed.Refresh(m_MapControl.ActiveView.ScreenDisplay.hDC);
                        //m_snappingFeed.UnInitialize();
                        //m_snappingFeed.Refresh(m_MapControl.ActiveView.ScreenDisplay.hDC);
                        //m_snappingFeed.Initialize(m_MapControl.Object, m_SnappingEnvironment, true);

                        m_SnappingEnvironment.SnappingType = esriSnappingType.esriSnappingTypePoint;
                        ISpatialFilter pSF    = new SpatialFilterClass();
                        IPoint         ProjPt = snapresult.Location;
                        ProjPt.Project(((IGeoDataset)(pCenterlinePointLayer.FeatureClass)).SpatialReference);
                        pSF.Geometry      = ProjPt;
                        pSF.GeometryField = pCenterlinePointLayer.FeatureClass.ShapeFieldName;
                        pSF.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
                        IFeatureCursor pCursor  = pCenterlinePointLayer.FeatureClass.Search(pSF, false);
                        IFeature       pFeature = pCursor.NextFeature();
                        if (pFeature != null)
                        {
                            CenterlinePointFeature = pFeature;



                            if (m_CenterlinePointFeatureList.Count > 0)
                            {
                                double newIMUM        = Convert.ToDouble(IMUFeature.Value[m_IMUFeatureList[0].Fields.FindField("记录距离")]);
                                double newCenterlineM = Convert.ToDouble(CenterlinePointFeature.Value[m_CenterlinePointFeatureList[0].Fields.FindField("里程")]);
                                for (int i = 0; i < m_CenterlinePointFeatureList.Count; i++)
                                {
                                    double previewIMUM      = Convert.ToDouble(m_IMUFeatureList[i].Value[m_IMUFeatureList[0].Fields.FindField("记录距离")]);
                                    double previewCentlineM = Convert.ToDouble(m_CenterlinePointFeatureList[i].Value[m_CenterlinePointFeatureList[0].Fields.FindField("里程")]);

                                    if ((newIMUM - previewIMUM) * (newCenterlineM - previewCentlineM) <= 0)
                                    {
                                        MessageBox.Show("特征点不能交叉匹配.");
                                        return;
                                    }
                                }
                            }

                            m_IMUFeatureList.Add(IMUFeature);
                            m_CenterlinePointFeatureList.Add(CenterlinePointFeature);
                            bFlag = true;
                            IPolyline pPline = m_NewLineFeedback.Stop();
                            m_FrmVectorLinkTable.RefreshDataTable();
                        }
                    }
                    m_MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null);
                    //m_snappingFeed.UnInitialize();

                    //m_snappingFeed.Initialize(m_MapControl.Object, m_SnappingEnvironment, true);
                    // m_snappingFeed.Refresh(m_MapControl.ActiveView.ScreenDisplay.hDC);
                }
            }
        }
    public void Initialize(IEditor pEditor)
    {
      // Initialize the constructor
      m_editor = pEditor as IEditor;
      m_edSketch = pEditor as IEditSketch3;

      //Get the snap environment
      m_snappingEnv = m_editor.Parent.FindExtensionByName("ESRI Snapping") as ISnappingEnvironment;
      m_snapper = m_snappingEnv.PointSnapper;
      m_snappingFeedback = new SnappingFeedbackClass();
      m_snappingFeedback.Initialize(m_editor.Parent, m_snappingEnv, true);

      m_firstPoint = new PointClass();
      m_secondPoint = new PointClass();
      m_activePoint = new PointClass();

      // Set the phase to inactive so we start at the beginning 
      m_etoolPhase = ToolPhase.Inactive;
    }
 //���ò�׽����
 public static void StartSnappingEnv()
 {
     if (m_bStartSnap)
     {
         m_SnappingEnv = DataEditCommon.GetSnapEnvironment(m_hookHelper, snappingType);
         if (m_SnappingEnv != null)
         {
             m_Snapper = m_SnappingEnv.PointSnapper;
             m_SnappingFeedback = new SnappingFeedbackClass();
             m_SnappingFeedback.Initialize(m_hookHelper.Hook, m_SnappingEnv);
         }
     }
 }