Пример #1
0
        private GraphicsPath ToGraphicsPath(GeometryOfDrawed geo, ICanvas canvas)
        {
            if (geo == null || geo.RasterPoints.Length == 0)
            {
                return(null);
            }
            float x, y;
            int   ix, iy;
            int   count = geo.RasterPoints.Length;

            PointF[] pts = pts = new PointF[count];
            for (int i = 0; i < count; i++)
            {
                if (geo.IsPrjCoord)
                {
                    canvas.CoordTransform.Prj2Screen(geo.RasterPoints[i].X, geo.RasterPoints[i].Y, out ix, out iy);
                    pts[i].X = ix;
                    pts[i].Y = iy;
                }
                else
                {
                    canvas.CoordTransform.Raster2Screen(geo.RasterPoints[i].Y, geo.RasterPoints[i].X, out x, out y);
                    pts[i].X = x;
                    pts[i].Y = y;
                }
            }

            if ((geo is GeometryOfDrawed) && (geo as GeometryOfDrawed).ShapeType == "Cross")
            {
                PointF[] vertexts;
                if ((geo as GeometryOfDrawed).ControlRasterPoints.Count() == 1)
                {
                    vertexts = new PointF[] { new PointF(pts[0].X - 50, pts[0].Y), new PointF(pts[0].X, pts[0].Y - 50),
                                              new PointF(pts[0].X + 50, pts[0].Y), new PointF(pts[0].X, pts[0].Y + 50) };
                }
                else
                {
                    vertexts = new PointF[] { new PointF(pts[0].X - 10, pts[0].Y), new PointF(pts[0].X, pts[0].Y - 10),
                                              new PointF(pts[0].X + 10, pts[0].Y), new PointF(pts[0].X, pts[0].Y + 10) };
                }
                return(new GraphicsPath(vertexts, geo.Types));
            }

            return(new GraphicsPath(pts.Take(count).ToArray(), geo.Types));
        }
Пример #2
0
        private void DoDragVertext(object sender, GeometryOfDrawed geometry, int offsetX, int offsetY)
        {
            ICanvas canvas = sender as ICanvas;
            float   scaleX = (float)(canvas.CurrentEnvelope.Width / canvas.Container.Width);
            float   scaleY = (float)(canvas.CurrentEnvelope.Height / canvas.Container.Height);
            float   dltX   = offsetX * scaleX;
            float   dltY   = -offsetY * scaleY;

            if (geometry.ShapeType == "Rectangle")
            {
                if (geometry.IsPrjCoord)
                {
                    switch (_crtVertextIndex)
                    {
                    case 0:
                        geometry.RasterPoints[0].X += dltX;
                        geometry.RasterPoints[3].X += dltX;
                        geometry.RasterPoints[0].Y += dltY;
                        geometry.RasterPoints[1].Y += dltY;
                        break;

                    case 1:
                        geometry.RasterPoints[1].X += dltX;
                        geometry.RasterPoints[2].X += dltX;
                        geometry.RasterPoints[0].Y += dltY;
                        geometry.RasterPoints[1].Y += dltY;
                        break;

                    case 2:
                        geometry.RasterPoints[1].X += dltX;
                        geometry.RasterPoints[2].X += dltX;
                        geometry.RasterPoints[3].Y += dltY;
                        geometry.RasterPoints[2].Y += dltY;
                        break;

                    case 3:
                        geometry.RasterPoints[0].X += dltX;
                        geometry.RasterPoints[3].X += dltX;
                        geometry.RasterPoints[3].Y += dltY;
                        geometry.RasterPoints[2].Y += dltY;
                        break;
                    }
                }
            }
        }
Пример #3
0
        //橡皮檫
        private void HandleErase(object result)
        {
            if (_canvasViewer == null)
            {
                return;
            }
            GeometryOfDrawed    geometry = result as GeometryOfDrawed;
            IRasterDataProvider prd      = GetRasterDataProvider(_canvasViewer);

            using (IVectorAOIGenerator gen = new VectorAOIGenerator())
            {
                int[]             aoi    = gen.GetAOI(geometry.RasterPoints.Clone() as PointF[], geometry.Types, new Size(prd.Width, prd.Height));
                string            name   = GetName(_currentProduct, _currentSubProduct);
                IPixelIndexMapper mapper = _resultObjects[name].BinaryValues;
                mapper.Remove(aoi);
                UpdateLayer(_resultObjects[name]);
            }
        }
