新手入門必看:VectorDraw 常見問題整理大全(十一)
VectorDraw Developer Framework(VDF)是一個(gè)用于應(yīng)用程序可視化的圖形引擎庫(kù)。有了VDF提供的功能,您可以輕松地創(chuàng)建、編輯、管理、輸出、輸入和打印2D和3D圖形文件。該庫(kù)還支持許多矢量和柵格輸入和輸出格式,包括本地PDF和SVG導(dǎo)出。
【VectorDraw Developer Framework最新版下載】
VectorDraw web library (javascript)是一個(gè)矢量圖形庫(kù)。VectorDraw web library (javascript)不僅能打開CAD圖紙,而且能顯示任何支持HTML5標(biāo)準(zhǔn)平臺(tái)上的通用矢量對(duì)象,如Windows,安卓,iOS和Linux。無需任何安裝,VectorDraw web library (javascript)就可以運(yùn)行在任何支持canvas標(biāo)簽和Javascript的主流瀏覽器(Chrome, Firefox, Safari, Opera, Dolphin, Boat等等)中。
【VectorDraw web library (javascript)最新版下載】
一. 在命令(或操作)處于活動(dòng)狀態(tài)時(shí)顯示實(shí)體的工具提示
問:我想在命令(或動(dòng)作)處于活動(dòng)狀態(tài)時(shí)顯示光標(biāo)下的實(shí)體工具提示。我怎樣才能做到這一點(diǎn) ?
答:默認(rèn)情況下,在GetUserPoint等操作或活動(dòng)命令期間無法顯示工具提示。這也是著名的CAD應(yīng)用程序的默認(rèn)行為,如果將其添加到VDF默認(rèn)行為,則可能會(huì)出現(xiàn)兩個(gè)問題。
- 隱藏工具提示區(qū)域下方的有用信息(端點(diǎn),快照等),
- 作為Osnaps減慢性能,除了繪圖數(shù)據(jù)庫(kù)搜索必須在工具提示窗口內(nèi)繪制的文本之外,還必須計(jì)算交叉點(diǎn)蝕刻。
為此,我們無法在組件中添加此行為。如果您愿意,可以使用ActiveDocument.ActionLayout.GetEntifromPoint(使用布爾值更快的響應(yīng))或GetTooltipFigure,并獲取光標(biāo)下方圖形的工具提示文本,并將其設(shè)置為文檔的ToolTipText屬性。就像是:
private void Form1_Load(object sender, EventArgs e) { vdFramedControl.BaseControl.ActiveDocument.EnableToolTips = true; vdFramedControl.BaseControl.MouseMove += new MouseEventHandler(BaseControl_MouseMove); } void BaseControl_MouseMove(object sender, MouseEventArgs e) { bool allobjectsAresearched = false; vdFigure fig = vdFramedControl.BaseControl.ActiveDocument.ActionLayout.GetToolTipFigure(e.Location,vdFramedControl.BaseControl.ActiveDocument.ActiveActionRender.GlobalProperties.PickSize,true,out allobjectsAresearched); vdFramedControl.BaseControl.ActiveDocument.ToolTipText = ""; if(fig == null) return; vdFramedControl.BaseControl.ActiveDocument.ToolTipText = fig.ToolTip; }
二. 在垂直于線的平面中的線起點(diǎn)和終點(diǎn)創(chuàng)建2個(gè)圓
問:如何在垂直于線的平面中的線起點(diǎn)和終點(diǎn)創(chuàng)建2個(gè)圓?
答:試試如下代碼:
private void button3_Click(object sender, EventArgs e) { //create a line VectorDraw.Professional.vdFigures.vdLine line = new VectorDraw.Professional.vdFigures.vdLine(); line.SetUnRegisterDocument(vdFramedControl.BaseControl.ActiveDocument); line.setDocumentDefaults(); line.StartPoint = new VectorDraw.Geometry.gPoint(2, 3, 4); line.EndPoint = new VectorDraw.Geometry.gPoint(7, 8, 2); line.PenColor.SystemColor = Color.Red; line.PenWidth = .1; vdFramedControl.BaseControl.ActiveDocument.ActiveLayOut.Entities.AddItem(line); //create a circle at the StartPoin of the previous line VectorDraw.Professional.vdFigures.vdCircle circle_SP = new VectorDraw.Professional.vdFigures.vdCircle(); circle_SP.SetUnRegisterDocument(vdFramedControl.BaseControl.ActiveDocument); circle_SP.setDocumentDefaults(); circle_SP.Center = new VectorDraw.Geometry.gPoint(line.StartPoint); circle_SP.Radius = (double)1.0; //Set the circle's Extrusion vector to have the direction StartPoint ---> EndPoint circle_SP.ExtrusionVector = new VectorDraw.Geometry.Vector(new VectorDraw.Geometry.gPoint(line.StartPoint), new VectorDraw.Geometry.gPoint(line.EndPoint)); vdFramedControl.BaseControl.ActiveDocument.ActiveLayOut.Entities.AddItem(circle_SP); //create a circle at the EndPoint of the previous line VectorDraw.Professional.vdFigures.vdCircle circle_EP = new VectorDraw.Professional.vdFigures.vdCircle(); circle_EP.SetUnRegisterDocument(vdFramedControl.BaseControl.ActiveDocument); circle_EP.setDocumentDefaults(); circle_EP.Center = new VectorDraw.Geometry.gPoint(line.EndPoint); circle_EP.Radius = (double)1.0; //Set the circle's Extrusion vector to have the direction EndPoint ---> StartPoint circle_EP.ExtrusionVector = new VectorDraw.Geometry.Vector(new VectorDraw.Geometry.gPoint(line.EndPoint), new VectorDraw.Geometry.gPoint(line.StartPoint)); vdFramedControl.BaseControl.ActiveDocument.ActiveLayOut.Entities.AddItem(circle_EP); vdFramedControl.BaseControl.ActiveDocument.CommandAction.Zoom("E", null, null); vdFramedControl.BaseControl.ActiveDocument.CommandAction.Zoom("S", (double)0.8, null); MessageBox.Show("Circles with the right extrusion VectorDraw created. Adding some thickness to the circles just to show the results"); circle_SP.Thickness = 0.8; circle_EP.Thickness = 0.8; vdFramedControl.BaseControl.ActiveDocument.Redraw(false); }
三. 顯示框架控件,如Scrollable或類似vdBase控件
問:我如何使用vdFramed控件但顯示它像vdScrollable控件或類似vdBase控件?
答:您可以使用以下代碼:
Private Sub btn_ShowAsFramed_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowAsFramed.Click '//Show PropertyGrid and Status Bar VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.CommandLine, True) VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.PropertyGrid, True) VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.StatusBar, True) VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.LayoutTab, True) '//Show scrollbars VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.HorizodalScroll, True) VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.VericalScroll, True) '//Show the Layout Tab VdFramedControl1.ScrollableControl.SetShowLayoutTab(True) '//if you set the vdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.StatusBar ,true) '// then you show some "features" like : VdFramedControl1.SetStatusBarOption(vdControls.vdFramedControl.StatusBarOptions.ProgressBar, True) VdFramedControl1.SetStatusBarOption(vdControls.vdFramedControl.StatusBarOptions.SnapButton, True) VdFramedControl1.SetStatusBarOption(vdControls.vdFramedControl.StatusBarOptions.Menu, True) VdFramedControl1.SetStatusBarOption(vdControls.vdFramedControl.StatusBarOptions.GridButton, True) VdFramedControl1.SetStatusBarOption(vdControls.vdFramedControl.StatusBarOptions.Paper, True) VdFramedControl1.SetStatusBarOption(vdControls.vdFramedControl.StatusBarOptions.OrthoButton, True) VdFramedControl1.SetStatusBarOption(vdControls.vdFramedControl.StatusBarOptions.OsnapButton, True) '// show the menu VdFramedControl1.ShowMenu(True) '// In the vdFramed's PropertyGrid the selection is show. This code below finds the selection and '// set this to be shown in the Property Grid Dim propertygrid As vdPropertyGrid.vdPropertyGrid propertygrid = VdFramedControl1.vdGrid propertygrid.SelectedObject = VdFramedControl1.BaseControl.ActiveDocument ' set the default value '// Here we find the name of the Grip Selection Dim gripset As VectorDraw.Professional.vdCollections.vdSelection Dim selsetname As String = "VDGRIPSET_" + VdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.Handle.ToStringValue() If Not VdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.ActiveViewPort Is Nothing Then selsetname = selsetname + VdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.ActiveViewPort.Handle.ToStringValue() End If '// This is the Grip Selections that is show in the PropertyGrid gripset = VdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.Document.Selections.FindName(selsetname) If Not (gripset Is Nothing) Then If gripset.Count > 0 Then propertygrid.SelectedObject = gripset End If End Sub Private Sub btn_ShowAsScrollable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowAsScrollable.Click '//Hide PropertyGrid, CommandLine and Status Bar VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.CommandLine, False) VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.PropertyGrid, False) VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.StatusBar, False) VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.LayoutTab, True) '//Show scrollbars VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.HorizodalScroll, True) VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.VericalScroll, True) '//Show the Layout Tab VdFramedControl1.ScrollableControl.SetShowLayoutTab(True) '//if you set the vdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.StatusBar ,true) '// then you can hide some "features" like : VdFramedControl1.SetStatusBarOption(vdControls.vdFramedControl.StatusBarOptions.ProgressBar, False) VdFramedControl1.SetStatusBarOption(vdControls.vdFramedControl.StatusBarOptions.SnapButton, False) VdFramedControl1.SetStatusBarOption(vdControls.vdFramedControl.StatusBarOptions.Menu, False VdFramedControl1.SetStatusBarOption(vdControls.vdFramedControl.StatusBarOptions.GridButton, False) VdFramedControl1.SetStatusBarOption(vdControls.vdFramedControl.StatusBarOptions.Paper, False) VdFramedControl1.SetStatusBarOption(vdControls.vdFramedControl.StatusBarOptions.OrthoButton, False) VdFramedControl1.SetStatusBarOption(vdControls.vdFramedControl.StatusBarOptions.OsnapButton, False) '// Hide the Menu VdFramedControl1.ShowMenu(False) End Sub Private Sub btn_ShowAsBase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowAsBase.Click '//Hide PropertyGrid, commandLine, Layout tab and Status Bar VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.CommandLine, False) VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.PropertyGrid, False) VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.StatusBar, False) VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.LayoutTab, False) '//Hide scrollbars VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.HorizodalScroll, False) VdFramedControl1.SetLayoutStyle(vdControls.vdFramedControl.LayoutStyle.VericalScroll, False) '//Hide the Layout Tab VdFramedControl1.ScrollableControl.SetShowLayoutTab(False) VdFramedControl1.ScrollableControl.SetShowVscroll(False) VdFramedControl1.ScrollableControl.SetShowVscroll(False) End Sub
四. Vertexes的IsClockWise屬性
問:可以在頂點(diǎn)中添加IsClockWise屬性嗎?凸起也不會(huì)在“頂點(diǎn)區(qū)域”中計(jì)算。
答:“頂點(diǎn)區(qū)域”僅針對(duì)2D點(diǎn)計(jì)算,沒有凸起。此外,無法應(yīng)用IsClockWise,因?yàn)轫旤c(diǎn)不像vdPolyline那樣具有ECS矩陣。因此,為了獲得Vertexes的區(qū)域,如果是時(shí)鐘方式,則必須使用如下代碼:
VectorDraw.Professional.vdFigures.vdPolyline poly = new VectorDraw.Professional.vdFigures.vdPolyline(); poly.SetUnRegisterDocument(vdFramedControl.BaseControl.ActiveDocument); poly.SetDocumentDefaults(); poly.VertexList = new VectorDraw.Geometry.Vertexes(myVertexes); poly.Update(); double myArea = poly.Area(); bool isClockW = poly.IsClockWise();
未完待續(xù)......