为了满足系统应用需求,现对ArcGIS三维地图进行二次开发,使用ArcEngine实现ArcScene 三维加载矢量图图层进行符号渲染;在开发时抽空对已完成开发的功能做以下记录,不完善之处请多多指教,具体如下:
一、实现效果预览
二、 部分代码
/// <summary>
/// 加载选中的样式符号
/// </summary>
/// <param name="path"></param>
private void loadStyle(string path)
{
this.styleColors.Clear();
this.styleWidths.Clear();
lineSymbologyControl.Clear();
string[] sts = path.Split('.');
// 做相关处理避免加载不同后缀样式时报错
if (sts[sts.Length - 1] == "style")
lineSymbologyControl.LoadDesktopStyleFile(path); // 加载后缀为Style样式文件
else
lineSymbologyControl.LoadStyleFile(path); // 加载后缀为ServerStyle样式文件
lineSymbologyControl.StyleClass = esriSymbologyStyleClass.esriStyleClassLineSymbols;
m_SymbologyStyleClass = lineSymbologyControl.GetStyleClass(lineSymbologyControl.StyleClass);
// 添加当前图层渲染的符号
IStyleGalleryItem pStyleGalleryItem = new ServerStyleGalleryItem();
pStyleGalleryItem.Name = "当前符号";
pStyleGalleryItem.Item = m_LegendClass.Symbol;
m_SymbologyStyleClass.AddItem(pStyleGalleryItem, 0);
// 符号属性集合处理存储
for (int i = 0; i < m_SymbologyStyleClass.get_ItemCount(); i++)
{
IStyleGalleryItem item = m_SymbologyStyleClass.GetItem(i);
ILineSymbol pLineSymbol = item.Item as ILineSymbol;
if (!styleWidths.ContainsKey(item.ID))
styleWidths.Add(item.ID, pLineSymbol.Width);
if (!styleColors.ContainsKey(item.ID))
styleColors.Add(item.ID, ConvertToColor(pLineSymbol.Color));
}
m_SymbologyStyleClass.SelectItem(0);
}
/// <summary>
/// Color转换为ESRI的IColor
/// </summary>
/// <param name="color"></param>
/// <returns></returns>
private IColor ConvertToRgbColor(Color color)
{
IColor pColor = new RgbColor();
pColor.RGB = color.R + color.G * 256 + color.B * 65536;
return pColor;
}
/// <summary>
/// ESRI的IColor转换为Color
/// </summary>
/// <param name="pColor"></param>
/// <returns></returns>
private Color ConvertToColor(IColor pColor)
{
return ColorTranslator.FromOle(pColor.RGB);
}
/// <summary>
/// 预览当前选择符号
/// </summary>
private void PreviewLineSymbol(IStyleGalleryItem pStyleGalleryItem)
{
IPictureDisp pPictureDisp = m_SymbologyStyleClass.PreviewItem(pStyleGalleryItem, symbolPreview.Width, symbolPreview.Height);
Image priviewImage = Image.FromHbitmap(new IntPtr(pPictureDisp.Handle));
symbolPreview.Image = priviewImage;
}
三、主窗口调用代码
点击AxTOCControl控件中图层的符号调用线符号窗口
private IFeatureLayer pToccFeatureLayer = null; //当前选择的要素类图层
private ILayer pTOCLayer = null;
private void MapTOCControl_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e)
{
esriTOCControlItem pItem = esriTOCControlItem.esriTOCControlItemNone;
IBasicMap pBasicMap = null;
object other = null;
object index = null;
if (e.button == 1)
{
mapTOCControl.HitTest(e.x, e.y, ref pItem, ref pBasicMap, ref pTOCLayer, ref other, ref index);
System.Drawing.Point pos = new System.Drawing.Point(e.x, e.y);
if (pItem == esriTOCControlItem.esriTOCControlItemLegendClass)
{
if (pTOCLayer is IFeatureLayer)
{
IFeatureLayer pFeatureLayer = pTOCLayer as IFeatureLayer;
if (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
{
ILegendGroup pLegendGroup = other as ILegendGroup;
ILegendClass pLegendClass = pLegendGroup.get_Class((int)index);
SceneLineSymbol frm = new SceneLineSymbol(this.mapSceneControl.SceneGraph, this.mapTOCControl, pTOCLayer, pLegendClass);
frm.ShowDialog();
}
}
}
}
}
四、源码下载
链接地址:线符号渲染下载
今天的文章C# AE ArcScene 二次开发线符号渲染实现分享到此就结束了,感谢您的阅读,如果确实帮到您,您可以动动手指转发给其他人。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/28681.html