Пример #4
0
        private void EventPoint(object sender, enumCanvasEventType eventType, DrawingMouseEventArgs e)
        {
            if (eventType != enumCanvasEventType.MouseDown)
            {
                return;
            }
            GeometryOfDrawed geometry = new GeometryOfDrawed();

            geometry.ShapeType = _pencilType.ToString();
            ICoordinateTransform tran = (sender as ICanvas).CoordTransform;
            float row = 0, col = 0;

            tran.Screen2Raster(e.ScreenX, e.ScreenY, out row, out col);
            geometry.RasterPoints = new PointF[] { new PointF(row, col) };
            if (this._pencilDrawedResultFinished != null)
            {
                this._pencilDrawedResultFinished(geometry);
            }
        }
Пример #5
0
        private GeoDo.RSS.Core.DrawEngine.CoordPoint GetCoordPoint(GeometryOfDrawed geometry)
        {
            if (geometry.RasterPoints.Length == 0)
            {
                return(null);
            }
            double geoX, geoY;

            if (canvasHost1.Canvas.PrimaryDrawObject != null)
            {
                if (canvasHost1.Canvas.PrimaryDrawObject.IsRasterCoord)
                {
                    geoX = geometry.RasterPoints[0].X;
                    geoY = geometry.RasterPoints[0].Y;
                }
                else
                {
                    if (canvasHost1.Canvas.CoordTransform.DataCoordType == enumDataCoordType.Geo)
                    {
                        canvasHost1.Canvas.CoordTransform.Raster2Geo(Convert.ToInt32(geometry.RasterPoints[0].Y), Convert.ToInt32(geometry.RasterPoints[0].X), out geoX, out geoY);
                    }
                    else
                    {
                        canvasHost1.Canvas.CoordTransform.Raster2Prj(geometry.RasterPoints[0].Y, geometry.RasterPoints[0].X, out geoX, out geoY);
                    }
                }
            }
            else
            {
                if (canvasHost1.Canvas.CoordTransform.DataCoordType == enumDataCoordType.Geo)
                {
                    canvasHost1.Canvas.CoordTransform.Prj2Geo(geometry.RasterPoints[0].X, geometry.RasterPoints[0].Y, out geoX, out geoY);
                }
                else
                {
                    geoX = geometry.RasterPoints[0].X;
                    geoY = geometry.RasterPoints[0].Y;
                }
            }

            return(new GeoDo.RSS.Core.DrawEngine.CoordPoint(geoX, geoY));
        }
Пример #6
0
        private void button15_Click(object sender, EventArgs e)
        {
            if (_aoiLayer == null)
            {
                _aoiLayer       = new AOIContainerLayer();
                _aoiLayer.Color = Color.Red;
                _canvas.LayerContainer.Layers.Add(_aoiLayer as GeoDo.RSS.Core.DrawEngine.ILayer);
            }
            IPencilToolLayer layer = new PencilToolLayer();

            layer.PencilType       = enumPencilType.FreeCurve;
            layer.PencilIsFinished = (result) =>
            {
                //ptfs = result.GeoPoints;
                //pts = result.RasterPoints;
                _result = result;
                _aoiLayer.AddAOI(_result);
            };
            _canvas.CurrentViewControl = layer;
        }
Пример #7
0
        public static CodeCell.AgileMap.Core.Shape ToPolygon(ICanvas canvas, GeometryOfDrawed geometry)
        {
            if (canvas == null || geometry == null || geometry.RasterPoints == null || geometry.RasterPoints.Length == 0)
            {
                return(null);
            }
            int count = geometry.RasterPoints.Length;
            List <ShapePoint> pts = new List <ShapePoint>(count);
            double            geoX = 0, geoY = 0;

            for (int i = 0; i < count; i++)
            {
                canvas.CoordTransform.Raster2Geo((int)geometry.RasterPoints[i].Y, (int)geometry.RasterPoints[i].X, out geoX, out geoY);
                pts.Add(new ShapePoint(geoX, geoY));
            }
            ShapeRing    ring = new ShapeRing(pts.ToArray());
            ShapePolygon ply  = new ShapePolygon(new ShapeRing[] { ring });

            return(ply);
        }
