gisempire100
捉鬼专家
捉鬼专家
  • 注册日期2004-08-13
  • 发帖数552
  • QQ
  • 铜币2462枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:918回复:0

AE中的选择集

楼主#
更多 发布于:2008-01-03 15:39
<div>以前我写过一个函数,其中一个参数是IEnumFeature,就是用来存储被选择的对象。</div>
<div>在调用时把下面获得的参数传进来即可:</div>
<br>
<div>ISelectionPtr ipSelect1;</div>
<div> m_ipMap->get_FeatureSelection(;ipSelect1);</div>
<br>
<div>后来我想了以下,如果用户没有选中,那么就把整个图层的元素都传进去,我天真的这样做:</div>
<div>ipSelect1=m_ipLayer;</div>
<br>
<div>我认为这句话就已经把图层上的所有元素提取出来到选择集中。</div>
<br>
<div>后来调试不成功,IEnumFeature的元素个数为0.</div>
<br>
<div>
<br>ArcMap has two different selections, a feature selection and an
element selection. Two different objects represent these selections and
both implement the <strong>ISelection</strong> interface.  The feature selection object additionally implements <strong>IEnumFeature</strong> and the element selection object <strong>IEnumElement</strong>.
The ISelection interface is used for clipboard type operations and the
IEnum interfaces are used to loop through the items in the collection.
</p>
<p>When you ask for the <strong>FeatureSelection</strong> from <strong>IMap</strong> you are returned an ISelection but you can perform a query interface for IEnumFeature and usually do so. However, if you get the selection via <strong>IActiveView::Selection</strong>,
the selection can either be an element selection or a feature selection
depending on which one is currently active - only one of the selections
can be active at a time.  Use FeatureSelection to ensure a reference to
the correct selection.</p>
<p>IEnumFeature works on all of the FeatureLayers as a whole. Each FeatureLayer has a ISelectionSet and IEnumFeature steps through all of these as though there was only one. Because IEnumFeature works with all the FeatureLayers, you cannot use it to loop through the features belonging to just one FeatureLayer.</p></div>
<div>那我没有办法,只有query一把,把所有的元素全部选中了,才能方便IEnumFeature。</div>
<br>
<br>
<div>  IFeatureSelectionPtr ipFeaSelection(m_ipLayer);<br>  IQueryFilterPtr ipQF(CLSID_QueryFilter);<br>  ipQF->put_WhereClause((_bstr_t)"FID>=0");//全部选中<br>  ipFeaSelection->SelectFeatures(ipQF,esriSelectionResultNew,VARIANT_FALSE);<br>  m_ipMap->get_FeatureSelection(;ipSelect1);<br>  ipEnum=ipSelect1;</div>
<div><br> </div>
<div>不知道谁有没有更好的方法,麻烦和我说下,谢谢了!!!</div>
喜欢0 评分0
A friend is never known till a man has need. ...CL
游客

返回顶部