VDF常见问题整理(四十):如何更改实体的图层?

VectorDraw Developer Framework试用版下载


问:

   如何在WebControl中更改实体的图层/p>

答:

    这是有关如何更改实体层的示例:

  • 首先需要创建一个红色图层和一条颜色为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();                  }         }

    对于以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。

热门文章推荐:

  • 如何排除GroundSurface对象的三角形区域/strong>

  • 复杂自定义对象的入门指南


    如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系在线客服>>咨询相关问题。

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2019年10月23日
下一篇 2019年10月23日

相关推荐

发表回复

登录后才能评论