Пример #8
0
        private CoordEnvelope GetCoordEnvelope(GeometryOfDrawed geometry)
        {
            if (geometry.RasterPoints.Length == 0)
            {
                return(null);
            }
            double geoX1, geoY1, geoX2, geoY2;

            if (geometry.IsPrjCoord)
            {
                canvasHost1.Canvas.CoordTransform.Prj2Geo(geometry.RasterPoints[0].X, geometry.RasterPoints[0].Y, out geoX1, out geoY1);
                canvasHost1.Canvas.CoordTransform.Prj2Geo(geometry.RasterPoints[2].X, geometry.RasterPoints[2].Y, out geoX2, out geoY2);
            }
            else
            {
                canvasHost1.Canvas.CoordTransform.Raster2Geo((int)geometry.RasterPoints[0].X, (int)geometry.RasterPoints[0].Y, out geoX1, out geoY1);
                canvasHost1.Canvas.CoordTransform.Raster2Geo((int)geometry.RasterPoints[2].X, (int)geometry.RasterPoints[2].Y, out geoX2, out geoY2);
            }
            return(new CoordEnvelope(Math.Min(geoX1, geoX2), Math.Max(geoX1, geoX2), Math.Min(geoY2, geoY1), Math.Max(geoY2, geoY1)));
        }
Пример #9
0
        private int[] GetBitmapIndexes(GeometryOfDrawed geometryOfDrawed)
        {
            PointF[] pts = geometryOfDrawed.RasterPoints.Clone() as PointF[];
            double   prjX, prjY;

            GeoDo.RSS.Core.DrawEngine.ICoordinateTransform tran = _canvas.CoordTransform;
            for (int i = 0; i < pts.Length; i++)
            {
                tran.Raster2Prj((int)pts[i].Y, (int)pts[i].X, out prjX, out prjY);
                pts[i].X = (float)prjX;
                pts[i].Y = (float)prjY;
            }
            IRasterDrawing rst  = _canvas.PrimaryDrawObject as IRasterDrawing;
            Size           size = rst.Bitmap.Size;

            using (IVectorAOIGenerator gen = new VectorAOIGenerator())
            {
                Envelope evp = new Envelope(rst.Envelope.MinX, rst.Envelope.MinY, rst.Envelope.MaxX, rst.Envelope.MaxY);
                return(gen.GetAOI(pts, geometryOfDrawed.Types, evp, size));
            }
        }
Пример #10
0
        private GeoDo.RSS.Core.DrawEngine.CoordEnvelope GetGeoRect(GeometryOfDrawed geometryOfDrawed)
        {
            int bRow = int.MaxValue, eRow = int.MinValue, bCol = int.MaxValue, eCol = int.MinValue;

            for (int i = 0; i < geometryOfDrawed.RasterPoints.Length; i++)
            {
                if (geometryOfDrawed.RasterPoints[i].X < bCol)
                {
                    bCol = (int)geometryOfDrawed.RasterPoints[i].X;
                }
                if (geometryOfDrawed.RasterPoints[i].X > eCol)
                {
                    eCol = (int)geometryOfDrawed.RasterPoints[i].X;
                }
                if (geometryOfDrawed.RasterPoints[i].Y < bRow)
                {
                    bRow = (int)geometryOfDrawed.RasterPoints[i].Y;
                }
                if (geometryOfDrawed.RasterPoints[i].Y > eRow)
                {
                    eRow = (int)geometryOfDrawed.RasterPoints[i].Y;
                }
            }
            IRasterDrawing rst = _canvas.PrimaryDrawObject as IRasterDrawing;
            DataIdentify   id  = rst.DataProvider.DataIdentify;

            if (id != null && id.IsOrbit)
            {
                rst.DataProvider.OrbitProjectionTransformControl.Build();
                GeoDo.RSS.Core.DF.CoordEnvelope evp = rst.DataProvider.OrbitProjectionTransformControl.OrbitProjectionTransform.ComputeEnvelope(bRow, bCol, eRow, eCol);
                return(new Core.DrawEngine.CoordEnvelope(evp.MinX, evp.MaxX, evp.MinY, evp.MaxY));
            }
            else
            {
                double geoX1, geoY1, geoX2, geoY2;
                _canvas.CoordTransform.Raster2Geo(bRow, bCol, out geoX1, out geoY1);
                _canvas.CoordTransform.Raster2Geo(eRow, eCol, out geoX2, out geoY2);
                return(new GeoDo.RSS.Core.DrawEngine.CoordEnvelope(geoX1, geoX2, geoY2, geoY1));
            }
        }
