개정판 44087b23
dev issue #507 : LineNumber 보정
Change-Id: Idb7dbc880ae3e5f65cec8efa2cdb88b856c95ac4
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
539 | 539 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "PipeRun Join - 1"); |
540 | 540 |
foreach (var line in document.LINES) |
541 | 541 |
{ |
542 |
Dictionary<LMConnector, List<double[]>> vertices = GetPipeRunVertices(line.SPPID.ModelItemId, false); |
|
543 |
List<List<double[]>> result = new List<List<double[]>>(); |
|
544 |
foreach (var item in vertices) |
|
545 |
{ |
|
546 |
ReleaseCOMObjects(item.Key); |
|
547 |
result.Add(item.Value); |
|
548 |
} |
|
549 |
line.SPPID.Vertices = result; |
|
550 |
vertices = null; |
|
551 |
} |
|
552 |
|
|
553 |
foreach (var line in document.LINES) |
|
554 |
{ |
|
542 | 555 |
foreach (var connector in line.CONNECTORS) |
543 | 556 |
{ |
544 | 557 |
if (connector.ConnectedObject != null && |
... | ... | |
902 | 915 |
} |
903 | 916 |
private void RunCorrectAssociationText() |
904 | 917 |
{ |
905 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.TEXTINFOS.Count); |
|
906 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Correct Association Text");
|
|
918 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.TEXTINFOS.Count + document.LINENUMBERS.Count);
|
|
919 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Correct Labels");
|
|
907 | 920 |
List<Text> endTexts = new List<Text>(); |
908 | 921 |
foreach (var item in document.TEXTINFOS) |
909 | 922 |
{ |
... | ... | |
915 | 928 |
} |
916 | 929 |
catch (Exception ex) |
917 | 930 |
{ |
918 |
Log.Write("Error in NoteModeling");
|
|
931 |
Log.Write("Error in RunCorrectAssociationText");
|
|
919 | 932 |
Log.Write("UID : " + item.UID); |
920 | 933 |
Log.Write(ex.Message); |
921 | 934 |
Log.Write(ex.StackTrace); |
922 | 935 |
} |
923 | 936 |
|
924 | 937 |
} |
938 |
|
|
939 |
foreach (var item in document.LINENUMBERS) |
|
940 |
{ |
|
941 |
try |
|
942 |
{ |
|
943 |
LineNumberCorrectModeling(item); |
|
944 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
|
945 |
} |
|
946 |
catch (Exception ex) |
|
947 |
{ |
|
948 |
Log.Write("Error in RunCorrectAssociationText"); |
|
949 |
Log.Write("UID : " + item.UID); |
|
950 |
Log.Write(ex.Message); |
|
951 |
Log.Write(ex.StackTrace); |
|
952 |
} |
|
953 |
} |
|
925 | 954 |
} |
926 | 955 |
/// <summary> |
927 | 956 |
/// 도면 생성 메서드 |
... | ... | |
3343 | 3372 |
/// </summary> |
3344 | 3373 |
/// <param name="modelId"></param> |
3345 | 3374 |
/// <returns></returns> |
3346 |
private Dictionary<LMConnector, List<double[]>> GetPipeRunVertices(string modelId) |
|
3375 |
private Dictionary<LMConnector, List<double[]>> GetPipeRunVertices(string modelId, bool ContainZeroLength = true)
|
|
3347 | 3376 |
{ |
3348 | 3377 |
Dictionary<LMConnector, List<double[]>> connectorVertices = new Dictionary<LMConnector, List<double[]>>(); |
3349 | 3378 |
LMModelItem modelItem = dataSource.GetModelItem(modelId); |
... | ... | |
3355 | 3384 |
if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
3356 | 3385 |
{ |
3357 | 3386 |
LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
3387 |
if (!ContainZeroLength && Convert.ToBoolean(_LMConnector.get_IsZeroLength())) |
|
3388 |
{ |
|
3389 |
ReleaseCOMObjects(_LMConnector); |
|
3390 |
_LMConnector = null; |
|
3391 |
continue; |
|
3392 |
} |
|
3358 | 3393 |
connectorVertices.Add(_LMConnector, new List<double[]>()); |
3359 | 3394 |
dynamic OID = rep.get_GraphicOID().ToString(); |
3360 | 3395 |
DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
... | ... | |
3787 | 3822 |
CalcLabelLocation(ref x, ref y, lineNumber.SPPID.ORIGINAL_X, lineNumber.SPPID.ORIGINAL_Y, lineNumber.SPPIDLabelLocation, _ETCSetting.LineNumberLocation); |
3788 | 3823 |
|
3789 | 3824 |
Array points = new double[] { 0, x, y }; |
3825 |
lineNumber.SPPID.SPPID_X = x; |
|
3826 |
lineNumber.SPPID.SPPID_Y = y; |
|
3790 | 3827 |
LMLabelPersist _LmLabelPresist = _placement.PIDPlaceLabel(lineNumber.SPPID.MAPPINGNAME, ref points, Rotation: lineNumber.ANGLE, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: false); |
3791 | 3828 |
|
3792 | 3829 |
if (_LmLabelPresist != null) |
... | ... | |
3813 | 3850 |
if (connectedLMConnector != null) |
3814 | 3851 |
{ |
3815 | 3852 |
Array points = new double[] { 0, x, y }; |
3853 |
lineNumber.SPPID.SPPID_X = x; |
|
3854 |
lineNumber.SPPID.SPPID_Y = y; |
|
3816 | 3855 |
LMLabelPersist _LmLabelPresist = _placement.PIDPlaceLabel(lineNumber.SPPID.MAPPINGNAME, ref points, Rotation: lineNumber.ANGLE, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: false); |
3817 | 3856 |
|
3818 | 3857 |
if (_LmLabelPresist != null) |
... | ... | |
3827 | 3866 |
ReleaseCOMObjects(item.Key); |
3828 | 3867 |
} |
3829 | 3868 |
} |
3869 |
private void LineNumberCorrectModeling(LineNumber lineNumber) |
|
3870 |
{ |
|
3871 |
Line line = SPPIDUtil.FindObjectByUID(document, lineNumber.CONNLINE) as Line; |
|
3872 |
if (line == null || line.SPPID.Vertices == null) |
|
3873 |
return; |
|
3874 |
|
|
3875 |
if (!string.IsNullOrEmpty(lineNumber.SPPID.RepresentationId)) |
|
3876 |
{ |
|
3877 |
LMLabelPersist removeLabel = dataSource.GetLabelPersist(lineNumber.SPPID.RepresentationId); |
|
3878 |
if (removeLabel != null) |
|
3879 |
{ |
|
3880 |
GridSetting gridSetting = GridSetting.GetInstance(); |
|
3881 |
double[] labelRange = null; |
|
3882 |
GetSPPIDSymbolRange(removeLabel, ref labelRange); |
|
3883 |
LMConnector connector = dataSource.GetConnector(removeLabel.RepresentationID); |
|
3884 |
List<double[]> vertices = GetConnectorVertices(connector); |
|
3885 |
|
|
3886 |
double[] resultStart = null; |
|
3887 |
double[] resultEnd = null; |
|
3888 |
double distance = double.MaxValue; |
|
3889 |
for (int i = 0; i < vertices.Count - 1; i++) |
|
3890 |
{ |
|
3891 |
double[] startPoint = vertices[i]; |
|
3892 |
double[] endPoint = vertices[i + 1]; |
|
3893 |
foreach (var item in line.SPPID.Vertices) |
|
3894 |
{ |
|
3895 |
double[] lineStartPoint = item[0]; |
|
3896 |
double[] lineEndPoint = item[item.Count - 1]; |
|
3897 |
|
|
3898 |
double tempDistance = SPPIDUtil.CalcPointToPointdDistance(startPoint[0], startPoint[1], lineStartPoint[0], lineStartPoint[1]) + |
|
3899 |
SPPIDUtil.CalcPointToPointdDistance(endPoint[0], endPoint[1], lineEndPoint[0], lineEndPoint[1]); |
|
3900 |
if (tempDistance < distance) |
|
3901 |
{ |
|
3902 |
distance = tempDistance; |
|
3903 |
resultStart = startPoint; |
|
3904 |
resultEnd = endPoint; |
|
3905 |
} |
|
3906 |
tempDistance = SPPIDUtil.CalcPointToPointdDistance(startPoint[0], startPoint[1], lineEndPoint[0], lineEndPoint[1]) + |
|
3907 |
SPPIDUtil.CalcPointToPointdDistance(endPoint[0], endPoint[1], lineStartPoint[0], lineStartPoint[1]); |
|
3908 |
if (tempDistance < distance) |
|
3909 |
{ |
|
3910 |
distance = tempDistance; |
|
3911 |
resultStart = startPoint; |
|
3912 |
resultEnd = endPoint; |
|
3913 |
} |
|
3914 |
} |
|
3915 |
} |
|
3916 |
|
|
3917 |
if (resultStart != null && resultEnd != null) |
|
3918 |
{ |
|
3919 |
SlopeType slope = SPPIDUtil.CalcSlope(resultStart[0], resultStart[1], resultEnd[0], resultEnd[1]); |
|
3920 |
double lineStartX = 0; |
|
3921 |
double lineStartY = 0; |
|
3922 |
double lineEndX = 0; |
|
3923 |
double lineEndY = 0; |
|
3924 |
double lineNumberX = 0; |
|
3925 |
double lineNumberY = 0; |
|
3926 |
SPPIDUtil.ConvertPointBystring(line.STARTPOINT, ref lineStartX, ref lineStartY); |
|
3927 |
SPPIDUtil.ConvertPointBystring(line.ENDPOINT, ref lineEndX, ref lineEndY); |
|
3928 |
|
|
3929 |
double lineX = (lineStartX + lineEndX) / 2; |
|
3930 |
double lineY = (lineStartY + lineEndY) / 2; |
|
3931 |
lineNumberX = (lineNumber.X1 + lineNumber.X2) / 2; |
|
3932 |
lineNumberY = (lineNumber.Y1 + lineNumber.Y2) / 2; |
|
3933 |
|
|
3934 |
double SPPIDCenterX = (resultStart[0] + resultEnd[0]) / 2; |
|
3935 |
double SPPIDCenterY = (resultStart[1] + resultEnd[1]) / 2; |
|
3936 |
double labelCenterX = (labelRange[0] + labelRange[2]) / 2; |
|
3937 |
double labelCenterY = (labelRange[1] + labelRange[3]) / 2; |
|
3938 |
|
|
3939 |
double offsetX = 0; |
|
3940 |
double offsetY = 0; |
|
3941 |
if (slope == SlopeType.HORIZONTAL) |
|
3942 |
{ |
|
3943 |
// Line Number 아래 |
|
3944 |
if (lineY < lineNumberY) |
|
3945 |
{ |
|
3946 |
offsetX = labelCenterX - SPPIDCenterX; |
|
3947 |
offsetY = labelRange[3] - SPPIDCenterY + gridSetting.Length; |
|
3948 |
MoveLineNumber(lineNumber, offsetX, offsetY); |
|
3949 |
} |
|
3950 |
// Line Number 위 |
|
3951 |
else |
|
3952 |
{ |
|
3953 |
offsetX = labelCenterX - SPPIDCenterX; |
|
3954 |
offsetY = labelRange[1] - SPPIDCenterY - gridSetting.Length; |
|
3955 |
MoveLineNumber(lineNumber, offsetX, offsetY); |
|
3956 |
} |
|
3957 |
} |
|
3958 |
else if (slope == SlopeType.VERTICAL) |
|
3959 |
{ |
|
3960 |
// Line Number 오르쪽 |
|
3961 |
if (lineX < lineNumberX) |
|
3962 |
{ |
|
3963 |
offsetX = labelRange[0] - SPPIDCenterX - gridSetting.Length; |
|
3964 |
offsetY = labelCenterY - SPPIDCenterY; |
|
3965 |
MoveLineNumber(lineNumber, offsetX, offsetY); |
|
3966 |
} |
|
3967 |
// Line Number 왼쪽 |
|
3968 |
else |
|
3969 |
{ |
|
3970 |
offsetX = labelRange[2] - SPPIDCenterX + gridSetting.Length; |
|
3971 |
offsetY = labelCenterY - SPPIDCenterY; |
|
3972 |
MoveLineNumber(lineNumber, offsetX, offsetY); |
|
3973 |
} |
|
3974 |
} |
|
3975 |
|
|
3976 |
if (offsetY != 0 && offsetY != 0) |
|
3977 |
{ |
|
3978 |
_placement.PIDRemovePlacement(removeLabel.AsLMRepresentation()); |
|
3979 |
Array points = new double[] { 0, lineNumber.SPPID.SPPID_X, lineNumber.SPPID.SPPID_Y }; |
|
3980 |
LMLabelPersist _LmLabelPresist = _placement.PIDPlaceLabel(lineNumber.SPPID.MAPPINGNAME, ref points, Rotation: lineNumber.ANGLE, LabeledItem: connector.AsLMRepresentation(), IsLeaderVisible: false); |
|
3981 |
|
|
3982 |
if (_LmLabelPresist != null) |
|
3983 |
{ |
|
3984 |
_LmLabelPresist.Commit(); |
|
3985 |
lineNumber.SPPID.RepresentationId = _LmLabelPresist.AsLMRepresentation().Id; |
|
3986 |
} |
|
3987 |
ReleaseCOMObjects(_LmLabelPresist); |
|
3988 |
_LmLabelPresist = null; |
|
3989 |
} |
|
3990 |
|
|
3991 |
void MoveLineNumber(LineNumber moveLineNumber, double x, double y) |
|
3992 |
{ |
|
3993 |
moveLineNumber.SPPID.SPPID_X = moveLineNumber.SPPID.SPPID_X - x; |
|
3994 |
moveLineNumber.SPPID.SPPID_Y = moveLineNumber.SPPID.SPPID_Y - y; |
|
3995 |
} |
|
3996 |
} |
|
3997 |
|
|
3998 |
|
|
3999 |
ReleaseCOMObjects(connector); |
|
4000 |
connector = null; |
|
4001 |
} |
|
4002 |
|
|
4003 |
ReleaseCOMObjects(removeLabel); |
|
4004 |
removeLabel = null; |
|
4005 |
} |
|
4006 |
} |
|
3830 | 4007 |
/// <summary> |
3831 | 4008 |
/// Flow Mark Modeling |
3832 | 4009 |
/// </summary> |
DTI_PID/SPPIDConverter/BaseModel/SPPID/SPPIDLineInfo.cs | ||
---|---|---|
15 | 15 |
public double END_X { get; set; } |
16 | 16 |
public double END_Y { get; set; } |
17 | 17 |
public string ModelItemId { get; set; } |
18 |
public List<List<double[]>> Vertices { get; set; } |
|
18 | 19 |
public List<string> Representations { get => _Representations; set => _Representations = value; } |
19 | 20 |
|
20 | 21 |
private List<string> _Representations = new List<string>(); |
내보내기 Unified diff