프로젝트

일반

사용자정보

개정판 495bb8f5

ID495bb8f5a9d436224437d9cd157e59396b8c0cc3
상위 b67077fb
하위 b3aacf73

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

dev issue #1231 : balloon, angle symbol modeling

Change-Id: I28222090ab167c58c6ad8d91578253a43936b1c8

차이점 보기:

DTI_PID/APIDConverter/AutoModeling.cs
21 21
using AVEVA.PID.GUI;
22 22
using AVEVA.PID.Common;
23 23
using AVEVA.PID.DWGSelector;
24
using AVEVA.PID.Utilities;
24 25

  
25 26
using AVEVA.PID.CustomizationUtility.DB;
26 27
using AVEVA.PID.CustomizationUtility.Model;
......
33 34
        public static AutoModeling Running { get; set; }
34 35
        Model.Document document;
35 36

  
36
        public AutoModeling(Model.Document document)
37
        System.Data.DataTable AvevaSymbolTable = null;
38

  
39
        public AutoModeling(Model.Document document, System.Data.DataTable AvevaSymbolTable)
37 40
        {
38 41
            this.document = document;
42
            this.AvevaSymbolTable = AvevaSymbolTable;
39 43
        }
40 44

  
41 45
        public void CreateDrawing()
......
126 130
        }
127 131
        private void SymbolModeling(Symbol symbol)
128 132
        {
129
            long handle = InsertSymbol(symbol.Aveva.Name, symbol.Aveva.X, symbol.Aveva.Y);
130
            if (handle != 0)
133
            DataRow[] allRows = AvevaSymbolTable.Select(string.Format("Symbol_Name = '{0}'", symbol.Aveva.Name));
134
            if (allRows.Length == 1)
131 135
            {
132
                symbol.Aveva.Handle = handle;
133
                ObjectId objectId = GetObjectIdByHandle(handle);
134
                if (objectId != ObjectId.Null)
136
                DataRow symbolRow = allRows[0];
137
                bool bAngle = CheckAngle(symbolRow);
138
                bool bBalloon = CheckBalloon(symbol);
139

  
140
                long handle = InsertSymbol(symbol, symbolRow, bAngle, bBalloon);
141
                if (handle != 0)
135 142
                {
136
                    SetBlockReferenceRotation(objectId, symbol.ANGLE);
143
                    symbol.Aveva.Handle = handle;
144

  
145
                    if (!bAngle)
146
                    {
147
                        ObjectId objectId = GetObjectIdByHandle(handle);
148
                        if (objectId != ObjectId.Null)
149
                        {
150
                            SetBlockReferenceRotation(objectId, symbol.ANGLE);
151
                        }
152
                    }
137 153
                }
138 154
            }
139
                
140 155
        }
141 156
        #endregion
142 157

  
......
236 251
            else
237 252
                return 0;
238 253
        }
239
        private long InsertSymbol(string insertSymbolName, double x, double y)
254
        private long InsertSymbol(Symbol symbol, DataRow symbolRow, bool needAngle, bool needBalloon)
