프로젝트

일반

사용자정보

개정판 5173ba5d

ID5173ba5d08626fbf5f36c60d7903e7215dc1087a
상위 026f394f
하위 1805d3b7, b2aa4cee

gaqhf 이(가) 5년 이상 전에 추가함

dev issue #000 : remodeling line 수정 / Clear Attribute 수정

Change-Id: Ia3a3a64e5ba0dd9ebbef7e5b994cd1a0cc618ccc

차이점 보기:

DTI_PID/SPPIDConverter/AutoModeling.cs
133 133
                        try
134 134
                        {
135 135
                            NewLineModeling(item);
136
                            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, document.LINES.FindAll(x => !string.IsNullOrEmpty(x.SPPID.ModelItemId)).Count);
136
                            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null);
137 137
                        }
138 138
                        catch (Exception ex)
139 139
                        {
......
154 154
                        {
155 155
                            SortBranchLines();
156 156
                            NewLineModeling(item, true);
157
                            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, branchCount - NewBranchLines.Count);
157
                            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null);
158 158
                        }
159 159
                        catch (Exception ex)
160 160
                        {
......
169 169
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.SYMBOLS.Count + document.LINES.Count);
170 170
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Clear Attribute");
171 171
                    SetSystemEditingCommand(false);
172
                    for (int i = 0; i < document.SYMBOLS.Count; i++)
172
                    List<string> endClearModelItemID = new List<string>();
173
                    for (int i = 0; i < document.LINES.Count; i++)
173 174
                    {
174
                        Symbol item = document.SYMBOLS[i];
175
                        string modelItemID = item.SPPID.ModelItemID;
175
                        Line item = document.LINES[i];
176
                        string modelItemID = item.SPPID.ModelItemId;
176 177
                        if (!string.IsNullOrEmpty(modelItemID))
177 178
                        {
178 179
                            LMModelItem modelItem = dataSource.GetModelItem(modelItemID);
......
181 182
                                LMAAttribute attribute = modelItem.Attributes["NominalDiameter"];
182 183
                                if (attribute != null)
183 184
                                    attribute.set_Value(DBNull.Value);
184
                                attribute = modelItem.Attributes["PipingPoint1.NominalDiameter"];
185
                                if (attribute != null)
186
                                    attribute.set_Value(DBNull.Value);
187
                                attribute = modelItem.Attributes["PipingPoint2.NominalDiameter"];
188
                                if (attribute != null)
189
                                    attribute.set_Value(DBNull.Value);
190 185

  
191 186
                                modelItem.Commit();
192 187
                                ReleaseCOMObjects(modelItem);
193 188
                            }
194 189
                        }
195
                        SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, i + 1);
190
                        if (!endClearModelItemID.Contains(modelItemID))
191
                            endClearModelItemID.Add(modelItemID);
192
                        SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null);
196 193
                    }
197
                    for (int i = 0; i < document.LINES.Count; i++)
194

  
195
                    for (int i = 0; i < document.SYMBOLS.Count; i++)
198 196
                    {
199
                        Line item = document.LINES[i];
200
                        string modelItemID = item.SPPID.ModelItemId;
197
                        Symbol item = document.SYMBOLS[i];
198
                        string repID = item.SPPID.RepresentationId;
199
                        string modelItemID = item.SPPID.ModelItemID;
201 200
                        if (!string.IsNullOrEmpty(modelItemID))
202 201
                        {
203 202
                            LMModelItem modelItem = dataSource.GetModelItem(modelItemID);
......
206 205
                                LMAAttribute attribute = modelItem.Attributes["NominalDiameter"];
207 206
                                if (attribute != null)
208 207
                                    attribute.set_Value(DBNull.Value);
208
                                attribute = modelItem.Attributes["PipingPoint1.NominalDiameter"];
209
                                if (attribute != null)
210
                                    attribute.set_Value(DBNull.Value);
211
                                attribute = modelItem.Attributes["PipingPoint2.NominalDiameter"];
212
                                if (attribute != null)
213
                                    attribute.set_Value(DBNull.Value);
214
                                modelItem.Commit();
209 215

  
210 216
                                modelItem.Commit();
211 217
                                ReleaseCOMObjects(modelItem);
212 218
                            }
213 219
                        }
220
                        if (!string.IsNullOrEmpty(repID))
