Ejemplo n.º 1
0
        public override bool HiTest(double double_0, IPoint ipoint_0, out IPoint ipoint_1, ref double double_1,
                                    ref int int_0, ref int int_1, out bool bool_0)
        {
            bool     flag;
            IHitTest mPGeometry = this.m_pGeometry as IHitTest;

            ipoint_1 = new ESRI.ArcGIS.Geometry.Point();
            bool_0   = false;
            bool flag1 = false;

            if (mPGeometry.HitTest(ipoint_0, double_0, esriGeometryHitPartType.esriGeometryPartVertex, ipoint_1,
                                   ref double_1, ref int_0, ref int_1, ref flag1))
            {
                bool_0 = true;
                flag   = true;
            }
            else if (
                !mPGeometry.HitTest(ipoint_0, double_0, esriGeometryHitPartType.esriGeometryPartBoundary, ipoint_1,
                                    ref double_1, ref int_0, ref int_1, ref flag1))
            {
                flag = false;
            }
            else
            {
                bool_0 = false;
                flag   = true;
            }
            return(flag);
        }
Ejemplo n.º 2
0
        public static bool TestGeometryHit(double double_0, IPoint ipoint_0, IGeometry igeometry_0, out IPoint ipoint_1,
                                           ref double double_1, ref int int_0, ref int int_1, out bool bool_0)
        {
            bool     flag;
            bool     flag1      = false;
            IHitTest igeometry0 = igeometry_0 as IHitTest;

            ipoint_1 = new ESRI.ArcGIS.Geometry.Point();
            bool_0   = false;
            bool flag2 = false;

            if (
                !(igeometry_0.GeometryType == esriGeometryType.esriGeometryPoint
                    ? false
                    : igeometry_0.GeometryType != esriGeometryType.esriGeometryMultipoint))
            {
                if (
                    !igeometry0.HitTest(ipoint_0, double_0, esriGeometryHitPartType.esriGeometryPartVertex, ipoint_1,
                                        ref double_1, ref int_0, ref int_1, ref flag2))
                {
                    bool_0 = false;
                }
                else
                {
                    flag1  = true;
                    bool_0 = true;
                }
                flag = flag1;
            }
            else if (igeometry0.HitTest(ipoint_0, double_0, esriGeometryHitPartType.esriGeometryPartVertex, ipoint_1,
                                        ref double_1, ref int_0, ref int_1, ref flag2))
            {
                bool_0 = true;
                flag   = true;
            }
            else if (igeometry0.HitTest(ipoint_0, double_0, esriGeometryHitPartType.esriGeometryPartBoundary, ipoint_1,
                                        ref double_1, ref int_0, ref int_1, ref flag2))
            {
                bool_0 = false;
                flag   = true;
            }
            else if ((igeometry_0.GeometryType == esriGeometryType.esriGeometryEnvelope
                         ? false
                         : igeometry_0.GeometryType != esriGeometryType.esriGeometryPolygon) ||
                     !((IRelationalOperator)igeometry_0).Contains(ipoint_0))
            {
                flag = false;
            }
            else
            {
                int_0  = -1;
                bool_0 = false;
                flag   = true;
            }
            return(flag);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 角度同步,点与线的角度同步
        /// </summary>
        /// <param name="pPolyline">线</param>
        /// <param name="pPoint">线附近的点(许可的范围内)</param>
        /// <param name="dAngle">返回点符号的角度</param>
        /// <param name="pRetPoint">返回的在线上的点的位置</param>
        /// <returns>是否可以同步角度(如果距离过大,无法执行角度同步)</returns>
        public static bool SynchronizeAngle(IPolyline pPolyline, IPoint pPoint, ref double dAngle, ref IPoint pRetPoint)
        {
            double   dRadius         = 10;
            IPoint   pHitPoint       = new PointClass();
            IHitTest pHitTest        = pPolyline as IHitTest;
            double   hitDist         = 0.0;
            int      hitPartIndex    = 0;
            int      hitSegmentIndex = 0;
            bool     bRightSide      = false;

            bool bPointOnLine = pHitTest.HitTest(pPoint, dRadius, esriGeometryHitPartType.esriGeometryPartBoundary, pHitPoint, ref hitDist, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);

            if (bPointOnLine)
            {
                if (distance(pHitPoint, pPoint) < 0.0001)
                {
                    pRetPoint = null;
                }
                else
                {
                    pRetPoint = pHitPoint;
                }

                ISegmentCollection pSegment = pPolyline as ISegmentCollection;
                ILine pLine = pSegment.get_Segment(hitSegmentIndex) as ILine;
                dAngle = pLine.Angle;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
        private static bool PointAffectsShape([NotNull] IPoint testPoint,
                                              double searchRadius,
                                              [NotNull] IPointCollection newPoints,
                                              [NotNull] IPoint prevPoint,
                                              [NotNull] IPoint nextPoint,
                                              [NotNull] ILine line,
                                              int pointIndex)
        {
            GetPreviousPoint(newPoints, pointIndex, ref prevPoint);
            GetNextPoint(newPoints, pointIndex, ref nextPoint);
            line.PutCoords(prevPoint, nextPoint);

            double distance = 0;
            var    right    = false;
            IPoint hitPoint = new PointClass();

            var lineHitPartIndex    = 0;
            var lineHitSegmentIndex = 0;

            IHitTest lineHitTest = GeometryUtils.GetHitTest(line, true);

            bool inLine = lineHitTest.HitTest(testPoint, searchRadius,
                                              esriGeometryHitPartType.esriGeometryPartBoundary,
                                              hitPoint, ref distance,
                                              ref lineHitPartIndex,
                                              ref lineHitSegmentIndex, ref right);

            return(!inLine);
        }
Ejemplo n.º 5
0
        public bool HitTest(Rect contentRect, Vector2 point)
        {
            if (!contentRect.Contains(point))
            {
                return(false);
            }

            bool flag = false;
            int  cnt  = elements.Count;

            for (int i = 0; i < cnt; i++)
            {
                IHitTest ht = elements[i] as IHitTest;
                if (ht != null)
                {
                    if (ht.HitTest(contentRect, point))
                    {
                        return(true);
                    }
                }
                else
                {
                    flag = true;
                }
            }

            return(flag);
        }
Ejemplo n.º 6
0
        private static void RemovePoint(IGeometry geometry, IPoint point, double searchRadius)
        {
            double   distance        = 0;
            var      right           = false;
            IPoint   hitPoint        = new PointClass();
            int      hitSegmentIndex = -2;
            int      hitPartIndex    = -2;
            IHitTest hitTest         = GeometryUtils.GetHitTest(geometry, true);

            bool found = hitTest.HitTest(point, searchRadius,
                                         esriGeometryHitPartType.esriGeometryPartVertex, hitPoint,
                                         ref distance, ref hitPartIndex,
                                         ref hitSegmentIndex, ref right);

            if (!found)
            {
                return;
            }

            IGeometry partGeometry = geometry is IGeometryCollection
                                                         ? GeometryUtils.GetHitGeometryPart(
                point, geometry, searchRadius)
                                                         : geometry;

            Assert.NotNull(partGeometry, "Geometry part at point {0} not found",
                           GeometryUtils.ToString(point));

            RemovePoint(geometry, hitPartIndex, hitSegmentIndex, partGeometry);
        }
Ejemplo n.º 7
0
        //捕捉
        public IPoint Snapping(double x, double y, IFeatureLayer featureLayer)
        {
            IMap          map          = this.axMapControl1.Map;
            IActiveView   activeView   = this.axMapControl1.ActiveView;
            IFeatureClass featureClass = featureLayer.FeatureClass;
            IPoint        point        = new PointClass();

            point.PutCoords(x, y);

            IFeature feature     = featureClass.GetFeature(0);
            IPoint   hitPoint1   = new PointClass();
            IPoint   hitPoint2   = new PointClass();
            IHitTest hitTest     = feature.Shape as IHitTest;
            double   hitDist     = 0;
            int      partIndex   = 0;
            int      vertexIndex = 0;
            bool     bVertexHit  = false;

            double tol = ConvertPixelsToMapUnits(activeView, 8);

            if (hitTest.HitTest(point, tol, esriGeometryHitPartType.esriGeometryPartBoundary,
                                hitPoint2, ref hitDist, ref partIndex, ref vertexIndex, ref bVertexHit))
            {
                hitPoint1 = hitPoint2;
            }
            axMapControl1.ActiveView.Refresh();
            return(hitPoint1);
        }
Ejemplo n.º 8
0
		override protected DisplayObject HitTest()
		{
			if (_disabled)
				return null;

			if (this.cachedTransform.localScale.x == 0 || this.cachedTransform.localScale.y == 0)
				return null;

			Vector2 localPoint = new Vector2();
			Vector3 savedWorldPoint = HitTestContext.worldPoint;
			Vector3 savedDirection = HitTestContext.direction;

			if (hitArea != null)
			{
				if (!hitArea.HitTest(this, ref localPoint))
				{
					HitTestContext.worldPoint = savedWorldPoint;
					HitTestContext.direction = savedDirection;
					return null;
				}
			}
			else
			{
				localPoint = GetHitTestLocalPoint();
				if (_clipRect != null && !((Rect)_clipRect).Contains(localPoint))
				{
					HitTestContext.worldPoint = savedWorldPoint;
					HitTestContext.direction = savedDirection;
					return null;
				}
			}

			if (_mask != null && _mask.InternalHitTestMask() == null)
				return null;

			DisplayObject target = null;
			if (touchChildren)
			{
				int count = _children.Count;
				for (int i = count - 1; i >= 0; --i) // front to back!
				{
					DisplayObject child = _children[i];
					if (child == _mask)
						continue;

					target = child.InternalHitTest();
					if (target != null)
						break;
				}
			}

			if (target == null && opaque && (hitArea != null || _contentRect.Contains(localPoint)))
				target = this;

			HitTestContext.worldPoint = savedWorldPoint;
			HitTestContext.direction = savedDirection;

			return target;
		}
Ejemplo n.º 9
0
        public bool Snap(IGeometry igeometry_0, IPoint ipoint_0, double double_0)
        {
            bool flag;

            if (EditorLicenseProviderCheck.Check())
            {
                IPoint ipoint0   = ipoint_0;
                double length    = 1000;
                bool   flag1     = false;
                ILine  lineClass = new Line();
                for (int i = 0; i < this.ifeatureCache_0.Count; i++)
                {
                    IGeometry shape = this.ifeatureCache_0.Feature[i].Shape;
                    if (shape is ISegmentCollection)
                    {
                        IHitTest hitTest = (IHitTest)shape;
                        if ((hitTest is IPolyline ? true : hitTest is IPolygon))
                        {
                            double num        = 0;
                            int    num1       = 0;
                            int    num2       = 0;
                            bool   flag2      = true;
                            IPoint pointClass = new ESRI.ArcGIS.Geometry.Point();
                            if (hitTest.HitTest(ipoint_0, double_0, esriGeometryHitPartType.esriGeometryPartBoundary,
                                                pointClass, ref num, ref num1, ref num2, ref flag2))
                            {
                                ISegment segment =
                                    ((shape as IGeometryCollection).Geometry[num1] as ISegmentCollection).Segment[num2];
                                if (segment is ICircularArc)
                                {
                                    pointClass = ((ICircularArc)segment).CenterPoint;
                                    lineClass.PutCoords(ipoint0, pointClass);
                                    if (!flag1)
                                    {
                                        length = lineClass.Length;
                                        ipoint_0.PutCoords(pointClass.X, pointClass.Y);
                                        flag1 = true;
                                    }
                                    else if (length > lineClass.Length)
                                    {
                                        length = lineClass.Length;
                                        ipoint_0.PutCoords(pointClass.X, pointClass.Y);
                                        flag1 = true;
                                    }
                                }
                            }
                        }
                    }
                }
                flag = flag1;
            }
            else
            {
                flag = false;
            }
            return(flag);
        }
Ejemplo n.º 10
0
        override protected DisplayObject HitTest()
        {
            if (_scale.x == 0 || _scale.y == 0)
            {
                return(null);
            }

            Vector2 localPoint       = new Vector2();
            Vector2 savedScreenPoint = HitTestContext.screenPoint;

            if (hitArea != null)
            {
                if (!hitArea.HitTest(this, ref localPoint))
                {
                    return(null);
                }
            }
            else
            {
                localPoint = GlobalToLocal(HitTestContext.screenPoint);
                if (_clipRect != null && !((Rect)_clipRect).Contains(localPoint.x, localPoint.y))
                {
                    return(null);
                }
            }

            DisplayObject target = null;

            if (touchChildren)
            {
                int count = _children.Count;
                for (int i = count - 1; i >= 0; --i)                 // front to back!
                {
                    DisplayObject child = _children[i];
                    if (child == _mask)
                    {
                        continue;
                    }

                    target = child.InternalHitTest();
                    if (target != null)
                    {
                        break;
                    }
                }
            }

            if (target == null && opaque && (hitArea != null || _contentRect.Contains(localPoint.x, localPoint.y)))
            {
                target = this;
            }

            HitTestContext.screenPoint = savedScreenPoint;

            return(target);
        }
Ejemplo n.º 11
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);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 测试是否击中地图对象或地图对象上的节点
        /// </summary>
        /// <param name="tolerance">查询容差</param>
        /// <param name="pPoint">点击位置</param>
        /// <param name="pFeature">测试对象</param>
        /// <param name="pHitPoint">查询目标点</param>
        /// <param name="hitDist">目标点与点击点距离</param>
        /// <param name="partIndex">节索引</param>
        /// <param name="vertexIndex">点索引</param>
        /// <param name="vertexHit">是否击中点</param>
        /// <returns>是否击中测试对象</returns>
        private bool TestGeometryHit(double tolerance, IPoint pPoint, IFeature pFeature, IPoint pHitPoint,
                                     double hitDist, out int partIndex, out int vertexIndex, out bool vertexHit)
        {
            try
            {
                IGeometry pGeom    = pFeature.Shape;
                IHitTest  pHitTest = (IHitTest)pGeom;
                pHitPoint = new PointClass();
                bool bRes = true;

                partIndex   = 0;
                vertexIndex = 0;
                vertexHit   = false;
                // 检查节点是否被击中
                if (pHitTest.HitTest(pPoint, tolerance, esriGeometryHitPartType.esriGeometryPartVertex, pHitPoint,
                                     ref hitDist, ref partIndex, ref vertexIndex, ref bRes))
                {
                    vertexHit = true;
                    return(true);
                }
                // 检边界是否被击中
                else
                {
                    if (pHitTest.HitTest(pPoint, tolerance, esriGeometryHitPartType.esriGeometryPartBoundary, pHitPoint,
                                         ref hitDist, ref partIndex, ref vertexIndex, ref bRes))
                    {
                        vertexHit = false;
                        return(true);
                    }
                }
                return(false);
            }

            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
                partIndex   = 0;
                vertexIndex = 0;
                vertexHit   = false;
                return(false);
            }
        }
Ejemplo n.º 13
0
        private bool TestGeometryHit(double tolerance, IPoint pPoint, IFeature pFeature, ref IPoint pHitPoint, ref double hitDist, ref int partIndex, ref int vertexIndex, ref int vertexOffset, ref bool vertexHit)
        {
            // Function returns true if a feature's shape is hit and further defines
            // if a vertex lies within the tolorance
            bool      bRetVal = false;
            IGeometry pGeom   = (IGeometry)pFeature.Shape;

            IHitTest pHitTest = (IHitTest)pGeom;

            pHitPoint = new ESRI.ArcGIS.Geometry.Point();
            bool bTrue = true;

            // 检查顶点是否被点击
            if (pHitTest.HitTest(pPoint, tolerance, esriGeometryHitPartType.esriGeometryPartVertex, pHitPoint, ref hitDist, ref partIndex, ref vertexIndex, ref bTrue))
            {
                bRetVal   = true;
                vertexHit = true;
            }
            // 检查边界是否被点击
            else if (pHitTest.HitTest(pPoint, tolerance, esriGeometryHitPartType.esriGeometryPartBoundary, pHitPoint, ref hitDist, ref partIndex, ref vertexIndex, ref bTrue))
            {
                bRetVal   = true;
                vertexHit = false;
            }

            // 统计vertexOffset顶点数目
            if (partIndex > 0)
            {
                IGeometryCollection pGeomColn = (IGeometryCollection)pGeom;
                vertexOffset = 0;
                for (int i = 0; i < partIndex; i++)
                {
                    IPointCollection pPointColn = (IPointCollection)pGeomColn.get_Geometry(i);
                    vertexOffset = vertexOffset + pPointColn.PointCount;
                }
            }
            return(bRetVal);
        }
Ejemplo n.º 14
0
        public override bool HiTest(double double_0, IPoint ipoint_0, out IPoint ipoint_1, ref double double_1,
                                    ref int int_0, ref int int_1, out bool bool_0)
        {
            bool     flag;
            IHitTest mPGeometry = this.m_pGeometry as IHitTest;

            ipoint_1 = new ESRI.ArcGIS.Geometry.Point();
            bool_0   = false;
            bool flag1 = false;

            if (mPGeometry.HitTest(ipoint_0, double_0, esriGeometryHitPartType.esriGeometryPartVertex, ipoint_1,
                                   ref double_1, ref int_0, ref int_1, ref flag1))
            {
                bool_0 = true;
                flag   = true;
            }
            else if (mPGeometry.HitTest(ipoint_0, double_0, esriGeometryHitPartType.esriGeometryPartBoundary, ipoint_1,
                                        ref double_1, ref int_0, ref int_1, ref flag1))
            {
                bool_0 = false;
                flag   = true;
            }
            else if (!((IRelationalOperator)this.m_pGeometry).Contains(ipoint_0))
            {
                flag = false;
            }
            else
            {
                int_0  = -1;
                bool_0 = false;
                ipoint_1.PutCoords(ipoint_0.X, ipoint_0.Y);
                double_1 = 0;
                flag     = true;
            }
            return(flag);
        }
        private bool TestGeometryHit(double tol, IPoint pPoint, IGeometry geometry, ref IPoint pHitPoint,
                                     ref double hitDist, ref int partIndex, ref int vertexOffset,
                                     ref int vertexIndex, ref bool vertexHit)
        {
            IHitTest pHitTest = geometry as IHitTest;

            pHitPoint = new PointClass();
            bool last = true;
            bool res  = false;

            if (pHitTest.HitTest(pPoint, tol, esriGeometryHitPartType.esriGeometryPartVertex, pHitPoint, ref hitDist, ref partIndex, ref vertexIndex, ref last))
            {
                vertexHit = true;
                res       = true;
            }
            else
            {
                if (pHitTest.HitTest(pPoint, tol, esriGeometryHitPartType.esriGeometryPartBoundary, pHitPoint, ref hitDist, ref partIndex, ref vertexIndex, ref last))
                {
                    vertexHit = false;
                    res       = true;
                }
            }

            if (partIndex > 0)
            {
                IGeometryCollection pGeoColl = geometry as IGeometryCollection;
                vertexOffset = 0;
                for (int i = 0; i < partIndex; i = 2 * i + 1)
                {
                    IPointCollection pointColl = pGeoColl.get_Geometry(i) as IPointCollection;
                    vertexOffset = vertexOffset + pointColl.PointCount;
                }
            }
            return(res);
        }
Ejemplo n.º 16
0
 public override void OnMouseDown(int int_2, int int_3, int int_4, int int_5)
 {
     if (int_2 == 1)
     {
         IPoint mapPoint = _context.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(int_4, int_5);
         double mapUnits = Common.ConvertPixelsToMapUnits((IActiveView)_context.FocusMap,
                                                          _context.Config.EngineSnapEnvironment.SnapTolerance);
         IFeature hitLineFeature = Yutai.ArcGIS.Common.Editor.Editor.GetHitLineFeature(_context.FocusMap,
                                                                                       mapPoint, mapUnits);
         if (hitLineFeature != null)
         {
             double   num        = 0;
             bool     flag       = false;
             int      num1       = -1;
             int      num2       = -1;
             IPoint   pointClass = new ESRI.ArcGIS.Geometry.Point();
             IHitTest shapeCopy  = hitLineFeature.ShapeCopy as IHitTest;
             shapeCopy.HitTest(mapPoint, mapUnits, esriGeometryHitPartType.esriGeometryPartBoundary, pointClass,
                               ref num, ref num1, ref num2, ref flag);
             if (this.ifeature_0 != null)
             {
                 IWorkspaceEdit workspace = (hitLineFeature.Class as IDataset).Workspace as IWorkspaceEdit;
                 workspace.StartEditOperation();
                 bool flag1 = Yutai.ArcGIS.Common.Editor.Editor.ConstructJunction(_context.FocusMap,
                                                                                  this.ifeature_0, this.ipoint_0, this.int_0, this.int_1, hitLineFeature, pointClass, num1,
                                                                                  num2);
                 workspace.StopEditOperation();
                 if (!flag1)
                 {
                     MessageBox.Show("两条线无法计算交点,线段可能不相交或交点在该图层坐标范围以外!");
                 }
                 else
                 {
                     _context.ActiveView.Refresh();
                 }
                 this.ifeature_0 = null;
             }
             else
             {
                 this.ifeature_0 = hitLineFeature;
                 this.int_0      = num1;
                 this.int_1      = num2;
                 this.ipoint_0   = pointClass;
             }
         }
     }
 }
Ejemplo n.º 17
0
        private static bool ExistsInNew([NotNull] IPoint testPoint,
                                        double searchRadius, [NotNull] IHitTest newHitTest,
                                        ref int hitPartIndex,
                                        ref int hitSegmentIndex)
        {
            double distance = 0;
            var    right    = false;
            IPoint hitPoint = new PointClass();

            bool inNew = newHitTest.HitTest(testPoint, searchRadius,
                                            esriGeometryHitPartType.esriGeometryPartVertex,
                                            hitPoint,
                                            ref distance, ref hitPartIndex, ref hitSegmentIndex,
                                            ref right);

            return(inNew);
        }
Ejemplo n.º 18
0
 public void OnMouseUp(int button, int shift, int x, int y)
 {
     if (button != 2)
     {
         try
         {
             IGeometry editShape       = Editor.UniqueInstance.EditShape;
             IPoint    queryPoint      = this._hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
             IHitTest  test            = editShape as IHitTest;
             IPoint    hitPoint        = new PointClass();
             double    hitDistance     = 0.0;
             int       hitPartIndex    = 0;
             int       hitSegmentIndex = 0;
             bool      bRightSide      = false;
             double    searchRadius    = 1.0 * this._hookHelper.ActiveView.FocusMap.MapScale;
             esriGeometryHitPartType esriGeometryPartBoundary = esriGeometryHitPartType.esriGeometryPartBoundary;
             test.HitTest(queryPoint, searchRadius, esriGeometryPartBoundary, hitPoint, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);
             if (!hitPoint.IsEmpty)
             {
                 IEngineSketchOperation operation = new EngineSketchOperationClass();
                 operation.Start(Editor.UniqueInstance.EngineEditor);
                 IGeometryCollection geometrys = editShape as IGeometryCollection;
                 IPointCollection    points    = geometrys.get_Geometry(hitPartIndex) as IPointCollection;
                 object missing = Type.Missing;
                 object after   = new object();
                 after = hitSegmentIndex;
                 object before = new object();
                 before = hitPartIndex;
                 points.AddPoint(queryPoint, ref missing, ref after);
                 operation.SetMenuString("Insert Vertex");
                 esriEngineSketchOperationType esriEngineSketchOperationVertexAdded = esriEngineSketchOperationType.esriEngineSketchOperationVertexAdded;
                 geometrys.RemoveGeometries(hitPartIndex, 1);
                 geometrys.AddGeometry(points as IGeometry, ref before, ref missing);
                 operation.Finish(null, esriEngineSketchOperationVertexAdded, queryPoint);
                 Editor.UniqueInstance.FinishSketch();
                 this.OnClick();
             }
         }
         catch (Exception exception)
         {
             Editor.UniqueInstance.AbortEditOperation();
             this._mErrOpt.ErrorOperate(this._mSubSysName, "ShapeEdit.InsertVertex", "OnMouseUp", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         }
     }
 }
Ejemplo n.º 19
0
        private static bool ExistsInOriginal([NotNull] IPoint testPoint,
                                             [NotNull] IHitTest orgHitTest,
                                             double searchRadius)
        {
            IPoint hitPoint        = new PointClass();
            double distance        = 0;
            var    hitPartIndex    = 0;
            var    hitSegmentIndex = 0;
            var    right           = false;

            bool inOriginal = orgHitTest.HitTest(testPoint, searchRadius,
                                                 esriGeometryHitPartType.esriGeometryPartVertex,
                                                 hitPoint,
                                                 ref distance, ref hitPartIndex,
                                                 ref hitSegmentIndex,
                                                 ref right);

            return(inOriginal);
        }
Ejemplo n.º 20
0
		override protected DisplayObject HitTest()
		{
			if (_scale.X == 0 || _scale.Y == 0)
				return null;

			Vector2 savedScreenPoint = HitTestContext.screenPoint;
			Vector2 localPoint = GlobalToLocal(HitTestContext.screenPoint);

			if (hitArea != null)
			{
				if (!hitArea.HitTest(_contentRect, localPoint))
					return null;
			}
			else
			{
				if (_clipRect != null && !((Rectangle)_clipRect).Contains(localPoint.X, localPoint.Y))
					return null;
			}

			DisplayObject target = null;
			if (touchChildren)
			{
				int count = _children.Count;
				for (int i = count - 1; i >= 0; --i) // front to back!
				{
					DisplayObject child = _children[i];
					if (child == _mask || child._touchDisabled)
						continue;

					target = child.InternalHitTest();
					if (target != null)
						break;
				}
			}

			if (target == null && opaque && (hitArea != null || _contentRect.Contains(localPoint.X, localPoint.Y)))
				target = this;

			HitTestContext.screenPoint = savedScreenPoint;

			return target;
		}
Ejemplo n.º 21
0
 /// <summary>
 /// 几何形状点击查询测试
 /// </summary>
 /// <param name="geometry">ESRI几何形状接口</param>
 /// <param name="queryPoint">查询点的ESRI几何形状接口</param>
 /// <param name="searchRadius">搜索半径</param>
 /// <param name="geometryPart">搜索命中的几何形状部位</param>
 /// <param name="hitPoint">搜索命中点的ESRI点接口</param>
 /// <param name="hitDistance">搜索命中的距离</param>
 /// <param name="hitPartIndex">搜索命中的几何形状部位索引</param>
 /// <param name="hitSegmentIndex">搜索命中的几何形状部位片段索引</param>
 /// <param name="bRightSide">是否命中几何形状的右方</param>
 /// <param name="hit">是否命中</param>
 public static void GeometryHitTest(IGeometry geometry, IPoint queryPoint, double searchRadius,
                                    out esriGeometryHitPartType geometryPart, out IPoint hitPoint, out double hitDistance,
                                    out int hitPartIndex, out int hitSegmentIndex, out bool bRightSide, out bool hit)
 {
     geometryPart    = esriGeometryHitPartType.esriGeometryPartNone;
     hitPoint        = new ESRI.ArcGIS.Geometry.Point();
     hitDistance     = -1;
     hitPartIndex    = -1;
     hitSegmentIndex = -1;
     bRightSide      = false;
     hit             = false;
     if (IsValidGeometry(geometry) && (geometry is IHitTest))
     {
         IHitTest hitTest = (IHitTest)geometry;
         geometryPart = esriGeometryHitPartType.esriGeometryPartVertex;
         hit          = hitTest.HitTest(queryPoint, searchRadius, geometryPart, hitPoint,
                                        ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);
         if (!hit)
         {
             geometryPart = esriGeometryHitPartType.esriGeometryPartBoundary;
             hit          = hitTest.HitTest(queryPoint, searchRadius, geometryPart, hitPoint,
                                            ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);
         }
         if (!hit)
         {
             geometryPart = esriGeometryHitPartType.esriGeometryPartMidpoint;
             hit          = hitTest.HitTest(queryPoint, searchRadius, geometryPart, hitPoint,
                                            ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);
         }
         if (!hit)
         {
             geometryPart = esriGeometryHitPartType.esriGeometryPartEndpoint;
             hit          = hitTest.HitTest(queryPoint, searchRadius, geometryPart, hitPoint,
                                            ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);
         }
         if (!hit)
         {
             geometryPart = esriGeometryHitPartType.esriGeometryPartCentroid;
             hit          = hitTest.HitTest(queryPoint, searchRadius, geometryPart, hitPoint,
                                            ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);
         }
         if (!hit)
         {
             geometryPart = esriGeometryHitPartType.esriGeometryPartSurface;
             hit          = hitTest.HitTest(queryPoint, searchRadius, geometryPart, hitPoint,
                                            ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);
         }
     }
 }
Ejemplo n.º 22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contentRect"></param>
        /// <param name="localPoint"></param>
        /// <returns></returns>
        public bool HitTest(Rect contentRect, Vector2 localPoint)
        {
            if (shape.graphics == null)
            {
                return(false);
            }

            if (shape.parent != null)
            {
                localPoint = shape.parent.TransformPoint(localPoint, shape);
            }

            IHitTest ht = shape.graphics.meshFactory as IHitTest;

            if (ht == null)
            {
                return(false);
            }

            return(ht.HitTest(contentRect, localPoint));
        }
        public IPointCollection4 modify1VertexOfAPolyline(IGeometryCollection geo, Double searchRadius, Double offsetX, Double offsetY)
        {
            IPoint   queryPoint = m_activePoint;
            IPoint   hitPoint = new PointClass();
            Double   hitDistance = 0; Int32 hitPartIndex = 0;
            Int32    hitSegmentIndex = 0;
            Boolean  rightSide       = false;
            IHitTest hitTest         = (IHitTest)geo;
            Boolean  foundGeometry   = hitTest.HitTest(queryPoint, searchRadius, esriGeometryHitPartType.esriGeometryPartVertex, hitPoint, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref rightSide);

            if (foundGeometry == true)
            {
                IGeometry         geometry        = geo.get_Geometry(hitPartIndex);
                IPointCollection4 pointCollection = (IPointCollection4)geometry;
                IPoint            transformPoint  = pointCollection.get_Point(hitSegmentIndex);
                ITransform2D      transform2D     = (ITransform2D)transformPoint;
                transform2D.Move(offsetX, offsetY);
                pointCollection.UpdatePoint(hitSegmentIndex, transformPoint);
                return(pointCollection);
            }
            return(null);
        }
        public ISegmentCollection Modify1Segment(IGeometryCollection polyline, Double searchRadius, Double offsetX, Double offsetY)
        {
            IPoint   queryPoint = m_activePoint;
            IPoint   hitPoint = new PointClass();
            double   hitDistance = 0; int hitPartIndex = 0;
            int      hitSegmentIndex = 0; bool rightSide = false;
            IHitTest hitTest       = (IHitTest)polyline;
            bool     foundGeometry = hitTest.HitTest(queryPoint, searchRadius, esriGeometryHitPartType.esriGeometryPartBoundary, hitPoint, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref rightSide);

            if (foundGeometry == true)
            {
                IGeometry          geometry          = polyline.get_Geometry(hitPartIndex);
                ISegmentCollection segmentCollection =
                    (ISegmentCollection)geometry;
                ISegment     segment     = segmentCollection.get_Segment(hitSegmentIndex);
                ITransform2D transform2D = (ITransform2D)segment;
                transform2D.Move(offsetX, offsetY);
                segmentCollection.SegmentsChanged();
                return(segmentCollection);
            }
            return(null);
        }
Ejemplo n.º 25
0
        private void SnapVertex(IPoint mousePoint)
        {
            int hitPartIndex = -1;

            this._vertexIndex = -1;
            this._isSnaped    = false;
            double   searchRadius = this._viewMap.ScreenDisplay.DisplayTransformation.FromPoints(ToolConfig.MouseTolerance);
            IHitTest linageShape  = Editor.UniqueInstance.LinageShape as IHitTest;
            IPoint   hitPoint     = null;
            double   hitDistance  = 0.0;
            bool     bRightSide   = false;
            bool     flag2        = linageShape.HitTest(mousePoint, searchRadius, esriGeometryHitPartType.esriGeometryPartVertex, hitPoint, ref hitDistance, ref hitPartIndex, ref this._vertexIndex, ref bRightSide);

            this._isSnaped = (flag2 && (this._vertexIndex > 0)) && (this._vertexIndex < ((Editor.UniqueInstance.LinageShape as IPointCollection).PointCount - 1));
            if (this._isSnaped)
            {
                this._cursor = this._cursorSnap;
            }
            else
            {
                this._cursor = this._cursorNormal;
            }
        }
Ejemplo n.º 26
0
        protected override DisplayObject HitTest()
        {
            if (graphics.meshFactory == null)
            {
                return(null);
            }

            Vector2 localPoint = GlobalToLocal(HitTestContext.screenPoint);

            IHitTest ht = graphics.meshFactory as IHitTest;

            if (ht != null)
            {
                return(ht.HitTest(_contentRect, localPoint) ? this : null);
            }
            else if (_contentRect.Contains(localPoint.X, localPoint.Y))
            {
                return(this);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 27
0
        protected override DisplayObject HitTest()
        {
            if (graphics.meshFactory == null)
            {
                return(null);
            }

            Vector2 localPoint = WorldToLocal(HitTestContext.worldPoint, HitTestContext.direction);

            IHitTest ht = graphics.meshFactory as IHitTest;

            if (ht != null)
            {
                return(ht.HitTest(_contentRect, localPoint) ? this : null);
            }
            else if (_contentRect.Contains(localPoint))
            {
                return(this);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 28
0
        override protected DisplayObject HitTest()
        {
            if (_disabled)
            {
                return(null);
            }

            if (this.cachedTransform.localScale.x == 0 || this.cachedTransform.localScale.y == 0)
            {
                return(null);
            }

            Vector3 savedWorldPoint = HitTestContext.worldPoint;
            Vector3 savedDirection  = HitTestContext.direction;
            Camera  savedCamera     = HitTestContext.camera;

            if (this.renderMode == RenderMode.WorldSpace)
            {
                HitTestContext.camera = GetRenderCamera();

                Vector3 screenPoint = HitTestContext.camera.WorldToScreenPoint(this.cachedTransform.position);                 //only for query z value
                screenPoint.x = HitTestContext.screenPoint.x;
                screenPoint.y = HitTestContext.screenPoint.y;

                //获得本地z轴在世界坐标的方向
                HitTestContext.worldPoint = HitTestContext.camera.ScreenToWorldPoint(screenPoint);
                Ray ray = HitTestContext.camera.ScreenPointToRay(screenPoint);
                HitTestContext.direction = Vector3.zero - ray.direction;
            }

            Vector2 localPoint = WorldToLocal(HitTestContext.worldPoint, HitTestContext.direction);

            if (hitArea != null)
            {
                if (!hitArea.HitTest(_contentRect, localPoint))
                {
                    HitTestContext.worldPoint = savedWorldPoint;
                    HitTestContext.direction  = savedDirection;
                    HitTestContext.camera     = savedCamera;
                    return(null);
                }

                if (hitArea is MeshColliderHitTest)
                {
                    localPoint = ((MeshColliderHitTest)hitArea).lastHit;
                }
            }
            else
            {
                if (_clipRect != null && !((Rect)_clipRect).Contains(localPoint))
                {
                    HitTestContext.worldPoint = savedWorldPoint;
                    HitTestContext.direction  = savedDirection;
                    HitTestContext.camera     = savedCamera;
                    return(null);
                }
            }

            if (_mask != null)
            {
                DisplayObject tmp = _mask.InternalHitTestMask();
                if (!reversedMask && tmp == null || reversedMask && tmp != null)
                {
                    HitTestContext.worldPoint = savedWorldPoint;
                    HitTestContext.direction  = savedDirection;
                    HitTestContext.camera     = savedCamera;
                    return(null);
                }
            }

            DisplayObject target = null;

            if (touchChildren)
            {
                int count = _children.Count;
                for (int i = count - 1; i >= 0; --i)                 // front to back!
                {
                    DisplayObject child = _children[i];
                    if (child == _mask || child._touchDisabled)
                    {
                        continue;
                    }

                    target = child.InternalHitTest();
                    if (target != null)
                    {
                        break;
                    }
                }
            }

            if (target == null && opaque && (hitArea != null || _contentRect.Contains(localPoint)))
            {
                target = this;
            }

            HitTestContext.worldPoint = savedWorldPoint;
            HitTestContext.direction  = savedDirection;
            HitTestContext.camera     = savedCamera;

            return(target);
        }
Ejemplo n.º 29
0
 private static DockStyle TestDrop(IHitTest hitTest, Point pt)
 {
     return(hitTest.Status = hitTest.HitTest(pt));
 }
 private static DockStyle TestDrop(IHitTest hitTest, Point pt)
 {
     return hitTest.Status = hitTest.HitTest(pt);
 }
        public void SnapVertex(int x, int y, IGeometry snapContainer, ref bool vertexSnaped, ref bool contained)
        {
            IPoint point = MyMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
            IPoint pHitPoint = null;
            double hitDist = -1, tol = -1;
            int    vertexIndex = -1, partIndex = -1;
            bool   vertex = false;

            tol = ConvertPixelsToMapUnits(4);

            IHitTest pHitTest = snapContainer as IHitTest;
            bool     bHit     = pHitTest.HitTest(point, tol, esriGeometryHitPartType.esriGeometryPartVertex, pHitPoint, ref hitDist, ref partIndex, ref vertexIndex, ref vertex);

            vertexSnaped = false;
            contained    = false;
            if (bHit)
            {
                MyMapControl.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
                vertexSnaped = true;
                return;
            }
            else
            {
                IRelationalOperator  pRelOperator = null;
                ITopologicalOperator pTopo        = null;
                IGeometry            buffer       = null;
                IPolygon             polygon      = null;
                switch (snapContainer.GeometryType)
                {
                case esriGeometryType.esriGeometryPolyline:
                    pTopo        = snapContainer as ITopologicalOperator;
                    buffer       = pTopo.Buffer(3);
                    polygon      = buffer as IPolygon;
                    pRelOperator = polygon as IRelationalOperator;
                    break;

                case esriGeometryType.esriGeometryPolygon:
                    polygon      = snapContainer as IPolygon;
                    pRelOperator = polygon as IRelationalOperator;
                    break;

                case esriGeometryType.esriGeometryPoint:
                    pTopo        = snapContainer as ITopologicalOperator;
                    buffer       = pTopo.Buffer(3);
                    polygon      = buffer as IPolygon;
                    pRelOperator = polygon as IRelationalOperator;
                    break;

                default:
                    break;
                }

                if (pRelOperator == null)
                {
                    return;
                }
                if (pRelOperator.Contains(point))
                {
                    MyMapControl.MousePointer = esriControlsMousePointer.esriPointerSizeAll;
                    contained = true;
                }
                else
                {
                    MyMapControl.MousePointer = esriControlsMousePointer.esriPointerArrow;
                }
                return;
            }
        }