240 255
        {
241 256
            long handle = 0;
242 257
            try
243 258
            {
259
                string insertSymbolName = symbol.Aveva.Name;
260
                double x = symbol.Aveva.X;
261
                double y = symbol.Aveva.Y;
262

  
244 263
                List<long> prevHandles = GetAllBlockHandlesByName(insertSymbolName);
245 264

  
246 265
                AVEVA.PID.Utilities.DrawingData drawingData = new AVEVA.PID.Utilities.DrawingData();
......
249 268
                Editor editor = acDoc.Editor;
250 269
                List<object> commandParam = new List<object>();
251 270
                commandParam.Add("INSSYM");
271

  
272
                // Insert Point
252 273
                Point3d point = new Point3d(x, y, 0);
253 274
                commandParam.Add(point);
254
                commandParam.Add(null);
275

  
276
                // Check Insert Point
277
                if (needAngle)
278
                    commandParam.Add(symbol.ANGLE);
279

  
280
                // Check Balloon
281
                if (needBalloon)
282
                {
283
                    point = new Point3d(x + 20, y + 20, 0);
284
                    commandParam.Add(point);
285
                    
286
                    // Check LeaderLine
287
                    if (GraphicalUtility.IsLeaderReqOnSymbolBalloons())
288
                        commandParam.Add(x + "," + y);
289
                }
290

  
291
                for (int i = 0; i < 8; i++)
292
                    commandParam.Add(null);
255 293

  
256 294
                editor.Command(commandParam.ToArray());
257 295

  
......
482 520
            
483 521
            return result;
484 522
        }
523
        private bool CheckAngle(DataRow symbolRow)
524
        {
525
            return int.Parse(symbolRow["Insert_Points"].ToString()).Equals(2);
526
        }
527
        private bool CheckBalloon(Symbol symbol)
528
        {
529
            bool result = false;
530

  
531
            string text = string.Empty;
532
            Hashtable symbolDefinitions = GraphicsUtility.GetSymbolDefinitions(symbol.Aveva.Name);
533
            if (symbolDefinitions.Count != 0)
534
            {
535
                text = symbolDefinitions[SymbolDefinition.symAflowType].ToString().ToUpper();
536

  
537
                if (text.Equals("VLP"))
538
                    text = "VPO";
539
                else if (text.Equals("IVP"))
540
                    text = "IPO";
541

  
542
                if (SymbolCategory.astrLabelBalloonBlockNames.Contains(text))
543
                    result = true;//dumbDwgUpgrade.addLabelBalloon(symbolForInsertion, objectId);
544
            }
545

  
546
            return result;
547
        }
485 548
        #endregion
486 549

  
487 550
        #region Test Source
......
491 554
            //DrawSignal("SONIC", new List<string>() { "2,100", "100,100" });
492 555

  
493 556
            DrawPipe("Main Pipe", new List<string>() { "2,100", "100,100" });
494
            InsertSymbol("BAVA", 50, 100);
557
            Symbol symbol = new Symbol();
558
            symbol.Aveva = new AvevaSymbolInfo();
559
            symbol.Aveva.Name = "INVB";
560
            symbol.Aveva.X = 50;
561
            symbol.Aveva.Y = 100;
562

  
563
            DataRow[] allRows = AvevaSymbolTable.Select(string.Format("Symbol_Name = '{0}'", symbol.Aveva.Name));
564
            if (allRows.Length == 1)
565
            {
566
                DataRow symbolRow = allRows[0];
567
                bool bAngle = CheckAngle(symbolRow);
568
                bool bBalloon = CheckBalloon(symbol);
569
                bBalloon = false;
570
                long handle = InsertSymbol(symbol, symbolRow, bAngle, bBalloon);
571
            }
572

  
573
            Hashtable symbolDefinitions = GraphicsUtility.GetSymbolDefinitions(symbol.Aveva.Name);
574
            string text = symbolDefinitions[SymbolDefinition.symAflowType].ToString().ToUpper();
575
            if (int.Parse(symbolDefinitions[SymbolDefinition.symNoOfInsertPoints].ToString()).Equals(2))
576
            {
577
                bool bIsPromptRotate = true;
578
            }
579
            int num = int.Parse(symbolDefinitions[SymbolDefinition.symFixedOrUserDefined].ToString());
580

  
581
            AssociateSymbolType eAssosiateSym = AssociateSymbolType.None;
582
            bool bIsSymbolHasAssociation = GraphicalUtility.FindSymbolHasAssociation(text, ref eAssosiateSym);
583
            bool bPlaceSimpleBlocks = SymbolCategory.astrSimplePlacedBlocks.Contains(text);
584

  
495 585
            //DrawPipe("Main Pipe", new List<string>() { "2,200", "100,200" });
496 586

  
497 587
            //DrawPipe("Sub Pipe", new List<string>() { "50,100", "50,200" });
498 588
        }
499 589
        public static void TESTStatic()
500 590
        {
501
            AutoModeling auto = new AutoModeling(null);
591
            System.Data.DataTable avevaSymbolTable = Project_DB.SelectSymbolTable();
592
            AutoModeling auto = new AutoModeling(null, avevaSymbolTable);
502 593
            auto.test();
503 594
        }
504 595
        #endregion

내보내기 Unified diff

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