五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

浮云繪圖CAD繪圖編輯器之直線、方塊、圓等基礎(chǔ)圖元操作和接口源碼

2022-06-10 15:09 作者:浮云繪圖  | 我要投稿

浮云繪圖是一整套繪圖軟件sdk(繪圖編輯器+繪圖組件DLL+API Demo+說明文檔),可以快速開發(fā)各類狀態(tài)度、電子圖圖紙、流程圖、平面布局圖等。其中基礎(chǔ)繪圖單元就有直線、矩形方塊、橢圓(含圓),本文詳細介紹此3類基礎(chǔ)圖元的詳細使用操作,和sdk二次開發(fā)中接口函數(shù)及使用實例(如有特殊需求,小功能微改免費,更多變動支持駐場開發(fā))。


先看看浮云繪圖的幾個示例如下所示,支持動態(tài)控制各線條、區(qū)域、文字、圖片的顏色、虛實、大小、狀態(tài)等屬性。

浮云繪圖示例:車站設(shè)備狀態(tài)圖
浮云繪圖示例:車站設(shè)備狀態(tài)圖


浮云繪圖示例:工控采集設(shè)備狀態(tài)圖
浮云繪圖示例:工控采集設(shè)備狀態(tài)圖


浮云繪圖示例:電路原理圖



1. 浮云繪圖開源軟件之直線

直線,是所有繪圖軟件的最基礎(chǔ)圖形,直線可以做連線、電路線路、關(guān)系線、分割線,還可以拼接成各類圖形,比如三角形、五角形等等。

線條的屬性,包括線的寬度、顏色、虛實(含隱藏)、端點模式。

1.1 直線的畫法

畫直線操作:點擊工具欄直線圖標按鈕 -> 在繪圖區(qū)按下鼠標左鍵 -> 移動鼠標(實時畫線) -> 松開鼠標(完成一條直線),再根據(jù)需要,(雙擊該直線,彈出屬性對話框)設(shè)置線條的寬度、顏色、虛實、端點模式等屬性值。

浮云繪圖之線段的畫法
浮云編輯器畫直線


浮云繪圖編輯器線條的屬性設(shè)置對話框


說明:1>畫直線過程是先確定左上點,然后鼠標移動過程中是右下點(左上點+右上點確定一個矩形),然后矩形的左上點與右下點連線。當起點的左上的上y值大于右下的下的y值時,直線高度是負值。2>關(guān)于旋轉(zhuǎn)和角度。直線的底層實際是矩形,矩形旋轉(zhuǎn)是取其4個角上點,回到xy坐標軸,成另一個矩形(如下圖所示),矩形在不斷旋轉(zhuǎn)中,會不斷趨近與正方形,而正方形旋轉(zhuǎn),兩定點連線的角度不會變,變的只有長度。即直線旋轉(zhuǎn)只有小于某角度才正常。

矩形旋轉(zhuǎn)后變形示意


?解決辦法是用浮云繪圖的四角形圖元,基于四個點旋轉(zhuǎn),而不是基于矩形旋轉(zhuǎn),從而旋轉(zhuǎn)任意角度而不變形。

1.2 直線API接口定義及使用實例

以C#版API Demo為例(完整浮云繪圖SDK開發(fā)及源碼下載地址)https://download.csdn.net/download/fyhhack/85528048?spm=1001.2014.3001.5503


直線相關(guān)的接口定義如下:


? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "SetLineColor", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern void SetLineColor(IntPtr canvas, IntPtr shape, int color);

? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "GetLineColor", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern int GetLineColor(IntPtr shape);


? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "SetLineStyle", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern void SetLineStyle(IntPtr canvas, IntPtr shape, int style);

? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "GetLineStyle", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern int GetLineStyle(IntPtr shape);


? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "SetLineWidth", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern void SetLineWidth(IntPtr canvas, IntPtr shape, int width);

? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "GetLineWidth", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern int GetLineWidth(IntPtr shape);


? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "SetLineEndMode", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern void SetLineEndMode(IntPtr canvas, IntPtr shape, int mode);

? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "GetLineEndMode", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern int GetLineEndMode(IntPtr shape);

直線相關(guān)的接口函數(shù)使用實例如下所示:

? ? ? ? private void btnLine_Click(object sender, EventArgs e)