221
                        {
222
                            LMSymbol symbol = dataSource.GetSymbol(repID);
223
                            if (symbol != null)
224
                            {
225
                                foreach (LMConnector connector in symbol.Connect1Connectors)
226
                                {
227
                                    if (connector.get_ItemStatus() == "Active" && !endClearModelItemID.Contains(connector.ModelItemID))
228
                                    {
229
                                        endClearModelItemID.Add(connector.ModelItemID);
230
                                        LMModelItem modelItem = connector.ModelItemObject;
231
                                        if (modelItem != null)
232
                                        {
233
                                            LMAAttribute attribute = modelItem.Attributes["NominalDiameter"];
234
                                            if (attribute != null)
235
                                                attribute.set_Value(DBNull.Value);
214 236

  
215
                        SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, document.SYMBOLS.Count + i + 1);
237
                                            modelItem.Commit();
238
                                            ReleaseCOMObjects(modelItem);
239
                                        }
240
                                    }
241
                                }
242
                                foreach (LMConnector connector in symbol.Connect2Connectors)
243
                                {
244
                                    if (connector.get_ItemStatus() == "Active" && !endClearModelItemID.Contains(connector.ModelItemID))
245
                                    {
246
                                        endClearModelItemID.Add(connector.ModelItemID);
247
                                        LMModelItem modelItem = connector.ModelItemObject;
248
                                        if (modelItem != null)
249
                                        {
250
                                            LMAAttribute attribute = modelItem.Attributes["NominalDiameter"];
251
                                            if (attribute != null)
252
                                                attribute.set_Value(DBNull.Value);
253

  
254
                                            modelItem.Commit();
255
                                            ReleaseCOMObjects(modelItem);
256
                                        }
257
                                    }
258
                                }
259
                                ReleaseCOMObjects(symbol);
260
                            }
261
                        }
262
                        SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null);
216 263
                    }
264
                    
217 265
                    #region RadApp 방식
218 266
                    //SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, radApp.ActiveDocument.ActiveSheet.Symbols.Count + radApp.ActiveDocument.ActiveSheet.AllDependencyObjects.Count);
219 267
                    //SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Clear Attribute");
......
292 340
                    SetSystemEditingCommand(true);
293 341
                    #endregion
294 342

  
295
                    //// EndBreak Modeling
296
                    //SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "EndBreaks Modeling");
297
                    //foreach (var item in document.EndBreaks)
298
                    //    try
299
                    //    {
300
                    //        EndBreakModeling(item);
301
                    //    }
302
                    //    catch (Exception ex)
303
                    //    {
304
                    //        Log.Write("Error in EndBreakModeling");
305
                    //        Log.Write("UID : " + item.UID);
306
                    //        Log.Write(ex.Message);
307
                    //        Log.Write(ex.StackTrace);
308
                    //    }
343
                    // EndBreak Modeling
344
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.EndBreaks.Count);
345
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "EndBreaks Modeling");
346
                    foreach (var item in document.EndBreaks)
347
                        try
348
                        {
349
                            EndBreakModeling(item);
350
                            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null);
351
                            if (string.IsNullOrEmpty(item.SPPID.ModelItemID))
352
                                Log.Write("Fail modeling endbreak UID : " + item.UID);
353
                        }
354
                        catch (Exception ex)
355
                        {
356
                            Log.Write("Error in EndBreakModeling");
357
                            Log.Write("UID : " + item.UID);
358
                            Log.Write(ex.Message);
359
                            Log.Write(ex.StackTrace);
360
                        }
309 361

  
310 362

  
311
                    //// SpecBreak Modeling
312
                    //SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "SpecBreaks Modeling");
313
                    //foreach (var item in document.SpecBreaks)
314
                    //    try
315
                    //    {
316
                    //        SpecBreakModeling(item);
317
                    //    }
318
                    //    catch (Exception ex)
319
                    //    {
320
                    //        Log.Write("Error in SpecBreakModeling");
321
                    //        Log.Write("UID : " + item.UID);
322
                    //        Log.Write(ex.Message);
323
                    //        Log.Write(ex.StackTrace);
324
                    //    }
363
                    // SpecBreak Modeling
364
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.SpecBreaks.Count);
365
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "SpecBreaks Modeling");
366
                    foreach (var item in document.SpecBreaks)
367
                        try
368
                        {
369
                            SpecBreakModeling(item);
370
                            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null);
371
                            if (string.IsNullOrEmpty(item.SPPID.ModelItemID))
372
                                Log.Write("Fail modeling specbreak UID : " + item.UID);
373
                        }
