프로젝트

일반

사용자정보

개정판 c3e8fa8e

IDc3e8fa8e14912076675fe1a59f2f2f9158116d09
상위 2b200a6e
하위 b9261a46

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

dev issue #000 : Symbol 대칭 기능 추가

Change-Id: I4a5376e2032474034cdd1e5165307fac39abf785

차이점 보기:

DTI_PID/SPPIDConverter/ConverterDocking.Designer.cs
32 32
            DevExpress.XtraSplashScreen.SplashScreenManager splashScreenManager = new DevExpress.XtraSplashScreen.SplashScreenManager(this, null, true, true, typeof(System.Windows.Forms.UserControl));
33 33
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ConverterDocking));
34 34
            this.layoutControl1 = new DevExpress.XtraLayout.LayoutControl();
35
            this.spinEditSymmetry = new DevExpress.XtraEditors.SpinEdit();
35 36
            this.btnSymmetry = new DevExpress.XtraEditors.SimpleButton();
36 37
            this.labelControl1 = new DevExpress.XtraEditors.LabelControl();
37 38
            this.btnLinkOPC = new DevExpress.XtraEditors.SimpleButton();
......
51 52
            this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem();
52 53
            this.layoutControlItem6 = new DevExpress.XtraLayout.LayoutControlItem();
53 54
            this.layoutControlGroup3 = new DevExpress.XtraLayout.LayoutControlGroup();
54
            this.layoutControlItem7 = new DevExpress.XtraLayout.LayoutControlItem();
55 55
            this.layoutControlItem8 = new DevExpress.XtraLayout.LayoutControlItem();
56
            this.defaultLookAndFeel = new DevExpress.LookAndFeel.DefaultLookAndFeel(this.components);
56
            this.layoutControlItem9 = new DevExpress.XtraLayout.LayoutControlItem();
57 57
            this.layoutControlGroup4 = new DevExpress.XtraLayout.LayoutControlGroup();
58
            this.layoutControlItem7 = new DevExpress.XtraLayout.LayoutControlItem();
59
            this.defaultLookAndFeel = new DevExpress.LookAndFeel.DefaultLookAndFeel(this.components);
58 60
            ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit();
59 61
            this.layoutControl1.SuspendLayout();
62
            ((System.ComponentModel.ISupportInitialize)(this.spinEditSymmetry.Properties)).BeginInit();
60 63
            ((System.ComponentModel.ISupportInitialize)(this.textEditDrawingY.Properties)).BeginInit();
61 64
            ((System.ComponentModel.ISupportInitialize)(this.textEditDrawingX.Properties)).BeginInit();
62 65
            ((System.ComponentModel.ISupportInitialize)(this.Root)).BeginInit();
......
70 73
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit();
71 74
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem6)).BeginInit();
72 75
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup3)).BeginInit();
73
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem7)).BeginInit();
74 76
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem8)).BeginInit();
77
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem9)).BeginInit();
75 78
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup4)).BeginInit();
79
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem7)).BeginInit();
76 80
            this.SuspendLayout();
77 81
            // 
78 82
            // splashScreenManager
......
81 85
            // 
82 86
            // layoutControl1
83 87
            // 
88
            this.layoutControl1.Controls.Add(this.spinEditSymmetry);
84 89
            this.layoutControl1.Controls.Add(this.btnSymmetry);
85 90
            this.layoutControl1.Controls.Add(this.labelControl1);
86 91
            this.layoutControl1.Controls.Add(this.btnLinkOPC);
......
97 102
            this.layoutControl1.TabIndex = 0;
98 103
            this.layoutControl1.Text = "layoutControl1";
99 104
            // 
105
            // spinEditSymmetry
106
            // 
107
            this.spinEditSymmetry.EditValue = new decimal(new int[] {
108
            1,
109
            0,
110
            0,
111
            0});
112
            this.spinEditSymmetry.Location = new System.Drawing.Point(119, 289);
113
            this.spinEditSymmetry.Name = "spinEditSymmetry";
114
            this.spinEditSymmetry.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
115
            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
116
            this.spinEditSymmetry.Properties.MaxValue = new decimal(new int[] {
117
            10,
118
            0,
119
            0,
120
            0});
121
            this.spinEditSymmetry.Properties.MinValue = new decimal(new int[] {
122
            1,
123
            0,
124
            0,
125
            0});
126
            this.spinEditSymmetry.Size = new System.Drawing.Size(107, 20);
127
            this.spinEditSymmetry.StyleController = this.layoutControl1;
128
            this.spinEditSymmetry.TabIndex = 12;
129
            // 
100 130
            // btnSymmetry
101 131
            // 
102 132
            this.btnSymmetry.ImageOptions.SvgImage = global::Converter.SPPID.Properties.Resources.productquickcomparisons;
103
            this.btnSymmetry.Location = new System.Drawing.Point(24, 289);
133
            this.btnSymmetry.Location = new System.Drawing.Point(24, 313);