Пример #11
0
        private Feature GetIceLineFeature(ref int oid, GeometryOfDrawed geo)
        {
            if (geo.ControlRasterPoints == null || geo.ControlRasterPoints.Length == 0)
            {
                return(null);
            }
            Feature           fet    = null;
            List <ShapePoint> points = new List <ShapePoint>();

            foreach (PointF rasterPoint in geo.RasterPoints)
            {
                double geoX, geoY;
                _canvas.CoordTransform.Raster2Geo((int)rasterPoint.Y, (int)rasterPoint.X, out geoX, out geoY);
                points.Add(new ShapePoint(geoX, geoY));
            }
            ShapeLineString shapeLine  = new ShapeLineString(points.ToArray());
            string          fieldValue = "冰缘线" + (oid + 1).ToString();

            fet = new Feature(oid, new ShapePolyline(new ShapeLineString[] { shapeLine }), new string[] { _fieldName }, new string[] { fieldValue }, new LabelLocation[] { new LabelLocation() });
            oid++;
            return(fet);
        }
Пример #12
0
        public GeometryOfDrawed AddGeometry(ICanvas canvas)
        {
            using (GraphicsPath path = GetGraphicsPath())
            {
                if (path == null)
                {
                    return(null);
                }

                GeometryOfDrawed geometry = new GeometryOfDrawed();
                geometry.ShapeType    = enumPencilType.Cross.ToString();
                geometry.RasterPoints = new PointF[] { new PointF(_vertexts[0].X, _vertexts[0].Y), new PointF(_vertexts[1].X, _vertexts[1].Y),
                                                       new PointF(_vertexts[2].X, _vertexts[2].Y), new PointF(_vertexts[3].X, _vertexts[3].Y) };

                float  row, col;
                double prjY, prjX;
                for (int i = 0; i < geometry.RasterPoints.Length; i++)
                {
                    if (canvas.PrimaryDrawObject != null)//有活动影像是返回栅格坐标
                    {
                        canvas.CoordTransform.Screen2Raster(geometry.RasterPoints[i].X, geometry.RasterPoints[i].Y, out row, out col);
                        geometry.RasterPoints[i].X = col;
                        geometry.RasterPoints[i].Y = row;
                    }
                    else//无活动影像时返回投影坐标
                    {
                        canvas.CoordTransform.Screen2Prj(geometry.RasterPoints[i].X, geometry.RasterPoints[i].Y, out prjX, out prjY);
                        geometry.RasterPoints[i].X = (float)prjX;
                        geometry.RasterPoints[i].Y = (float)prjY;
                        geometry.IsPrjCoord        = true;
                    }
                }

                geometry.Types = path.PathData.Types;

                return(geometry);
            }
        }
Пример #13
0
        private void DoDrag(object sender, GeometryOfDrawed geometry, int offsetX, int offsetY)
        {
            ICanvas canvas = sender as ICanvas;
            float   scaleX = (float)(canvas.CurrentEnvelope.Width / canvas.Container.Width);
            float   scaleY = (float)(canvas.CurrentEnvelope.Height / canvas.Container.Height);
            float   dltX   = offsetX * scaleX;
            float   dltY   = -offsetY * scaleY;

            if (geometry.IsPrjCoord)
            {
                for (int i = 0; i < geometry.RasterPoints.Length; i++)
                {
                    geometry.RasterPoints[i].X += dltX;
                    geometry.RasterPoints[i].Y += dltY;
                }
            }
            else
            {
                float screenX_origin = 0;
                float screenY_origin = 0;
                float screenX_other  = 0;
                float screenY_other  = 0;
                canvas.CoordTransform.Raster2Screen(0, 0, out screenX_origin, out screenY_origin);
                canvas.CoordTransform.Raster2Screen(100, 100, out screenX_other, out screenY_other);
                scaleX = (float)(100 / (screenX_other - screenX_origin));
                scaleY = (float)(100 / (screenY_other - screenY_origin));
                dltX   = offsetX * scaleX;
                dltY   = offsetY * scaleY;

                for (int i = 0; i < geometry.RasterPoints.Length; i++)
                {
                    geometry.RasterPoints[i].X += dltX;
                    geometry.RasterPoints[i].Y += dltY;
                }
            }
        }