374
                        catch (Exception ex)
375
                        {
376
                            Log.Write("Error in SpecBreakModeling");
377
                            Log.Write("UID : " + item.UID);
378
                            Log.Write(ex.Message);
379
                            Log.Write(ex.StackTrace);
380
                        }
325 381

  
326 382

  
327 383
                    //// LineNumber Modeling
......
1342 1398
            ReleaseCOMObjects(_LMSymbol);
1343 1399
        }
1344 1400

  
1345
        private void NewLineModeling(Line line, bool isBranchModeling = false)
1401
        private void NewLineModeling(Line line, bool isBranchModeling = false, Tuple<LMConnector, bool, bool> reModelingInfo = null)
1346 1402
        {
1347 1403
            if (!string.IsNullOrEmpty(line.SPPID.ModelItemId) || (NewBranchLines.Contains(line) && !isBranchModeling))
1348 1404
                return;
......
1353 1409

  
1354 1410
            foreach (var groupLine in group)
1355 1411
            {
1356
                try
1412
                if (!isBranchModeling && SPPIDUtil.IsBranchLine(groupLine))
1413
                {
1414
                    NewBranchLines.Add(groupLine);
1415
                    continue;
1416
                }
1417

  
1418
                _LMAItem _LMAItem = _placement.PIDCreateItem(groupLine.SPPID.MAPPINGNAME);
1419
                LMSymbol _LMSymbolStart = null;
1420
                LMSymbol _LMSymbolEnd = null;
1421
                PlaceRunInputs placeRunInputs = new PlaceRunInputs();
1422
                foreach (var connector in groupLine.CONNECTORS)
1357 1423
                {
1358
                    if (!isBranchModeling && SPPIDUtil.IsBranchLine(groupLine))
1424
                    double x = 0;
1425
                    double y = 0;
1426
                    GetTargetLineConnectorPoint(connector, groupLine, ref x, ref y);
1427
                    if (connector.ConnectedObject == null)
1359 1428
                    {
1360
                        NewBranchLines.Add(groupLine);
1361
                        continue;
1429
                        placeRunInputs.AddPoint(x, y);
1362 1430
                    }
1363

  
1364
                    _LMAItem _LMAItem = _placement.PIDCreateItem(groupLine.SPPID.MAPPINGNAME);
1365
                    PlaceRunInputs placeRunInputs = new PlaceRunInputs();
1366
                    foreach (var connector in groupLine.CONNECTORS)
1431
                    else if (connector.ConnectedObject.GetType() == typeof(Symbol))
1367 1432
                    {
1368
                        double x = 0;
1369
                        double y = 0;
1370
                        GetTargetLineConnectorPoint(connector, groupLine, ref x, ref y);
1371
                        if (connector.ConnectedObject == null)
1433
                        Symbol targetSymbol = connector.ConnectedObject as Symbol;
1434
                        if (groupLine.CONNECTORS.IndexOf(connector) == 0)
1372 1435
                        {
1373
                            placeRunInputs.AddPoint(x, y);
1436
                            _LMSymbolStart = GetTargetSymbol(targetSymbol, groupLine);
1437
                            placeRunInputs.AddSymbolTarget(_LMSymbolStart, x, y);
1374 1438
                        }
1375
                        else if (connector.ConnectedObject.GetType() == typeof(Symbol))
1439
                        else
1376 1440
                        {
1377
                            Symbol targetSymbol = connector.ConnectedObject as Symbol;
1378
                            LMSymbol _LMSymbol = GetTargetSymbol(targetSymbol, groupLine);
1379
                            placeRunInputs.AddSymbolTarget(_LMSymbol, x, y);
1441
                            _LMSymbolEnd = GetTargetSymbol(targetSymbol, groupLine);
1442
                            placeRunInputs.AddSymbolTarget(_LMSymbolEnd, x, y);
1380 1443
                        }
1381
                        else if (connector.ConnectedObject.GetType() == typeof(Line))
1444
                    }
1445
                    else if (connector.ConnectedObject.GetType() == typeof(Line))
1446
                    {
1447
                        Line targetLine = connector.ConnectedObject as Line;
1448
                        if (!string.IsNullOrEmpty(targetLine.SPPID.ModelItemId))
1382 1449
                        {
1383
                            Line targetLine = connector.ConnectedObject as Line;
1384
                            if (!string.IsNullOrEmpty(targetLine.SPPID.ModelItemId))
1450
                            LMConnector targetConnector = FindTargetLMConnectorForBranch(line, targetLine, ref x, ref y);
1451
                            placeRunInputs.AddConnectorTarget(targetConnector, x, y);
1452
                            ChangeLineSPPIDCoordinateByConnector(groupLine, targetLine, x, y, false);
1453
                        }
1454
                        else
1455
                        {
1456
                            if (groupLine.CONNECTORS.IndexOf(connector) == 0)
1385 1457
                            {
1386
                                LMConnector targetConnector = FindTargetLMConnectorForBranch(line, targetLine, ref x, ref y);
1387
                                placeRunInputs.AddConnectorTarget(targetConnector, x, y);
1388
                                ChangeLineSPPIDCoordinateByConnector(groupLine, targetLine, x, y, false);
1458
                                if (groupLine.SlopeType == SlopeType.HORIZONTAL)
1459
                                    placeRunInputs.AddPoint(x, -0.1);
1460
                                else if (groupLine.SlopeType == SlopeType.VERTICAL)
1461
                                    placeRunInputs.AddPoint(-0.1, y);
1462
                                else
1463
                                    placeRunInputs.AddPoint(x, -0.1);
1389 1464
                            }
1390
                            else
1391
                            {
1392
                                if (groupLine.CONNECTORS.IndexOf(connector) == 0)
1393
                                {
1394
                                    if (groupLine.SlopeType == SlopeType.HORIZONTAL)
1395
                                        placeRunInputs.AddPoint(x, -0.1);
1396
                                    else if (groupLine.SlopeType == SlopeType.VERTICAL)
1397
                                        placeRunInputs.AddPoint(-0.1, y);
1398
                                    else
1399
                                        placeRunInputs.AddPoint(x, -0.1);
1400
                                }
1401 1465

  
1402
                                placeRunInputs.AddPoint(x, y);
1466
                            placeRunInputs.AddPoint(x, y);
1403 1467

  
1404
                                if (groupLine.CONNECTORS.IndexOf(connector) == 1)
1405
                                {
1406
                                    if (groupLine.SlopeType == SlopeType.HORIZONTAL)
1407
                                        placeRunInputs.AddPoint(x, -0.1);
1408
                                    else if (groupLine.SlopeType == SlopeType.VERTICAL)
1409
                                        placeRunInputs.AddPoint(-0.1, y);
1410
                                    else
1411
                                        placeRunInputs.AddPoint(x, -0.1);
1412
                                }
1468
                            if (groupLine.CONNECTORS.IndexOf(connector) == 1)
1469
                            {
1470
                                if (groupLine.SlopeType == SlopeType.HORIZONTAL)
1471
                                    placeRunInputs.AddPoint(x, -0.1);
1472
                                else if (groupLine.SlopeType == SlopeType.VERTICAL)
1473
                                    placeRunInputs.AddPoint(-0.1, y);
1474
                                else
1475
                                    placeRunInputs.AddPoint(x, -0.1);
1413 1476
                            }
1414 1477
                        }
1415 1478
                    }
1479
                }
1416 1480

  
1417
                    LMConnector _lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs);
1418
                    if (_lMConnector != null)
1419
                    {
1420
                        groupLine.SPPID.ModelItemId = _lMConnector.ModelItemID;
1421
                        ReleaseCOMObjects(_lMConnector);
1422
                    }
1481
                LMConnector _lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs);
1482
                if (_lMConnector != null)
1483
                {
1484
                    groupLine.SPPID.ModelItemId = _lMConnector.ModelItemID;
1485
                    bool bRemodelingStart = false;
1486
                    if (_LMSymbolStart != null)
1487
                        NeedReModeling(groupLine, _LMSymbolStart, ref bRemodelingStart);
1488
                    bool bRemodelingEnd = false;
1489
                    if (_LMSymbolEnd != null)
1490
                        NeedReModeling(groupLine, _LMSymbolEnd, ref bRemodelingEnd);
1423 1491

  
1424
                    List<object> removeLines = groupLine.CONNECTORS.FindAll(x =>
1425
                    x.ConnectedObject != null &&
1426
                    x.ConnectedObject.GetType() == typeof(Line) &&
1427
                    !string.IsNullOrEmpty(((Line)x.ConnectedObject).SPPID.ModelItemId))
1428
                    .Select(x => x.ConnectedObject)
1429
                    .ToList();
1492
                    if (bRemodelingStart || bRemodelingEnd)
1493
                        ReModelingLine(groupLine, _lMConnector, _LMSymbolStart, _LMSymbolEnd, bRemodelingStart, bRemodelingEnd);
1494
                    
1495
                    ReleaseCOMObjects(_lMConnector);
1496
                }
1430 1497

  
1431
                    foreach (var item in removeLines)
1432
                        RemoveLineForModeling(item as Line);
1498
                List<object> removeLines = groupLine.CONNECTORS.FindAll(x =>
1499
                x.ConnectedObject != null &&
1500
                x.ConnectedObject.GetType() == typeof(Line) &&
1501
                !string.IsNullOrEmpty(((Line)x.ConnectedObject).SPPID.ModelItemId))
1502
                .Select(x => x.ConnectedObject)
1503
                .ToList();
1433 1504

  
1434
                    if (_LMAItem != null)
1435
                        ReleaseCOMObjects(_LMAItem);
1436
                    if (placeRunInputs != null)
1437
                        ReleaseCOMObjects(placeRunInputs);
1505
                foreach (var item in removeLines)
1506
                    RemoveLineForModeling(item as Line);
1438 1507

  
1439
                    if (isBranchModeling && NewBranchLines.Contains(groupLine))
1440
                        NewBranchLines.Remove(groupLine);
1441
                }
