文档半岛外围网上直营>>VectorDraw Developer Framework使用教程>>VDF常见问题整理(四十):如何更改实体的图层?
VDF常见问题整理(四十):如何更改实体的图层?
VectorDraw Developer Framework(VDF)是一个用于应用程序可视化的图形引擎库。有了VDF提供的功能,您可以轻松地创建、编辑、管理、输出、输入和打印2D和3D图形文件。
VectorDraw Developer Framework试用版下载
问:
如何在WebControl中更改实体的图层?
答:
这是有关如何更改实体层的示例:
首先需要创建一个红色图层和一条颜色为bylayer的线。
然后,调用_vdmousedown,在此处再次创建绿色的新层。
再使用新图层的手柄,当我们单击该行时,将新图层更改为旧图层的手柄。
因此,现在该行已从新层移至new2。
function test() {
//create a new layer
var newLayer = vdcanvas.AddLayer("new");
newLayer.PenColor = vdConst.colorFromString("255,0,0");
//set active the layer in order the new entities that will be added to have the newlayer as reference
vdcanvas.SetActiveLayer(newLayer);
//set the color of new added entities to be bylayer color
vdcanvas.SetActivePenColor(vdConst.colorFromString("bylayer"));
var line = vdcanvas.AddLine([1, -1, 0], [1, 1, 0], true);
vdcanvas.vdmousedown = _vdmousedown;
}
function _vdmousedown(e) {
if (vdcanvas.ActiveAction().IsStarted()) return; //check if user mouse click and no action is active(like move , pan etc)
var entity = e.target.GetEntityFromPoint(e.xPix, e.yPix);
if (entity != null) {
//create a new layer with color green
var newLayer2 = vdcanvas.AddLayer("new2");
newLayer2.PenColor = vdConst.colorFromString("0,255,0");
//get the handle of the layer used by entities 'Layer' property var handle2 = "h_" + newLayer2.HandleId.toString();
entity.Layer = handle2;//change the layer to new one.
vdcanvas.UpdateFig(entity); //needed in order the entity get the change
//draw the entity over the screen
vdcanvas.DrawEntity(entity);
vdcanvas.Refresh();
}
} 对于以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。
热门文章推荐:
如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系咨询相关问题。
关注慧聚IT微信公众号 ???,了解产品的最新动态及最新资讯。


QQ交谈
在线咨询

渝公网安备
50010702500608号

客服热线