? ? ? ? {

? ? ? ? ? ? IntPtr shape = GetShapeAt(m_shapeCanvas, m_shapeSeqNum);? ? //獲得圖元對象

? ? ? ? ? ? if (shape != IntPtr.Zero)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? // 獲取數(shù)據(jù)

? ? ? ? ? ? ? ? LinePropForm frm = new LinePropForm();

? ? ? ? ? ? ? ? frm.m_iSeqNum = m_shapeSeqNum;

? ? ? ? ? ? ? ? frm.m_iLineColor = GetLineColor(shape);

? ? ? ? ? ? ? ? frm.m_iLineWidth = GetLineWidth(shape);

? ? ? ? ? ? ? ? frm.m_iLineStyle = GetLineStyle(shape);

? ? ? ? ? ? ? ? frm.m_iEndMode = GetLineEndMode(shape);


? ? ? ? ? ? ? ? // 設(shè)置數(shù)據(jù)

? ? ? ? ? ? ? ? if (DialogResult.OK == frm.ShowDialog())

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? m_shapeSeqNum = frm.m_iSeqNum;? ? ? // 可以修改默認的圖元序號

? ? ? ? ? ? ? ? ? ? if (GetShapeCount(m_shapeCanvas) - 1 < m_shapeSeqNum)

? ? ? ? ? ? ? ? ? ? ? ? m_shapeSeqNum = GetShapeCount(m_shapeCanvas) - 1;

? ? ? ? ? ? ? ? ? ? if (m_shapeSeqNum < 0)

? ? ? ? ? ? ? ? ? ? ? ? m_shapeSeqNum = 0;


? ? ? ? ? ? ? ? ? ? IntPtr shape2 = GetShapeAt(m_shapeCanvas, m_shapeSeqNum);

? ? ? ? ? ? ? ? ? ? if (shape2 != IntPtr.Zero)

? ? ? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? SetLineColor(m_shapeCanvas, shape2, frm.m_iLineColor);

? ? ? ? ? ? ? ? ? ? ? ? SetLineWidth(m_shapeCanvas, shape2, frm.m_iLineWidth);

? ? ? ? ? ? ? ? ? ? ? ? SetLineStyle(m_shapeCanvas, shape2, frm.m_iLineStyle);

? ? ? ? ? ? ? ? ? ? ? ? SetLineEndMode(m_shapeCanvas, shape2, frm.m_iEndMode);

? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }

? ? ? ? }


2. 浮云繪圖開源軟件之方塊(矩形)

矩形方塊,是浮云繪圖第2基礎(chǔ)圖元,方塊可以畫矩形、畫正方形,一般應(yīng)用于框、區(qū)域塊、設(shè)備盒子等邏輯對象。

矩形方塊屬性包括線條、區(qū)域、文字三個方面。

線條:線寬、顏色、虛實;

區(qū)域:是否填充區(qū)域、填充顏色;

文字:文字內(nèi)容、文字是否顯示、字體顏色、字體類型、字體大小。

2.1 矩形方塊的畫法

矩形畫法:點擊左側(cè)工具欄矩形圖標按鈕? -> 在繪圖區(qū)按下鼠標左鍵 -> 移動鼠標(實時畫矩形) -> 松開鼠標(完成畫矩形),再根據(jù)需要,(雙擊該矩形,彈出屬性對話框)設(shè)置矩形線條(寬度、顏色、虛實)、區(qū)域(是否填充、填充顏色)、文字(內(nèi)容、字體顏色、字號等)屬性值。

浮云繪圖之矩形方塊畫法
浮云繪圖之矩形方塊畫法


?上圖為了更容易看清區(qū)域是否填充,繪圖背景使用了灰底+網(wǎng)格線。

浮云繪圖之矩形方塊屬性設(shè)置對話框
浮云繪圖之矩形方塊屬性設(shè)置對話框


2.2 矩形API接口定義及使用實例

以C#版API Demo為例(完整浮云繪圖SDK開發(fā)及源碼下載地址

矩形圖元相關(guān)的接口定義如下(矩形的線條屬性設(shè)置接口與上節(jié)直線接口一致):