104 134
            this.btnSymmetry.Name = "btnSymmetry";
105 135
            this.btnSymmetry.Size = new System.Drawing.Size(202, 36);
106 136
            this.btnSymmetry.StyleController = this.layoutControl1;
......
110 140
            // 
111 141
            // labelControl1
112 142
            // 
113
            this.labelControl1.Location = new System.Drawing.Point(24, 374);
143
            this.labelControl1.Location = new System.Drawing.Point(24, 398);
114 144
            this.labelControl1.Name = "labelControl1";
115 145
            this.labelControl1.Size = new System.Drawing.Size(179, 14);
116 146
            this.labelControl1.StyleController = this.layoutControl1;
......
140 170
            // 
141 171
            // textEditDrawingY
142 172
            // 
143
            this.textEditDrawingY.Location = new System.Drawing.Point(35, 220);
173
            this.textEditDrawingY.Location = new System.Drawing.Point(119, 220);
144 174
            this.textEditDrawingY.Name = "textEditDrawingY";
145 175
            this.textEditDrawingY.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
146 176
            this.textEditDrawingY.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
147 177
            this.textEditDrawingY.Properties.ReadOnly = true;
148
            this.textEditDrawingY.Size = new System.Drawing.Size(191, 20);
178
            this.textEditDrawingY.Size = new System.Drawing.Size(107, 20);
149 179
            this.textEditDrawingY.StyleController = this.layoutControl1;
150 180
            this.textEditDrawingY.TabIndex = 7;
151 181
            // 
152 182
            // textEditDrawingX
153 183
            // 
154
            this.textEditDrawingX.Location = new System.Drawing.Point(35, 196);
184
            this.textEditDrawingX.Location = new System.Drawing.Point(119, 196);
155 185
            this.textEditDrawingX.Name = "textEditDrawingX";
156 186
            this.textEditDrawingX.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
157 187
            this.textEditDrawingX.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
158 188
            this.textEditDrawingX.Properties.ReadOnly = true;
159
            this.textEditDrawingX.Size = new System.Drawing.Size(191, 20);
189
            this.textEditDrawingX.Size = new System.Drawing.Size(107, 20);
160 190
            this.textEditDrawingX.StyleController = this.layoutControl1;
161 191
            this.textEditDrawingX.TabIndex = 6;
162 192
            // 
163 193
            // simpleButton1
164 194
            // 
165
            this.simpleButton1.Location = new System.Drawing.Point(12, 404);
195
            this.simpleButton1.Location = new System.Drawing.Point(12, 428);
166 196
            this.simpleButton1.Name = "simpleButton1";
167 197
            this.simpleButton1.Size = new System.Drawing.Size(226, 22);
168 198
            this.simpleButton1.StyleController = this.layoutControl1;
......
199 229
            // emptySpaceItem1
200 230
            // 
201 231
            this.emptySpaceItem1.AllowHotTrack = false;
202
            this.emptySpaceItem1.Location = new System.Drawing.Point(0, 418);
232
            this.emptySpaceItem1.Location = new System.Drawing.Point(0, 442);
203 233
            this.emptySpaceItem1.Name = "emptySpaceItem1";
204
            this.emptySpaceItem1.Size = new System.Drawing.Size(230, 62);
234
            this.emptySpaceItem1.Size = new System.Drawing.Size(230, 38);
205 235
            this.emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);
206 236
            // 
207 237
            // layoutControlItem2
208 238
            // 
209 239
            this.layoutControlItem2.Control = this.simpleButton1;
210
            this.layoutControlItem2.Location = new System.Drawing.Point(0, 392);
240
            this.layoutControlItem2.Location = new System.Drawing.Point(0, 416);
211 241
            this.layoutControlItem2.Name = "layoutControlItem2";
212 242
            this.layoutControlItem2.Size = new System.Drawing.Size(230, 26);
213 243
            this.layoutControlItem2.TextSize = new System.Drawing.Size(0, 0);
......
232 262
            this.layoutControlItem3.Name = "layoutControlItem3";
233 263
            this.layoutControlItem3.Size = new System.Drawing.Size(206, 24);
234 264
            this.layoutControlItem3.Text = "X";
235
            this.layoutControlItem3.TextSize = new System.Drawing.Size(8, 14);
265
            this.layoutControlItem3.TextSize = new System.Drawing.Size(92, 14);
236 266
            // 
237 267
            // layoutControlItem4
238 268
            // 
......
241 271
            this.layoutControlItem4.Name = "layoutControlItem4";
242 272
            this.layoutControlItem4.Size = new System.Drawing.Size(206, 24);
243 273
            this.layoutControlItem4.Text = "Y";
244
            this.layoutControlItem4.TextSize = new System.Drawing.Size(8, 14);
274
            this.layoutControlItem4.TextSize = new System.Drawing.Size(92, 14);
245 275
            // 
246 276
            // layoutControlItem5
247 277
            // 
