프로젝트

일반

사용자정보

개정판 bf42803b

IDbf42803bca552586a20059e1e313dade244b8872
상위 e479c7e2
하위 c2e4c93b

gaqhf 이(가) 약 6년 전에 추가함

dev issue #000 : add AutoModeling proj

차이점 보기:

DTI_PID/DTI_PID.sln
9 9
EndProject
10 10
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPPIDConverter_CustomCommand", "SPPIDConverter_CustomCommand\SPPIDConverter_CustomCommand.csproj", "{4B35A8E9-DBE4-4D2E-8555-1CD5CB907D2D}"
11 11
EndProject
12
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPPIDConverter_AutoModeling", "SPPIDConverter_AutoModeling\SPPIDConverter_AutoModeling.csproj", "{650EF0EA-BD38-4DF8-9A76-0D13AA145F4D}"
13
EndProject
12 14
Global
13 15
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 16
		Debug|Any CPU = Debug|Any CPU
......
37 39
		{4B35A8E9-DBE4-4D2E-8555-1CD5CB907D2D}.Release|Any CPU.Build.0 = Release|Any CPU
38 40
		{4B35A8E9-DBE4-4D2E-8555-1CD5CB907D2D}.Release|x64.ActiveCfg = Release|Any CPU
39 41
		{4B35A8E9-DBE4-4D2E-8555-1CD5CB907D2D}.Release|x64.Build.0 = Release|Any CPU
