개정판 8056c558
dev issue #728: 소스 정리 및 C#언어로 개발
DTI_PID/SPPIDAutoModeling/SPPIDUtill.cs | ||
---|---|---|
6 | 6 | |
7 | 7 |
namespace SPPIDAutoModeling |
8 | 8 |
{ |
9 |
public class SPPIDUtill |
|
9 |
public static class SPPIDUtill
|
|
10 | 10 |
{ |
11 | 11 |
private static readonly double _DWG_X = 0.875; |
12 | 12 |
private static readonly double _DWG_Y = 0.617; |
... | ... | |
15 | 15 |
{ |
16 | 16 |
double calcX = 0; |
17 | 17 |
double calcY = 0; |
18 |
calcX = (dX * _DWG_X) / dDwgY;
|
|
18 |
calcX = (dX * _DWG_X) / dDwgX;
|
|
19 | 19 |
calcX = Math.Truncate(calcX * 1000) / 1000; |
20 | 20 |
calcY = _DWG_Y - ((dY * _DWG_Y) / dDwgY); |
21 | 21 |
calcY = Math.Truncate(calcY * 1000) / 1000; |
22 | 22 |
dX = calcX; |
23 | 23 |
dY = calcY; |
24 | 24 |
} |
25 | ||
26 |
public static bool ConvertPointBystring(string sPoint, ref double dX, ref double dY) |
|
27 |
{ |
|
28 |
try |
|
29 |
{ |
|
30 |
string[] pointArr = sPoint.Split(new char[] { ',' }); |
|
31 |
if (pointArr.Length == 2) |
|
32 |
{ |
|
33 |
dX = Convert.ToDouble(pointArr[0]); |
|
34 |
dY = Convert.ToDouble(pointArr[1]); |
|
35 |
} |
|
36 |
} |
|
37 |
catch (Exception) |
|
38 |
{ |
|
39 |
dX = 0; |
|
40 |
dY = 0; |
|
41 |
return false; |
|
42 |
} |
|
43 |
|
|
44 |
return true; |
|
45 |
} |
|
46 | ||
47 |
public static Line.SlopType CalcSlop(Pointd point1, Pointd point2) |
|
48 |
{ |
|
49 |
Line.SlopType _type = Line.SlopType.NONE; |
|
50 | ||
51 |
if (point1.X - point2.X == 0) |
|
52 |
_type = Line.SlopType.VERTICAL; |
|
53 |
else |
|
54 |
{ |
|
55 |
double angle = Math.Atan(Math.Abs(point2.Y - point1.Y) / Math.Abs(point2.X - point1.X)) * 180 / Math.PI; |
|
56 |
if (angle < 20) |
|
57 |
_type = Line.SlopType.HORIZONTAL; |
|
58 |
else if (angle > 70) |
|
59 |
_type = Line.SlopType.VERTICAL; |
|
60 |
else |
|
61 |
_type = Line.SlopType.SLOPE; |
|
62 |
} |
|
63 | ||
64 |
return _type; |
|
65 |
} |
|
66 | ||
67 |
public static object FindObjectByUID(string UID) |
|
68 |
{ |
|
69 |
foreach (Symbol item in AutoModeling.DrawingItem.SYMBOLS) |
|
70 |
{ |
|
71 |
if (item.UID == UID) |
|
72 |
return item; |
|
73 |
} |
|
74 | ||
75 |
foreach (Line item in AutoModeling.DrawingItem.LINES) |
|
76 |
{ |
|
77 |
if (item.UID == UID) |
|
78 |
return item; |
|
79 |
} |
|
80 | ||
81 |
return null; |
|
82 |
} |
|
25 | 83 |
} |
26 | 84 |
} |
내보내기 Unified diff