一、選擇適合的軟件
在繪製功能結構圖前,首要任務就是選擇合適的軟件。主流的功能結構圖繪製軟件有Visio、Lucidchart、OmniGraffle等。選擇軟件時需考慮自身使用習慣以及軟件的功能性、易用性及價格等,以及該軟件是否支持導出多種格式的文件以定製化輸出。
二、繪製框架結構
在繪製功能結構圖時,需要首先在畫布上繪製框架結構,即整個結構的組成部分。這些部分可以是具體的子功能模塊或某種設備組件。繪製時可以選用預先設計好的圖形模板,也可以自行設計符合自身習慣的自定義模板。這裡以Visio為例,給出如下代碼示例:
Sub DrawFramework()
'新建頁面
Set currentPage = Application.ActiveDocument.Pages.Add
'設置頁面預定義尺寸
Set pageSize = currentPage.PageSheet.Cells("PageWidth")
pageSize.Result(VisUnitCodes.visInches) = 8.5
Set pageSize = currentPage.PageSheet.Cells("PageHeight")
pageSize.Result(VisUnitCodes.visInches) = 11
'設置頁面背景顏色
currentPage.PageSheet.Cells("PageBackColor").FormulaU = """253,253,223"""
'在頁面上添加基本框架結構
Set myshape = currentPage.DrawRectangle(1.25, 1.25, 2.5, 2.25)
myshape.Text = "Function A"
Set myshape = currentPage.DrawRectangle(4, 1.25, 5.25, 2.25)
myshape.Text = "Function B"
Set myshape = currentPage.DrawRectangle(1.25, 8.25, 2.5, 9.25)
myshape.Text = "Function C"
Set myshape = currentPage.DrawRectangle(4, 8.25, 5.25, 9.25)
myshape.Text = "Function D"
End Sub
三、繪製功能模塊
在框架結構確定後,需要對每個子部分進行細化,即繪製具體的功能模塊。在繪製時需考慮該模塊的輸入、輸出及實現方式。不同軟件中,繪製功能模塊的方式不同,但都需表示清楚模塊的功能及其屬性。
以Lucidchart為例,給出如下代碼示例:
function drawModule(x, y, name, inputs, outputs) {
//繪製模塊框架
var mod = new joint.shapes.standard.Rectangle();
mod.position(x, y);
mod.resize(80, 50);
//插入模塊名稱
var nameLabel = new joint.shapes.standard.TextBlock();
nameLabel.position(x + 40, y + 6);
nameLabel.resize(80, 20);
nameLabel.attr('text/text', name);
//繪製輸入輸出端口
var inputPorts = [];
for (var i = 0; i < inputs; i++) {
var input = new joint.shapes.standard.Circle();
input.position(x, y + 15 + i*15);
input.resize(10, 10);
mod.embed(input);
input.ports.item(0).label(Colors.inputLabel);
inputPorts.push(input);
}
var outputPorts = [];
for (var i = 0; i < outputs; i++) {
var output = new joint.shapes.standard.Circle();
output.position(x + 80, y + 15 + i*15);
output.resize(10, 10);
mod.embed(output);
output.ports.item(0).label(Colors.outputLabel);
outputPorts.push(output);
}
mod.label(0, ' ', { position: { distance: -20 } });
mod.label(1, ' ', { position: { distance: 20 } });
mod.addTo(graph);
return {module: mod, inputs: inputPorts, outputs: outputPorts};
}
四、連線
在功能結構圖中,每個部分都需明確其與其他組件的聯繫。連線可以表示數據及傳遞方向等,使整個結構更加清晰易懂。較為直觀的連線方式是使用箭頭連接,箭頭指向方向一般表示數據流動方向。在連線時需注意線條的粗細、顏色及箭頭的大小、顏色等。
以OmniGraffle為例,給出如下代碼示例:
function drawLine(fromx, fromy, tox, toy, color, weight) {
//繪製連線
var line = new joint.dia.Link({
source: { x: fromx, y: fromy },
target: { x: tox, y: toy },
attrs: {
'.connection': { stroke: color, 'stroke-width': weight || 1, 'stroke-dasharray': '0' },
'.marker-target': { fill: color, d: 'M 10 0 L 0 5 L 10 10 z' }
},
smooth: true,
router: { name: 'orthogonal' },
connector: { name: 'rounded' }
});
graph.addCell(line);
}
五、調整布局
功能結構圖繪製完畢後,為了使它更加美觀、易讀,在布局方面也有或多或少的調整工作。較為常見的布局方式有左對齊、右對齊、居中等,但需注意不同軟件具有不同的布局方式。此外,還需注意控制文字和組件的大小及位置,以使圖形比例協調,細節美觀。
以Visio為例,給出如下代碼示例:
Sub AdjustLayout()
'設定組件位置及大小
Set shapeA = currentPage.Shapes.Item("Function A")
shapeA.Cells("PinX").Result(VisUnitCodes.visInches) = 2
shapeA.Cells("PinY").Result(VisUnitCodes.visInches) = 2
shapeA.Cells("Width").Result(VisUnitCodes.visInches) = 1.25
shapeA.Cells("Height").Result(VisUnitCodes.visInches) = 1
Set shapeB = currentPage.Shapes.Item("Function B")
shapeB.Cells("PinX").Result(VisUnitCodes.visInches) = 5
shapeB.Cells("PinY").Result(VisUnitCodes.visInches) = 2
shapeB.Cells("Width").Result(VisUnitCodes.visInches) = 1.25
shapeB.Cells("Height").Result(VisUnitCodes.visInches) = 1
Set shapeC = currentPage.Shapes.Item("Function C")
shapeC.Cells("PinX").Result(VisUnitCodes.visInches) = 2
shapeC.Cells("PinY").Result(VisUnitCodes.visInches) = 8
shapeC.Cells("Width").Result(VisUnitCodes.visInches) = 1.25
shapeC.Cells("Height").Result(VisUnitCodes.visInches) = 1
Set shapeD = currentPage.Shapes.Item("Function D")
shapeD.Cells("PinX").Result(VisUnitCodes.visInches) = 5
shapeD.Cells("PinY").Result(VisUnitCodes.visInches) = 8
shapeD.Cells("Width").Result(VisUnitCodes.visInches) = 1.25
shapeD.Cells("Height").Result(VisUnitCodes.visInches) = 1
Set connector1 = currentPage.Shapes.Item("Connector1")
connector1.Cells("BeginX").Result(VisUnitCodes.visInches) = 2.25
connector1.Cells("EndX").Result(VisUnitCodes.visInches) = 3.75
connector1.Cells("BeginY").Result(VisUnitCodes.visInches) = 2.5
connector1.Cells("EndY").Result(VisUnitCodes.visInches) = 2.5
Set connector2 = currentPage.Shapes.Item("Connector2")
connector2.Cells("BeginX").Result(VisUnitCodes.visInches) = 5.25
connector2.Cells("EndX").Result(VisUnitCodes.visInches) = 6.75
connector2.Cells("BeginY").Result(VisUnitCodes.visInches) = 2.5
connector2.Cells("EndY").Result(VisUnitCodes.visInches) = 2.5
Set connector3 = currentPage.Shapes.Item("Connector3")
connector3.Cells("BeginX").Result(VisUnitCodes.visInches) = 2.25
connector3.Cells("EndX").Result(VisUnitCodes.visInches) = 3.75
connector3.Cells("BeginY").Result(VisUnitCodes.visInches) = 8.5
connector3.Cells("EndY").Result(VisUnitCodes.visInches) = 8.5
Set connector4 = currentPage.Shapes.Item("Connector4")
connector4.Cells("BeginX").Result(VisUnitCodes.visInches) = 5.25
connector4.Cells("EndX").Result(VisUnitCodes.visInches) = 6.75
connector4.Cells("BeginY").Result(VisUnitCodes.visInches) = 8.5
connector4.Cells("EndY").Result(VisUnitCodes.visInches) = 8.5
'對齊
currentPage.AlignHorizontal VisSelectionTypes.visSelTypeAll, VisHorizontalAlignTypes.visHorzAlignCenter
currentPage.AlignVertical VisSelectionTypes.visSelTypeAll, VisVerticalAlignTypes.visVertAlignMiddle
End Sub
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/201101.html
微信掃一掃
支付寶掃一掃