Пример #14
0
        public GeometryOfDrawed AddGeometry(bool hasPrimaryDrawObject)
        {
            using (GraphicsPath path = GetGraphicsPath())
            {
                if (path == null)
                {
                    return(null);
                }

                GeometryOfDrawed geometry = new GeometryOfDrawed();
                geometry.ShapeType = enumPencilType.Cross.ToString();
                if (_vertexts.Count() == 4)
                {
                    geometry.RasterPoints = new PointF[] { new PointF(_vertexts[0].X, _vertexts[0].Y), new PointF(_vertexts[1].X, _vertexts[1].Y),
                                                           new PointF(_vertexts[2].X, _vertexts[2].Y), new PointF(_vertexts[3].X, _vertexts[3].Y) };
                }
                else
                {
                    geometry.RasterPoints = new PointF[] { new PointF(_vertexts[0].X, _vertexts[0].Y) };
                }
                geometry.Types = path.PathData.Types;
                if (!hasPrimaryDrawObject)
                {
                    geometry.IsPrjCoord = true;
                }
                if (IsMoved)
                {
                    geometry.ControlRasterPoints = new PointF[1];
                }
                else
                {
                    geometry.ControlRasterPoints = new PointF[0];
                }
                return(geometry);
            }
        }
Пример #15
0
 private void NotifyResult(ICoordinateTransform coordTran, ICanvas canvas)
 {
     if (_pencilDrawedResultFinished == null)
     {
         return;
     }
     using (GraphicsPath path = GetGraphicsPath())
     {
         if (path == null)
         {
             return;
         }
         GeometryOfDrawed geometry = new GeometryOfDrawed();
         geometry.ShapeType    = _pencilType.ToString();
         geometry.RasterPoints = path.PathData.Points;
         //using (StreamWriter sw = new StreamWriter("F:\\1.txt", false, Encoding.Default))
         //{
         //    for (int i = 0; i < geometry.RasterPoints.Length; i++)
         //    {
         //        sw.WriteLine(geometry.RasterPoints[i].ToString());
         //    }
         //}
         float  row, col;
         double prjY, prjX;
         for (int i = 0; i < geometry.RasterPoints.Length; i++)
         {
             if (canvas.PrimaryDrawObject != null)//有活动影像是返回栅格坐标
             {
                 coordTran.Screen2Raster(geometry.RasterPoints[i].X, geometry.RasterPoints[i].Y, out row, out col);
                 geometry.RasterPoints[i].X = col;
                 geometry.RasterPoints[i].Y = row;
             }
             else//无活动影像时返回投影坐标
             {
                 canvas.CoordTransform.Screen2Prj(geometry.RasterPoints[i].X, geometry.RasterPoints[i].Y, out prjX, out prjY);
                 geometry.RasterPoints[i].X = (float)prjX;
                 geometry.RasterPoints[i].Y = (float)prjY;
                 geometry.IsPrjCoord        = true;
             }
         }
         //记录拐点(例如:海冰冰缘线绘制时使用)
         if (_pencilType == enumPencilType.ControlFreeCurve && _controls.Count > 0)
         {
             geometry.ControlRasterPoints = new PointF[_controls.Count];
             for (int i = 0; i < _controls.Count; i++)
             {
                 if (canvas.PrimaryDrawObject != null)//有活动影像是返回栅格坐标
                 {
                     coordTran.Screen2Raster(_controls[i].X, _controls[i].Y, out row, out col);
                     geometry.ControlRasterPoints[i].X = col;
                     geometry.ControlRasterPoints[i].Y = row;
                 }
                 else//无活动影像时返回投影坐标
                 {
                     canvas.CoordTransform.Screen2Prj(_controls[i].X, _controls[i].Y, out prjX, out prjY);
                     geometry.ControlRasterPoints[i].X = (float)prjX;
                     geometry.ControlRasterPoints[i].Y = (float)prjY;
                     geometry.IsPrjCoord = true;
                 }
             }
         }
         //
         geometry.Types = path.PathData.Types;
         _pencilDrawedResultFinished(geometry);
     }
 }
Пример #16
0
 private void UpdateDrawedAOI(GeometryOfDrawed geometry)
 {
     _drawedAOI = GetCoordEnvelope(geometry);
 }
Пример #17
0
 private void UpdateDrawedAOI(GeometryOfDrawed geometry)
 {
     _drawedAOI = GetCoordPoint(geometry);
 }
Пример #18
0
 private CodeCell.AgileMap.Core.Shape GetGeoGeometry(GeometryOfDrawed v)
 {
     return(DrawedGeometry2Polygon.ToPolygon(this.canvasHost1.Canvas, v));
 }