文档彩票走势图>>VectorDraw Developer Framework使用教程>>VDF常见问题整理(三十四):如何选定实体的用户操作?
VDF常见问题整理(三十四):如何选定实体的用户操作?
VectorDraw Developer Framework(VDF)是一个用于应用程序可视化的图形引擎库。有了VDF提供的功能,您可以轻松地创建、编辑、管理、输出、输入和打印2D和3D图形文件。
VectorDraw Developer Framework试用版下载
问:
如何选定实体的用户操作?
答:
为了选择许多图形并对其进行处理,请参见以下代码:
//Set the section window colors.It is not important but help the user for selecting. vdcanvas.SetActionFillColor(new Array(0, 0, 255, 100));// fill color for simple window select, from left to right // ( select only entities completely inside rectangle). vdcanvas.SetActionCrossFillColor(new Array(0, 255, 0, 100));//fill color for crossing window select ,from right to left // (select entities that are inside or intersect rectangle). //begin a selection action //If a user pick to a point with no entity a new window select will open //continue add entities until command cancel by right click // -or- // a vdcanvas.ActiveAction.cancel(); method is called by your application //Selected entities are drawn with Red color //cmdselectCallback a callback function that is fire when the selection is successfully finished. vdcanvas.CmdSelect(_cmdselectCallback); //Is fired when selection successfully finished function _cmdselectCallback(action) { //enum all selected entities if (!action.customData || action.customData.length == 0) return; for (var k = 0; k < action.customData.length; k++) { var fig = action.customData[k];//get the selected figure //do something with figure like hightlight it fig.HighLight = true; } action.vdrawOwner().redraw(); } In order select a single figure see following code: vdcanvas.PickSize = 8;// 8 pixel wide vdcanvas.GetUserPoint(_onActionPointIdStateChanged); // prompts the user to pick a point on the control and fire the // _onActionPointIdStateChanged when the action finsh or cancel function _onActionPointIdStateChanged(action, status) { var vdcanvas = action.vdrawOwner(); if (status == 'start') { vdcanvas.Prompt('pick a point'); } else if (status == 'end') { if (!action.IsCanceled()) { //vdcanvas.Prompt('X= ' + action.ResValue[X].toString() + ' Y= ' + action.ResValue[Y].toString()); var p1 = vdcanvas.WorldToPixel(action.ResValue); //transorm the passed action point from world to pixel var fig = vdcanvas.GetEntityFromPoint(p1[X], p1[Y]); //get the last drawn entity passing throw a pick box //with center the p1 and size define by vdcanvas.PickSize if (fig) { //do somthing with selected figure //for example mark as highlight and re-draw it fig.HighLight = true; //redraw a single entity procedure vdcanvas.UpdateFig(fig); vdcanvas.DrawEntity(fig); vdcanvas.Refresh(); vdcanvas.Prompt(String(fig.HandleId) + " selected");//display the selected figure handle } } else { vdcanvas.Prompt(''); } } }
对于以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。
热门文章推荐:
如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系咨询相关问题。
关注慧聚IT微信公众号 ???,了解产品的最新动态及最新资讯。