42
		{650EF0EA-BD38-4DF8-9A76-0D13AA145F4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43
		{650EF0EA-BD38-4DF8-9A76-0D13AA145F4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
44
		{650EF0EA-BD38-4DF8-9A76-0D13AA145F4D}.Debug|x64.ActiveCfg = Debug|Any CPU
45
		{650EF0EA-BD38-4DF8-9A76-0D13AA145F4D}.Debug|x64.Build.0 = Debug|Any CPU
46
		{650EF0EA-BD38-4DF8-9A76-0D13AA145F4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
47
		{650EF0EA-BD38-4DF8-9A76-0D13AA145F4D}.Release|Any CPU.Build.0 = Release|Any CPU
48
		{650EF0EA-BD38-4DF8-9A76-0D13AA145F4D}.Release|x64.ActiveCfg = Release|Any CPU
49
		{650EF0EA-BD38-4DF8-9A76-0D13AA145F4D}.Release|x64.Build.0 = Release|Any CPU
40 50
	EndGlobalSection
41 51
	GlobalSection(SolutionProperties) = preSolution
42 52
		HideSolutionNode = FALSE
DTI_PID/SPPIDConverter_AutoModeling/Model/SPPID/Connector.cs
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Linq;
5
using System.Runtime.InteropServices;
6
using System.Text;
7
using System.Threading.Tasks;
8
using Llama;
9
using Plaice;
10
using SPPID.Utill;
11
using SPPID.Modeling;
12

  
13
namespace SPPID.Model
14
{
15
    public class Connector
16
    {
17
        #region Property
18
        private string _CONNECTEDITEM;
19
        private string _CONNECTPOINT;
20
        private string _SCENECONNECTPOINT;
21
        private int _INDEX;
22

  
23
        public string CONNECTEDITEM { get => _CONNECTEDITEM; set => _CONNECTEDITEM = value; }
24
        public string CONNECTPOINT { get => _CONNECTPOINT; set => _CONNECTPOINT = value; }
25
        public string SCENECONNECTPOINT { get => _SCENECONNECTPOINT; set => _SCENECONNECTPOINT = value; }
26
        public int INDEX { get => _INDEX; set => _INDEX = value; }
27
        #endregion
28
    }
29
}
DTI_PID/SPPIDConverter_AutoModeling/Model/SPPID/Document.cs
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Linq;
5
using System.Runtime.InteropServices;
6
using System.Text;
7
using System.Threading.Tasks;
8
using Llama;
9
using Plaice;
10
using SPPID.Utill;
11
using SPPID.Modeling;
12
using System.Xml.Linq;
13

  
14
namespace SPPID.Model
15
{
16
    public class Document
17
    {
18
        #region Property
19
        private string _DWGNAME;
20
        private string _SIZE;
21
        private string _UNIT;
22
        private List<Symbol> _SYMBOLS = new List<Symbol>();
23
        private List<Line> _LINES = new List<Line>();
24
        private List<LineNumber> _LINENUMBERS = new List<LineNumber>();
25
        private List<Text> _TEXTS = new List<Text>();
26
        private List<SpecBreak> _SPECBREAK = new List<SpecBreak>();
27
        private Dictionary<string, List<PointInfo>> _PipeRunPoint = new Dictionary<string, List<PointInfo>>();
28
        private List<Group> _GROUPS = new List<Group>();
29
        private Dictionary<string, string> _SymbolMapping;
30
        private Dictionary<string, string> _AttributeMapping;
31

  
32
        private double _WIDTH;
33
        private double _HEIGHT;
34

  
35
        public string DWGNAME { get => _DWGNAME; set => _DWGNAME = value; }
36
        public string SIZE
37
        {
38
            get { return _SIZE; }
39
            set
40
            {
41
                _SIZE = value;
42
                SPPIDUtill.ConvertPointBystring(_SIZE, ref _WIDTH, ref _HEIGHT);
43
            }
44
        }
45
        public string UNIT { get => _UNIT; set => _UNIT = value; }
46
        public Dictionary<string, List<PointInfo>> PipeRunPoint { get => _PipeRunPoint; set => _PipeRunPoint = value; }
47
        public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; }
48
        public List<Line> LINES { get => _LINES; set => _LINES = value; }
49
        public List<LineNumber> LINENUMBERS { get => _LINENUMBERS; set => _LINENUMBERS = value; }
50
        public List<Text> TEXTS { get => _TEXTS; set => _TEXTS = value; }
51
        public double WIDTH { get => _WIDTH; set => _WIDTH = value; }
52
        public double HEIGHT { get => _HEIGHT; set => _HEIGHT = value; }
53
        public List<Group> GROUPS { get => _GROUPS; set => _GROUPS = value; }
54
        public Dictionary<string, string> SymbolMapping { get => _SymbolMapping; set => _SymbolMapping = value; }
55
        internal List<SpecBreak> SPECBREAK { get => _SPECBREAK; set => _SPECBREAK = value; }
56
        public Dictionary<string, string> AttributeMapping { get => _AttributeMapping; set => _AttributeMapping = value; }
57

  
58
        #region Xml Read and Data Setting
59
        public static Document Load(string filePath, Dictionary<string, string> symbolMapping, Dictionary<string, string> attributeMapping)
60
        {
61
            try
62
            {
63
                XElement xml = XElement.Load(filePath);
64
                Document doc = new Document();
65
                doc.SymbolMapping = symbolMapping;
66
                doc.AttributeMapping = attributeMapping;
67
                doc.DWGNAME = xml.Element("DWGNAME").Value;
68
                doc.SIZE = xml.Element("SIZE").Value;
69

  
70
                doc.SetSymbol(xml.Element("SYMBOLS"));
71
                doc.SetLine(xml.Element("LINEINFOS"));
72
                doc.SetLineNumber(xml.Element("LINENOS"));
73
                doc.SetText(xml.Element("TEXTINFOS"));
74
                doc.SetTrimLine(xml.Element("TRIMLINENOS"));
75
                doc.SetNote(xml.Element("NOTES"));
76

  
77
                doc.SetGrouping();
78

  
79
                return doc;
80
            }
81
            catch (Exception ex)
82
            {
83
                Log.WriteLine(ex);
84
                return null;
85
            }
86
        }
87

  
88
        #region SPPID Item
89
        private void SetSymbol(XElement node)
90
        {
91
            foreach (XElement item in node.Elements("SYMBOL"))
92
            {
93
                try
94
                {
95
                    if (item.Element("TYPE").Value == "Segment Breaks")
96
                    {
97
                        SetSpecBreak(item);
98
                        continue;
99
                    }
100
                        
101

  
102
                    Symbol symbol = new Symbol()
103
                    {
104
                        UID = item.Element("UID").Value,
105
                        NAME = item.Element("NAME").Value,
106
                        TYPE = item.Element("TYPE").Value,
107
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
108
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
109
                        LOCATION = item.Element("LOCATION").Value,
110
                        SIZE = item.Element("SIZE").Value,
111
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
112
                        PARENT = item.Element("PARENT").Value,
113
                        CHILD = item.Element("CHILD").Value,
114
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
115
                        AREA = item.Element("AREA").Value
116
                    };
117
                    SetConnectors(item.Element("CONNECTORS"), symbol.CONNECTORS);
118
                    SetAssociations(item.Element("ASSOCIATIONS"), symbol.ASSOCIATIONS);
119
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), symbol.ATTRIBUTES);
120

  
121
                    symbol.AfterSetting(this);
122
                }
123
                catch (Exception ex)
124
                {
125
                    Log.WriteLine(ex);
126
                }
127
            }
128
        }
129

  
130
        private void SetLine(XElement node)
131
        {
132
            try
133
            {
134
                foreach (XElement item in node.Elements("LINE"))
135
                {
136
                    try
137
                    {
138
                        Line line = new Line()
139
                        {
140
                            UID = item.Element("UID").Value,
141
                            STARTPOINT = item.Element("STARTPOINT").Value,
142
                            ENDPOINT = item.Element("ENDPOINT").Value,
143
                            TYPE = item.Element("TYPE").Value,
144
                            AREA = item.Element("AREA").Value
145
                        };
146
                        SetConnectors(item.Element("CONNECTORS"), line.CONNECTORS);
147

  
148
                        line.AfterSetting(this);
149
                    }
150
                    catch (Exception ex)
151
                    {
152
                        Log.WriteLine(ex);
153
                    }
154
                }
155
            }
156
            catch (Exception ex)
157
            {
158
                Log.WriteLine(ex);
159
            }
160
        }
161

  
162
        private void SetLineNumber(XElement node)
163
        {
164
            try
165
            {
166
                foreach (XElement item in node.Elements("LINE_NO"))
167
                {
168
                    try
169
                    {
170
                        LineNumber lineNumber = new LineNumber()
171
                        {
172
                            UID = item.Element("UID").Value,
173
                            TEXT = item.Element("TEXT").Value,
174
                            LOCATION = item.Element("LOCATION").Value,
175
                            ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
176
                            AREA = item.Element("AREA").Value,
177
                            LINENUMBERTYPE = LineNumber.LineNumberType.LineNumber,
178
                            NAME = "LineNumber",
179
                        };
180

  
181
                        if (item.Element("CONNLINE") != null)
182
                            lineNumber.CONNECTLINE = item.Element("CONNLINE").Value;
183
                        SetAttributes(item, lineNumber.ATTRIBUTES);
184
                        lineNumber.AfterSetting(this);
185
                    }
186
                    catch (Exception ex)
187
                    {
188
                        Log.WriteLine(ex);
189
                    }
190
                }
191
            }
192
            catch (Exception ex)
193
            {
194
                Log.WriteLine(ex);
195
            }
196
        }
197

  
198
        private void SetTrimLine(XElement node)
199
        {
200
            try
201
            {
202
                foreach (XElement item in node.Elements("LINE_NO"))
203
                {
204
                    try
205
                    {
206
                        LineNumber lineNumber = new LineNumber()
207
                        {
208
                            UID = item.Element("UID").Value,
209
                            TEXT = item.Element("TEXT").Value,
210
                            LOCATION = item.Element("LOCATION").Value,
211
                            ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
212
                            AREA = item.Element("AREA").Value,
213
                            LINENUMBERTYPE = LineNumber.LineNumberType.TrimLine,
214
                            NAME = "LineNumber",
215
                        };
216

  
217
                        if (item.Element("CONNLINE") != null)
218
                            lineNumber.CONNECTLINE = item.Element("CONNLINE").Value;
219
                        SetAttributes(item, lineNumber.ATTRIBUTES);
220
                        lineNumber.AfterSetting(this);
221
                    }
222
                    catch (Exception ex)
223
                    {
224
                        Log.WriteLine(ex);
225
                    }
226
                }
227
            }
228
            catch (Exception ex)
229
            {
230
                Log.WriteLine(ex);
231
            }
232
        }
233

  
234
        private void SetText(XElement node)
235
        {
236
            foreach (XElement item in node.Elements("ATTRIBUTE"))
237
            {
238
                try
239
                {
240
                    Text text = new Text()
241
                    {
242
                        UID = item.Element("UID").Value,
243
                        NAME = item.Element("NAME").Value,
244
                        LOCATION = item.Element("LOCATION").Value,
245
                        VALUE = item.Element("VALUE").Value,
246
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
247
                        AREA = item.Element("AREA").Value,
248
                    };
249
                    text.AfterSetting(this);
250
                }
251
                catch (Exception ex)
252
                {
253
                    Log.WriteLine(ex);
254
                }
255
            }
256
        }
257

  
258
        private void SetNote(XElement node)
259
        {
260
            foreach (XElement item in node.Elements("ATTRIBUTE"))
261
            {
262
                try
263
                {
264
                    Text text = new Text()
265
                    {
266
                        UID = item.Element("UID").Value,
267
                        NAME = item.Element("NAME").Value,
268
                        LOCATION = item.Element("LOCATION").Value,
269
                        VALUE = item.Element("VALUE").Value,
270
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
271
                        AREA = item.Element("AREA").Value,
272
                    };
273
                    text.AfterSetting(this);
274
                }
275
                catch (Exception ex)
276
                {
277
                    Log.WriteLine(ex);
278
                }
279
            }
280
        }
281

  
282
        private void SetSpecBreak(XElement item)
283
        {
284
            try
285
            {
286
                SpecBreak specBreak = new SpecBreak()
287
                {
288
                    UID = item.Element("UID").Value,
289
                    NAME = item.Element("NAME").Value,
290
                    TYPE = item.Element("TYPE").Value,
291
                    ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
292
                    CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
293
                    LOCATION = item.Element("LOCATION").Value,
294
                    SIZE = item.Element("SIZE").Value,
295
                    ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
296
                    PARENT = item.Element("PARENT").Value,
297
                    CHILD = item.Element("CHILD").Value,
298
                    HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
299
                    AREA = item.Element("AREA").Value
300
                };
301
                SetConnectors(item.Element("CONNECTORS"), specBreak.CONNECTORS);
302
                SetAttributes(item.Element("SYMBOLATTRIBUTES"), specBreak.ATTRIBUTES);
303

  
304
                specBreak.AfterSetting(this);
305
            }
306
            catch (Exception ex)
307
            {
308
                Log.WriteLine(ex);
309
            }
310
        }
311
        #endregion
312

  
313
        #region Connector, Association, Attribute
314
        private void SetConnectors(XElement node, List<Connector> connectors)
315
        {
316
            foreach (XElement item in node.Elements("CONNECTOR"))
317
            {
318
                try
319
                {
320
                    connectors.Add(new Connector()
321
                    {
322
                        CONNECTEDITEM = item.Element("CONNECTEDITEM").Value,
323
                        CONNECTPOINT = item.Element("CONNECTPOINT").Value,
324
                        SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value,
325
                    });
326
                }
327
                catch (Exception ex)
328
                {
329
                    Log.WriteLine(ex);
330
                }
331
            }
332
        }
333

  
334
        private void SetAssociations(XElement node, List<Association> associations)
335
        {
336
            foreach (XElement item in node.Elements("ASSOCIATION"))
337
            {
338
                try
339
                {
340
                    associations.Add(new Association()
341
                    {
342
                        TYPE = item.Attribute("TYPE").Value,
343
                        TYPE_VALUE = item.Value,
344
                    });
345
                }
346
                catch (Exception ex)
347
                {
348
                    Log.WriteLine(ex);
349
                }
350
            }
351
        }
352

  
353
        private void SetAttributes(XElement node, List<ItemAttribute> attributes)
354
        {
355
            try
356
            {
357
                foreach (XElement item in node.Elements("ATTRIBUTE"))
358
                {
359
                    ItemAttribute attribute = new ItemAttribute()
360
                    {
361
                        UID = item.Attribute("UID").Value,
362
                        Length = item.Attribute("Length").Value,
363
                        Expression = item.Attribute("Expression").Value,
364
                        DisplayAttribute = item.Attribute("DisplayAttribute").Value,
365
                        AttributeType = item.Attribute("AttributeType").Value,
366
                        Attribute = item.Attribute("Attribute").Value,
367
                        AttrAt = item.Attribute("AttrAt").Value,
368
                        VALUE = item.Value,
369
                    };
370
                    attribute.SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDAttributeMappingName(attribute.Attribute, AttributeMapping);
371
                    attributes.Add(attribute);
372
                }
373
            }
374
            catch (Exception ex)
375
            {
376
                Log.WriteLine(ex);
377
            }
378
        }
379
        #endregion
380

  
381

  
382
        public bool Init()
383
        {
384
            return ReMapping();
385
        }
386

  
387
        private bool ReMapping()
388
        {
389
            bool result = true;
390
            foreach (Symbol item in SYMBOLS)
391
            {
392
                item.SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDSymbolMappingName(item.PARENT, SymbolMapping);
393
                if (string.IsNullOrEmpty(item.SPPIDMAPPINGNAME))
394
                {
395
                    Log.WriteLine("Fail Mapping" + item.UID + "/" + item.PARENT);
396
                    result = false;
397
                }
398

  
399
                foreach (SymbolChild child in item.CHILD_LIST)
400
                {
401
                    child.SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDSymbolMappingName(child.Name, SymbolMapping);
402
                    if (string.IsNullOrEmpty(child.SPPIDMAPPINGNAME))
403
                    {
404
                        Log.WriteLine("Fail Mapping" + child.Name);
405
                        result = false;
406
                    }
407
                }
408

  
409
                foreach (ItemAttribute attribute in item.ATTRIBUTES)
410
                    attribute.SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDAttributeMappingName(attribute.Attribute, AttributeMapping);
411
            }
412

  
413
            foreach (Line item in LINES)
414
            {
415
                item.SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDSymbolMappingName(item.TYPE, SymbolMapping);
416
                if (string.IsNullOrEmpty(item.SPPIDMAPPINGNAME))
417
                {
418
                    Log.WriteLine("Fail Mapping" + item.UID + "/" + item.TYPE);
419
                    result = false;
420
                }
421

  
422
                foreach (ItemAttribute attribute in item.ATTRIBUTES)
423
                    attribute.SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDAttributeMappingName(attribute.Attribute, AttributeMapping);
424
            }
425

  
426
            foreach (LineNumber item in LINENUMBERS)
427
            {
428
                item.SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDSymbolMappingName(LineNumber.LineNumberSymbolPath, SymbolMapping);
429
                if (string.IsNullOrEmpty(item.SPPIDMAPPINGNAME))
430
                {
431
                    Log.WriteLine("Fail Mapping" + item.UID + "/" + item.NAME);
432
                    result = false;
433
                }
434

  
435
                foreach (ItemAttribute attribute in item.ATTRIBUTES)
436
                    attribute.SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDAttributeMappingName(attribute.Attribute, AttributeMapping);
437
            }
438

  
439
            foreach (Text item in TEXTS)
440
            {
441
                item.SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDSymbolMappingName(item.NAME, SymbolMapping);
442
                if (string.IsNullOrEmpty(item.SPPIDMAPPINGNAME))
443
                {
444
                    Log.WriteLine("Fail Mapping" + item.UID + "/" + item.NAME);
445
                    result = false;
446
                }
447

  
448
                foreach (ItemAttribute attribute in item.ATTRIBUTES)
449
                    attribute.SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDAttributeMappingName(attribute.Attribute, AttributeMapping);
450
            }
451

  
452
            return result;
453
        }
454

  
455
        #endregion
456

  
457
        #endregion
458

  
459
        #region Grouping Source
460
        private void SetGrouping()
461
        {
462
            try
463
            {
464
                // Line 기준으로 묶음
465
                foreach (Line item in LINES)
466
                    if (!item.GROUPING)
467
                        SetGroupingByItem(item);
468
                // End
469

  
470
                // Symbol 기준으로 묶음
471
                foreach (Symbol item in SYMBOLS)
472
                    if (!item.GROUPING)
473
                        SetGroupingByItem(item);
474
                // End
475
            }
476
            catch (Exception ex)
477
            {
478
                Log.WriteLine(ex);
479
            }
480
        }
481

  
482
        private void SetGroupingByItem(SPPID_ITEM item)
483
        {
484
            try
485
            {
486
                Group group = new Group();
487
                group.Items.Add(item);
488
                bool forward = true;
489
                SetGroupingByConnectedItem(item, group.Items, ref forward);
490

  
491
                GROUPS.Add(group);
492
            }
493
            catch (Exception ex)
494
            {
495
                Log.WriteLine(ex);
496
            }
497
        }
498

  
499
        private void SetGroupingByConnectedItem(SPPID_ITEM item, List<object> list, ref bool IsForward)
500
        {
501
            try
502
            {
503
                item.GROUPING = true;
504
                if (typeof(Line) == item.GetType())
505
                {
506
                    Line line = item as Line;
507
                    SetGroupingByConnectedItem_ConnectorsLogic(item, list, ref IsForward, line.CONNECTORS);
508
                }
509
                else if (typeof(Symbol) == item.GetType())
510
                {
511
                    Symbol symbol = item as Symbol;
512
                    // Symbol의 경우 BaseSymbol Connector가 2개 이하때 진행 / 나머지는 Grouping 종료
513
                    int baseSymbolCount = 0;
514
                    foreach (Connector symbolConnector in symbol.CONNECTORS)
515
                        if (symbolConnector.INDEX == 0)
516
                            baseSymbolCount++;
517

  
518
                    if (baseSymbolCount <= 2)
519
                        SetGroupingByConnectedItem_ConnectorsLogic(item, list, ref IsForward, symbol.CONNECTORS);
520
                }
521
                IsForward = false;
522
            }
523
            catch (Exception ex)
524
            {
525
                Log.WriteLine(ex);
526
            }
527
        }
528

  
529
        private void SetGroupingByConnectedItem_ConnectorsLogic(SPPID_ITEM item, List<object> list, ref bool IsForward, List<Connector> connectors)
530
        {
531
            foreach (Connector connector in connectors)
532
            {
533
                // 부가 심볼일 경우 continue
534
                if (connector.INDEX > 0)
535
                    continue;
536

  
537
                SPPID_ITEM connItem = SPPIDUtill.FindObjectByUID(this, connector.CONNECTEDITEM) as SPPID_ITEM;
538
                if (connItem != null)
539
                {
540
                    bool result = false;
541
                    if (typeof(Line) == connItem.GetType())
542
                    {
543
                        Line connLine = connItem as Line;
544
                        // 연결되는 Item이 전부 Line일 경우 Branch, Line Type을 확인
545
                        if (item.GetType() == connLine.GetType() &&
546
                            (SPPIDUtill.IsBranchLine(item.UID, connLine) || item.SPPIDMAPPINGNAME != connLine.SPPIDMAPPINGNAME))
547
                            continue;
548

  
549
                        result = true;
550
                    }
551
                    else if (typeof(Symbol) == connItem.GetType())
552
                    {
553
                        Symbol connSymbol = connItem as Symbol;
554
                        // 연결되는 Symbol의 Connector가 부가 심볼일 경우는 result = false
555
                        foreach (Connector symbolConnector in connSymbol.CONNECTORS)
556
                        {
557
                            if (symbolConnector.CONNECTEDITEM == item.UID)
558
                            {
559
                                if (symbolConnector.INDEX == 0)
560
                                    result = true;
561
                                else
562
                                    result = false;
563
                                break;
564
                            }
565
                        }
566
                    }
567

  
568
                    if (!connItem.GROUPING && result)
569
                    {
570
                        if (IsForward)
571
                            list.Add(connItem);
572
                        else
573
                            list.Insert(0, connItem);
574
                        SetGroupingByConnectedItem(connItem, list, ref IsForward);
575
                    }
576
                }
577
            }
578
        }
579
        #endregion
580
    }
581
}
DTI_PID/SPPIDConverter_AutoModeling/Model/SPPID/ItemAbstract.cs
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Linq;
5
using System.Runtime.InteropServices;
6
using System.Text;
7
using System.Threading.Tasks;
8
using Llama;
9
using Plaice;
10
using SPPID.Utill;
11
using SPPID.Modeling;
12

  
13
namespace SPPID.Model
14
{
15
    public enum SPPID_ITEM_TYPE
16
    {
17
        SYMBOL = 1,
18
        LINE = 2,
19
        LABEL = 3,
20
        TEXT = 4,
21
    }
22
    public abstract class SPPID_ITEM
23
    {
24
        #region Property
25
        private string _UID;
26
        private string _TYPE;
27
        private string _NAME;
28
        private SPPID_ITEM_TYPE _SPPID_TYPE;
29
        private string _SPPIDMAPPINGNAME;
30
        private bool _GROUPING;
31
        private string _AREA;
32
        private List<ItemAttribute> _ATTRIBUTES = new List<ItemAttribute>();
33
        private object _SPPID_ITEM_OBJECT;
34

  
35
        public string UID { get => _UID; set => _UID = value; }
36
        public string TYPE { get => _TYPE; set => _TYPE = value; }
37
        public string NAME { get => _NAME; set => _NAME = value; }
38
        public string SPPIDMAPPINGNAME { get => _SPPIDMAPPINGNAME; set => _SPPIDMAPPINGNAME = value; }
39
        public bool GROUPING { get => _GROUPING; set => _GROUPING = value; }
40
        public string AREA { get => _AREA; set => _AREA = value; }
41
        public object SPPID_ITEM_OBJECT { get => _SPPID_ITEM_OBJECT; set => _SPPID_ITEM_OBJECT = value; }
42
        public SPPID_ITEM_TYPE SPPID_TYPE { get => _SPPID_TYPE; set => _SPPID_TYPE = value; }
43
        public List<ItemAttribute> ATTRIBUTES { get => _ATTRIBUTES; set => _ATTRIBUTES = value; }
44
        #endregion
45

  
46
        public abstract bool Modeling(Document document);
47
        public abstract void AfterSetting(Document document);
48
        public abstract void SetAttribute(Document document);
49
    }
50
}
DTI_PID/SPPIDConverter_AutoModeling/Model/SPPID/Line.cs
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Linq;
5
using System.Runtime.InteropServices;
6
using System.Text;
7
using System.Threading.Tasks;
8
using Llama;
9
using Plaice;
10
using SPPID.Utill;
11
using SPPID.Modeling;
12

  
13
namespace SPPID.Model
14
{
15
    public class Line : SPPID_ITEM
16
    {
17
        public enum SlopeType
18
        {
19
            NONE = 0,
20
            VERTICAL = 1,
21
            HORIZONTAL = 2,
22
            SLOPE = 3,
23
        }
24
        #region Property
25
        private string _STARTPOINT;
26
        private string _ENDPOINT;
27
        private List<Connector> _CONNECTORS = new List<Connector>();
28
        private SlopeType _SLOPTYPE;
29
        private double _START_X;
30
        private double _START_Y;
31
        private double _END_X;
32
        private double _END_Y;
33

  
34
        public string STARTPOINT { get => _STARTPOINT; set => _STARTPOINT = value; }
35
        public string ENDPOINT { get => _ENDPOINT; set => _ENDPOINT = value; }
36
        public double START_X { get => _START_X; set => _START_X = value; }
37
        public double START_Y { get => _START_Y; set => _START_Y = value; }
38
        public double END_X { get => _END_X; set => _END_X = value; }
39
        public double END_Y { get => _END_Y; set => _END_Y = value; }
40
        public List<Connector> CONNECTORS { get => _CONNECTORS; set => _CONNECTORS = value; }
41
        public SlopeType SLOPTYPE { get => _SLOPTYPE; set => _SLOPTYPE = value; }
42
        #endregion
43
        public override void AfterSetting(Document document)
44
        {
45
            // SPPIDMAPPINGNAME Setting
46
            SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDSymbolMappingName(TYPE, document.SymbolMapping);
47
            // End
48

  
49
            // Point Setting
50
            SPPIDUtill.ConvertPointBystring(_STARTPOINT, ref _START_X, ref _START_Y);
51
            SPPIDUtill.ConvertSPPIDPoint(ref _START_X, ref _START_Y, document.WIDTH, document.HEIGHT);
52
            SPPIDUtill.ConvertPointBystring(_ENDPOINT, ref _END_X, ref _END_Y);
53
            SPPIDUtill.ConvertSPPIDPoint(ref _END_X, ref _END_Y, document.WIDTH, document.HEIGHT);
54
            // End
55

  
56
            // Slop Setting
57
            SLOPTYPE = SPPIDUtill.CalcSlop(new PointInfo(_START_X, _START_Y), new PointInfo(_END_X, _END_Y));
58
            // End
59

  
60
            // SPPID Type Setting
61
            SPPID_TYPE = SPPID_ITEM_TYPE.LINE;
62
            // End
63

  
64
            // Input Drawing
65
            document.LINES.Add(this);
66
            // End
67
        }
68

  
69
        public override bool Modeling(Document document)
70
        {
71
            throw new MissingMethodException();
72
        }
73

  
74
        public override void SetAttribute(Document document)
75
        {
76
            throw new NotImplementedException();
77
        }
78

  
79
        public static void SetAttribute(Line line, string attrName, string value)
80
        {
81
            Placement _placement = new Placement();
82
            if (line.SPPID_ITEM_OBJECT != null)
83
            {
84
                LMPipeRun _LMPipeRun = _placement.PIDDataSource.GetPipeRun(line.SPPID_ITEM_OBJECT.ToString());
85
                LMAAttribute _LMAAttribute = _LMPipeRun.Attributes[attrName];
86
                if (_LMAAttribute != null)
87
                {
88
                    _LMAAttribute.set_Value(value);
89
                    _LMPipeRun.Commit();
90
                }
91
            }
92
        }
93
    }
94
}
DTI_PID/SPPIDConverter_AutoModeling/Model/SPPID/LineNumber.cs
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Linq;
5
using System.Runtime.InteropServices;
6
using System.Text;
7
using System.Threading.Tasks;
8
using Llama;
9
using Plaice;
10
using SPPID.Utill;
11
using SPPID.Modeling;
12

  
13
namespace SPPID.Model
14
{
15
    public class LineNumber : SPPID_ITEM
16
    {
17
        public static readonly string LineNumberSymbolPath = "Line Number";
18
        public enum LineNumberType
19
        {
20
            LineNumber = 1,
21
            TrimLine = 2,
22
        }
23
        #region Property
24
        private double _ANGLE;
25
        private string _LOCATION;
26
        private double _LOCATION_X;
27
        private double _LOCATION_Y;
28
        private string _TEXT;
29
        private string _CONNECTLINE;
30
        private LineNumberType _LINENUMBERTYPE;
31

  
32
        public double ANGLE { get => _ANGLE; set => _ANGLE = value; }
33
        public string LOCATION { get => _LOCATION; set => _LOCATION = value; }
34
        public double LOCATION_X { get => _LOCATION_X; set => _LOCATION_X = value; }
35
        public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; }
36
        public string TEXT { get => _TEXT; set => _TEXT = value; }
37
        public string CONNECTLINE { get => _CONNECTLINE; set => _CONNECTLINE = value; }
38
        public LineNumberType LINENUMBERTYPE { get => _LINENUMBERTYPE; set => _LINENUMBERTYPE = value; }
39
        #endregion
40

  
41
        public override void AfterSetting(Document document)
42
        {
43
            // SPPIDMAPPINGNAME Setting
44
            SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDSymbolMappingName(LineNumberSymbolPath, document.SymbolMapping);
45
            // End
46

  
47
            // Angle Setting
48
            if (ANGLE == 1.57)
49
                ANGLE = 90 * Math.PI / 180;
50
            else if (ANGLE == 3.14)
51
                ANGLE = Math.PI;
52
            else if (ANGLE == 4.71)
53
                ANGLE = 270 * Math.PI / 180;
54
            else
55
                ANGLE = 0;
56
            // End
57

  
58
            // Location Setting
59
            SPPIDUtill.ConvertPointBystring(_LOCATION, ref _LOCATION_X, ref _LOCATION_Y);
60
            SPPIDUtill.ConvertSPPIDPoint(ref _LOCATION_X, ref _LOCATION_Y, document.WIDTH, document.HEIGHT);
61
            // End
62

  
63
            // SPPID  Type Setting
64
            SPPID_TYPE = SPPID_ITEM_TYPE.LABEL;
65
            // End
66

  
67
            // Input Drawing
68
            document.LINENUMBERS.Add(this);
69
            // End
70
        }
71

  
72
        public override bool Modeling(Document document)
73
        {
74
            try
75
            {
76
                Line targetLine = SPPIDUtill.FindObjectByUID(document, CONNECTLINE) as Line;
77
                if (targetLine != null && !string.IsNullOrEmpty(targetLine.SPPID_ITEM_OBJECT.ToString()))
78
                {
79
                    Placement _placement = new Placement();
80
                    Array points = new double[] { 0, LOCATION_X, LOCATION_Y };
81
                    LMPipeRun _pipeRun = _placement.PIDDataSource.GetPipeRun(targetLine.SPPID_ITEM_OBJECT.ToString());
82
                    if (_pipeRun != null)
83
                    {
84
                        foreach (LMRepresentation rep in _pipeRun.Representations)
85
                        {
86
                            if (rep.get_RepresentationType() == "Connector" && rep.get_ItemStatus() == "Active")
87
                            {
88
                                LMConnector _LmConnector = _placement.PIDDataSource.GetConnector(rep.Id);
89
                                LMLabelPersist _LmLabelPresist = _placement.PIDPlaceLabel(SPPIDMAPPINGNAME, ref points, Rotation: ANGLE, LabeledItem: _LmConnector.AsLMRepresentation(), IsLeaderVisible: true);
90
                                _LmLabelPresist.Commit();
91
                                SPPID_ITEM_OBJECT = _LmLabelPresist;
92
                            }
93
                        }
94
                    }
95
                }
96
            }
97
            catch (Exception ex)
98
            {
99
                Log.WriteLine(ex);
100
                return false;
101
            }
102
            return true;
103
        }
104

  
105
        public override void SetAttribute(Document document)
106
        {
107
            try
108
            {
109
                Line targetLine = SPPIDUtill.FindObjectByUID(document, CONNECTLINE) as Line;
110
                if (targetLine != null)
111
                {
112
                    Placement _placement = new Placement();
113
                    LMPipeRun _pipeRun = _placement.PIDDataSource.GetPipeRun(targetLine.SPPID_ITEM_OBJECT.ToString());
114
                    if (_pipeRun != null)
115
                    {
116
                        foreach (ItemAttribute attr in ATTRIBUTES)
117
                        {
118
                            if (string.IsNullOrEmpty(attr.VALUE))
119
                                continue;
120

  
121
                            LMAAttribute lMAAttribute = _pipeRun.Attributes[attr.Attribute];
122
                            if (lMAAttribute != null)
123
                            {
124
                                if (DBNull.Value.Equals(lMAAttribute.get_Value()))
125
                                    lMAAttribute.set_Value(attr.VALUE);
126
                                else if (lMAAttribute.get_Value() != attr.VALUE)
127
                                    lMAAttribute.set_Value(attr.VALUE);
128
                            }
129
                        }
130
                        _pipeRun.Commit();
131
                    }
132
                }
133
            }
134
            catch (Exception ex)
135
            {
136
                Log.WriteLine(ex);
137
            }
138
        }
139
    }