1442
                catch (Exception ex)
1443
                {
1444
                    throw new Exception(groupLine.UID);
1445
                }
1508
                if (_LMAItem != null)
1509
                    ReleaseCOMObjects(_LMAItem);
1510
                if (placeRunInputs != null)
1511
                    ReleaseCOMObjects(placeRunInputs);
1512
                if (_LMSymbolStart != null)
1513
                    ReleaseCOMObjects(_LMSymbolStart);
1514
                if (_LMSymbolEnd != null)
1515
                    ReleaseCOMObjects(_LMSymbolEnd);
1516

  
1517
                if (isBranchModeling && NewBranchLines.Contains(groupLine))
1518
                    NewBranchLines.Remove(groupLine);
1446 1519
            }
1447 1520
        }
1448 1521

  
......
1680 1753
        /// <param name="prevLMConnector"></param>
1681 1754
        /// <param name="startSymbol"></param>
1682 1755
        /// <param name="endSymbol"></param>
1683
        private void ReModelingLine(List<Line> lines, LMConnector prevLMConnector, LMSymbol startSymbol, LMSymbol endSymbol, bool bStart, bool bEnd)
1756
        private void ReModelingLine(Line line, LMConnector prevLMConnector, LMSymbol startSymbol, LMSymbol endSymbol, bool bStart, bool bEnd)
