男默女泪,ArcGIS AddIN 编辑逻辑赏析,走过路过,不要错过
看到了一段ESRI写的一个工具,我反编译了一下,学习工具中的几个代码片段
一.
IEditTask task = (this._editor as IEditTaskSearch).get_TaskByUniqueName("GarciaUI_CreateNewFeatureTask");
this._editor.CurrentTask = task;
IEditTask :Provides access to a task that receives notification when the sketch is complete.
IEditTaskSearch: Provides access to members that find edit tasks by name.
常见的EditTask及其名称:(From帮助文档)
|
Edit Task |
UniqueName |
|
Create New Feature |
"GarciaUI_CreateNewFeatureTask" |
|
Reshape Feature |
"GarciaUI_ReshapeFeatureTask" |
|
Cut Polygon Features |
"GarciaUI_CutPolygonFeaturesTask" |
|
Mirror Features |
"GarciaUI_MirrorFeaturesTask" |
|
Extend/Trim Features |
"GarciaUI_ExtendTrimFeaturesTask" |
|
Modify Feature |
"GarciaUI_ModifyFeatureTask" |
|
Calibrate Route Feature |
"RouteEditorUI_CalibrateRouteFeatureTask" |
|
Modify Portion of Line |
"RouteEditorUI_ModifyPortionOfLineTask" |
|
Modify Edge |
"TitusUI_ModifyEdgeTask" |
|
Reshape Edge |
"TitusUI_ReshapeEdgeTask" |
|
Auto Complete Polygon |
"TitusUI_AutoCompletePolygonTask" |
|
Select Features Using a Line |
"GarciaUI_SelectFeaturesUsingLineTask" |
|
Select Features Using an Area |
"GarciaUI_SelectFeaturesUsingPolygonTask" |
|
Create 2-Point Line Features |
"EditTools_Create2PointLineFeaturesTask" |
二.
this._editLayers = this._editor as IEditLayers;
IEditLayers: Provides access to members that control information about layers in the edit session.
The IEditLayers interface exposes members for setting and getting the editor's current layer and current subtype. The current layer (or target layer) determines which layer will contain newly created features. For instance, if you set the target layer to 'Buildings', any new features created will be part of the Buildings layer. Edit tasks and commands that create new features use this property to determine which layer to write out the new features to. For example, the 'Create New Features' task and the 'Union' command both create new features in the target layer.
说明:IEditLayers接口用于管理编辑会话期间的图层
可以用来获取或设置编辑器的当前图层或subtype(不知为何物),当前图层决定了哪个图层用于新建要素
三.
if (this._lineFeedback == null)
{
this._lineFeedback = new NewTextBezierCurveFeedbackClass();
this._lineFeedback.Display = this._editor.Display;
this._lineFeedback.Start(this._mousePoint, this._editor.Map.ReferenceScale);
}
else
{
this._lineFeedback.AddPoint(this._mousePoint);
}
INewLineFeedback: Provides access to members that control the new line display feedback.
The NewLineFeedback coclass allows the user to form a new Polyline geometry on the display. While the feedback is being used, the line shown on the screen is a series of segments made up of straight lines between each of the points clicked by the user. If the user opts to add no intermediate vertices, that is, they simply click at the start point (Start), move the mouse (MoveTo), and double-click at the end (AddPoint and Stop), then a polyline with only one segment will be generated.
同上,还有其他很多INew***Feedback接口与对象,可以实现辅助绘制功能
以前写Tool时,经常使用Graphic对象,进行绘制和保存临时创建的对象,这么做需要做的工作很多,比如graphic对象的管理,以及Symbol符号的设置,绘制线时,代码中需要考虑以绘制的线与当前鼠标的节点所组成的图形,并进行动态更新绘制,逻辑复杂的很.
有了上述接口与对象,可以直接调用,通过AddPoint(),Stop()等方法,轻松实现对象的绘制与交互.
大体实现逻辑,在mousedown事件中,调用Start(),AddPoint(),以添加节点
在MouseMove事件中,调用MoveTo(),以更新
在DoubleClick事件中,调用Stop(),以结束绘制
四.关于捕捉逻辑
ISnapEnvironment environment = this._editor as ISnapEnvironment;
if (this._mousePoint != null)
{
this._editor.InvertAgent(this._mousePoint, );
}
this._mousePoint = this._editor.Display.DisplayTransformation.ToMapPoint(arg.X, arg.Y);
if (KeyboardInfo.GetKeyState(Keys.Space).IsPressed)
{
environment.SnapPoint(null);
}
else
{
environment.SnapPoint(this._mousePoint);
}
this._editor.InvertAgent(this._mousePoint, );
if (this._lineFeedback != null)
{
this._lineFeedback.MoveTo(this._mousePoint);
}
之前写过一篇关于如何调用捕捉的帖子,当时只顾为了实现捕捉,没有进一步优化
上述代码中在MouseMove事件中判断了当前是否按住了 空格键,以实现在按住空格键时临时不捕捉的效果,
与ArcMap的使用习惯一致
男默女泪,ArcGIS AddIN 编辑逻辑赏析,走过路过,不要错过的更多相关文章
- [蘑菇街] 搜索、算法团队招募牛人啦-年底了走过路过不要错过 - V2EX
[蘑菇街] 搜索.算法团队招募牛人啦-年底了走过路过不要错过 - V2EX [蘑菇街] 搜索.算法团队招募牛人啦-年底了走过路过不要错过
- 上海投行需要一大群JAVA,C++,C#,UNIX.走过路过不要错过!过完年想换工作看过来初级资深都有 - V2EX
上海投行需要一大群JAVA,C++,C#,UNIX.走过路过不要错过!过完年想换工作看过来初级资深都有 - V2EX 上海投行需要一大群JAVA,C++,C#,UNIX.走过路过不要错过!过完年想换工 ...
- 走过路过不要错过 包你一文看懂支撑向量机SVM
假设我们要判断一个人是否得癌症,比如下图:红色得癌症,蓝色不得. 看一下上图,要把红色的点和蓝色的点分开,可以画出无数条直线.上图里黄色的分割更好还是绿色的分割更好呢?直觉上一看,就是绿色的线更好.对 ...
- 走过路过不要错过~教你用java抓取网页中你想要的东东~~
学习了正则之后,打算用java玩一玩,所以就决定用它来实现一个好玩的idea import java.io.BufferedReader; import java.io.IOException; im ...
- 再见Jenkins,从Gitlab代码提交到k8s服务持续交付只需七毛三(走过路过不要错过)
Gitlab runner 快速搭建CICD pipeline 背景 日常开发中,相信大家已经做了很多的自动化运维环境,用的最多的想必就是利用Jenkins实现代码提交到自动化测试再到自动化打包,部署 ...
- ArcGIS Add-in插件开发从0到1及实际案例分享
同学做毕设,要求我帮着写个ArcGIS插件,实现功能为:遍历所有图斑,提取相邻图斑的公共边长及其他属性(包括相邻图斑的ID),链接到属性表中.搞定后在这里做个记录.本文分两大部分: ArcGIS插件开 ...
- ArcGIS AddIN开发异常之--“ValidateAddInXMLTask”任务意外失败
ArcGIS AddIN开发时,产生如下异常错误 2 “ValidateAddInXMLTask”任务意外失败.System.NullReferenceException: 未将对象引用设置到对象的 ...
- ArcGIS学习记录—ArcGIS ArcMap编辑状态中线打断的问题
摘要:在处理数据时,我们经常会遇到线打断的问题,比如需要指定在线上某处打断线,或者新建网络数据集时需要在线的交点处打段线等等.现将桌面版中我所遇到的线打断的工具总结如下: 在ArcGIS矢量处理数据时 ...
- ArcGIS Add-In调试无法重新生成
在调试ArcGIS Add-In时,出现错误:无法注册程序集"……\Projects\ArcGISAddIn\ArcGISAddIn\bin\Debug\ArcGISAddIn.dll&qu ...
随机推荐
- JGUI源码:从头开始,建一个自己的UI框架(1)
开篇 1.JGUI是为了逼迫自己研究底层点的前端技术而做的框架,之前对web底层实现一直没有深入研究,有了技术瓶颈,痛定思痛从头研究, 2.虽然现在vue技术比较火,但还在发展阶段,暂时先使用JQue ...
- [再寄小读者之数学篇](2014-10-08 乘积型 Sobolev 不等式)
$$\bex n\geq 2, 1\leq p<n\ra \sen{f}_{L^\frac{np}{n-p}(\bbR^n)} \leq C\prod_{k=1}^n \sen{\p_k f}_ ...
- An Apple a day keeps the doctor away
An apple a day keeps the doctor away. 一天一苹果,不用请医生. 活学活用:apple as like as an apple to an oyster 毫无相同之 ...
- [再寄小读者之数学篇](2014-06-23 二阶导数估计 [中国科学技术大学2013年高等数学B 考研试题])
设 $f(x)$ 二阶连续可导, $f(0)=f(1)=0$, $\dps{\max_{0\leq x\leq 1}f(x)=2}$. 证明: $$\bex \min_{0\leq x\leq 1}f ...
- Linux Shell远程执行命令
1.问题描述 经常需要远程到其他节点上执行一些shell命令,如果分别ssh到每台主机上再去执行很麻烦,下边介绍shell命令远程执行的方法. 前提: 远程电脑之间已经配置ssh免密码登陆 2.脚本方 ...
- java web添加mysql过程中遇到的错误及解决办法
问题一:遇到提示找不到驱动 com.mysql.jdbc.Driver 起初项目中是导入了mysql-connector-java-5.1.45-bin.jar 包的,但是一直依然报错,最后去官网 ...
- linux服务器安装Mysql后,只能看到information_schema/test这两个库,无法修改密码
参考链接:https://www.cnblogs.com/ThinkVenus/p/7670722.html 问题背景:登录mysql失败,密码错误,由此想到需要更改密码 然而,进入数据库后,只能看到 ...
- 解决只读时ios下input光标问题
应用场景:在ios手机下对只读的input设置readonly=readonly属性还是会出现光标 解决方法: //解决ios日期光标问题 $("#Stime ,#provinceCity& ...
- DataStructure-链表实现指数非递减一元多项式的求和
// 2-链表实现多项式的求和.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include<stdio.h> #inclu ...
- java接口自动化基础知识(二)
二.HttpClient+testNG实现对接口的测试及校验 在上面第一篇中已经实现了基础配置和测试用例数据准备,本篇文章将以登录举例进行测试执行. 这是之前login接口的代码 @Test(grou ...