......
283 313
            // layoutControlGroup3
284 314
            // 
285 315
            this.layoutControlGroup3.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
286
            this.layoutControlItem8});
316
            this.layoutControlItem8,
317
            this.layoutControlItem9});
287 318
            this.layoutControlGroup3.Location = new System.Drawing.Point(0, 244);
288 319
            this.layoutControlGroup3.Name = "layoutControlGroup3";
289
            this.layoutControlGroup3.Size = new System.Drawing.Size(230, 85);
320
            this.layoutControlGroup3.Size = new System.Drawing.Size(230, 109);
290 321
            this.layoutControlGroup3.Text = "SPPID Utils";
291 322
            // 
292
            // layoutControlItem7
293
            // 
294
            this.layoutControlItem7.Control = this.labelControl1;
295
            this.layoutControlItem7.Location = new System.Drawing.Point(0, 0);
296
            this.layoutControlItem7.Name = "layoutControlItem7";
297
            this.layoutControlItem7.Size = new System.Drawing.Size(206, 18);
298
            this.layoutControlItem7.TextSize = new System.Drawing.Size(0, 0);
299
            this.layoutControlItem7.TextVisible = false;
300
            // 
301 323
            // layoutControlItem8
302 324
            // 
303 325
            this.layoutControlItem8.Control = this.btnSymmetry;
304
            this.layoutControlItem8.Location = new System.Drawing.Point(0, 0);
326
            this.layoutControlItem8.Location = new System.Drawing.Point(0, 24);
305 327
            this.layoutControlItem8.Name = "layoutControlItem8";
306 328
            this.layoutControlItem8.Size = new System.Drawing.Size(206, 40);
307 329
            this.layoutControlItem8.TextSize = new System.Drawing.Size(0, 0);
308 330
            this.layoutControlItem8.TextVisible = false;
309 331
            // 
310
            // defaultLookAndFeel
332
            // layoutControlItem9
311 333
            // 
312
            this.defaultLookAndFeel.LookAndFeel.SkinName = "Office 2019 Colorful";
334
            this.layoutControlItem9.Control = this.spinEditSymmetry;
335
            this.layoutControlItem9.Location = new System.Drawing.Point(0, 0);
336
            this.layoutControlItem9.Name = "layoutControlItem9";
337
            this.layoutControlItem9.Size = new System.Drawing.Size(206, 24);
338
            this.layoutControlItem9.Text = "Symmetry Count";
339
            this.layoutControlItem9.TextSize = new System.Drawing.Size(92, 14);
313 340
            // 
314 341
            // layoutControlGroup4
315 342
            // 
316 343
            this.layoutControlGroup4.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
317 344
            this.layoutControlItem7});
318
            this.layoutControlGroup4.Location = new System.Drawing.Point(0, 329);
345
            this.layoutControlGroup4.Location = new System.Drawing.Point(0, 353);
319 346
            this.layoutControlGroup4.Name = "layoutControlGroup4";
320 347
            this.layoutControlGroup4.Size = new System.Drawing.Size(230, 63);
321 348
            this.layoutControlGroup4.Text = "Keyboard Shortcut";
322 349
            // 
350
            // layoutControlItem7
351
            // 
352
            this.layoutControlItem7.Control = this.labelControl1;
353
            this.layoutControlItem7.Location = new System.Drawing.Point(0, 0);
354
            this.layoutControlItem7.Name = "layoutControlItem7";
355
            this.layoutControlItem7.Size = new System.Drawing.Size(206, 18);
356
            this.layoutControlItem7.TextSize = new System.Drawing.Size(0, 0);
357
            this.layoutControlItem7.TextVisible = false;
358
            // 
359
            // defaultLookAndFeel
360
            // 
361
            this.defaultLookAndFeel.LookAndFeel.SkinName = "Office 2019 Colorful";
362
            // 
323 363
            // ConverterDocking
324 364
            // 
325 365
            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
......
330 370
            this.Load += new System.EventHandler(this.ConverterDocking_Load);
331 371
            ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).EndInit();
332 372
            this.layoutControl1.ResumeLayout(false);
373
            ((System.ComponentModel.ISupportInitialize)(this.spinEditSymmetry.Properties)).EndInit();
333 374
            ((System.ComponentModel.ISupportInitialize)(this.textEditDrawingY.Properties)).EndInit();
334 375
            ((System.ComponentModel.ISupportInitialize)(this.textEditDrawingX.Properties)).EndInit();
335 376
            ((System.ComponentModel.ISupportInitialize)(this.Root)).EndInit();
......
343 384
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit();
344 385
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem6)).EndInit();
345 386
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup3)).EndInit();
346
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem7)).EndInit();
347 387
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem8)).EndInit();
388
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem9)).EndInit();
348 389
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup4)).EndInit();
390
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem7)).EndInit();
349 391
            this.ResumeLayout(false);
350 392

  
351 393
        }
......
376 418
        private DevExpress.XtraEditors.SimpleButton btnSymmetry;
