Arcengine制图表达的一些理解

Arcgis的制图表达博大精深,首先是一个图层转换为制图表达图层,其中的每一个要素都会绑定一个规则ID(Rule_id),
那么在arcengine中,我们如何去编辑制图表达呢?
首先选中制图表达就成了一个问题,因为如果表达有几何覆盖,也就是表达和数据(Feature)的位置不在一起,甚至偏移很大,普通选择Element的方法根本无法选中它,
我们是借助影子表
根据图层得到表达
private IRepresentationClass getRepClassByLayer ( IGeoFeatureLayer pGeoFeatureLayer )
{
 if(pGeoFeatureLayer .Renderer is RepresentationRenderer )
  {
              IRepresentationRenderer  pRepresentationRenderer = (IRepresentationRenderer   )pGeoFeatureLayer .Renderer ;
             return  pRepresentationRenderer .RepresentationClass 
  }
}
然后再根据 IRepresentationClass.GetRepresentation即可获得要素的表达
每一个RepResentation 都有一个Feature 和一个shape ,这个shape是表达的几何图形 ,不是要素的几何图形
那么表达的编辑是如何的呢
首先说一下表达的几何编辑
几何编辑比较简单,说白了就是编辑Representation的shape;
如果是自由制图表达,则编辑其IRepresentationGraphics
编辑就用ITransform2D接口,即可完成缩放、移动、旋转

下面说一声属性编辑,每一个制图表达可能有多个规则,每一个规则都有对应的ID,
IRepresentationClass.RepresentationRules 获得所有的规则;
每一个规则对应了很多个Layer, 干脆叫规则图层
规则图层分 Marker,Line,Filll
这里涉及到IBasicSymbol接口 以及其三个实现类 BasicFillSymbol,BasicLineSymbol,BasicMarkerSymbol
BasicMarkerSymbol:
在设置基本属性时将 BasicMarkerSymbol直接转换成 IGraphicAttributes  然后 IGraphicAttributes  的SetValue 即可设置属性值
其中BasicMarker的属性值ID时从 1 开始,其他的都由 0  开始;
BasicFillSymbol,BasicLineSymbol :
都有固定属性FillPattern/Stroke 用于设置属性 和 Marker一样
将FillPattern/Stroke 转换成IGraphicAttributes 然后设置其属性值

说完基础符号,接下来是几何效果
每一个BasicSymbol 都可以存储多个几何效果 IGeometricEffect,IGeometricEffect接口的实现类包含所有的几何效果,详细查看帮助;
怎么样将几何效果添加到规则呢?
IGeometricEffects pGeometricEffects=pBasicSymbol as IGeometricEffects ;
IGeometricEffect pGeometricEffect=new  GeometricEffectCut();//任意一个几何效果
IGraphicAttribute pGraphicAttribute=pGeometricEffect as IGraphicAttribute ;
pGraphicAttribute.SetValue(1,?);//设置几何效果的属性值
pGeometricEffects.Add(pGeometricEffect);
实例化IRepresentationRule,调用InsterLayer方法 添加BasicSymbol;
这样一条简单的规则就完成了

如何将制定好的规则赋给图层呢?
1、非自由制图表达 调用 IRepresentationWorkspaceExtension 的 CreateRepresentationClass方法 给图层设置表达;如果它已经存在制图表达则先删除;
2、自由制图表达,首先调用IRepresentaionGraphic的Next方法找出所有的几何图形,记录下IGeometric,然后用Remove方法删除它,并用新的规则Rule重新添加,

执行所有的Representation都要执行IRepresentation.UpdateFeature()和IRepresentation.Feature.Store();

2017年5月25日16:40:15 新增

发现选择制图表达新方法 : IRepresentationRenderer->IIdentify

转载自:https://blog.csdn.net/wangtao510/article/details/47828647

You may also like...

退出移动版