? ? ? ?[DllImport("FYEDC.dll", EntryPoint = "SetFillColor", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern void SetFillColor(IntPtr canvas, IntPtr shape, int color);

? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "GetFillColor", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern int GetFillColor(IntPtr shape);


? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "SetIsFill", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern void SetIsFill(IntPtr canvas, IntPtr shape, int isFill);

? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "GetIsFill", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern int GetIsFill(IntPtr shape);


? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "SetFontColor", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern void SetFontColor(IntPtr canvas, IntPtr shape, int color);

? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "GetFontColor", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern int GetFontColor(IntPtr shape);

? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "SetFontType", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern void SetFontType(IntPtr canvas, IntPtr shape, string type);

? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "GetFontType", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern void GetFontType(IntPtr shape, ref byte type);

? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "SetFontSize", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern void SetFontSize(IntPtr canvas, IntPtr shape, int size);

? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "GetFontSize", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern int GetFontSize(IntPtr shape);


? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "SetShapeText", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern void SetShapeText(IntPtr canvas, IntPtr shape, string text);

? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "GetShapeText", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern void GetShapeText(IntPtr shape, ref byte text);

? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "SetTextVisible", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern void SetTextVisible(IntPtr canvas, IntPtr shape, int isShow);

? ? ? ? [DllImport("FYEDC.dll", EntryPoint = "GetTextVisible", CallingConvention = CallingConvention.Cdecl)]

? ? ? ? public static extern int GetTextVisible(IntPtr shape);

浮云繪圖DLL組件的矩形接口API使用實例如下所示:

? ? ? ? private void btnArea_Click(object sender, EventArgs e)

? ? ? ? {

? ? ? ? ? ? IntPtr shape = GetShapeAt(m_shapeCanvas, m_shapeSeqNum);? ? //獲得圖元對象

? ? ? ? ? ? if (shape != IntPtr.Zero)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? // 獲取數(shù)據(jù)

? ? ? ? ? ? ? ? AreaPropForm frm = new AreaPropForm();

? ? ? ? ? ? ? ? frm.m_iSeqNum = m_shapeSeqNum;

? ? ? ? ? ? ? ? frm.m_iFillColor = GetFillColor(shape);

? ? ? ? ? ? ? ? frm.m_isFill = GetIsFill(shape);


? ? ? ? ? ? ? ? // 設(shè)置數(shù)據(jù)

? ? ? ? ? ? ? ? if (DialogResult.OK == frm.ShowDialog())

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? m_shapeSeqNum = frm.m_iSeqNum;? ? ? // 可以修改默認的圖元序號

? ? ? ? ? ? ? ? ? ? if (GetShapeCount(m_shapeCanvas) - 1 < m_shapeSeqNum)

? ? ? ? ? ? ? ? ? ? ? ? m_shapeSeqNum = GetShapeCount(m_shapeCanvas) - 1;

? ? ? ? ? ? ? ? ? ? if (m_shapeSeqNum < 0)

? ? ? ? ? ? ? ? ? ? ? ? m_shapeSeqNum = 0;


? ? ? ? ? ? ? ? ? ? IntPtr shape2 = GetShapeAt(m_shapeCanvas, m_shapeSeqNum);

? ? ? ? ? ? ? ? ? ? if (shape2 != IntPtr.Zero)

? ? ? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? SetFillColor(m_shapeCanvas, shape2, frm.m_iFillColor);

? ? ? ? ? ? ? ? ? ? ? ? SetIsFill(m_shapeCanvas, shape2, frm.m_isFill);

? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }

? ? ? ? }



? ? ? ? private void btnText_Click(object sender, EventArgs e)

? ? ? ? {

? ? ? ? ? ? IntPtr shape = GetShapeAt(m_shapeCanvas, m_shapeSeqNum);? ? //獲得圖元對象

? ? ? ? ? ? if (shape != IntPtr.Zero)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? // 獲取數(shù)據(jù)

? ? ? ? ? ? ? ? TextPropForm frm = new TextPropForm();

? ? ? ? ? ? ? ? frm.m_iSeqNum = m_shapeSeqNum;


? ? ? ? ? ? ? ? byte[] bys = new byte[200];

? ? ? ? ? ? ? ? lock (bys)

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? GetShapeText(shape, ref bys[0]);? ? ?//獲取圖元Title

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? String sTxt = ByteToString(bys);


? ? ? ? ? ? ? ? frm.m_sContent = sTxt;

? ? ? ? ? ? ? ? frm.m_isDisplay = GetTextVisible(shape);


? ? ? ? ? ? ? ? // 設(shè)置數(shù)據(jù)

? ? ? ? ? ? ? ? if (DialogResult.OK == frm.ShowDialog())

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? m_shapeSeqNum = frm.m_iSeqNum;? ? ? // 可以修改默認的圖元序號

? ? ? ? ? ? ? ? ? ? if (GetShapeCount(m_shapeCanvas) - 1 < m_shapeSeqNum)

? ? ? ? ? ? ? ? ? ? ? ? m_shapeSeqNum = GetShapeCount(m_shapeCanvas) - 1;

? ? ? ? ? ? ? ? ? ? if (m_shapeSeqNum < 0)

? ? ? ? ? ? ? ? ? ? ? ? m_shapeSeqNum = 0;


? ? ? ? ? ? ? ? ? ? IntPtr shape2 = GetShapeAt(m_shapeCanvas, m_shapeSeqNum);

? ? ? ? ? ? ? ? ? ? if (shape2 != IntPtr.Zero)

? ? ? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? SetShapeText(m_shapeCanvas, shape2, frm.m_sContent);

? ? ? ? ? ? ? ? ? ? ? ? SetTextVisible(m_shapeCanvas, shape2, frm.m_isDisplay);

? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }

? ? ? ? }