377 419
        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem8;
378 420
        private DevExpress.XtraLayout.LayoutControlGroup layoutControlGroup4;
421
        private DevExpress.XtraEditors.SpinEdit spinEditSymmetry;
422
        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem9;
379 423
    }
380 424
}
DTI_PID/SPPIDConverter/ConverterDocking.cs
34 34
        public ConverterDocking()
35 35
        {
36 36
            InitializeComponent();
37

  
37
            spinEditSymmetry.Properties.Mask.EditMask = "f0";
38 38
            dynamic dApplication = Interaction.GetObject("", "PIDAutomation.Application");
39 39
            WrapperApplication wApp = new WrapperApplication(dApplication.Application);
40 40
            application = wApp.RADApplication;
......
229 229
        #region SPPID Utils
230 230
        private void btnSymmetry_Click(object sender, EventArgs e)
231 231
        {
232
            if (application.ActiveSelectSet.Count == 1 && application.ActiveSelectSet[0].GetType() == typeof(Symbol2d))
233
            {
234
                int symCount = (int)spinEditSymmetry.Value;
235
                Symbol2d symbol = application.ActiveSelectSet[0] as Symbol2d;
236
                double x, y;
237
                symbol.GetOrigin(out x, out y);
238
                string rep = GetRepresentationId(symbol);
239
                List<string> verticalRepID = new List<string>();
240
                List<string> horizontalRepID = new List<string>();
241

  
242
                if ((symbol.LinearName.Contains("Piping") ||
243
                    symbol.LinearName.Contains("Instrument")) &&
244
                    !string.IsNullOrEmpty(rep))
245
                {
246
                    Placement placement = new Placement();
247
                    LMADataSource dataSource = placement.PIDDataSource;
248
                    List<List<string>> datas = SetSymbol(dataSource, rep, x, y, symCount);
249
                    Dictionary<SymmetryArrow, List<string>> resultDatas = new Dictionary<SymmetryArrow, List<string>>();
250
                    if (datas.Count >= 2 && datas.Find(loop => loop.Count != symCount) == null)
251
                    {
252
                        SymmetryArrow arrow = SymmetryArrow.None;
253
                        foreach (var data in datas)
254
                        {
255
                            LMSymbol firstSymbol = dataSource.GetSymbol(data[0]);
256
                            double fX = firstSymbol.get_XCoordinate();
257
                            double fY = firstSymbol.get_YCoordinate();
258

  
259
                            SlopeType type = SPPIDUtil.CalcSlope(x, y, fX, fY, 1);
260
                            if (type == SlopeType.HORIZONTAL)
261
                            {
262
                                if (fX < x)
263
                                {
264
                                    arrow |= SymmetryArrow.Left;
265
                                    resultDatas.Add(SymmetryArrow.Left, data);
266
                                }
267
                                else
268
                                {
269
                                    arrow |= SymmetryArrow.Right;
270
                                    resultDatas.Add(SymmetryArrow.Right, data);
271
                                }
272

  
273
                            }
274
                            else if (type == SlopeType.VERTICAL)
275
                            {
276
                                if (fY < y)
277
                                {
278
                                    arrow |= SymmetryArrow.Down;
279
                                    resultDatas.Add(SymmetryArrow.Down, data);
280
                                }
281
                                else
282
                                {
283
                                    arrow |= SymmetryArrow.Up;
284
                                    resultDatas.Add(SymmetryArrow.Up, data);
285
                                }
286
                            }
287

  
288
                            ReleaseCOMObjects(firstSymbol);
289
                        }
290

  
291
                        SymmetryForm form = new SymmetryForm(arrow);
292
                        if (form.ShowDialog() == DialogResult.OK)
293
                        {
294
                            MoveByResult(dataSource, resultDatas, x, y, form.Result, rep);
295
                        }
296
                    }
297
                    else
298
                        MessageBox.Show("Check Symmetry Rules", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
299
                    ReleaseCOMObjects(dataSource);
300
                    ReleaseCOMObjects(placement);
301
                }
302
            }
303

  
304
            return;
232 305

  
306
            List<Symbol2d> symbols = new List<Symbol2d>();
307
            foreach (var item in application.ActiveSelectSet)
308
            {
309
                Type type = item.GetType();
310
                if (type == typeof(Symbol2d))
311
                {
312
                    Symbol2d symbol = item as Symbol2d;
313
                    if (symbol.LinearName.Contains("Piping") ||
314
                        symbol.LinearName.Contains("Instrument"))
315
                        symbols.Add(symbol);
316
                }
317
                //if (item.GetType() == typeof(Symbol2d) || item.GetType() == typeof(Point2d))
318
                //    items.Add(item);
319
            }
320

  
321
            List<Symbol2d> verticalSymbols = new List<Symbol2d>();
322
            List<Symbol2d> horizontalSymbols = new List<Symbol2d>();
323
            Symbol2d mainSymbol = null;
324
            for (int i = 0; i < symbols.Count - 1; i++)
325
            {
326
                Symbol2d symbol1 = symbols[i];
327
                for (int j = 1; j < symbols.Count; j++)
328
                {
329
                    Symbol2d symbol2 = symbols[j];
330

  
331
                    if (symbol1 != symbol2)
332
                    {
333
                        double x1, y1, x2, y2;
334
                        symbol1.GetOrigin(out x1, out y1);
335
                        symbol2.GetOrigin(out x2, out y2);
336
                        SlopeType slopeType = SPPIDUtil.CalcSlope(x1, y1, x2, y2, 1);
337
                        if (slopeType == SlopeType.HORIZONTAL)
338
                        {
339
                            if (!horizontalSymbols.Contains(symbol1))
340
                                horizontalSymbols.Add(symbol1);
341
                            if (!horizontalSymbols.Contains(symbol2))
342
                                horizontalSymbols.Add(symbol2);
343

  
344
                            if (verticalSymbols.Contains(symbol1))
345
                                mainSymbol = symbol1;
346
                            if (verticalSymbols.Contains(symbol2))
347
                                mainSymbol = symbol2;
348
                        }
349
                        else if (slopeType == SlopeType.VERTICAL)
350
                        {
351
                            if (!verticalSymbols.Contains(symbol1))
352
                                verticalSymbols.Add(symbol1);
353
                            if (!verticalSymbols.Contains(symbol2))
354
                                verticalSymbols.Add(symbol2);
355

  
356
                            if (horizontalSymbols.Contains(symbol1))
357
                                mainSymbol = symbol1;
358
                            if (horizontalSymbols.Contains(symbol2))
359
                                mainSymbol = symbol2;
360
                        }
361
                    }
362
                }
363
            }
364

  
365
            application.ActiveSelectSet.RemoveAll();
366
            foreach (var item in verticalSymbols)
367
                application.ActiveSelectSet.Add(item);
368
            foreach (var item in horizontalSymbols)
369
                application.ActiveSelectSet.Add(item);
370
                
371

  
372
            if (MessageBox.Show("Continue?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
373
            {
374
                application.ActiveSelectSet.RemoveAll();
375

  
376
            }
233 377
        }
234
        
378
        private void MoveByResult(LMADataSource dataSource,Dictionary<SymmetryArrow, List<string>> resultDatas, double x, double y, SymmetryArrow arrow, string centerRepID)
379
        {
380
            List<string> datas = resultDatas[arrow];
381
            foreach (var item in resultDatas)
382
            {
383
                if (item.Key != arrow)
384
                {
385
                    for (int i = 0; i < item.Value.Count; i++)
386
                    {
387
                        Symbol2d moveSymbol2d = GetSymbol2DByRepID(dataSource, item.Value[i]);
388
                        Symbol2d symbol2d = GetSymbol2DByRepID(dataSource, datas[i]);
389

  
390
                        double x1, y1, x2, y2;
391
                        symbol2d.GetOrigin(out x1, out y1);
392
                        moveSymbol2d.GetOrigin(out x2, out y2);
393
                        double distance = SPPIDUtil.CalcPointToPointdDistance(x, y, x1, y1);
394

  
395
                        List<Point2d> point2ds;
396
                        if (i == 0)
397
                            point2ds = FindAllPoint2d(dataSource, centerRepID, item.Value[i]);
398
                        else
399
                            point2ds = FindAllPoint2d(dataSource, item.Value[i - 1], item.Value[i]);
400
                        double moveX = 0;
401
                        double moveY = 0;
402

  
403
                        if (item.Key == SymmetryArrow.Left)
404
                            moveX = x - distance - x2;
405
                        else if (item.Key == SymmetryArrow.Right)
406
                            moveX = x + distance - x2;
407
                        else if (item.Key == SymmetryArrow.Down)
408
                            moveY = y - distance - y2;
409
                        else if (item.Key == SymmetryArrow.Up)
410
                            moveY = y + distance - y2;
411

  
412
                        moveSymbol2d.Move(0, 0, moveX, moveY);
413
                        MovePoint2d(dataSource, item.Value[i], arrow, moveX, moveY);
414
                        foreach (var point in point2ds)
415
                            point.Move(0, 0, moveX, moveY);
416
                    }
417
                }
418
            }
419
        }
420
        private string GetRepresentationId(Symbol2d symbol)
421
        {
422
            foreach (var attributes in symbol.AttributeSets)
423
            {
424
                foreach (var attribute in attributes)
425
                {
426
                    string name = attribute.Name;
427
                    object value = attribute.GetValue();
428
                    if (name == "DrawingID")
429
                    {
430
                        return value.ToString();  
431
                    }
432
                }
433
            }
434
            return null;
435
        }
436
        private List<List<string>> SetSymbol(LMADataSource dataSource, string rep, double x, double y, int count)
437
        {
438
            LMSymbol _LMSymbol = dataSource.GetSymbol(rep);
439
            List<List<string>> result = new List<List<string>>();
440
            List<string> oldIDs = new List<string>() { rep };
441
            foreach (LMConnector connector in _LMSymbol.Connect1Connectors)
442
            {
443
                if (connector.get_ItemStatus() != "Active")
444
                    continue;
445

  
446
                string repID = connector.AsLMRepresentation().Id;
447
                string status = connector.get_ItemStatus();
448
                if (status == "Active" && !oldIDs.Contains(repID))
449
                {
450
                    List<string> symbols = new List<string>();
451
                    oldIDs.Add(repID);
452
                    loop(dataSource, oldIDs, symbols, connector, x, y, count);
453
                    result.Add(symbols);
454
                }
455
            }
456

  
457
            foreach (LMConnector connector in _LMSymbol.Connect2Connectors)
458
            {
459
                if (connector.get_ItemStatus() != "Active")
460
                    continue;
461

  
462
                string repID = connector.AsLMRepresentation().Id;
463
                string status = connector.get_ItemStatus();
464
                if (status == "Active" && !oldIDs.Contains(repID))
465
                {
466
                    List<string> symbols = new List<string>();
467
                    oldIDs.Add(repID);
468
                    loop(dataSource, oldIDs, symbols, connector, x, y, count);
469
                    result.Add(symbols);
470
                }
471
            }
472

  
473
            ReleaseCOMObjects(_LMSymbol);
474
            return result;
475
        }
476
        private void loop(LMADataSource dataSource, List<string> oldIDs, List<string> symbols, LMConnector connector, double x, double y, int count)
477
        {
478
            if (symbols.Count >= count)
479
                return;
480

  
481
            if (connector.ConnectItem1SymbolObject != null && !oldIDs.Contains(connector.ConnectItem1SymbolObject.AsLMRepresentation().Id))
482
            {
483
                string repID = connector.ConnectItem1SymbolObject.AsLMRepresentation().Id;
484
                oldIDs.Add(repID);
485
                if (connector.ConnectItem1SymbolObject.get_RepresentationType() != "Branch" && connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active")
486
                {
487
                    double sX = connector.ConnectItem1SymbolObject.get_XCoordinate(), sY = connector.ConnectItem1SymbolObject.get_YCoordinate(); ;
488
                    SlopeType slopeType = SPPIDUtil.CalcSlope(x, y, sX, sY, 1);
489
                    if (slopeType == SlopeType.HORIZONTAL || slopeType == SlopeType.VERTICAL)
490
                        symbols.Add(repID);
491
                }
492

  
493
                loop(dataSource, oldIDs, symbols, connector.ConnectItem1SymbolObject, x, y, count);
494
            }
495

  
496
            if (symbols.Count >= count)
497
                return;
498

  
499
            if (connector.ConnectItem2SymbolObject != null && !oldIDs.Contains(connector.ConnectItem2SymbolObject.AsLMRepresentation().Id))
500
            {
501
                string repID = connector.ConnectItem2SymbolObject.AsLMRepresentation().Id;
502
                oldIDs.Add(repID);
503
                if (connector.ConnectItem2SymbolObject.get_RepresentationType() != "Branch" && connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active")
504
                {
505
                    double sX = connector.ConnectItem2SymbolObject.get_XCoordinate(), sY = connector.ConnectItem2SymbolObject.get_YCoordinate(); ;
506
                    SlopeType slopeType = SPPIDUtil.CalcSlope(x, y, sX, sY, 1);
507
                    if (slopeType == SlopeType.HORIZONTAL || slopeType == SlopeType.VERTICAL)
508
                        symbols.Add(repID);
509
                }
510

  
511
                loop(dataSource, oldIDs, symbols, connector.ConnectItem2SymbolObject, x, y, count);
512
            }
513
        }
514
        private void loop(LMADataSource dataSource, List<string> oldIDs, List<string> symbols, LMSymbol _LMSymbol, double x, double y, int count)
515
        {
516
            if (symbols.Count >= count)
517
                return;
518

  
519
            foreach (LMConnector connector in _LMSymbol.Connect1Connectors)
520
            {
521
                if (connector.get_ItemStatus() != "Active")
522
                    continue;
523

  
524
                string repID = connector.AsLMRepresentation().Id;
525
                string status = connector.get_ItemStatus();
526
                if (status == "Active" && !oldIDs.Contains(repID))
527
                {
528
                    oldIDs.Add(repID);
529
                    loop(dataSource, oldIDs, symbols, connector, x, y, count);
530
                }
531
            }
532

  
533
            foreach (LMConnector connector in _LMSymbol.Connect2Connectors)
534
            {
535
                if (connector.get_ItemStatus() != "Active")
536
                    continue;
537

  
538
                string repID = connector.AsLMRepresentation().Id;
539
                string status = connector.get_ItemStatus();
540
                if (status == "Active" && !oldIDs.Contains(repID))
541
                {
542
                    oldIDs.Add(repID);
543
                    loop(dataSource, oldIDs, symbols, connector, x, y, count);
544
                }
545
            }
546
        }
547
        private Symbol2d GetSymbol2DByRepID(LMADataSource dataSource, string repID)
548
        {
549
            LMSymbol _LMSymbol = dataSource.GetSymbol(repID);
550
            Symbol2d symbol2D = application.ActiveDocument.ActiveSheet.DrawingObjects[_LMSymbol.get_GraphicOID().ToString()];
551
            ReleaseCOMObjects(_LMSymbol);
552
            return symbol2D;
553
        }
554
        private void MovePoint2d(LMADataSource datasource, string repID, SymmetryArrow arrow, double moveX, double moveY)
555
        {
556
            LMSymbol _LMSymbol = datasource.GetSymbol(repID);
557
            foreach (LMConnector connector in _LMSymbol.Connect1Connectors)
558
            {
559
                if (connector.get_ItemStatus() == "Active" && Convert.ToBoolean(connector.get_IsZeroLength()))
560
                {
561
                    if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_RepresentationType() == "Branch")
562
                    {
563
                        Point2d point = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem1SymbolObject.get_GraphicOID().ToString()];
564
                        point.X += moveX;
565
                        point.Y += moveY;
566
                    }
567
                    else if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_RepresentationType() == "Branch")
568
                    {
569
                        Point2d point = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem2SymbolObject.get_GraphicOID().ToString()];
570
                        point.X += moveX;
571
                        point.Y += moveY;
572
                    }
573
                }
574
            }
575
            foreach (LMConnector connector in _LMSymbol.Connect2Connectors)
576
            {
577
                if (connector.get_ItemStatus() == "Active" && Convert.ToBoolean(connector.get_IsZeroLength()))
578
                {
579
                    if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_RepresentationType() == "Branch")
580
                    {
581
                        Point2d point = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem1SymbolObject.get_GraphicOID().ToString()];
582
                        point.X += moveX;
583
                        point.Y += moveY;
584
                    }
585
                    else if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_RepresentationType() == "Branch")
586
                    {
587
                        Point2d point = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem2SymbolObject.get_GraphicOID().ToString()];
588
                        point.X += moveX;
589
                        point.Y += moveY;
590
                    }
591
                }
