public void WarpLayer() { IGeoReference pGR = pRasterLayer as IGeoReference; if (pGR != null) { pGR.Reset(); if (OriginPoints == null || TargetPoints == null || OriginPoints.PointCount < 1 || TargetPoints.PointCount < 1) { return; } if (OriginPoints.PointCount == 1) { IPoint pt1, pt2; pt1 = OriginPoints.get_Point(0); pt2 = TargetPoints.get_Point(0); pGR.Shift(pt2.X - pt1.X, pt2.Y - pt1.Y); } else { if (OriginPoints.PointCount == 2) { pGR.TwoPointsAdjust(OriginPoints, TargetPoints); } else { pGR.Warp(OriginPoints, TargetPoints, WarpType); } TransformedOriginPoints = pGR.PointsTransform(OriginPoints, true); //RefreshWarpType(); } } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { // TODO: Add ToolAddControlPoints.OnMouseDown implementation object Miss = Type.Missing; IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2; if (pMapCtr != null) { IGeoReference pGR = pRasterLayer as IGeoReference; IPoint mapPoint = pMapCtr.ToMapPoint(X, Y); m_NewLineFeedback.Display = pMapCtr.ActiveView.ScreenDisplay; if (FirstPoint == true)//起始点 { IPointCollection pPCFrom; IPointCollection pPCTo = new MultipointClass(); pPCTo.AddPoint(mapPoint, ref Miss, ref Miss); pPCFrom = pGR.PointsTransform(pPCTo, false); //for (int i = 0; i < OriginPoints.PointCount; i++) //{ // pPCFrom.AddPoint(OriginPoints.get_Point(i)); //} //pPCFrom.AddPoint(mapPoint); m_NewLineFeedback.Start(mapPoint); // OriginPoints.AddPoint(mapPoint); IPoint pt = pPCFrom.get_Point(0); OriginPoints.AddPoint(pt); FirstPoint = false; } else//目标点 { TargetPoints.AddPoint(mapPoint); FirstPoint = true; m_NewLineFeedback.Stop(); // IPointCollection pPC = pGR.PointsTransform(TargetPoints, false); //IPointCollection pPC = OriginPoints; //IPoint pt1, pt2; //pt1 = pPC.get_Point(0); //pt2 = TargetPoints.get_Point(0); //if (pPC.PointCount == 1) //{ // //IPoint pt1,pt2; // //pt1 = pPC.get_Point(0); // //pt2 = TargetPoints.get_Point(0); // pGR.Shift(pt2.X - pt1.X, pt2.Y - pt1.Y); //} //else //if (pPC.PointCount ==2 ) //{ // pGR.TwoPointsAdjust(pPC, TargetPoints); //} //else //{ // pGR.Warp(pPC, TargetPoints, m_FrmLinkTableRaster.WarpType); //} //m_FrmLinkTableRaster.AddControlPoints(OriginPoints.get_Point(OriginPoints.PointCount -1) // ,TargetPoints.get_Point(TargetPoints.PointCount -1)); m_FrmLinkTableRaster.pRasterLayer = pRasterLayer; m_FrmLinkTableRaster.pMapCtr = pMapCtr; m_FrmLinkTableRaster.RefreshControlAllPoints(); } TransformedOriginPoints = pGR.PointsTransform(OriginPoints, true); // pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); } }