? ? ? ? private void btnFont_Click(object sender, EventArgs e)

? ? ? ? {

? ? ? ? ? ? IntPtr shape = GetShapeAt(m_shapeCanvas, m_shapeSeqNum);? ? //獲得圖元對象

? ? ? ? ? ? if (shape != IntPtr.Zero)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? // 獲取數(shù)據(jù)

? ? ? ? ? ? ? ? FontPropForm frm = new FontPropForm();

? ? ? ? ? ? ? ? frm.m_iSeqNum = m_shapeSeqNum;? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? frm.m_iFontColor = GetFontColor(shape);

? ? ? ? ? ? ? ? frm.m_iFontSize = GetFontSize(shape);


? ? ? ? ? ? ? ? byte[] bys = new byte[200];

? ? ? ? ? ? ? ? lock (bys)

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? GetFontType(shape, ref bys[0]);? ? ?

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? String sTxt = ByteToString(bys);

? ? ? ? ? ? ? ? frm.m_sFontStyle = sTxt;


? ? ? ? ? ? ? ? // 設(shè)置數(shù)據(jù)

? ? ? ? ? ? ? ? if (DialogResult.OK == frm.ShowDialog())

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? m_shapeSeqNum = frm.m_iSeqNum;? ? ? // 可以修改默認的圖元序號

? ? ? ? ? ? ? ? ? ? if (GetShapeCount(m_shapeCanvas) - 1 < m_shapeSeqNum)

? ? ? ? ? ? ? ? ? ? ? ? m_shapeSeqNum = GetShapeCount(m_shapeCanvas) - 1;

? ? ? ? ? ? ? ? ? ? if (m_shapeSeqNum < 0)

? ? ? ? ? ? ? ? ? ? ? ? m_shapeSeqNum = 0;


? ? ? ? ? ? ? ? ? ? IntPtr shape2 = GetShapeAt(m_shapeCanvas, m_shapeSeqNum);

? ? ? ? ? ? ? ? ? ? if (shape2 != IntPtr.Zero)

? ? ? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? SetFontType(m_shapeCanvas, shape2, frm.m_sFontStyle);

? ? ? ? ? ? ? ? ? ? ? ? SetFontColor(m_shapeCanvas, shape2, frm.m_iFontColor);

? ? ? ? ? ? ? ? ? ? ? ? SetFontSize(m_shapeCanvas, shape2, frm.m_iFontSize);

? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }

? ? ? ? }


3. 浮云繪圖開源軟件之橢圓(圓)

橢圓,是浮云繪圖第3基礎(chǔ)圖元,橢圓可以畫各種橢圓、畫正圓,一般應(yīng)用于區(qū)域、信號燈、球體等邏輯對象。

橢圓屬性與矩形方塊一致,包括線條、區(qū)域、文字三個方面。

線條:線寬、顏色、虛實;

區(qū)域:是否填充區(qū)域、填充顏色;

文字:文字內(nèi)容、文字是否顯示、字體顏色、字體類型、字體大小。

3.1 橢圓的畫法

參考畫矩形操作。

浮云繪圖開源軟件之橢圓
?浮云繪圖開源軟件之橢圓


3.2 橢圓API接口定義及使用實例

參考矩形接口使用。

浮云繪圖基礎(chǔ)圖元還包括三角形、四角形、多點線、扇形、文字、圖片等。具體操作和API示例請參考后面章節(jié)。如需定制更多基礎(chǔ)圖元(小改免費),甚至駐場定制開發(fā)都可以。

浮云繪圖CAD繪圖編輯器之直線、方塊、圓等基礎(chǔ)圖元操作和接口源碼的評論 (共 條)

分享到微博請遵守國家法律
宜兰市| 彰化市| 交城县| 方正县| 恩施市| 白玉县| 台湾省| 宝兴县| 郯城县| 响水县| 临夏市| 沙坪坝区| 通化县| 新干县| 永新县| 无棣县| 同德县| 阿坝县| 洪湖市| 乌什县| 北京市| 青河县| 温泉县| 静海县| 胶州市| 莎车县| 浏阳市| 肃北| 武安市| 丹棱县| 龙里县| 托克托县| 南岸区| 乌兰浩特市| 开阳县| 仁布县| 台东县| 江永县| 鹤峰县| 泌阳县| 阿巴嘎旗|