140
}
DTI_PID/SPPIDConverter_AutoModeling/Model/SPPID/Other/Association.cs
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Linq;
5
using System.Runtime.InteropServices;
6
using System.Text;
7
using System.Threading.Tasks;
8
using Llama;
9
using Plaice;
10
using SPPID.Utill;
11
using SPPID.Modeling;
12

  
13
namespace SPPID.Model
14
{
15
    public class Association
16
    {
17
        private string _TYPE;
18
        private string _TYPE_VALUE;
19

  
20
        public string TYPE { get => _TYPE; set => _TYPE = value; }
21
        public string TYPE_VALUE { get => _TYPE_VALUE; set => _TYPE_VALUE = value; }
22
    }
23
}
DTI_PID/SPPIDConverter_AutoModeling/Model/SPPID/Other/Group.cs
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Linq;
5
using System.Runtime.InteropServices;
6
using System.Text;
7
using System.Threading.Tasks;
8
using Llama;
9
using Plaice;
10
using SPPID.Utill;
11
using SPPID.Modeling;
12

  
13
namespace SPPID.Model
14
{
15
    public class Group
16
    {
17
        private List<object> _Items = new List<object>();
18
        private bool _Enable = true;
19

  
20
        public List<object> Items { get => _Items; set => _Items = value; }
21
        public bool Enable { get => _Enable; set => _Enable = value; }
22
    }
23
}
DTI_PID/SPPIDConverter_AutoModeling/Model/SPPID/Other/ItemAttribute.cs
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Linq;
5
using System.Runtime.InteropServices;
6
using System.Text;
7
using System.Threading.Tasks;
8
using Llama;
9
using Plaice;
10
using SPPID.Utill;
11
using SPPID.Modeling;
12

  
13
namespace SPPID.Model
14
{
15
    public class ItemAttribute
16
    {
17
        #region Property
18
        private string _UID;
19
        private string _Length;
20
        private string _Expression;
21
        private string _DisplayAttribute;
22
        private string _AttributeType;
23
        private string _Attribute;
24
        private string _AttrAt;
25
        private string _SPPIDMAPPINGNAME;
26

  
27
        private string _VALUE;
28

  
29
        public string UID { get => _UID; set => _UID = value; }
30
        public string VALUE { get => _VALUE; set => _VALUE = value; }
31
        public string Length { get => _Length; set => _Length = value; }
32
        public string Expression { get => _Expression; set => _Expression = value; }
33
        public string DisplayAttribute { get => _DisplayAttribute; set => _DisplayAttribute = value; }
34
        public string AttributeType { get => _AttributeType; set => _AttributeType = value; }
35
        public string Attribute { get => _Attribute; set => _Attribute = value; }
36
        public string AttrAt { get => _AttrAt; set => _AttrAt = value; }
37
        public string SPPIDMAPPINGNAME { get => _SPPIDMAPPINGNAME; set => _SPPIDMAPPINGNAME = value; }
38
        #endregion
39
    }
40
}
DTI_PID/SPPIDConverter_AutoModeling/Model/SPPID/Other/PointInfo.cs
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Linq;
5
using System.Runtime.InteropServices;
6
using System.Text;
7
using System.Threading.Tasks;
8
using Llama;
9
using Plaice;
10
using SPPID.Utill;
11
using SPPID.Modeling;
12

  
13
namespace SPPID.Model
14
{
15
    public class PointInfo
16
    {
17
        public PointInfo(double x, double y)
18
        {
19
            this.x = x;
20
            this.y = y;
21
        }
22

  
23
        public enum PointType
24
        {
25
            None = 0,
26
            Run = 1,
27
            Branch = 2,
28
        }
29
        #region Property
30
        private double x;
31
        private double y;
32
        private PointType _Type;
33
        private string _ConnectedItem;
34
        private string _SP_ID;
35
        private SPPID_ITEM _ConnectedItemObject;
36

  
37
        public double X { get { return x; } set { x = value; } }
38
        public double Y { get { return y; } set { y = value; } }
39
        public PointType Type { get => _Type; set => _Type = value; }
40
        public string ConnectedItem { get => _ConnectedItem; set => _ConnectedItem = value; }
41
        public SPPID_ITEM ConnectedItemObject { get => _ConnectedItemObject; set => _ConnectedItemObject = value; }
42
        public string SP_ID { get => _SP_ID; set => _SP_ID = value; }
43
        #endregion
44
    }
45
}
DTI_PID/SPPIDConverter_AutoModeling/Model/SPPID/SpecBreak.cs
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Linq;
5
using System.Runtime.InteropServices;
6
using System.Text;
7
using System.Threading.Tasks;
8
using Llama;
9
using Plaice;
10
using SPPID.Utill;
11
using SPPID.Modeling;
12

  
13
namespace SPPID.Model
14
{
15
    class SpecBreak : SPPID_ITEM
16
    {
17
        #region Property
18
        private string _ORIGINALPOINT;
19
        private Dictionary<string, LMLabelPersist> sPPID_ITEM_OBJECT_LIST = new Dictionary<string, LMLabelPersist>();
20
        private List<Connector> _CONNECTORS = new List<Connector>();
21
        private string _CONNECTIONPOINT;
22
        private string _LOCATION;
23
        private string _SIZE;
24
        private double _ANGLE;
25
        private string _PARENT;
26
        private string _CHILD;
27
        private string _HASINSTRUMENTLABEL;
28
        private string _CURRENTPOINTMODEINDEX;
29
        private bool _DRAWCHECKED;
30
        private double _LOCATION_X;
31
        private double _LOCATION_Y;
32
        private int _MIRROR = 0;
33

  
34
        private string _UpStream;
35
        private string _DownStream;
36

  
37
        Dictionary<string, string[]> SpecItems = new Dictionary<string, string[]>();
38

  
39
        public string ORIGINALPOINT { get => _ORIGINALPOINT; set => _ORIGINALPOINT = value; }
40
        public string LOCATION { get => _LOCATION; set => _LOCATION = value; }
41
        public string SIZE { get => _SIZE; set => _SIZE = value; }
42
        public double ANGLE { get => _ANGLE; set => _ANGLE = value; }
43
        public string PARENT { get => _PARENT; set => _PARENT = value; }
44
        public string CHILD { get => _CHILD; set => _CHILD = value; }
45
        public string HASINSTRUMENTLABEL { get => _HASINSTRUMENTLABEL; set => _HASINSTRUMENTLABEL = value; }
46
        public string CURRENTPOINTMODEINDEX { get => _CURRENTPOINTMODEINDEX; set => _CURRENTPOINTMODEINDEX = value; }
47
        public bool DRAWCHECKED { get => _DRAWCHECKED; set => _DRAWCHECKED = value; }
48
        public double LOCATION_X { get => _LOCATION_X; set => _LOCATION_X = value; }
49
        public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; }
50
        public int MIRROR { get => _MIRROR; set => _MIRROR = value; }
51
        public List<Connector> CONNECTORS { get => _CONNECTORS; set => _CONNECTORS = value; }
52
        public string CONNECTIONPOINT { get => _CONNECTIONPOINT; set => _CONNECTIONPOINT = value; }
53
        public string UpStream { get => _UpStream; set => _UpStream = value; }
54
        public string DownStream { get => _DownStream; set => _DownStream = value; }
55
        public Dictionary<string, LMLabelPersist> SPPID_ITEM_OBJECT_LIST { get => sPPID_ITEM_OBJECT_LIST; set => sPPID_ITEM_OBJECT_LIST = value; }
56

  
57

  
58

  
59
        #endregion
60
        public override void AfterSetting(Document document)
61
        {
62
            ItemAttribute upStreamAttr = null;
63
            ItemAttribute downStreamAttr = null;
64
            foreach (ItemAttribute attribute in ATTRIBUTES)
65
            {
66
                if (attribute.Attribute == "UpStream")
67
                {
68
                    upStreamAttr = attribute;
69
                    UpStream = attribute.VALUE;
70
                }
71
                else if (attribute.Attribute == "DownStream")
72
                {
73
                    downStreamAttr = attribute;
74
                    DownStream = attribute.VALUE;
75
                }
76
                else
77
                {
78
                    string[] values = attribute.VALUE.Split(new char[] { ',' });
79
                    if (values.Length == 2)
80
                        SpecItems.Add(attribute.Attribute, values);
81
                }
82
            }
83
            ATTRIBUTES.Remove(upStreamAttr);
84
            ATTRIBUTES.Remove(downStreamAttr);
85

  
86
            // Angle Setting
87
            if (ANGLE == 1.57)
88
                ANGLE = 90 * Math.PI / 180;
89
            else if (ANGLE == 3.14)
90
                ANGLE = Math.PI;
91
            else if (ANGLE == 4.71)
92
                ANGLE = 270 * Math.PI / 180;
93
            else
94
                ANGLE = 0;
95
            // End
96

  
97
            // Location Setting
98
            SPPIDUtill.ConvertPointBystring(_ORIGINALPOINT, ref _LOCATION_X, ref _LOCATION_Y);
99
            SPPIDUtill.ConvertSPPIDPoint(ref _LOCATION_X, ref _LOCATION_Y, document.WIDTH, document.HEIGHT);
100
            // End
101

  
102
            // SPPID Type Setting
103
            SPPID_TYPE = SPPID_ITEM_TYPE.SYMBOL;
104
            // End
105

  
106
            // Input Drawing
107
            document.SPECBREAK.Add(this);
108
            // End
109
        }
110

  
111
        public override bool Modeling(Document document)
112
        {
113
            try
114
            {
115
                Placement _placement = new Placement();
116
                foreach (var item in SpecItems)
117
                {
118
                    LMLabelPersist _LmLabelPersist = null;
119
                    string name = item.Key;
120
                    string[] values = item.Value;
121
                    SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDSymbolMappingName(name, document.SymbolMapping);
122
                    if (!string.IsNullOrEmpty(SPPIDMAPPINGNAME))
123
                    {
124
                        Array array = new double[] { 0, LOCATION_X, LOCATION_Y };
125
                        LMConnector connectedLMConnector = null;
126
                        SPPID_ITEM upStreamItem = SPPIDUtill.FindObjectByUID(document, UpStream) as SPPID_ITEM;
127
                        SPPID_ITEM downStreamItem = SPPIDUtill.FindObjectByUID(document, DownStream) as SPPID_ITEM;
128

  
129
                        if (upStreamItem != null && downStreamItem != null && upStreamItem.SPPID_ITEM_OBJECT != null && downStreamItem.SPPID_ITEM_OBJECT != null)
130
                        {
131
                            if (typeof(Symbol) == upStreamItem.GetType() && typeof(Line) == downStreamItem.GetType())
132
                            {
133
                                LMSymbol _LMSymbol = upStreamItem.SPPID_ITEM_OBJECT as LMSymbol;
134
                                string symbolRepresentationId = _LMSymbol.AsLMRepresentation().Id;
135
                                string lineModelId = downStreamItem.SPPID_ITEM_OBJECT.ToString();
136

  
137

  
138

  
139
                                LMPipeRun _LMPipeRun = _placement.PIDDataSource.GetPipeRun(lineModelId);
140
                                if (_LMSymbol != null && _LMPipeRun != null)
141
                                {
142
                                    foreach (LMRepresentation rep in _LMPipeRun.Representations)
143
                                    {
144
                                        if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active")
145
                                        {
146
                                            LMConnector _LMConnector = _placement.PIDDataSource.GetConnector(rep.Id);
147
                                            if (_LMConnector.ConnectItem1SymbolID != null && !DBNull.Value.Equals(_LMConnector.ConnectItem1SymbolID) && _LMConnector.ConnectItem1SymbolID == symbolRepresentationId)
148
                                                connectedLMConnector = _LMConnector;
149
                                            else if (_LMConnector.ConnectItem2SymbolID != null && !DBNull.Value.Equals(_LMConnector.ConnectItem2SymbolID) && _LMConnector.ConnectItem2SymbolID == symbolRepresentationId)
150
                                                connectedLMConnector = _LMConnector;
151
                                        }
152
                                    }
153
                                }
154
                            }
155
                            else if (typeof(Symbol) == downStreamItem.GetType() && typeof(Line) == upStreamItem.GetType())
156
                            {
157
                                LMSymbol _LMSymbol = downStreamItem.SPPID_ITEM_OBJECT as LMSymbol;
158
                                string symbolRepresentationId = _LMSymbol.AsLMRepresentation().Id;
159
                                string lineModelId = upStreamItem.SPPID_ITEM_OBJECT.ToString();
160

  
161

  
162

  
163
                                LMPipeRun _LMPipeRun = _placement.PIDDataSource.GetPipeRun(lineModelId);
164
                                if (_LMSymbol != null && _LMPipeRun != null)
165
                                {
166
                                    foreach (LMRepresentation rep in _LMPipeRun.Representations)
167
                                    {
168
                                        if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active")
169
                                        {
170
                                            LMConnector _LMConnector = _placement.PIDDataSource.GetConnector(rep.Id);
171
                                            if (_LMConnector.ConnectItem1SymbolID != null && !DBNull.Value.Equals(_LMConnector.ConnectItem1SymbolID) && _LMConnector.ConnectItem1SymbolID == symbolRepresentationId)
172
                                                connectedLMConnector = _LMConnector;
173
                                            else if (_LMConnector.ConnectItem2SymbolID != null && !DBNull.Value.Equals(_LMConnector.ConnectItem2SymbolID) && _LMConnector.ConnectItem2SymbolID == symbolRepresentationId)
174
                                                connectedLMConnector = _LMConnector;
175
                                        }
176
                                    }
177
                                }
178
                            }
179
                        }
180

  
181
                        if (connectedLMConnector != null)
182
                        {
183
                            _LmLabelPersist = _placement.PIDPlaceLabel(SPPIDMAPPINGNAME, ref array, Rotation: ANGLE, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: true);
184
                        }
185
                    }
186

  
187
                    SPPID_ITEM_OBJECT_LIST.Add(name, _LmLabelPersist);
188
                }
189
            }
190
            catch (Exception ex)
191
            {
192
                Log.WriteLine(ex);
193
                return false;
194
            }
195
            return true;
196
        }
197

  
198

  
199
        public override void SetAttribute(Document document)
200
        {
201
            try
202
            {
203
                Placement _placement = new Placement();
204

  
205
                object upStreamItem = SPPIDUtill.FindObjectByUID(document, UpStream);
206
                object downStreamItem = SPPIDUtill.FindObjectByUID(document, DownStream);
207

  
208
                if (upStreamItem != null && downStreamItem != null)
209
                {
210
                    foreach (var item in SPPID_ITEM_OBJECT_LIST)
211
                    {
212
                        if (item.Value != null)
213
                        {
214
                            string name = item.Key;
215
                            string attributeName = SPPIDUtill.GetSPPIDAttributeMappingName(name, document.AttributeMapping);
216
                            if (!string.IsNullOrEmpty(attributeName))
217
                            {
218
                                string[] values = SpecItems[name];
219

  
220
                                if (upStreamItem.GetType() == typeof(Line))
221
                                    Line.SetAttribute(upStreamItem as Line, attributeName, values[0]);
222
                                if (downStreamItem.GetType() == typeof(Line))
223
                                    Line.SetAttribute(downStreamItem as Line, attributeName, values[1]);
224

  
225
                                if (upStreamItem.GetType() == typeof(Symbol))
226
                                    FindFirstLine(document, upStreamItem as Symbol, attributeName, values[0]);
227
                                if (downStreamItem.GetType() == typeof(Symbol))
228
                                    FindFirstLine(document, downStreamItem as Symbol, attributeName, values[1]);
229
                            }
230
                        }
231
                    }
232
                }
233
            }
234
            catch (Exception ex)
235
            {
236
                Log.WriteLine(ex);
237
            }
238
        }
239

  
240
        private void FindFirstLine(Document document,  Symbol symbol, string attrName, string value)
241
        {
242
            Placement _placement = new Placement();
243

  
244
            foreach (Connector connector in symbol.CONNECTORS)
245
            {
246
                Line line = SPPIDUtill.FindObjectByUID(document, connector.CONNECTEDITEM) as Line;
247
                if (line != null && line.SPPID_ITEM_OBJECT != null)
248
                {
249
                    LMPipeRun _LMPipeRun = _placement.PIDDataSource.GetPipeRun(line.SPPID_ITEM_OBJECT.ToString());
250
                    LMAAttribute _LMAAttribute = _LMPipeRun.Attributes[attrName];
251
                    if (_LMAAttribute != null)
252
                    {
253
                        if (DBNull.Value.Equals(_LMAAttribute.get_Value()))
254
                            _LMAAttribute.set_Value(value);
255
                        _LMPipeRun.Commit();
256
                    }
257
                }
258
            }
259
        }
260

  
261
    }