1684 1757
        {
1685 1758
            string symbolPath = string.Empty;
1686 1759
            #region get symbol path
......
1813 1886
                    ReleaseCOMObjects(_LMAItem);
1814 1887
                }
1815 1888

  
1816
                foreach (var line in lines)
1817
                    line.SPPID.ModelItemId = newConnector.ModelItemID;
1889
                line.SPPID.ModelItemId = newConnector.ModelItemID;
1818 1890
                ReleaseCOMObjects(newConnector);
1819 1891
            }
1820 1892

  
......
1921 1993
            {
1922 1994
                Array array = new double[] { 0, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y };
1923 1995
                LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: true);
1996
                if (_LmLabelPersist != null)
1997
                {
1998
                    endBreak.SPPID.RepresentationId = _LmLabelPersist.AsLMRepresentation().Id;
1999
                    endBreak.SPPID.ModelItemID = _LmLabelPersist.ModelItemID;
2000
                    endBreak.SPPID.GraphicOID = _LmLabelPersist.get_GraphicOID();
2001
                    ReleaseCOMObjects(_LmLabelPersist);
2002
                }
2003
                ReleaseCOMObjects(targetLMConnector);
1924 2004
            }
1925 2005
        }
1926 2006

  
......
2033 2113

  
2034 2114
                            if (_LmLabelPersist != null)
2035 2115
                            {
2116
                                specBreak.SPPID.RepresentationId = _LmLabelPersist.AsLMRepresentation().Id;
2117
                                specBreak.SPPID.ModelItemID = _LmLabelPersist.ModelItemID;
2118
                                specBreak.SPPID.GraphicOID = _LmLabelPersist.get_GraphicOID();
2036 2119
                                ReleaseCOMObjects(_LmLabelPersist);
2037 2120
                            }
2038 2121
                        }

내보내기 Unified diff

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