592
            }
593
            ReleaseCOMObjects(_LMSymbol);
594
        }
595

  
596
        private List<Point2d> FindAllPoint2d(LMADataSource dataSource, string repID, string nextRepID)
597
        {
598
            LMSymbol _LMSymbol = dataSource.GetSymbol(repID);
599
            List<string> endIDs = new List<string>() { repID };
600
            List<string> graphicOIDs = new List<string>();
601
            List<Point2d> result = new List<Point2d>();
602
            FindPointsLoop(dataSource, _LMSymbol, endIDs, nextRepID, graphicOIDs);
603
            ReleaseCOMObjects(_LMSymbol);
604
            foreach (var item in graphicOIDs)
605
            {
606
                Point2d point = application.ActiveDocument.ActiveSheet.DrawingObjects[item] as Point2d;
607
                result.Add(point);
608
            }
609
            
610
            return result;
611
        }
612

  
613
        private bool FindPointsLoop(LMADataSource dataSource, LMSymbol _LMSymbol, List<string> endIDs, string targetRepID, List<string> graphicOIDs)
614
        {
615
            foreach (LMConnector connector in _LMSymbol.Connect1Connectors)
616
            {
617
                if (connector.get_ItemStatus() != "Active")
618
                    continue;
619

  
620
                if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active")
621
                {
622
                    string repID = connector.ConnectItem1SymbolObject.AsLMRepresentation().Id;
623
                    if (!endIDs.Contains(repID))
624
                    {
625
                        endIDs.Add(repID);
626
                        if (connector.ConnectItem1SymbolObject.get_RepresentationType() == "Branch")
627
                        {
628
                            if (FindPointsLoop(dataSource, connector.ConnectItem1SymbolObject, endIDs, targetRepID, graphicOIDs))
629
                            {
630
                                if (!Convert.ToBoolean(connector.get_IsZeroLength()))
631
                                    graphicOIDs.Add(connector.ConnectItem1SymbolObject.get_GraphicOID().ToString());
632
                                return true;
633
                            }
634
                        }
635
                        else if (targetRepID == repID)
636
                        {
637
                            return true;
638
                        }
639
                    }
640
                }
641
                if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active")
642
                {
643
                    string repID = connector.ConnectItem2SymbolObject.AsLMRepresentation().Id;
644
                    if (!endIDs.Contains(repID))
645
                    {
646
                        endIDs.Add(repID);
647
                        if (connector.ConnectItem2SymbolObject.get_RepresentationType() == "Branch")
648
                        {
649
                            if (FindPointsLoop(dataSource, connector.ConnectItem2SymbolObject, endIDs, targetRepID, graphicOIDs))
650
                            {
651
                                if (!Convert.ToBoolean(connector.get_IsZeroLength()))
652
                                    graphicOIDs.Add(connector.ConnectItem2SymbolObject.get_GraphicOID().ToString());
653
                                return true;
654
                            }
655
                        }
656
                        else if (targetRepID == repID)
657
                        {
658
                            return true;
659
                        }
660
                    }
661
                }
662
            }
663
            foreach (LMConnector connector in _LMSymbol.Connect2Connectors)
664
            {
665
                if (connector.get_ItemStatus() != "Active")
666
                    continue;
667

  
668
                if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active")
669
                {
670
                    string repID = connector.ConnectItem1SymbolObject.AsLMRepresentation().Id;
671
                    if (!endIDs.Contains(repID))
672
                    {
673
                        endIDs.Add(repID);
674
                        if (connector.ConnectItem1SymbolObject.get_RepresentationType() == "Branch")
675
                        {
676
                            if (FindPointsLoop(dataSource, connector.ConnectItem1SymbolObject, endIDs, targetRepID, graphicOIDs))
677
                            {
678
                                if (!Convert.ToBoolean(connector.get_IsZeroLength()))
679
                                    graphicOIDs.Add(connector.ConnectItem1SymbolObject.get_GraphicOID().ToString());
680
                                return true;
681
                            }
682
                        }
683
                        else if (targetRepID == repID)
684
                        {
685
                            return true;
686
                        }
687
                    }
688
                }
689
                if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active")
690
                {
691
                    string repID = connector.ConnectItem2SymbolObject.AsLMRepresentation().Id;
692
                    if (!endIDs.Contains(repID))
693
                    {
694
                        endIDs.Add(repID);
695
                        if (connector.ConnectItem2SymbolObject.get_RepresentationType() == "Branch")
696
                        {
697
                            if (FindPointsLoop(dataSource, connector.ConnectItem2SymbolObject, endIDs, targetRepID, graphicOIDs))
698
                            {
699
                                if (!Convert.ToBoolean(connector.get_IsZeroLength()))
700
                                    graphicOIDs.Add(connector.ConnectItem2SymbolObject.get_GraphicOID().ToString());
701
                                return true;
702
                            }
703
                        }
704
                        else if (targetRepID == repID)
705
                        {
706
                            return true;
707
                        }
708
                    }
709
                }
710
            }
711

  
712
            return false;
713
        }
