프로젝트

일반

사용자정보

개정판 68464385

ID684643856d4f0addb9c759d2ca909e9d6b197ef6
상위 0a4292cc
하위 c65ef6a5, 5a83fda2

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

dev issue #000 : LineNumberModeling 수정

Change-Id: I848740e9e1a177245069994b7f13dc0bb8d4a1bb

차이점 보기:

DTI_PID/SPPIDConverter/AutoModeling.cs
1355 1355
            return targetConnector;
1356 1356
        }
1357 1357

  
1358
        private LMConnector FindTargetLMConnectorForLabel(Dictionary<LMConnector, List<double[]>> connectorVertices, double connX, double connY)
1359
        {
1360
            double length = double.MaxValue;
1361
            LMConnector targetConnector = null;
1362
            foreach (var item in connectorVertices)
1363
            {
1364
                List<double[]> points = item.Value;
1365
                for (int i = 0; i < points.Count - 1; i++)
1366
                {
1367
                    double[] point1 = points[i];
1368
                    double[] point2 = points[i + 1];
1369
                    double x1 = Math.Min(point1[0], point2[0]);
1370
                    double y1 = Math.Min(point1[1], point2[1]);
1371
                    double x2 = Math.Max(point1[0], point2[0]);
1372
                    double y2 = Math.Max(point1[1], point2[1]);
1373

  
1374
                    if ((x1 <= connX && x2 >= connX) ||
1375
                        (y1 <= connY && y2 >= connY))
1376
                    {
1377
                        double distance = SPPIDUtil.CalcPointToPointdDistance(point1[0], point1[1], connX, connY);
1378
                        if (length >= distance)
1379
                        {
1380
                            targetConnector = item.Key;
1381
                            length = distance;
1382
                        }
1383

  
1384
                        distance = SPPIDUtil.CalcPointToPointdDistance(point2[0], point2[1], connX, connY);
1385
                        if (length >= distance)
1386
                        {
1387
                            targetConnector = item.Key;
1388
                            length = distance;
1389
                        }
1390
                    }
1391
                }
1392
            }
1393

  
1394
            // 못찾았을때.
1395
            length = double.MaxValue;
1396
            if (targetConnector == null)
1397
            {
1398
                foreach (var item in connectorVertices)
1399
                {
1400
                    List<double[]> points = item.Value;
1401

  
1402
                    foreach (double[] point in points)
1403
                    {
1404
                        double distance = SPPIDUtil.CalcPointToPointdDistance(point[0], point[1], connX, connY);
1405
                        if (length >= distance)
1406
                        {
1407
                            targetConnector = item.Key;
1408
                            length = distance;
1409
                        }
1410
                    }
1411
                }
1412
            }
1413

  
1414
            return targetConnector;
1415
        }
1416

  
1358 1417
        private void LineNumberModeling(LineNumber lineNumber)
1359 1418
        {
1360 1419
            Line line = SPPIDUtil.FindObjectByUID(document, lineNumber.CONNLINE) as Line;
1361 1420
            Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(line.SPPID.ModelItemId);
1362
            LMConnector connectedLMConnector = FindTargetLMConnectorByPoint(connectorVertices, lineNumber.SPPID.ORIGINAL_X, lineNumber.SPPID.ORIGINAL_Y);
1421
            LMConnector connectedLMConnector = FindTargetLMConnectorForLabel(connectorVertices, lineNumber.SPPID.ORIGINAL_X, lineNumber.SPPID.ORIGINAL_Y);
1363 1422
            if (connectedLMConnector != null)
1364 1423
            {
1365 1424
                double x = 0;
......
1387 1446

  
1388 1447
        private void InputLineNumberAttribute(LineNumber lineNumber)
1389 1448
        {
1390
            foreach (var run in lineNumber.RUNS)
1449
            if (lineNumber.UID == "02425e4f-7a41-4334-afa6-83decda9f2d4")
1450
            {
1451

  
1452
            }
1453
            Line line = SPPIDUtil.FindObjectByUID(document, lineNumber.CONNLINE) as Line;
1454
            if (line != null)
1391 1455
            {
1392
                foreach (var item in run.RUNITEMS)
1456
                LMModelItem _LMModelItem = dataSource.GetModelItem(line.SPPID.ModelItemId);
1457
                if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active")
1393 1458
                {
1394
                    if (item.GetType() == typeof(Line))
1459
                    foreach (var attribute in lineNumber.ATTRIBUTES)
1395 1460
                    {
1396
                        Line line = item as Line;
1397
                        LMModelItem _LMModelItem = dataSource.GetModelItem(line.SPPID.ModelItemId);
1398
                        if (_LMModelItem.get_ItemStatus() == "Active")
1461
                        LineNumberMapping mapping = document.LineNumberMappings.Find(x => x.UID == attribute.UID);
1462
                        if (mapping != null)
1399 1463
                        {
1400
                            foreach (var attribute in lineNumber.ATTRIBUTES)
1464
                            LMAAttribute _LMAAttribute = _LMModelItem.Attributes[mapping.SPPIDATTRIBUTENAME];
1465
                            if (_LMAAttribute != null)
1401 1466
                            {
1402
                                LineNumberMapping mapping = document.LineNumberMappings.Find(x => x.UID == attribute.UID);
1403
                                if (mapping != null)
1404
                                {
1405
                                    LMAAttribute _LMAAttribute = _LMModelItem.Attributes[mapping.SPPIDATTRIBUTENAME];
1406
                                    if (_LMAAttribute != null)
1407
                                    {
1408
                                        if (DBNull.Value.Equals(_LMAAttribute.get_Value()))
1409
                                            _LMAAttribute.set_Value(attribute.VALUE);
1410
                                        else if (_LMAAttribute.get_Value() != attribute.VALUE)
1411
                                            _LMAAttribute.set_Value(attribute.VALUE);
1412
                                    }
1413
                                }
1467
                                if (DBNull.Value.Equals(_LMAAttribute.get_Value()))
1468
                                    _LMAAttribute.set_Value(attribute.VALUE);
1469
                                else if (_LMAAttribute.get_Value() != attribute.VALUE)
1470
                                    _LMAAttribute.set_Value(attribute.VALUE);
1471
                                _LMModelItem.Commit();
1414 1472
                            }
1415
                            _LMModelItem.Commit();
1416
                            break;
1417 1473
                        }
1418
                        ReleaseCOMObjects(_LMModelItem);
1419 1474
                    }
1420 1475
                }
1476
                ReleaseCOMObjects(_LMModelItem);
1421 1477
            }
1422 1478
        }
1423 1479

  

내보내기 Unified diff

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