本系列教程整理了VectorDraw Developer Framework(VDF)最常见问题,教程整理的很齐全,非常适合新手学习,本节教程将会介绍如何在折线上创建新顶点并单击来移动它。
VectorDraw Developer Framework试用版下载
点开本篇文章,是否对矢量图形工具感兴趣呢看看最新的矢量图形工具测评吧!点击此处>>即可直达哦!
问:
我正在尝试添加一个函数,用户可以在按住Shift的同时单击多段线上的一点,在该点处添加新顶点,并且拖动操作立即开始。我怎样才能做到这一点 /p>
答:
使用InsertAt在折线的VertexList中添加一个点,并使用cmdMoveGripPoints开始移动新添加的夹点。代码如下所示:
using VectorDraw.Professional.vdObjects;using VectorDraw.Professional.vdFigures;using VectorDraw.Geometry;using VectorDraw.Professional.vdCollections;using VectorDraw.Professional.vdPrimaries;using System.Runtime.InteropServices;using VectorDraw.Professional.ActionUtilities;using VectorDraw.Generics;.............. [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] public static extern short GetAsyncKeyState(int vkey); // see // http://msdn.microsoft.com/en-us/library/windows/desktop/ms646293%28v=vs.85%29.aspx void BaseControl_vdMouseDown(MouseEventArgs e, ref bool cancel) { gPoint pos = doc.CCS_CursorPos(); gPoint p1 = doc.World2PixelMatrix.Transform(pos as gPoint); Point location1 = new Point((int)p1.x, (int)p1.y); vdFigure fig10 = doc.ActiveLayOut.GetEntityFromPoint(location1, 10, false); if (fig10 is vdPolyline) { if (GetAsyncKeyState((int)Keys.ShiftKey) < 0) { //add a vertex after the segment index vdPolyline tmp = (vdPolyline)fig10 as vdPolyline; int vertIDX = tmp.SegmentIndexFromPoint(pos, 1); tmp.VertexList.InsertAt(vertIDX + 1, new Vertex(pos)); tmp.Update(); tmp.Invalidate(); vdSelection sel = new VectorDraw.Professional.vdCollections.vdSelection(); sel.SetUnRegisterDocument(doc); Box box = new Box(); box.AddPoint(doc.Model.View2WorldMatrix.Transform(pos)); box.AddWidth(doc.GlobalRenderProperties.GripSize * doc.ActiveRender.PixelSize / 2.0d); sel.AddItem(tmp, false,vdSelection.AddItemCheck.Nochecking, true); Int32Array indexes = doc.Model.getGripIndexes(tmp, box); VectorDraw.Generics.vdArrayindexesArray = new vdArray(); indexesArray.AddItem(indexes); VectorDraw.Actions.BaseAction movegrips = new CmdMoveGripPoints(pos, doc.ActiveLayOut, sel, indexesArray); doc.ActionAdd(movegrips); VectorDraw.Actions.StatusCode ret = movegrips.WaitToFinish(); string retStr = ret.ToString(); //MessageBox.Show("Action cmdMoveGripPoints ended with result : " + retStr + // " . new vertex is now : " + pos.ToString()); cancel = true; } } }
对于以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。
热门文章推荐:
如何排除GroundSurface对象的三角形区域/strong>
复杂自定义对象的入门指南
点击此处还有VectorDraw Developer Framework的demo示例等着你来体验哦!
如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系在线客服>>咨询相关问题。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!