714

  
715

  
716

  
235 717
        #region Hot Key
236 718
        [System.Runtime.InteropServices.DllImport("user32.dll")]
237 719
        private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
DTI_PID/SPPIDConverter/SPPIDConverter.csproj
137 137
    <Compile Include="Form\ID2DBSetting.Designer.cs">
138 138
      <DependentUpon>ID2DBSetting.cs</DependentUpon>
139 139
    </Compile>
140
    <Compile Include="Form\SymmetryForm.cs">
141
      <SubType>Form</SubType>
142
    </Compile>
143
    <Compile Include="Form\SymmetryForm.Designer.cs">
144
      <DependentUpon>SymmetryForm.cs</DependentUpon>
145
    </Compile>
140 146
    <Compile Include="License.cs" />
141 147
    <Compile Include="OPC\AutoModeling_OPC.cs" />
142 148
    <Compile Include="BaseModel\ChildSymbol.cs" />
......
267 273
    <EmbeddedResource Include="Form\SPPID_DB_SettingForm.resx">
268 274
      <DependentUpon>SPPID_DB_SettingForm.cs</DependentUpon>
269 275
    </EmbeddedResource>
276
    <EmbeddedResource Include="Form\SymmetryForm.resx">
277
      <DependentUpon>SymmetryForm.cs</DependentUpon>
278
    </EmbeddedResource>
270 279
    <EmbeddedResource Include="Form\UnitForm.resx">
271 280
      <DependentUpon>UnitForm.cs</DependentUpon>
272 281
    </EmbeddedResource>
DTI_PID/SPPIDConverter/Util/SPPIDUtil.cs
178 178
            return value;
179 179
        }
180 180

  
181
        public static SlopeType CalcSlope(double x1, double y1, double x2, double y2)
181
        public static SlopeType CalcSlope(double x1, double y1, double x2, double y2, double degree = 15)
182 182
        {
183 183
            if (x1 - x2 == 0)
184 184
            {
......
187 187
            else
188 188
            {
189 189
                double angle = Math.Atan(Math.Abs(y2 - y1) / Math.Abs(x2 - x1)) * 180 / Math.PI;
190
                if (angle <= 15)
190
                if (angle <= degree)
191 191
                    return SlopeType.HORIZONTAL;
192
                else if (angle >= 75)
192
                else if (angle >= 90 - degree)
193 193
                    return SlopeType.VERTICAL;
194 194
                else
195 195
                    return SlopeType.Slope;

내보내기 Unified diff

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