개정판 bca81f4c
dev issue #000 : add grouping
Change-Id: I2d73f7cf5a88d09ff8e3f51bd45cc70369c34c24
DTI_PID/BaseModel/Model/Document.cs | ||
---|---|---|
77 | 77 |
CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value) |
78 | 78 |
}; |
79 | 79 |
SetAssociations(item.Element("ASSOCIATIONS"), symbol.ASSOCIATIONS); |
80 |
SetConnectors(item.Element("CONNECTORS"), symbol.CONNECTORS);
|
|
80 |
SetSymbolConnectors(item.Element("CONNECTORS"), symbol.CONNECTORS, symbol.CONNECTIONPOINT);
|
|
81 | 81 |
SetProperties(item.Element("PROPERTIES"), symbol.PROPERTIES); |
82 | 82 |
SetAttributes(item.Element("SYMBOLATTRIBUTES"), symbol.ATTRIBUTES); |
83 | 83 |
|
84 |
// Child |
|
85 |
if (!string.IsNullOrEmpty(symbol.CONNECTIONPOINT) && symbol.CONNECTIONPOINT != "None") |
|
86 |
{ |
|
87 |
string[] array = symbol.CONNECTIONPOINT.Split(new char[] { '/' }); |
|
88 |
for (int i = 0; i < array.Length; i++) |
|
89 |
{ |
|
90 |
string[] arrConn = array[i].Split(new char[] { ',' }); |
|
91 |
symbol.CONNECTORS[i].INDEX = Convert.ToInt32(arrConn[3]); |
|
92 |
} |
|
93 |
} |
|
94 |
|
|
84 | 95 |
SYMBOLS.Add(symbol); |
85 | 96 |
} |
86 | 97 |
} |
... | ... | |
194 | 205 |
} |
195 | 206 |
} |
196 | 207 |
|
208 |
private void SetSymbolConnectors(XElement node, List<Connector> connectors, string CONNECTIONPOINT) |
|
209 |
{ |
|
210 |
foreach (XElement item in node.Elements("CONNECTOR")) |
|
211 |
{ |
|
212 |
connectors.Add(new Connector() |
|
213 |
{ |
|
214 |
UID = item.Attribute("UID").Value, |
|
215 |
CONNECTED_AT = Convert.ToInt32(item.Attribute("CONNECTED_AT").Value), |
|
216 |
CONNECTEDITEM = item.Element("CONNECTEDITEM").Value, |
|
217 |
CONNECTPOINT = item.Element("CONNECTPOINT").Value, |
|
218 |
SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value, |
|
219 |
}); |
|
220 |
} |
|
221 |
} |
|
222 |
|
|
197 | 223 |
private void SetProperties(XElement node, List<Property> properties) |
198 | 224 |
{ |
199 | 225 |
foreach (XElement item in node.Elements("PROPERTY")) |
DTI_PID/BaseModel/Model/Other/Connector.cs | ||
---|---|---|
13 | 13 |
private string _CONNECTEDITEM; |
14 | 14 |
private string _CONNECTPOINT; |
15 | 15 |
private string _SCENECONNECTPOINT; |
16 |
private int _INDEX; |
|
16 | 17 |
|
17 | 18 |
public string UID { get => _UID; set => _UID = value; } |
18 | 19 |
public int CONNECTED_AT { get => _CONNECTED_AT; set => _CONNECTED_AT = value; } |
19 | 20 |
public string CONNECTEDITEM { get => _CONNECTEDITEM; set => _CONNECTEDITEM = value; } |
20 | 21 |
public string CONNECTPOINT { get => _CONNECTPOINT; set => _CONNECTPOINT = value; } |
21 | 22 |
public string SCENECONNECTPOINT { get => _SCENECONNECTPOINT; set => _SCENECONNECTPOINT = value; } |
23 |
public int INDEX { get => _INDEX; set => _INDEX = value; } |
|
22 | 24 |
} |
23 | 25 |
} |
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
34 | 34 |
application.ActiveWindow.Zoom = 60; |
35 | 35 |
Thread.Sleep(100); |
36 | 36 |
|
37 |
foreach (LineNumber lineNumber in document.LINENUMBERS) |
|
38 |
{ |
|
39 |
foreach (LineNumberRun run in lineNumber.RUNS) |
|
40 |
{ |
|
41 |
foreach (object item in run.RUNITEMS) |
|
42 |
{ |
|
37 | 43 |
|
38 | 44 |
|
39 |
|
|
45 |
} |
|
46 |
} |
|
47 |
} |
|
40 | 48 |
|
41 | 49 |
} |
42 | 50 |
|
DTI_PID/SPPIDConverter/Model/SPPID_Document.cs | ||
---|---|---|
4 | 4 |
using System.Text; |
5 | 5 |
using System.Threading.Tasks; |
6 | 6 |
using Converter.BaseModel; |
7 |
using Converter.SPPID.Util; |
|
7 | 8 |
|
8 | 9 |
namespace Converter.SPPID.Model |
9 | 10 |
{ |
... | ... | |
11 | 12 |
{ |
12 | 13 |
public SPPID_Document(string xmlPath) : base(xmlPath) |
13 | 14 |
{ |
14 |
|
|
15 |
SetGrouping(); |
|
15 | 16 |
} |
16 | 17 |
|
17 | 18 |
public List<SymbolMapping> SymbolMappings { get; set; } |
... | ... | |
23 | 24 |
public string DrawingNumber { get; set; } |
24 | 25 |
public string Unit { get; set; } |
25 | 26 |
public string Template { get; set; } |
27 |
|
|
28 |
|
|
29 |
#region Grouping Source |
|
30 |
List<object> groupingList = new List<object>(); |
|
31 |
public List<Group> GROUPS = new List<Group>(); |
|
32 |
private void SetGrouping() |
|
33 |
{ |
|
34 |
try |
|
35 |
{ |
|
36 |
// Line 기준으로 묶음 |
|
37 |
foreach (Line item in LINES) |
|
38 |
if (!item.GROUPING) |
|
39 |
SetGroupingByItem(item); |
|
40 |
// End |
|
41 |
|
|
42 |
// Symbol 기준으로 묶음 |
|
43 |
foreach (Symbol item in SYMBOLS) |
|
44 |
if (!item.GROUPING) |
|
45 |
SetGroupingByItem(item); |
|
46 |
// End |
|
47 |
} |
|
48 |
catch (Exception ex) |
|
49 |
{ |
|
50 |
|
|
51 |
} |
|
52 |
} |
|
53 |
|
|
54 |
private void SetGroupingByItem(Base item) |
|
55 |
{ |
|
56 |
try |
|
57 |
{ |
|
58 |
Group group = new Group(); |
|
59 |
group.Items.Add(item); |
|
60 |
bool forward = true; |
|
61 |
SetGroupingByConnectedItem(item, group.Items, ref forward); |
|
62 |
|
|
63 |
GROUPS.Add(group); |
|
64 |
} |
|
65 |
catch (Exception ex) |
|
66 |
{ |
|
67 |
|
|
68 |
} |
|
69 |
} |
|
70 |
|
|
71 |
private void SetGroupingByConnectedItem(Base item, List<object> list, ref bool IsForward) |
|
72 |
{ |
|
73 |
try |
|
74 |
{ |
|
75 |
item.GROUPING = true; |
|
76 |
if (typeof(Line) == item.GetType()) |
|
77 |
{ |
|
78 |
Line line = item as Line; |
|
79 |
SetGroupingByConnectedItem_ConnectorsLogic(item, list, ref IsForward, line.CONNECTORS); |
|
80 |
} |
|
81 |
else if (typeof(Symbol) == item.GetType()) |
|
82 |
{ |
|
83 |
Symbol symbol = item as Symbol; |
|
84 |
// Symbol의 경우 BaseSymbol Connector가 2개 이하때 진행 / 나머지는 Grouping 종료 |
|
85 |
int baseSymbolCount = 0; |
|
86 |
foreach (Connector symbolConnector in symbol.CONNECTORS) |
|
87 |
if (symbolConnector.INDEX == 0) |
|
88 |
baseSymbolCount++; |
|
89 |
|
|
90 |
if (baseSymbolCount <= 2) |
|
91 |
SetGroupingByConnectedItem_ConnectorsLogic(item, list, ref IsForward, symbol.CONNECTORS); |
|
92 |
} |
|
93 |
IsForward = false; |
|
94 |
} |
|
95 |
catch (Exception ex) |
|
96 |
{ |
|
97 |
|
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 |
private void SetGroupingByConnectedItem_ConnectorsLogic(Base item, List<object> list, ref bool IsForward, List<Connector> connectors) |
|
102 |
{ |
|
103 |
foreach (Connector connector in connectors) |
|
104 |
{ |
|
105 |
// 부가 심볼일 경우 continue |
|
106 |
if (connector.INDEX > 0) |
|
107 |
continue; |
|
108 |
|
|
109 |
Base connItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM) as Base; |
|
110 |
if (connItem != null) |
|
111 |
{ |
|
112 |
bool result = false; |
|
113 |
if (typeof(Line) == connItem.GetType()) |
|
114 |
{ |
|
115 |
Line connLine = connItem as Line; |
|
116 |
// 연결되는 Item이 전부 Line일 경우 Branch, Line Type을 확인 |
|
117 |
if (item.GetType() == connLine.GetType() && |
|
118 |
(SPPIDUtil.IsBranchLine(((Line)item).UID, connLine) || SPPIDUtil.GetSPPIDMappingPath(this, item) != SPPIDUtil.GetSPPIDMappingPath(this, connLine))) |
|
119 |
continue; |
|
120 |
|
|
121 |
result = true; |
|
122 |
} |
|
123 |
else if (typeof(Symbol) == connItem.GetType()) |
|
124 |
{ |
|
125 |
Symbol connSymbol = connItem as Symbol; |
|
126 |
// 연결되는 Symbol의 Connector가 부가 심볼일 경우는 result = false |
|
127 |
foreach (Connector symbolConnector in connSymbol.CONNECTORS) |
|
128 |
{ |
|
129 |
dynamic item2 = item; |
|
130 |
if (symbolConnector.CONNECTEDITEM == item2.UID) |
|
131 |
{ |
|
132 |
if (symbolConnector.INDEX == 0) |
|
133 |
result = true; |
|
134 |
else |
|
135 |
result = false; |
|
136 |
break; |
|
137 |
} |
|
138 |
} |
|
139 |
} |
|
140 |
|
|
141 |
if (!connItem.GROUPING && result) |
|
142 |
{ |
|
143 |
if (IsForward) |
|
144 |
list.Add(connItem); |
|
145 |
else |
|
146 |
list.Insert(0, connItem); |
|
147 |
SetGroupingByConnectedItem(connItem, list, ref IsForward); |
|
148 |
} |
|
149 |
} |
|
150 |
} |
|
151 |
} |
|
152 |
#endregion |
|
26 | 153 |
} |
27 | 154 |
} |
DTI_PID/SPPIDConverter/SPPIDConverter.csproj | ||
---|---|---|
286 | 286 |
<ItemGroup> |
287 | 287 |
<None Include="Resources\pencolor_16x16.png" /> |
288 | 288 |
</ItemGroup> |
289 |
<ItemGroup> |
|
290 |
<Folder Include="AutoModeling\" /> |
|
291 |
</ItemGroup> |
|
289 |
<ItemGroup /> |
|
292 | 290 |
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
293 | 291 |
</Project> |
DTI_PID/SPPIDConverter/Util/SPPIDUtil.cs | ||
---|---|---|
8 | 8 |
using Converter.SPPID.DB; |
9 | 9 |
using Converter.BaseModel; |
10 | 10 |
using System.Windows.Forms; |
11 |
using Converter.SPPID.Model; |
|
11 | 12 |
|
12 | 13 |
namespace Converter.SPPID.Util |
13 | 14 |
{ |
... | ... | |
62 | 63 |
} |
63 | 64 |
return true; |
64 | 65 |
} |
66 |
|
|
67 |
public static string GetSPPIDMappingPath(SPPID_Document document, object itemObj) |
|
68 |
{ |
|
69 |
if (itemObj.GetType() == typeof(Symbol)) |
|
70 |
{ |
|
71 |
Symbol item = itemObj as Symbol; |
|
72 |
return document.SymbolMappings.Find(x => x.SYMBOLNAME == item.NAME).SPPIDSYMBOLNAME; |
|
73 |
} |
|
74 |
else if (itemObj.GetType() == typeof(Line)) |
|
75 |
{ |
|
76 |
Line item = itemObj as Line; |
|
77 |
return document.LineMappings.Find(x => x.LINENAME == item.TYPE).SPPIDSYMBOLNAME; |
|
78 |
} |
|
79 |
else if (itemObj.GetType() == typeof(Text)) |
|
80 |
{ |
|
81 |
|
|
82 |
} |
|
83 |
else if (itemObj.GetType() == typeof(Note)) |
|
84 |
{ |
|
85 |
|
|
86 |
} |
|
87 |
|
|
88 |
return null; |
|
89 |
} |
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
#region |
|
94 |
public static bool IsBranchLine(string UID, Line connectedLine) |
|
95 |
{ |
|
96 |
try |
|
97 |
{ |
|
98 |
if (connectedLine.CONNECTORS[0].CONNECTEDITEM != UID && connectedLine.CONNECTORS[1].CONNECTEDITEM != UID) |
|
99 |
return true; |
|
100 |
} |
|
101 |
catch (Exception ex) |
|
102 |
{ |
|
103 |
|
|
104 |
} |
|
105 |
|
|
106 |
return false; |
|
107 |
} |
|
108 |
public static object FindObjectByUID(Document document, string UID) |
|
109 |
{ |
|
110 |
foreach (Symbol item in document.SYMBOLS) |
|
111 |
{ |
|
112 |
if (item.UID == UID) |
|
113 |
return item; |
|
114 |
} |
|
115 |
|
|
116 |
foreach (Line item in document.LINES) |
|
117 |
{ |
|
118 |
if (item.UID == UID) |
|
119 |
return item; |
|
120 |
} |
|
121 |
|
|
122 |
foreach (Text item in document.TEXTINFOS) |
|
123 |
{ |
|
124 |
if (item.UID == UID) |
|
125 |
return item; |
|
126 |
} |
|
127 |
|
|
128 |
foreach (Note item in document.NOTES) |
|
129 |
{ |
|
130 |
if (item.UID == UID) |
|
131 |
return item; |
|
132 |
} |
|
133 |
|
|
134 |
foreach (LineNumber item in document.LINENUMBERS) |
|
135 |
{ |
|
136 |
if (item.UID == UID) |
|
137 |
return item; |
|
138 |
} |
|
139 |
|
|
140 |
return null; |
|
141 |
} |
|
142 |
#endregion |
|
65 | 143 |
} |
66 | 144 |
} |
내보내기 Unified diff