프로젝트

일반

사용자정보

개정판 b2064e69

IDb2064e69efc648d8d14720756c619a044c040be2
상위 c9a4db3a
하위 d91db37c

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

dev issue #507 : Branched Line 보정

Change-Id: I627c71969c49926bacd97c4483678d1f226c3158

차이점 보기:

DTI_PID/SPPIDConverter/AutoModeling.cs
1917 1917
                            Symbol connSymbol = connItem as Symbol;
1918 1918
                            if (string.IsNullOrEmpty(connSymbol.SPPID.RepresentationId))
1919 1919
                            {
1920
                                Line connLine = SPPIDUtil.GetConnectedLine(prevSymbol, connSymbol);
1921
                                int branchCount = 0;
1922
                                if (connLine != null)
1923
                                    branchCount = SPPIDUtil.GetBranchLineCount(document, connLine);
1924

  
1920 1925
                                List<Symbol> group = new List<Symbol>();
1921 1926
                                SPPIDUtil.FindConnectedSymbolGroup(document, connSymbol, group);
1922 1927
                                Symbol priority = prioritySymbols.Find(x => group.Contains(x));
......
1946 1951

  
1947 1952
                                        SymbolGroupModeling(priority, group);
1948 1953
                                    }
1954
                                    else if (branchCount > 0)
1955
                                    {
1956
                                        LMConnector _connector = JustLineModeling(connLine);
1957
                                        if (_connector != null)
1958
                                        {
1959
                                            double distance = GetConnectorDistance(_connector);
1960
                                            int cellCount = (int)Math.Truncate(distance / GridSetting.GetInstance().Length);
1961
                                            _placement.PIDRemovePlacement(_connector.AsLMRepresentation());
1962
                                            _connector.Commit();
1963
                                            ReleaseCOMObjects(_connector);
1964
                                            _connector = null;
1965
                                            if (cellCount < branchCount + 1)
1966
                                            {
1967
                                                int moveCount = branchCount - cellCount;
1968
                                                RemoveSymbol(group);
1969
                                                foreach (var _temp in group)
1970
                                                    SPPIDUtil.CalcNewCoordinateForSymbol(_temp, prevSymbol, moveCount * GridSetting.GetInstance().Length, moveCount * GridSetting.GetInstance().Length);
1971

  
1972
                                                SymbolGroupModeling(priority, group);
1973
                                            }
1974
                                        }
1975
                                    }
1949 1976
                                }
1950 1977
                                else
1951 1978
                                {
......
1970 1997

  
1971 1998
                                        SymbolModeling(connSymbol, null);
1972 1999
                                    }
2000
                                    else if (branchCount > 0)
2001
                                    {
2002
                                        LMConnector _connector = JustLineModeling(connLine);
2003
                                        if (_connector != null)
2004
                                        {
2005
                                            double distance = GetConnectorDistance(_connector);
2006
                                            int cellCount = (int)Math.Truncate(distance / GridSetting.GetInstance().Length);
2007
                                            _placement.PIDRemovePlacement(_connector.AsLMRepresentation());
2008
                                            _connector.Commit();
2009
                                            ReleaseCOMObjects(_connector);
2010
                                            _connector = null;
2011
                                            if (cellCount < branchCount + 1)
2012
                                            {
2013
                                                int moveCount = branchCount - cellCount;
2014
                                                RemoveSymbol(group);
2015
                                                foreach (var _temp in group)
2016
                                                    SPPIDUtil.CalcNewCoordinateForSymbol(_temp, prevSymbol, moveCount * GridSetting.GetInstance().Length, moveCount * GridSetting.GetInstance().Length);
2017

  
2018
                                                SymbolGroupModeling(priority, group);
2019
                                            }
2020
                                        }
2021
                                    }
1973 2022
                                }
1974 2023
                            }
1975 2024
                            SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, document.SYMBOLS.FindAll(x => !string.IsNullOrEmpty(x.SPPID.RepresentationId)).Count);
......
2198 2247
                foreach (var item in removeLines)
2199 2248
                    RemoveLineForModeling(item as Line);
2200 2249

  
2201
                if (_LMAItem != null)
2202
                    ReleaseCOMObjects(_LMAItem);
2203
                if (placeRunInputs != null)
2204
                    ReleaseCOMObjects(placeRunInputs);
2205
                if (_LMSymbolStart != null)
2206
                    ReleaseCOMObjects(_LMSymbolStart);
2207
                if (_LMSymbolEnd != null)
2208
                    ReleaseCOMObjects(_LMSymbolEnd);
2250
                ReleaseCOMObjects(_LMAItem);
2251
                _LMAItem = null;
2252
                ReleaseCOMObjects(placeRunInputs);
2253
                placeRunInputs = null;
2254
                ReleaseCOMObjects(_LMSymbolStart);
2255
                _LMSymbolStart = null;
2256
                ReleaseCOMObjects(_LMSymbolEnd);
2257
                _LMSymbolEnd = null;
2209 2258

  
2210 2259
                if (isBranchModeling && BranchLines.Contains(groupLine))
2211 2260
                    BranchLines.Remove(groupLine);
2212 2261
            }
2213 2262
        }
2214 2263

  
2264
        private LMConnector JustLineModeling(Line line)
