文档半岛外围网上直营>>VectorDraw Developer Framework使用教程>>VDF常见问题整理(十九):如何在折线上创建新顶点并单击来移动它?
VDF常见问题整理(十九):如何在折线上创建新顶点并单击来移动它?
VectorDraw Developer Framework(VDF)是一个用于应用程序可视化的图形引擎库。有了VDF提供的功能,您可以轻松地创建、编辑、管理、输出、输入和打印2D和3D图形文件。
VectorDraw Developer Framework试用版下载
点开本篇文章,是否对矢量图形工具感兴趣呢?来看看最新的矢量图形工具测评吧!点击此处>>即可直达哦!
问:
我正在尝试添加一个函数,用户可以在按住Shift的同时单击多段线上的一点,在该点处添加新顶点,并且拖动操作立即开始。我怎样才能做到这一点 ?
答:
使用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
// //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;
}
}
} 对于以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。
热门文章推荐:
点击此处还有VectorDraw Developer Framework的demo示例等着你来体验哦!
如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系咨询相关问题。
关注慧聚IT微信公众号 ???,了解产品的最新动态及最新资讯。


QQ交谈
在线咨询

渝公网安备
50010702500608号

客服热线