개정판 06b40010
dev issue #497 : Snap Grid 기능 추가 (SPPID 도면만 현재 가능)
Change-Id: If1fd23c7e22a18f95054160fe12914ed0384bc4b
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
451 | 451 |
SlopeType slopeType = SPPIDUtil.CalcSlope(x, y, prevSymbol.SPPID.ORIGINAL_X, prevSymbol.SPPID.ORIGINAL_Y); |
452 | 452 |
double prevX = _PrevSymbol.get_XCoordinate(); |
453 | 453 |
double prevY = _PrevSymbol.get_YCoordinate(); |
454 |
if (slopeType == SlopeType.HORIZONTAL) |
|
455 |
y = prevY; |
|
456 |
else if (slopeType == SlopeType.VERTICAL) |
|
457 |
x = prevX; |
|
454 |
//if (slopeType == SlopeType.HORIZONTAL) |
|
455 |
// y = prevY; |
|
456 |
//else if (slopeType == SlopeType.VERTICAL) |
|
457 |
// x = prevX; |
|
458 |
ReleaseCOMObjects(_PrevSymbol); |
|
458 | 459 |
_LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
459 | 460 |
} |
460 | 461 |
else |
DTI_PID/SPPIDConverter/SPPIDModel/GridSetting.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Threading.Tasks; |
|
6 |
|
|
7 |
namespace Converter.SPPID |
|
8 |
{ |
|
9 |
enum GridUnit |
|
10 |
{ |
|
11 |
Inch |
|
12 |
} |
|
13 |
class GridSetting |
|
14 |
{ |
|
15 |
private static GridSetting setting; |
|
16 |
public bool UseSnapGrid { get; set; } |
|
17 |
public double Density { get; set; } |
|
18 |
public GridUnit Unit { get; set; } |
|
19 |
|
|
20 |
public static GridSetting GetInstance() |
|
21 |
{ |
|
22 |
if (setting == null) |
|
23 |
setting = new GridSetting(); |
|
24 |
|
|
25 |
return setting; |
|
26 |
} |
|
27 |
|
|
28 |
public static void Clear() |
|
29 |
{ |
|
30 |
setting = new GridSetting(); |
|
31 |
} |
|
32 |
} |
|
33 |
} |
DTI_PID/SPPIDConverter/SPPIDModel/SPPID_Document.cs | ||
---|---|---|
90 | 90 |
double y = double.NaN; |
91 | 91 |
SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y); |
92 | 92 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY); |
93 |
|
|
94 |
SPPIDUtil.ConvertGridPoint(ref x, ref y); |
|
95 |
|
|
93 | 96 |
item.SPPID.ORIGINAL_X = x; |
94 | 97 |
item.SPPID.ORIGINAL_Y = y; |
95 | 98 |
} |
... | ... | |
116 | 119 |
double y = double.NaN; |
117 | 120 |
SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y); |
118 | 121 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY); |
122 |
|
|
123 |
SPPIDUtil.ConvertGridPoint(ref x, ref y); |
|
124 |
|
|
119 | 125 |
item.SPPID.ORIGINAL_X = x; |
120 | 126 |
item.SPPID.ORIGINAL_Y = y; |
121 | 127 |
} |
DTI_PID/SPPIDConverter/Util/SPPIDUtil.cs | ||
---|---|---|
138 | 138 |
dY = Convert.ToDouble(calcY); |
139 | 139 |
} |
140 | 140 |
|
141 |
public static void ConvertGridPoint(ref double x, ref double y) |
|
142 |
{ |
|
143 |
GridSetting _GridSetting = GridSetting.GetInstance(); |
|
144 |
if (_GridSetting.UseSnapGrid) |
|
145 |
{ |
|
146 |
if (_GridSetting.Unit == GridUnit.Inch) |
|
147 |
{ |
|
148 |
double length = _GridSetting.Density * 0.0254; |
|
149 |
double tempX = x; |
|
150 |
double tempY = y; |
|
151 |
x = Math.Round(tempX / length) * length; |
|
152 |
y = Math.Round(tempY / length) * length; |
|
153 |
} |
|
154 |
} |
|
155 |
} |
|
156 |
|
|
141 | 157 |
public static SlopeType CalcSlope(double x1, double y1, double x2, double y2) |
142 | 158 |
{ |
143 | 159 |
if (x1 - x2 == 0) |
내보내기 Unified diff