2265
        {
2266
            bool diagonal = false;
2267
            if (line.SlopeType != SlopeType.HORIZONTAL && line.SlopeType != SlopeType.VERTICAL)
2268
                diagonal = true;
2269
            _LMAItem _LMAItem = _placement.PIDCreateItem(line.SPPID.MAPPINGNAME);
2270
            LMSymbol _LMSymbolStart = null;
2271
            LMSymbol _LMSymbolEnd = null;
2272
            PlaceRunInputs placeRunInputs = new PlaceRunInputs();
2273
            foreach (var connector in line.CONNECTORS)
2274
            {
2275
                double x = 0;
2276
                double y = 0;
2277
                GetTargetLineConnectorPoint(connector, line, ref x, ref y);
2278
                if (connector.ConnectedObject == null)
2279
                {
2280
                    placeRunInputs.AddPoint(x, y);
2281
                }
2282
                else if (connector.ConnectedObject.GetType() == typeof(Symbol))
2283
                {
2284
                    Symbol targetSymbol = connector.ConnectedObject as Symbol;
2285
                    GetTargetSymbolConnectorPoint(targetSymbol.CONNECTORS.Find(z => z.ConnectedObject == line), targetSymbol, ref x, ref y);
2286
                    if (line.CONNECTORS.IndexOf(connector) == 0)
2287
                    {
2288
                        _LMSymbolStart = GetTargetSymbol(targetSymbol, line);
2289
                        if (_LMSymbolStart != null)
2290
                            placeRunInputs.AddSymbolTarget(_LMSymbolStart, x, y, diagonal);
2291
                        else
2292
                            placeRunInputs.AddPoint(x, y);
2293
                    }
2294
                    else
2295
                    {
2296
                        _LMSymbolEnd = GetTargetSymbol(targetSymbol, line);
2297
                        if (_LMSymbolEnd != null)
2298
                            placeRunInputs.AddSymbolTarget(_LMSymbolEnd, x, y, diagonal);
2299
                        else
2300
                            placeRunInputs.AddPoint(x, y);
2301
                    }
2302
                }
2303
                else if (connector.ConnectedObject.GetType() == typeof(Line))
2304
                {
2305
                    Line targetLine = connector.ConnectedObject as Line;
2306
                    if (!string.IsNullOrEmpty(targetLine.SPPID.ModelItemId))
2307
                    {
2308
                        LMConnector targetConnector = FindTargetLMConnectorForBranch(line, targetLine, ref x, ref y);
2309
                        if (targetConnector != null)
2310
                        {
2311
                            placeRunInputs.AddConnectorTarget(targetConnector, x, y, diagonal);
2312
                            ChangeLineSPPIDCoordinateByConnector(line, targetLine, x, y, false);
2313
                        }
2314
                        else
2315
                        {
2316
                            placeRunInputs.AddPoint(x, y);
2317
                            ChangeLineSPPIDCoordinateByConnector(line, targetLine, x, y, false);
2318
                        }
2319
                    }
2320
                    else
2321
                        placeRunInputs.AddPoint(x, y);
2322
                }
2323
            }
2324

  
2325
            LMConnector _lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs);
2326
            if (_lMConnector != null)
2327
                _lMConnector.Commit();
2328

  
2329
            ReleaseCOMObjects(_LMAItem);
2330
            _LMAItem = null;
2331
            ReleaseCOMObjects(placeRunInputs);
2332
            placeRunInputs = null;
2333
            ReleaseCOMObjects(_LMSymbolStart);
2334
            _LMSymbolStart = null;
2335
            ReleaseCOMObjects(_LMSymbolEnd);
2336
            _LMSymbolEnd = null;
2337

  
2338
            return _lMConnector;
2339
        }
2340

  
2215 2341
        private void RemoveLineForModeling(Line line)
2216 2342
        {
2217 2343
            LMModelItem modelItem = dataSource.GetModelItem(line.SPPID.ModelItemId);
......
3456 3582
            return vertices;
3457 3583
        }
3458 3584

  
3585
        private double GetConnectorDistance(LMConnector connector)
3586
        {
3587
            double result = 0;
3588
            List<double[]> vertices = new List<double[]>();
3589
            if (connector != null)
3590
            {
3591
                dynamic OID = connector.get_GraphicOID().ToString();
3592
                DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID];
3593
                Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d;
3594
                int verticesCount = lineStringGeometry.VertexCount;
3595
                double[] value = null;
3596
                lineStringGeometry.GetVertices(ref verticesCount, ref value);
3597
                for (int i = 0; i < verticesCount; i++)
3598
                {
3599
                    double x = 0;
3600
                    double y = 0;
3601
                    lineStringGeometry.GetVertex(i + 1, ref x, ref y);
3602
                    vertices.Add(new double[] { x, y });
3603
                    if (vertices.Count > 1)
3604
                    {
3605
                        result += SPPIDUtil.CalcPointToPointdDistance(vertices[vertices.Count - 2][0], vertices[vertices.Count - 2][1], x, y);
3606
                    }
3607
                }
3608
            }
3609
            return result;
3610
        }
3459 3611
        private List<double[]> GetConnectorVertices(dynamic graphicOID)
3460 3612
        {
3461 3613
            List<double[]> vertices = null;

내보내기 Unified diff

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