翻譯|使用教程|編輯:況魚杰|2019-11-28 13:42:56.170|閱讀 230 次
概述:本系列教程整理了VectorDraw Developer Framework(VDF)最常見問題,教程整理的很齊全,非常適合新手學習。本文將會展示如何突出顯示vdInsert,將會有一個例子演示如何操作。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
VectorDraw Developer Framework(VDF)是一個用于應用程序可視化的圖形引擎庫。有了VDF提供的功能,您可以輕松地創(chuàng)建、編輯、管理、輸出、輸入和打印2D和3D圖形文件。
VectorDraw Developer Framework試用版下載
問:
如果想要實現(xiàn)當將鼠標懸停在一些元素上時,它們突出顯示,或者是能夠在內部繪制陰影線。這能夠實現(xiàn)嗎?當然,也有可能不可能實現(xiàn),因為這是vdInsert而不是像rect這樣的標準形狀。
答:
突出顯示Insert對象是無法實現(xiàn)的,但是我們可以以塊的邊界框的大小創(chuàng)建一個新的矩形,而不是突出顯示該矩形。
下面是一個使用AddBlockFromFile(ccc.vds)方法加載vds文件并創(chuàng)建一個新塊(aaa)的示例,之后我們調用vdmousemove和vdmouseout方法,當光標在包含該塊的矩形上方時,需要依次調用該vdmousemove和vdmouseout方法,然后將該矩形突出顯示。當光標移出該矩形區(qū)域之外時,使用vdmouseout方法 將不再突出顯示。
以下是操作演示圖:


以下是操作代碼:
var lastSelectedEntity = null;//Keep the entity in a variable
function _vdmousemove(e) {
if (vdcanvas.ActiveAction().IsStarted()) return;// We check tha action in case another action has been started
var entity = e.target.GetEntityFromPoint(e.xPix, e.yPix);// Found the entity above the cursor
if (entity == lastSelectedEntity) return;
lastSelectedEntity = entity;
if (entity != null && entity._t == vdConst.vdInsert_code && entity.BlockRef && entity.BlockRef.Name == "aaa") {//if the entity is the block that we want
var minpt = [entity.BoundingBox[0], entity.BoundingBox[1], entity.BoundingBox[2]];//The lowest left corner of the boundingBox
var maxpt = [entity.BoundingBox[3], entity.BoundingBox[4], entity.BoundingBox[5]]; //The upper right corner of the boundingBox
var rect = vdcanvas.AddRect(minpt, maxpt, false, {});//We draw a rectangle in the size of the bounding box of the block
//rect.HatchProperties = vdcanvas.createNewHatchProperties("solid", vdConst.colorFromString("byblock"), vdConst.colorFromString("255,0,0,50"));
rect.HatchProperties = vdcanvas.createNewHatchProperties("u20", vdConst.colorFromString("255,255,255,50"), vdConst.colorFromString("255,255,255,255"), 1, vdgeo.DegreesToRadians(45));//We add hatch properties to the rect
vdcanvas.Refresh();
vdcanvas.ActionDrawEntities([rect]);//We draw the rect
} else {
vdcanvas.ActionDrawEntities(null);
}
}
function _vdmouseout(e) {//Incase cursor is out of the canvas
if (!lastSelectedEntity) return;
lastSelectedEntity = null;
vdcanvas.ActionDrawEntities(null);
}
function test() {
var blk = vdcanvas.AddBlockFromFile("ccc.vds", "aaa", true);//We load the block from ccc.vds
vdcanvas.AddBlockSymbol("aaa", [0, 0, 0], 1, 0, true, null);//We draw the block
vdcanvas.zoomExtents();
vdcanvas.redraw();
vdcanvas.vdmousemove = _vdmousemove;
vdcanvas.vdmouseout = _vdmouseout;//Incase cursor is out of the canvas
} 對于以上問答,如果您有任何的疑惑都可以在評論區(qū)留言,我們會及時回復。此系列的問答教程我們會持續(xù)更新,如果您感興趣,可以多多關注本教程。
熱門文章推薦:
如果您對想要購買正版授權VectorDraw Developer Framework(VDF),可以聯(lián)系咨詢相關問題。
關注慧聚IT微信公眾號 ???,了解產品的最新動態(tài)及最新資訊。

本站文章除注明轉載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@ke049m.cn
文章轉載自: