프로젝트

일반

사용자정보

개정판 ac82b020

IDac82b0204003727aae80b1efca262020de24445f
상위 892bd8a2
하위 0860c756

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

dev issue #000 : Zero Length로 인한 bug Fix

Change-Id: I1c89320c2c972994b71b5b8f697e71998fd2c172

차이점 보기:

DTI_PID/SPPIDConverter/AutoModeling.cs
167 167
                    foreach (var item in document.SpecBreaks)
168 168
                        SpecBreakModeling(item);
169 169

  
170
                    JoinZeroLengthLine();
171

  
172 170
                    // LineNumber Modeling
173 171
                    SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "LineNumbers Modeling");
174 172
                    foreach (var item in document.LINENUMBERS)
......
1109 1107

  
1110 1108
            if (_lMConnector != null)
1111 1109
            {
1112
                if (_LMSymbol1 != null || _LMSymbol2 != null)
1113
                    ReModelingLine(lines, _lMConnector, _LMSymbol1, _LMSymbol2);
1110
                bool bStart = false;
1111
                bool bEnd = false;
1112

  
1113
                NeedReModeling(lines, _LMSymbol1, _LMSymbol2, ref bStart, ref bEnd);
1114

  
1115
                if (bStart || bEnd)
1116
                    ReModelingLine(lines, _lMConnector, _LMSymbol1, _LMSymbol2, bStart, bEnd);
1114 1117
                else
1115 1118
                {
1116 1119
                    foreach (var line in lines)
1117 1120
                        line.SPPID.ModelItemId = _lMConnector.ModelItemID;
1118 1121
                    _lMConnector.Commit();
1119 1122
                }
1123

  
1120 1124
                if (startBranchLine != null || endBranchLine != null)
1121 1125
                    BranchLines.Add(new Tuple<string, Line, Line>(lines[0].SPPID.ModelItemId, startBranchLine, endBranchLine));
1122
                
1123 1126
            }
1124 1127

  
1125 1128
            if (_LMSymbol1 != null)
......
1140 1143
            ReleaseCOMObjects(_LMAItem);
1141 1144
        }
1142 1145

  
1146
        private void NeedReModeling(List<Line> lines, LMSymbol startSymbol, LMSymbol endSymbol,ref bool bStart, ref bool bEnd)
1147
        {
1148
            if (startSymbol != null)
1149
            {
1150
                string startSymbolUID = document.SYMBOLS.Find(x => x.SPPID.RepresentationId == startSymbol.AsLMRepresentation().Id).UID;
1151
                string startLineUID = lines[0].UID;
1152

  
1153
                SpecBreak startSpecBreak = document.SpecBreaks.Find(x =>
1154
                (x.DownStreamUID == startSymbolUID || x.UpStreamUID == startSymbolUID) &&
1155
                (x.DownStreamUID == startLineUID || x.UpStreamUID == startLineUID));
1156

  
1157
                EndBreak startEndBreak = document.EndBreaks.Find(x =>
1158
                (x.OWNER == startSymbolUID || x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE == startSymbolUID) &&
1159
                (x.OWNER == startLineUID || x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE == startLineUID));
1160

  
1161
                if (startSpecBreak != null || startEndBreak != null)
1162
                    bStart = true;
1163
            }
1164

  
1165
            if (endSymbol != null)
1166
            {
1167
                string endSymbolUID = document.SYMBOLS.Find(x => x.SPPID.RepresentationId == endSymbol.AsLMRepresentation().Id).UID;
1168
                string endLineUID = lines[lines.Count - 1].UID;
1169

  
1170
                SpecBreak endSpecBreak = document.SpecBreaks.Find(x =>
1171
                (x.DownStreamUID == endSymbolUID || x.UpStreamUID == endSymbolUID) &&
1172
                (x.DownStreamUID == endLineUID || x.UpStreamUID == endLineUID));
1173

  
1174
                EndBreak endEndBreak = document.EndBreaks.Find(x =>
1175
                (x.OWNER == endSymbolUID || x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE == endSymbolUID) &&
1176
                (x.OWNER == endLineUID || x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE == endLineUID));
1177

  
1178
                if (endSpecBreak != null || endEndBreak != null)
1179
                    bEnd = true;
1180
            }
1181
        }
