public static IElement ConstructPointElement(IGeometry geometry, IColor color, esriSimple3DMarkerStyle style, double size) { ISimpleMarker3DSymbol simpleMarker3DSymbol = new SimpleMarker3DSymbolClass(); simpleMarker3DSymbol.Style = style; simpleMarker3DSymbol.ResolutionQuality = HighResolution; IMarkerSymbol markerSymbol = simpleMarker3DSymbol as IMarkerSymbol; markerSymbol.Color = color; markerSymbol.Size = size; IMarker3DPlacement marker3DPlacement = markerSymbol as IMarker3DPlacement; marker3DPlacement.Units = Units; IMarkerElement markerElement = new MarkerElementClass(); markerElement.Symbol = markerSymbol; IElement element = markerElement as IElement; element.Geometry = geometry; return(element); }
private IElement GetElement(IGeometry geometry, double size, esriSimple3DMarkerStyle simple3DMarkerStyle) { IElement element; IMarkerElement markerElement = new MarkerElementClass(); element = markerElement as IElement; ISimpleMarker3DSymbol simpleMarker3DSymbol = new SimpleMarker3DSymbolClass(); simpleMarker3DSymbol.Style = simple3DMarkerStyle; simpleMarker3DSymbol.ResolutionQuality = GetResolutionQuality(); IMarkerSymbol markerSymbol = simpleMarker3DSymbol as IMarkerSymbol; markerSymbol.Color = ColorSelection.GetColor(); markerSymbol.Size = size; IMarker3DPlacement marker3DPlacement = markerSymbol as IMarker3DPlacement; SetMarker3DPlacement(marker3DPlacement, markerSymbol.Size); element.Geometry = geometry; markerElement.Symbol = markerSymbol; return(element); }
public void Update(double newvalue, int row, int column)//x,y一起修改 { IPoint ipoint = (IPoint)pointCollection.Point[row]; switch (column) { case 0: break; case 1: ipoint.X = newvalue; break; case 2: ipoint.Y = newvalue; break; } //对于pointCollection进行修改 pointCollection.UpdatePoint(row, ipoint); //清空图像容器 pGraphicsContainer.DeleteAllElements(); IGeometry polygon = pointCollection as IGeometry; IPolygonElement polygonElement = new PolygonElementClass(); IElement polyElement = polygonElement as IElement; polyElement.Geometry = polygon; pGraphicsContainer.AddElement((IElement)polygonElement, 0); m_form.axMapControl1.ActiveView.Refresh(); for (int i = 0; i < pointCollection.PointCount; i++) { IMarkerSymbol markerSymbol = new SimpleMarker3DSymbolClass(); //markerSymbol的类型和分辨率 ((ISimpleMarker3DSymbol)markerSymbol).Style = esriSimple3DMarkerStyle.esriS3DMSSphere; ((ISimpleMarker3DSymbol)markerSymbol).ResolutionQuality = 1.0; //markerSymbol的颜色和大小 IRgbColor color = new RgbColorClass(); color.Red = 255; color.Green = 0; color.Blue = 0; markerSymbol.Size = 5; markerSymbol.Color = color as IColor; IElement pElement = new MarkerElementClass(); ((IMarkerElement)pElement).Symbol = markerSymbol; pElement.Geometry = pointCollection.Point[i]; pGraphicsContainer.AddElement(pElement, 0); /*IElement pElement=new MarkerElementClass(); * pElement.Geometry = pointCollection.Point[i]; * pGraphicsContainer.AddElement(pElement, 0);*/ } m_form.axMapControl1.ActiveView.Refresh(); }
/// <summary> /// Adds a sphere element to the given graphics layer at the specified position /// </summary> /// <param name="globeGraphicsLayer"></param> /// <param name="position"></param> /// <returns></returns> private int AddTrackElement(IGlobeGraphicsLayer globeGraphicsLayer, esriGpsPositionInfo position) { if (null == globeGraphicsLayer) { return(-1); } //create a new point at the given position IPoint point = new PointClass(); ((IZAware)point).ZAware = true; point.X = position.longitude; point.Y = position.latitude; point.Z = 0.0; //set the color for the element (red) IRgbColor color = new RgbColorClass(); color.Red = 255; color.Green = 0; color.Blue = 0; //create a new 3D marker symbol IMarkerSymbol markerSymbol = new SimpleMarker3DSymbolClass(); //set the marker symbol's style and resolution ((ISimpleMarker3DSymbol)markerSymbol).Style = esriSimple3DMarkerStyle.esriS3DMSSphere; ((ISimpleMarker3DSymbol)markerSymbol).ResolutionQuality = 1.0; //set the symbol's size and color markerSymbol.Size = 700; markerSymbol.Color = color as IColor; //crate the graphic element IElement trackElement = new MarkerElementClass(); //set the element's symbol and geometry (location and shape) ((IMarkerElement)trackElement).Symbol = markerSymbol; trackElement.Geometry = point as IPoint; //add the element to the graphics layer int elemIndex = 0; ((IGraphicsContainer)globeGraphicsLayer).AddElement(trackElement, 0); //get the element's index globeGraphicsLayer.FindElementIndex(trackElement, out elemIndex); return(elemIndex); }
/// <summary> /// 在场景中绘制点要素 20110609 /// </summary> /// <param name="pGeometry">点要素</param> /// <param name="r"></param> /// <param name="g"></param> /// <param name="b"></param> /// <param name="Size">符号大小</param> /// <returns></returns> public static IElement DrawPoint(IGeometry pGeometry, int r, int g, int b, double Size) { IElement markerElement = new MarkerElementClass(); ISimpleMarker3DSymbol pSimpleMarker3DSymbol = new SimpleMarker3DSymbolClass(); pSimpleMarker3DSymbol.Style = esriSimple3DMarkerStyle.esriS3DMSSphere; pSimpleMarker3DSymbol.ResolutionQuality = 1; IMarkerSymbol pMarkerSymbol = pSimpleMarker3DSymbol as IMarkerSymbol; pMarkerSymbol.Size = Size; pMarkerSymbol.Color = getRGB(r, g, b); markerElement.Geometry = pGeometry; IMarkerElement pMarkerElement = markerElement as IMarkerElement; pMarkerElement.Symbol = pMarkerSymbol; return(markerElement); }
/// <summary> /// 根据传入的点集合绘制符号 /// </summary> /// <param name="points">传入的点集合</param> /// <param name="symbolStyle">符号样式</param> /// <param name="symbolColor">符号颜色</param> /// <param name="symbolSize">符号大小</param> public static void AddGraphics(IScene pScene, IPoint point, string name) { try { esriSimple3DMarkerStyle symbolStyle = esriSimple3DMarkerStyle.esriS3DMSSphere; IRgbColor symbolColor = GetRGBColor(255, 0, 0); int symbolSize = 1; ISimpleMarker3DSymbol pSimpleMarker3DSymbol; pSimpleMarker3DSymbol = new SimpleMarker3DSymbolClass(); pSimpleMarker3DSymbol.Style = symbolStyle; pSimpleMarker3DSymbol.ResolutionQuality = 0.1; IMarker3DPlacement pMarker3DPlacement; pMarker3DPlacement = (IMarker3DPlacement)pSimpleMarker3DSymbol; pMarker3DPlacement.Color = symbolColor; pMarker3DPlacement.Width = 1; pMarker3DPlacement.Size = symbolSize; pMarker3DPlacement.Depth = 1; pMarker3DPlacement.SetRotationAngles(0, 0, 0); IGraphicsContainer3D pGC3D; pGC3D = pScene.BasicGraphicsLayer as IGraphicsContainer3D; MarkerElementClass pElement = new MarkerElementClass(); IMarkerElement pPointElement; pPointElement = (IMarkerElement)pElement; IMarkerSymbol pMarkerSymbol; pMarkerSymbol = (IMarkerSymbol)pSimpleMarker3DSymbol; pMarkerSymbol.Color = symbolColor; pPointElement.Symbol = pMarkerSymbol; (pPointElement as IElementProperties).Name = name; pElement.Geometry = point; pGC3D.AddElement(pElement); } catch (Exception ex) { Console.WriteLine(ex.Message + ex.StackTrace); } }
/// <summary> /// 释放资源 /// </summary> public void Dispose() { if (flashTimer != null) { flashTimer.Stop(); flashTimer.Dispose(); flashTimer = null; } markerSymbol = null; graphicsLayer = null; index = -1; isFlash = false; isVisible = true; isHightLight = false; isTimer = false; mapControl = null; layer = null; ElementProperties = null; }
private IElement GetElement(IGeometry geometry, double size, esriSimple3DMarkerStyle simple3DMarkerStyle) { IElement element; IMarkerElement markerElement = new MarkerElementClass(); element = markerElement as IElement; ISimpleMarker3DSymbol simpleMarker3DSymbol = new SimpleMarker3DSymbolClass(); simpleMarker3DSymbol.Style = simple3DMarkerStyle; simpleMarker3DSymbol.ResolutionQuality = GetResolutionQuality(); IMarkerSymbol markerSymbol = simpleMarker3DSymbol as IMarkerSymbol; markerSymbol.Color = ColorSelection.GetColor(); markerSymbol.Size = size; IMarker3DPlacement marker3DPlacement = markerSymbol as IMarker3DPlacement; SetMarker3DPlacement(marker3DPlacement, markerSymbol.Size); element.Geometry = geometry; markerElement.Symbol = markerSymbol; return element; }
//function for adding point markers public void addPointGraphicElements(ESRI.ArcGIS.Geometry.IPoint inPoint, int symbolColor, double symbolSize) { IElement pElement = new MarkerElementClass(); ISimpleMarker3DSymbol symbol3d = new SimpleMarker3DSymbolClass(); string markerStyle = ""; if (theCamForm.symbolTypeListBox.SelectedItem != null) { markerStyle = theCamForm.symbolTypeListBox.SelectedItem.ToString(); } if (markerStyle == "Cone") { symbol3d.Style = esriSimple3DMarkerStyle.esriS3DMSCone; } else if (markerStyle == "Sphere") { symbol3d.Style = esriSimple3DMarkerStyle.esriS3DMSSphere; } else if (markerStyle == "Cylinder") { symbol3d.Style = esriSimple3DMarkerStyle.esriS3DMSCylinder; } else if (markerStyle == "Cube") { symbol3d.Style = esriSimple3DMarkerStyle.esriS3DMSCube; } else if (markerStyle == "Diamond") { symbol3d.Style = esriSimple3DMarkerStyle.esriS3DMSDiamond; } else if (markerStyle == "Tetrahedron") { symbol3d.Style = esriSimple3DMarkerStyle.esriS3DMSTetra; } else { symbol3d.Style = esriSimple3DMarkerStyle.esriS3DMSCone; } symbol3d.ResolutionQuality = 1; IColor pColor = new RgbColorClass(); pColor.RGB = symbolColor; //16732415; IMarkerSymbol pMarkerSymbol; pMarkerSymbol = (IMarkerSymbol)symbol3d; pMarkerSymbol.Color = pColor; if (symbolSize < 0) { symbolSize = Math.Abs(symbolSize); } if (symbolSize == 0) { symbolSize = 5000; } pMarkerSymbol.Size = symbolSize; pElement.Geometry = inPoint; IMarkerElement pMarkerElement; pMarkerElement = (IMarkerElement)pElement; pMarkerElement.Symbol = pMarkerSymbol; graphicsLayer.AddElement(pElement, 1); }
public void ShowGeometry(IGeometry geometry) { //强制转换,将Geometry对象转化为pointCollection pointCollection = (Polygon)geometry; DataTable dataTable = new DataTable(); DataColumn dataColumn = new DataColumn(); //===创建一个有三列的表格==================== dataColumn = new DataColumn(); dataColumn.ColumnName = "number"; //设置第一列,表示用户指定的列名 dataColumn.DataType = System.Type.GetType("System.String"); dataColumn.ReadOnly = true; //第一列无法修改 dataTable.Columns.Add(dataColumn); dataColumn = new DataColumn(); dataColumn.ColumnName = "X";//设置第二列为在目标图层类作为分类标准的属性 dataColumn.DataType = System.Type.GetType("System.String"); dataTable.Columns.Add(dataColumn); dataColumn = new DataColumn(); dataColumn.ColumnName = "Y";//设置第三列为在目标图层类作为分类标准的属性 dataColumn.DataType = System.Type.GetType("System.String"); dataTable.Columns.Add(dataColumn); //提供一个图形的容器 pGraphicsContainer = m_map as IGraphicsContainer;//只在本函数 DataRow dataRow; for (int i = 0; i < pointCollection.PointCount; i++) { dataRow = dataTable.NewRow(); dataRow[0] = i + 1; dataRow[1] = Math.Round(pointCollection.Point[i].X, 3); dataRow[2] = Math.Round(pointCollection.Point[i].Y, 3);//将统计结果添加到第三列 dataTable.Rows.Add(dataRow); /*IElement pElement = new MarkerElementClass(); * pElement.Geometry = pointCollection.Point[i]; * pGraphicsContainer.AddElement(pElement, 0);//0 represents z-order */ //确定Element对象,并将对象加载到pGraphicsContainer中 IMarkerSymbol markerSymbol = new SimpleMarker3DSymbolClass(); //markerSymbol的类型和分辨率 ((ISimpleMarker3DSymbol)markerSymbol).Style = esriSimple3DMarkerStyle.esriS3DMSSphere; ((ISimpleMarker3DSymbol)markerSymbol).ResolutionQuality = 1.0; //markerSymbol的颜色和大小 IRgbColor color = new RgbColorClass(); color.Red = 255; color.Green = 0; color.Blue = 0; markerSymbol.Size = 5; markerSymbol.Color = color as IColor; IElement pElement = new MarkerElementClass(); ((IMarkerElement)pElement).Symbol = markerSymbol; pElement.Geometry = pointCollection.Point[i]; pGraphicsContainer.AddElement(pElement, 0); } DataBoard dataBoard = new DataBoard("Position", dataTable, this, pointCollection.PointCount); dataBoard.Show(); m_form.setButton_miShowTime(false); }
public void HighLight(int row) { DataOperator dataoperator = new DataOperator(m_map); IMarkerSymbol markerSymbol = new SimpleMarker3DSymbolClass(); //markerSymbol的类型和分辨率 ((ISimpleMarker3DSymbol)markerSymbol).Style = esriSimple3DMarkerStyle.esriS3DMSSphere; ((ISimpleMarker3DSymbol)markerSymbol).ResolutionQuality = 1.0; //markerSymbol的颜色和大小 IRgbColor color = new RgbColorClass(); color.Red = 250; color.Green = 230; color.Blue = 20; markerSymbol.Size = 8; markerSymbol.Color = color as IColor; // 将showElement对象赋予markerSymbol的属性 IElement showElement = new MarkerElementClass(); ((IMarkerElement)showElement).Symbol = markerSymbol; showElement.Geometry = pointCollection.Point[row]; //在绘制前,清楚图像容器内的所有Elements pGraphicsContainer.DeleteAllElements();//通过name删除 //为了使点在上面,先显示polygon IGeometry polygon = pointCollection as IGeometry; IPolygonElement polygonElement = new PolygonElementClass(); IElement polyElement = polygonElement as IElement; polyElement.Geometry = polygon; pGraphicsContainer.AddElement((IElement)polygonElement, 0); //绘制高亮显示的点 pGraphicsContainer.AddElement((IElement)showElement, 0); //重新绘制除了高亮点外的构造点 for (int i = 0; (i < pointCollection.PointCount); i++) { if (i != row) { IRgbColor color3 = new RgbColorClass(); //如果出现重复 将函数独立出来 color3.Red = 255; color3.Green = 0; color3.Blue = 0; markerSymbol.Size = 5; markerSymbol.Color = color3; IElement pElement = new MarkerElementClass(); ((IMarkerElement)pElement).Symbol = markerSymbol; pElement.Geometry = pointCollection.Point[i]; pGraphicsContainer.AddElement(pElement, 0); /*IElement pElement=new MarkerElementClass(); * pElement.Geometry = pointCollection.Point[i]; * pGraphicsContainer.AddElement(pElement, 0);*/ } } m_form.axMapControl1.ActiveView.Refresh();//partialrefresh }
/// <summary> /// 构造函数 /// </summary> /// <param name="_graphicsLayer">图层</param> /// <param name="pointKml">点kml</param> public Point_ArcGlobe(IGlobeGraphicsLayer _graphicsLayer, KmlPoint pointKml) { graphicsLayer = _graphicsLayer; this.ElementType = Core.Model.ElementTypeEnum.Point; //图元类型 this.Description = pointKml.Description; //图元描述 #region 位置 IPoint pt = new PointClass(); pt.PutCoords(pointKml.Position.Lng, pointKml.Position.Lat); pt.Z = pointKml.Position.Alt; (pt as IZAware).ZAware = true;//设置高度 base.Geometry = pt; #endregion #region 符号 markerSymbol = new SimpleMarker3DSymbolClass(); //设置颜色 if (pointKml.Color.ToArgb() == 0) { IRgbColor color = new RgbColorClass() { Transparency = 50, Red = Color.Green.R, Green = Color.Green.G, Blue = Color.Green.B }; markerSymbol.Color = color; } else { IRgbColor color = new RgbColorClass() { Transparency = pointKml.Color.A, Red = pointKml.Color.R, Green = pointKml.Color.G, Blue = pointKml.Color.B }; markerSymbol.Color = color; } //设置大小 if (pointKml.Size.Height == 0) { markerSymbol.Size = 500; } else { markerSymbol.Size = pointKml.Size.Height; } markerSymbol.Angle = 90; markerSymbol.Style = (esriSimple3DMarkerStyle)pointKml.PointStyle; base.Symbol = markerSymbol; #endregion flashTimer = new System.Timers.Timer(); flashTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTimer_Elapsed); flashTimer.Interval = 3000; isFlash = false; }
/// <summary> /// Adds a sphere element to the given graphics layer at the specified position /// </summary> /// <param name="globeGraphicsLayer"></param> /// <param name="position"></param> /// <returns></returns> private int AddTrackElement(IGlobeGraphicsLayer globeGraphicsLayer, esriGpsPositionInfo position) { if (null == globeGraphicsLayer) return -1; //create a new point at the given position IPoint point = new PointClass(); ((IZAware)point).ZAware = true; point.X = position.longitude; point.Y = position.latitude; point.Z = 0.0; //set the color for the element (red) IRgbColor color = new RgbColorClass(); color.Red = 255; color.Green = 0; color.Blue = 0; //create a new 3D marker symbol IMarkerSymbol markerSymbol = new SimpleMarker3DSymbolClass(); //set the marker symbol's style and resolution ((ISimpleMarker3DSymbol)markerSymbol).Style = esriSimple3DMarkerStyle.esriS3DMSSphere; ((ISimpleMarker3DSymbol)markerSymbol).ResolutionQuality = 1.0; //set the symbol's size and color markerSymbol.Size = 700; markerSymbol.Color = color as IColor; //crate the graphic element IElement trackElement = new MarkerElementClass(); //set the element's symbol and geometry (location and shape) ((IMarkerElement)trackElement).Symbol = markerSymbol; trackElement.Geometry = point as IPoint; //add the element to the graphics layer int elemIndex = 0; ((IGraphicsContainer)globeGraphicsLayer).AddElement(trackElement, 0); //get the element's index globeGraphicsLayer.FindElementIndex(trackElement, out elemIndex); return elemIndex; }
//function for adding point markers public void addPointGraphicElements(ESRI.ArcGIS.Geometry.IPoint inPoint, int symbolColor, double symbolSize) { IElement pElement = new MarkerElementClass(); ISimpleMarker3DSymbol symbol3d = new SimpleMarker3DSymbolClass(); string markerStyle = ""; if (theCamForm.symbolTypeListBox.SelectedItem != null) { markerStyle = theCamForm.symbolTypeListBox.SelectedItem.ToString(); } if (markerStyle == "Cone") symbol3d.Style = esriSimple3DMarkerStyle.esriS3DMSCone; else if (markerStyle == "Sphere") symbol3d.Style = esriSimple3DMarkerStyle.esriS3DMSSphere; else if (markerStyle == "Cylinder") symbol3d.Style = esriSimple3DMarkerStyle.esriS3DMSCylinder; else if (markerStyle == "Cube") symbol3d.Style = esriSimple3DMarkerStyle.esriS3DMSCube; else if (markerStyle == "Diamond") symbol3d.Style = esriSimple3DMarkerStyle.esriS3DMSDiamond; else if (markerStyle == "Tetrahedron") symbol3d.Style = esriSimple3DMarkerStyle.esriS3DMSTetra; else symbol3d.Style = esriSimple3DMarkerStyle.esriS3DMSCone; symbol3d.ResolutionQuality = 1; IColor pColor = new RgbColorClass(); pColor.RGB = symbolColor; //16732415; IMarkerSymbol pMarkerSymbol; pMarkerSymbol = (IMarkerSymbol)symbol3d; pMarkerSymbol.Color = pColor; if (symbolSize < 0) symbolSize = Math.Abs(symbolSize); if (symbolSize == 0) symbolSize = 5000; pMarkerSymbol.Size = symbolSize; pElement.Geometry = inPoint; IMarkerElement pMarkerElement; pMarkerElement = (IMarkerElement)pElement; pMarkerElement.Symbol = pMarkerSymbol; graphicsLayer.AddElement(pElement, 1); }