• <menu id="w2i4a"></menu>
  • logo VectorDraw教程
    文檔首頁(yè)>>VectorDraw教程>>新手入門必看:VectorDraw 常見問題整理大全(七)

    新手入門必看: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)最新版下載

    一. 從一個(gè)點(diǎn)選擇實(shí)體(提供四種方法)

    問:如何從單個(gè)點(diǎn)選擇鎖定/未鎖定圖層中的實(shí)體?

    答:在本文中,我們將使用四種方法從我們使用getUserPoint()(這是pt)獲得的點(diǎn)中選擇可能處于鎖定或未鎖定層中的實(shí)體,如:

                gPoint pt = vdScrollableControl1.BaseControl.ActiveDocument.ActionUtility.getUserPoint() as gPoint;
    and for the Selection Set :
                vdSelection selectionSet = null;
                selectionSet = vdScrollableControl1.BaseControl.ActiveDocument.Selections.FindName(name);
                if (selectionSet == null)
                {
                    selectionSet = vdScrollableControl1.BaseControl.ActiveDocument.Selections.Add(name);
                }
                gPoint p1 = m_ActiveDoc.World2PixelMatrix.Transform(pt as gPoint);

    方法1:使用RenderSelect.SelectingMode.SingleEntitiyPoint進(jìn)行選擇

    這將獲得最頂層的實(shí)體。如果此實(shí)體位于鎖定圖層中,則返回的selectionSet將為空

                // Selection with RenderSelect.SelectingMode.SingleEntitiyPoint
                gPoints points = new gPoints();
                selectSet.RemoveAll();
                points.Add(pt);
                selectSet.Select(RenderSelect.SelectingMode.SingleEntitiyPoint, points);
    
                if (selectSet.Count > 0)
                {
                    foreach (vdFigure fig in selectSet)
                    {
                        MessageBox.Show("Found figure with Handle " + fig.HandleId.ToString() + " in Layer: " + fig.Layer.Name + " which is locked: " + fig.Layer.Lock.ToString(), "[Select with SingleEntitiyPoint]");
                    }
                }
                else
                {
                    MessageBox.Show("No object selected","[Select with SingleEntitiyPoint]");
                }

    方法2:使用GetEntityFromPoint選擇選擇

    即使此實(shí)體位于鎖定層中,也將獲得最頂層實(shí)體。

                // Selection with GetEntityFromPoint
                Point location1 = new Point((int)p1.x, (int)p1.y);
                vdFigure fig2 = m_ActiveDoc.ActiveLayOut.GetEntityFromPoint(location1, m_ActiveDoc.ActiveLayOut.Render.GlobalProperties.PickSize, false);
                if (fig2 != null)
                {
                    MessageBox.Show("Found figure with Handle: " + fig2.HandleId.ToString() + " in Layer: " + fig2.Layer.Name + " which is locked: " + fig2.Layer.Lock.ToString(),"[Select with GetEntityFromPoint]" );
                }
                else
                {
                    MessageBox.Show("No object selected", "[Select with GetEntityFromPoint]");
                }
    

    方法3:使用RenderSelect.SelectingMode.CrossingWindowRectangle和光標(biāo)的PickSize進(jìn)行選擇

    這將獲得當(dāng)前點(diǎn)+ picksize中的所有實(shí)體,但不會(huì)獲取鎖定圖層中的實(shí)體

                // Selection with RenderSelect.SelectingMode.CrossingWindowRectangle and the cursors PickSize
                selectSet.RemoveAll();
                gPoints points2 = new gPoints();
                int size = m_ActiveDoc.ActiveLayOut.Render.GlobalProperties.PickSize;
                Point location2 = new Point((int)p1.x-size/2, (int)p1.y-size/2);
                Point location3 = new Point((int)p1.x+size/2, (int)p1.y+size/2);
                points2.Add(m_ActiveDoc.ActiveLayOut.Render.Pixel2View(location2));
                points2.Add(m_ActiveDoc.ActiveLayOut.Render.Pixel2View(location3));
                
                selectSet.Select(RenderSelect.SelectingMode.CrossingWindowRectangle, points2);
    
                if (selectSet.Count > 0)
                {
                    foreach (vdFigure fig in selectSet)
                    {
                        MessageBox.Show("Found figure with Handle " + fig.HandleId.ToString() + " in Layer: " + fig.Layer.Name + " which is locked: " + fig.Layer.Lock.ToString(), "[Select with CrossingWindowRectangle & PickSize]");
                    }
                }
                else
                {
                    MessageBox.Show("No object selected", "[Select with CrossingWindowRectangle & PickSize]");
                }
    

    方法4:使用Select3D和光標(biāo)的PickSize選擇

    這將獲得當(dāng)前點(diǎn)中的所有實(shí)體+ picksize甚至鎖定圖層中的實(shí)體

    注意:Select3d方法不適用于Handle屬性大于UInt的實(shí)體(32位)無符號(hào)整數(shù))。

                // Selection using Select3D and cursor's picksize
                Point location4 = new Point((int)p1.x , (int)p1.y );
                vdEntities ents = m_ActiveDoc.Select3d(location4, m_ActiveDoc.ActiveLayOut.Render.GlobalProperties.PickSize);
                if (ents.Count > 0)
                {
                    foreach (vdFigure fig in ents)
                    {
                        MessageBox.Show("Found figure with Handle " + fig.HandleId.ToString() + " in Layer: " + fig.Layer.Name + " which is locked: " + fig.Layer.Lock.ToString(), "[Select with Select3d & PickSize]");
                    }
                }
                else
                {
                    MessageBox.Show("No object selected", "[Select with Select3d & PickSize]");
                }

    二. 在打印期間,DrawAfter事件使用render.PrinterMode PRINT_PRINTER多次觸發(fā)

    問:在C#中使用vdProControl并在打印期間使用render.PrinterMode = PRINT_PRINTER多次觸發(fā)DrawAfter事件?

    答:根據(jù)打印機(jī)及其分辨率,VDF將紙張分割成區(qū)域,以便可以在大型打印機(jī)中打印,這是因?yàn)閳D紙可能包含大尺寸位圖,或者只能打印為位圖(如3D渲染模式)。VDF 6中的渲染在版本5中發(fā)生了很大變化,這就是您遇到問題的原因。代碼應(yīng)該寫成不同的代碼:

    如果你使用PRINT_PRINTER,那么你應(yīng)該繪制你喜歡它們是繪圖單位中的實(shí)際對(duì)象的對(duì)象,例如:

    if (render.PrinterMode == VDrawI5.VdConstPrintMode.PRINT_PRINTER)
    {
        VDrawI5.vdPrint printer = vdProControl.ActiveDocument.Printer;
        double[] rect = printer.PrintWindow as double[];
        double[] bottomLeft = new double[] { rect[0],rect[1] };
        double[] topRight = new double[] { rect[2], rect[3] };
        render.Select_Pen(VDrawI5.VdConstPen.VdPenSolid, 1, 0);
        render.PushMatrix();
        render.SelectWorldMatrix();
        render.Drawline(bottomLeft[0], bottomLeft[1], 0, topRight[0], topRight[1], 0, 0);
        render.Drawline(topRight[0], bottomLeft[1], 0, bottomLeft[0], topRight[1], 0, 0);
        render.Drawcircle((bottomLeft[0] + topRight[0]) / 2, (bottomLeft[1] + topRight[1]) / 2, 0, (-bottomLeft[1] + topRight[1]) / 2);
        render.PopMatrix();
    }

    if {}內(nèi)的代碼將運(yùn)行4次(或者更多地取決于打印機(jī)/紙張/分辨率),并且只有部分線條/圓圈將在每個(gè)“區(qū)域”中呈現(xiàn)并繪制你喜歡的內(nèi)容。

    如果你使用PRINT_PRINTER_PAPER,那么你應(yīng)該像你一樣使用代碼,這里的問題是你設(shè)置筆(顏色,類型,寬度),如:

    if (render.PrinterMode == VDrawI5.VdConstPrintMode.PRINT_PRINTER_PAPER)
    {
        Console.WriteLine(render.PrinterMode.ToString());
        render.Select_Pen(VDrawI5.VdConstPen.VdPenSolid, 1, 0);
        double[] bottomLeft = new double[3];
        double[] topRight = new double[3];
        int left = 0, top = 0, right = 0, bottom = 0;
        render.GetWindowExt(ref left, ref top, ref right, ref bottom);
        render.PixelToView(left, bottom, ref bottomLeft[0], ref bottomLeft[1]);
        render.PixelToView(right, top, ref topRight[0], ref topRight[1]);
        render.Drawline(bottomLeft[0], bottomLeft[1], 0, topRight[0], topRight[1], 0, 0);
        render.Drawline(topRight[0], bottomLeft[1], 0, bottomLeft[0], topRight[1], 0, 0);
        render.Drawcircle((bottomLeft[0] + topRight[0]) / 2, (bottomLeft[1] + topRight[1]) / 2, 0, (-bottomLeft[1] + topRight[1]) / 2);
    }

    這取決于你在打印輸出時(shí)要繪制的內(nèi)容,你應(yīng)該遵循哪種方法。

    你也可以使用VDF .Net庫(kù)的Render和DrawAfter事件,如(在Form_Load中):

    VectorDraw.Professional.vdObjects.vdDocument doc = vdProControl.ActiveDocument.WrapperObject as VectorDraw.Professional.vdObjects.vdDocument;
    doc.OnDrawAfter += new VectorDraw.Professional.vdObjects.vdDocument.DrawAfterEventHandler(doc_OnDrawAfter);
    and use the
    void doc_OnDrawAfter(object sender, VectorDraw.Render.vdRender render)
            {
                //Do your things here
            }

    編寫代碼以在printout中繪制額外的東西。在這種情況下,你將不得不在C#項(xiàng)目中添加額外的引用,如VectorDraw.Render,VectorDraw.Geometry,VectorDraw.Serialize和VectorDraw.Generics

    未完待續(xù)......

    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();