1182

  
1143 1183
        /// <summary>
1144 1184
        /// Symbol에 붙을 경우 Line을 Remodeling 한다.
1145 1185
        /// </summary>
......
1147 1187
        /// <param name="prevLMConnector"></param>
1148 1188
        /// <param name="startSymbol"></param>
1149 1189
        /// <param name="endSymbol"></param>
1150
        private void ReModelingLine(List<Line> lines, LMConnector prevLMConnector, LMSymbol startSymbol, LMSymbol endSymbol)
1190
        private void ReModelingLine(List<Line> lines, LMConnector prevLMConnector, LMSymbol startSymbol, LMSymbol endSymbol, bool bStart, bool bEnd)
1151 1191
        {
1152 1192
            
1153 1193
            string symbolPath = string.Empty;
......
1185 1225
                // 시작 심볼이 있고 첫번째 좌표일 때
1186 1226
                if (startSymbol != null && i == 0)
1187 1227
                {
1188
                    SlopeType slopeType = SPPIDUtil.CalcSlope(points[0], points[1], vertices[i + 1][0], vertices[i + 1][1]);
1189
                    if (slopeType == SlopeType.HORIZONTAL)
1190
                        placeRunInputs.AddPoint(points[0], -0.1);
1191
                    else if (slopeType == SlopeType.VERTICAL)
1192
                        placeRunInputs.AddPoint(-0.1, points[1]);
1193
                    else
1194
                        placeRunInputs.AddPoint(points[0], -0.1);
1228
                    if (bStart)
1229
                    {
1230
                        SlopeType slopeType = SPPIDUtil.CalcSlope(points[0], points[1], vertices[i + 1][0], vertices[i + 1][1]);
1231
                        if (slopeType == SlopeType.HORIZONTAL)
1232
                            placeRunInputs.AddPoint(points[0], -0.1);
1233
                        else if (slopeType == SlopeType.VERTICAL)
1234
                            placeRunInputs.AddPoint(-0.1, points[1]);
1235
                        else
1236
                            placeRunInputs.AddPoint(points[0], -0.1);
1195 1237

  
1196
                    placeRunInputs.AddPoint(points[0], points[1]);
1238
                        placeRunInputs.AddPoint(points[0], points[1]);
1239
                    }
1240
                    else
1241
                    {
1242
                        placeRunInputs.AddSymbolTarget(startSymbol, points[0], points[1]);
1243
                    }
1197 1244
                }
1198 1245
                // 마지막 심볼이 있고 마지막 좌표일 때
1199 1246
                else if (endSymbol != null && i == vertices.Count - 1)
1200 1247
                {
1201
                    placeRunInputs.AddPoint(points[0], points[1]);
1248
                    if (bEnd)
1249
                    {
1250
                        placeRunInputs.AddPoint(points[0], points[1]);
1202 1251

  
1203
                    SlopeType slopeType = SPPIDUtil.CalcSlope(points[0], points[1], vertices[i - 1][0], vertices[i - 1][1]);
1204
                    if (slopeType == SlopeType.HORIZONTAL)
1205
                        placeRunInputs.AddPoint(points[0], -0.1);
1206
                    else if (slopeType == SlopeType.VERTICAL)
1207
                        placeRunInputs.AddPoint(-0.1, points[1]);
1252
                        SlopeType slopeType = SPPIDUtil.CalcSlope(points[0], points[1], vertices[i - 1][0], vertices[i - 1][1]);
1253
                        if (slopeType == SlopeType.HORIZONTAL)
1254
                            placeRunInputs.AddPoint(points[0], -0.1);
1255
                        else if (slopeType == SlopeType.VERTICAL)
1256
                            placeRunInputs.AddPoint(-0.1, points[1]);
1257
                        else
1258
                            placeRunInputs.AddPoint(points[0], -0.1);
1259
                    }
1208 1260
                    else
1209
                        placeRunInputs.AddPoint(points[0], -0.1);
1261
                    {
1262
                        placeRunInputs.AddSymbolTarget(endSymbol, points[0], points[1]);
1263
                    }
1210 1264
                }
1211 1265
                // 첫번째이며 시작 심볼이 아니고 Connecotr일 경우
1212 1266
                else if (i == 0 && prevLMConnector.ConnectItem1SymbolObject != null)
......
1227 1281

  
1228 1282
            if (newConnector != null)
1229 1283
            {
1230
                if (startSymbol != null)
1284
                if (startSymbol != null && bStart)
1231 1285
                {
1232 1286
                    _LMAItem = _placement.PIDCreateItem(symbolPath);
1233 1287
                    placeRunInputs = new PlaceRunInputs();
......
1244 1298
                    ReleaseCOMObjects(_LMAItem);
1245 1299
                }
1246 1300

  
1247
                if (endSymbol != null)
1301
                if (endSymbol != null && bEnd)
1248 1302
                {
1249 1303
                    if (startSymbol != null)
1250 1304
                    {
......
1860 1914
                {
1861 1915
                    foreach (LMConnector connector in connectedLMSymbol.Avoid1Connectors)
1862 1916
                    {
1917
                        if (connector.get_ItemStatus() != "Active")
1918
                            continue;
1919

  
1863 1920
                        if (IsConnected(connector, targetModelItem))
1864 1921
                        {
1865 1922
                            targetConnector = connector;
......
1871 1928
                    {
1872 1929
                        foreach (LMConnector connector in connectedLMSymbol.Avoid2Connectors)
1873 1930
                        {
1931
                            if (connector.get_ItemStatus() != "Active")
1932
                                continue;
1933

  
1874 1934
                            if (IsConnected(connector, targetModelItem))
1875 1935
                            {
1876 1936
                                targetConnector = connector;
......
3062 3122
                    intNewRefCount = intNewRefCount + System.Runtime.InteropServices.Marshal.FinalReleaseComObject(obj);
3063 3123
            }
3064 3124
        }
3065

  
3066
        public void JoinZeroLengthLine()
3067
        {
3068
            foreach (var sModelID in ZeroLengthModelItemID)
3069
            {
3070
                LMModelItem modelItem = dataSource.GetModelItem(sModelID);
3071
                int connectorCount = 0;
3072
                string representationID = string.Empty;
3073

  
3074
                if (modelItem != null && modelItem.get_ItemStatus() == "Active")
3075
                {
3076
                    foreach (LMRepresentation rep in modelItem.Representations)
3077
                    {
3078
                        if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active")
3079
                        {
3080
                            connectorCount++;
3081
                            representationID = rep.Id;
3082
                        }
3083
                    }
3084
                }
3085

  
3086
                ReleaseCOMObjects(modelItem);
3087

  
3088
                if (connectorCount == 1)
3089
                {
3090
                    LMConnector _LMConnector = dataSource.GetConnector(representationID);
3091
                    if (_LMConnector.LabelPersists.Count == 0)
3092
                    {
3093
                        LMSymbol symbol2 = _LMConnector.ConnectItem2SymbolObject;
3094

  
3095
                        LMConnector targetLine = null;
3096
                        if (symbol2 != null && symbol2.get_RepresentationType() == "Branch")
3097
                        {
3098
                            foreach (LMConnector connector in symbol2.Connect1Connectors)
3099
                            {
3100
                                if (connector.get_ItemStatus() == "Active" && _LMConnector.Id != connector.Id)
3101
                                    targetLine = connector;
3102
                            }
3103

  
3104
                            foreach (LMConnector connector in symbol2.Connect2Connectors)
3105
                            {
3106
                                if (connector.get_ItemStatus() == "Active" && _LMConnector.Id != connector.Id)
3107
                                    targetLine = connector;
3108
                            }
3109
                        }
3110

  
3111
                        JoinPipeRun(_LMConnector.ModelItemID, targetLine.ModelItemID);
3112
                    }
3113
                        
3114
                    ReleaseCOMObjects(_LMConnector);
3115
                }
3116
            }
3117

  
3118
            return;
3119
        }
3120 3125
    }
3121 3126
}

내보내기 Unified diff

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