개정판 119db452
Modify segment break position and position
Change-Id: I2c14fd50ab71c85f5926143c6f2e81c9b51dc6e6
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
50 | 50 |
public string DocumentLabelText { get; set; } |
51 | 51 |
|
52 | 52 |
List<double[]> itemRange = new List<double[]>(); |
53 |
List<double[]> endBreakRange = new List<double[]>(); |
|
53 | 54 |
|
54 | 55 |
List<Line> BranchLines = new List<Line>(); |
55 | 56 |
List<string> ZeroLengthSymbolToSymbolModelItemID = new List<string>(); |
... | ... | |
1319 | 1320 |
{ |
1320 | 1321 |
ETCSetting setting = ETCSetting.GetInstance(); |
1321 | 1322 |
|
1322 |
if (!string.IsNullOrEmpty(setting.BorderFilePath) && System.IO.File.Exists(setting.BorderFilePath))
|
|
1323 |
if (!string.IsNullOrEmpty(setting.BorderFilePath)) |
|
1323 | 1324 |
{ |
1324 |
foreach (Ingr.RAD2D.SmartFrame2d smartFrame in radApp.ActiveDocument.ActiveSheet.SmartFrames2d)
|
|
1325 |
if (System.IO.File.Exists(setting.BorderFilePath))
|
|
1325 | 1326 |
{ |
1326 |
if (!string.IsNullOrEmpty(smartFrame.LinkMoniker) && smartFrame.LinkMoniker != setting.BorderFilePath)
|
|
1327 |
foreach (Ingr.RAD2D.SmartFrame2d smartFrame in radApp.ActiveDocument.ActiveSheet.SmartFrames2d)
|
|
1327 | 1328 |
{ |
1328 |
smartFrame.ChangeSource(Ingr.RAD2D.OLEInsertionTypeConstant.igOLELinked, setting.BorderFilePath, true); |
|
1329 |
smartFrame.Update(); |
|
1329 |
if (!string.IsNullOrEmpty(smartFrame.LinkMoniker) && smartFrame.LinkMoniker != setting.BorderFilePath) |
|
1330 |
{ |
|
1331 |
smartFrame.ChangeSource(Ingr.RAD2D.OLEInsertionTypeConstant.igOLELinked, setting.BorderFilePath, true); |
|
1332 |
smartFrame.Update(); |
|
1333 |
} |
|
1330 | 1334 |
} |
1331 |
|
|
1335 |
} |
|
1336 |
else |
|
1337 |
{ |
|
1338 |
setting.BorderFilePath = string.Empty; |
|
1332 | 1339 |
} |
1333 | 1340 |
} |
1334 | 1341 |
} |
... | ... | |
3434 | 3441 |
/// </summary> |
3435 | 3442 |
/// <param name="endBreak"></param> |
3436 | 3443 |
private void EndBreakModeling(EndBreak endBreak) |
3437 |
{ |
|
3444 |
{
|
|
3438 | 3445 |
object ownerObj = SPPIDUtil.FindObjectByUID(document, endBreak.OWNER); |
3439 | 3446 |
object connectedItem = SPPIDUtil.FindObjectByUID(document, endBreak.PROPERTIES.Find(x => x.ATTRIBUTE == "Connected Item").VALUE); |
3440 | 3447 |
|
... | ... | |
3472 | 3479 |
} |
3473 | 3480 |
else |
3474 | 3481 |
{ |
3475 |
_LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, null, null, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: leaderLine); |
|
3482 |
double angle = 0; |
|
3483 |
switch (location) |
|
3484 |
{ |
|
3485 |
case SegmentLocation.Right: |
|
3486 |
angle = Math.PI * 0.5; |
|
3487 |
break; |
|
3488 |
case SegmentLocation.Left: |
|
3489 |
angle = Math.PI * 1.5; |
|
3490 |
break; |
|
3491 |
case SegmentLocation.Up: |
|
3492 |
angle = Math.PI; |
|
3493 |
break; |
|
3494 |
default: |
|
3495 |
break; |
|
3496 |
} |
|
3497 |
_LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, null, Rotation: angle, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: leaderLine); |
|
3476 | 3498 |
if (_LmLabelPersist == null) |
3477 | 3499 |
{ |
3478 |
_LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, null, null, IsLeaderVisible: leaderLine);
|
|
3500 |
_LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, null, Rotation: angle, IsLeaderVisible: leaderLine);
|
|
3479 | 3501 |
} |
3480 | 3502 |
} |
3481 | 3503 |
|
... | ... | |
3622 | 3644 |
string MappingPath = mapping.SPPIDSYMBOLNAME; |
3623 | 3645 |
SegmentLocation location; |
3624 | 3646 |
double[] point = GetSegmentPoint(upStreamObj, downStreamObj, targetLMConnector, out location); |
3647 |
double angle = 0; |
|
3648 |
switch (location) |
|
3649 |
{ |
|
3650 |
case SegmentLocation.Right: |
|
3651 |
angle = Math.PI * 0.5; |
|
3652 |
break; |
|
3653 |
case SegmentLocation.Left: |
|
3654 |
angle = Math.PI * 1.5; |
|
3655 |
break; |
|
3656 |
case SegmentLocation.Up: |
|
3657 |
angle = Math.PI; |
|
3658 |
break; |
|
3659 |
default: |
|
3660 |
break; |
|
3661 |
} |
|
3625 | 3662 |
Array array = null; |
3626 | 3663 |
if (point != null) |
3627 | 3664 |
array = new double[] { 0, point[0], point[1] }; |
3628 | 3665 |
else |
3629 | 3666 |
array = new double[] { 0, specBreak.SPPID.ORIGINAL_X, specBreak.SPPID.ORIGINAL_Y }; |
3630 |
LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(MappingPath, ref array, null, null, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine);
|
|
3667 |
LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(MappingPath, ref array, null, Rotation: angle, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine);
|
|
3631 | 3668 |
|
3632 | 3669 |
if (_LmLabelPersist != null) |
3633 | 3670 |
{ |
... | ... | |
3700 | 3737 |
line2D.GetStartPoint(out x1, out y1); |
3701 | 3738 |
line2D.GetEndPoint(out x2, out y2); |
3702 | 3739 |
double tX1 = Math.Min(x1, x2), tY1 = Math.Min(y1, y2), tX2 = Math.Max(x1, x2), tY2 = Math.Max(y1, y2); |
3703 |
if (minX > tX1) |
|
3704 |
minX = tX1; |
|
3705 |
if (minY > tY1) |
|
3706 |
minY = tY1; |
|
3707 |
if (maxX < tX2) |
|
3708 |
maxX = tX2; |
|
3709 |
if (maxY < tY2) |
|
3710 |
maxY = tY2; |
|
3740 |
minX = Math.Min(minX, tX1); |
|
3741 |
minY = Math.Min(minY, tY1); |
|
3742 |
maxX = Math.Max(maxX, tX2); |
|
3743 |
maxY = Math.Max(maxY, tY2); |
|
3711 | 3744 |
} |
3712 | 3745 |
} |
3713 | 3746 |
|
... | ... | |
3830 | 3863 |
} |
3831 | 3864 |
|
3832 | 3865 |
if (!bFind) |
3866 |
{ |
|
3833 | 3867 |
MoveSegmentBestLocation(labelPersist.get_GraphicOID().ToString(), new double[] { x - radius, y - radius, x + radius, y + radius }, itemRange); |
3868 |
} |
|
3869 |
|
|
3870 |
DependencyObject dependencyItem = radApp.ActiveDocument.ActiveSheet.DrawingObjects[labelPersist.get_GraphicOID().ToString()] as DependencyObject; |
|
3871 |
foreach (DrawingObjectBase drawingObject in dependencyItem.DrawingObjects) |
|
3872 |
{ |
|
3873 |
if (drawingObject.Type == Ingr.RAD2D.ObjectType.igLine2d) |
|
3874 |
{ |
|
3875 |
double x1, y1, x2, y2; |
|
3876 |
drawingObject.Range(out x1, out y1, out x2, out y2); |
|
3877 |
itemRange.Add(new double[] { x1, y1, x2, y2 }); |
|
3878 |
endBreakRange.Add(new double[] { x1, y1, x2, y2 }); |
|
3879 |
} |
|
3880 |
} |
|
3834 | 3881 |
} |
3835 | 3882 |
|
3836 | 3883 |
LMConnectors GetConnectors() |
... | ... | |
3939 | 3986 |
ReleaseCOMObjects(symbol); |
3940 | 3987 |
} |
3941 | 3988 |
ReleaseCOMObjects(symbols); |
3989 |
if (endBreakRange.Count > 0) |
|
3990 |
{ |
|
3991 |
itemRange.AddRange(endBreakRange.ToArray()); |
|
3992 |
} |
|
3942 | 3993 |
} |
3943 | 3994 |
|
3944 | 3995 |
private void MoveSegmentBestLocation(string oid, double[] segmentRange, List<double[]> allRanges) |
... | ... | |
3947 | 3998 |
double maxValue = Math.Max(segmentRange[2] - segmentRange[0], segmentRange[3] - segmentRange[1]); |
3948 | 3999 |
|
3949 | 4000 |
double maxX = 0, maxY = 0; |
3950 |
maxX = maxValue * 10;
|
|
3951 |
maxY = minValue * 10;
|
|
4001 |
maxX = maxValue * 1.1d;
|
|
4002 |
maxY = minValue * 1.1d;
|
|
3952 | 4003 |
|
3953 |
double move = minValue / 10d;
|
|
3954 |
double textGap = minValue / 3d;
|
|
3955 |
segmentRange = new double[] { segmentRange[0] - textGap, segmentRange[1] - textGap, segmentRange[2] + textGap, segmentRange[3] + textGap };
|
|
4004 |
double move = minValue * 0.1d;
|
|
4005 |
double margin = minValue * 0.1d;
|
|
4006 |
segmentRange = new double[] { segmentRange[0] - margin, segmentRange[1] - margin, segmentRange[2] + margin, segmentRange[3] + margin };
|
|
3956 | 4007 |
|
3957 | 4008 |
|
3958 | 4009 |
List<double[]> containRanges = new List<double[]>(); |
... | ... | |
3965 | 4016 |
containRanges.Add(range); |
3966 | 4017 |
|
3967 | 4018 |
double movePointX = 0, movePointY = 0, distance = double.MaxValue; |
4019 |
bool bChange = false; |
|
3968 | 4020 |
for (double x = 0; x < maxX; x = x + move) |
4021 |
{ |
|
3969 | 4022 |
for (double y = 0; y < maxY; y = y + move) |
4023 |
{ |
|
3970 | 4024 |
for (int i = 0; i < 4; i++) |
3971 | 4025 |
{ |
3972 | 4026 |
double tempX = 0d, tempY = 0d; |
... | ... | |
4007 | 4061 |
{ |
4008 | 4062 |
//double tempDistance = Utils.CalcDistance(new double[] { 0, 0, 0 }, new double[] { tempX, tempY, 0 }); |
4009 | 4063 |
double tempDistance = SPPIDUtil.CalcPointToPointdDistance(0, 0, tempX, tempY); |
4010 |
bool bChange = false; |
|
4011 | 4064 |
if (distance > tempDistance) |
4012 | 4065 |
bChange = true; |
4013 | 4066 |
else if (distance.Equals(tempDistance) && (movePointX.Equals(0d) || movePointY.Equals(0d))) |
... | ... | |
4018 | 4071 |
distance = tempDistance; |
4019 | 4072 |
movePointX = tempX; |
4020 | 4073 |
movePointY = tempY; |
4074 |
break; |
|
4021 | 4075 |
} |
4022 | 4076 |
} |
4077 |
if (bChange) break; |
|
4023 | 4078 |
} |
4079 |
if (bChange) break; |
|
4080 |
} |
|
4081 |
if (bChange) break; |
|
4082 |
} |
|
4024 | 4083 |
|
4025 | 4084 |
DependencyObject dependency = radApp.ActiveDocument.ActiveSheet.DrawingObjects[oid] as DependencyObject; |
4026 | 4085 |
if (dependency != null) |
내보내기 Unified diff