262
}
DTI_PID/SPPIDConverter_AutoModeling/Model/SPPID/Symbol.cs
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Linq;
5
using System.Runtime.InteropServices;
6
using System.Text;
7
using System.Threading.Tasks;
8
using Llama;
9
using Plaice;
10
using SPPID.Utill;
11
using SPPID.Modeling;
12

  
13
namespace SPPID.Model
14
{
15
    public class Symbol : SPPID_ITEM
16
    {
17
        #region Property
18
        private string _ORIGINALPOINT;
19
        private List<Association> _ASSOCIATIONS = new List<Association>();
20
        private List<Connector> _CONNECTORS = new List<Connector>();
21
        private string _CONNECTIONPOINT;
22
        private string _LOCATION;
23
        private string _SIZE;
24
        private double _ANGLE;
25
        private string _PARENT;
26
        private string _CHILD;
27
        private List<SymbolChild> _CHILD_LIST = new List<SymbolChild>();
28
        private string _HASINSTRUMENTLABEL;
29
        private string _CURRENTPOINTMODEINDEX;
30
        private bool _DRAWCHECKED;
31
        private double _LOCATION_X;
32
        private double _LOCATION_Y;
33
        private int _MIRROR = 0;
34

  
35
        public string ORIGINALPOINT { get => _ORIGINALPOINT; set => _ORIGINALPOINT = value; }
36
        public string LOCATION { get => _LOCATION; set => _LOCATION = value; }
37
        public string SIZE { get => _SIZE; set => _SIZE = value; }
38
        public double ANGLE { get => _ANGLE; set => _ANGLE = value; }
39
        public string PARENT { get => _PARENT; set => _PARENT = value; }
40
        public string CHILD { get => _CHILD; set => _CHILD = value; }
41
        public string HASINSTRUMENTLABEL { get => _HASINSTRUMENTLABEL; set => _HASINSTRUMENTLABEL = value; }
42
        public string CURRENTPOINTMODEINDEX { get => _CURRENTPOINTMODEINDEX; set => _CURRENTPOINTMODEINDEX = value; }
43
        public bool DRAWCHECKED { get => _DRAWCHECKED; set => _DRAWCHECKED = value; }
44
        public double LOCATION_X { get => _LOCATION_X; set => _LOCATION_X = value; }
45
        public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; }
46
        public int MIRROR { get => _MIRROR; set => _MIRROR = value; }
47
        public List<Connector> CONNECTORS { get => _CONNECTORS; set => _CONNECTORS = value; }
48
        public string CONNECTIONPOINT { get => _CONNECTIONPOINT; set => _CONNECTIONPOINT = value; }
49
        public List<SymbolChild> CHILD_LIST { get => _CHILD_LIST; set => _CHILD_LIST = value; }
50
        public List<Association> ASSOCIATIONS { get => _ASSOCIATIONS; set => _ASSOCIATIONS = value; }
51
        #endregion
52
        public override void AfterSetting(Document document)
53
        {
54
            // SPPIDMAPPINGNAME Setting
55
            SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDSymbolMappingName(PARENT, document.SymbolMapping);
56
            // End
57

  
58
            // Angle Setting
59
            if (ANGLE == 1.57)
60
                ANGLE = 90 * Math.PI / 180;
61
            else if (ANGLE == 3.14)
62
                ANGLE = Math.PI;
63
            else if (ANGLE == 4.71)
64
                ANGLE = 270 * Math.PI / 180;
65
            else
66
                ANGLE = 0;
67
            // End
68

  
69
            // Location Setting
70
            SPPIDUtill.ConvertPointBystring(_ORIGINALPOINT, ref _LOCATION_X, ref _LOCATION_Y);
71
            SPPIDUtill.ConvertSPPIDPoint(ref _LOCATION_X, ref _LOCATION_Y, document.WIDTH, document.HEIGHT);
72
            // End
73

  
74
            // SPPID Type Setting
75
            SPPID_TYPE = SPPID_ITEM_TYPE.SYMBOL;
76
            // End
77

  
78
            // Child Setting
79
            if (!string.IsNullOrEmpty(CHILD) && CHILD != "None")
80
            {
81
                string[] array = CHILD.Split(new char[] { '/' });
82
                for (int i = 0; i < array.Length; i++)
83
                {
84
                    string[] childArray = array[i].Split(new char[] { ',' });
85
                    SymbolChild child = new SymbolChild()
86
                    {
87
                        Arrow = childArray[0],
88
                        Name = childArray[1],
89
                        Index = i + 1,
90
                    };
91
                    child.SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDSymbolMappingName(child.Name, document.SymbolMapping);
92
                    CHILD_LIST.Add(child);
93
                }
94
            }
95
            // End
96

  
97
            // ConnectionPoint Setting
98
            if (!string.IsNullOrEmpty(CONNECTIONPOINT) && CONNECTIONPOINT != "None")
99
            {
100
                string[] array = CONNECTIONPOINT.Split(new char[] { '/' });
101
                for (int i = 0; i < array.Length; i++)
102
                {
103
                    string[] arrConn = array[i].Split(new char[] { ',' });
104
                    CONNECTORS[i].INDEX = Convert.ToInt32(arrConn[3]);
105
                }
106
            }
107
            // End
108

  
109
            // Input Drawing
110
            document.SYMBOLS.Add(this);
111
            // End
112
        }
113

  
114
        public override bool Modeling(Document document)
... 이 차이점은 표시할 수 있는 최대 줄수를 초과해서 이 차이점은 잘렸습니다.

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)