-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathSketcher_SnapLineParallel.cxx
104 lines (91 loc) · 2.28 KB
/
Sketcher_SnapLineParallel.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/**
* \file Sketcher_SnapLineParallel.cxx
* \brief Implementation file for the class Sketcher_SnapLineParallel
* \author <a href="mailto:[email protected]?subject=Sketcher_SnapLineParallel.cxx">Sergei Maslov</a>
*/
#include "Sketcher_SnapLineParallel.hxx"
IMPLEMENT_STANDARD_RTTIEXT(Sketcher_SnapLineParallel, Sketcher_SnapLine)
/**
* \fn Sketcher_SnapLineParallel()
* \brief Constructs a Sketcher_SnapLineParallel
*/
Sketcher_SnapLineParallel::Sketcher_SnapLineParallel()
{
myParRelation = new AIS_ParallelRelation(FirstEdge,SecondEdge,myPlane);
}
/**
* \fn ~Sketcher_SnapLineParallel()
* \brief Destructor
*/
Sketcher_SnapLineParallel::~Sketcher_SnapLineParallel()
{
}
/**
* \fn SelectEvent()
* \brief construct line parallel to existing line
* \return void
*/
void Sketcher_SnapLineParallel::SelectEvent()
{
SelectNearest();
if(minDistance == minimumSnapDistance/2)
{
nearestPnt2d = curPnt2d;
curDir2d = gp_Dir2d (gp_Vec2d(curGeom2d_Point->Pnt2d(),curPnt2d));
minAngle = MINANGLE;
for( Standard_Integer i=1; i<=data->Length(); i++)
{
mySObject = Handle(Sketcher_Object)::DownCast(data->Value(i));
myGeometryType = mySObject->GetGeometryType();
switch (myGeometryType)
{
case PointSketcherObject: break;
case LineSketcherObject: curGeom2d_Line = Handle(Geom2d_Line)::DownCast(mySObject->GetGeometry());
tempDir2d = curGeom2d_Line->Lin2d().Direction();
checkparallel();
break;
case CircleSketcherObject: break;
case ArcSketcherObject: break;
default:break;
}
}
if(minAngle == MINANGLE)
bestPnt2d = curPnt2d;
else setEdges();
}
else
{
ProjectPoint();
setEdges();
}
}
/**
* \fn GetSnapType()
* \brief get Snap type
* \return Sketcher_SnapType
*/
Sketcher_SnapType Sketcher_SnapLineParallel::GetSnapType()
{
return SnapParallel;
}
/**
* \fn DrawRelation()
* \brief draw relation
* \return void
*/
void Sketcher_SnapLineParallel::DrawRelation()
{
myParRelation->SetFirstShape(FirstEdge);
myParRelation->SetSecondShape(SecondEdge);
if(firstDisplay) myContext->Display(myParRelation,0,-1, true);
else myContext->Redisplay(myParRelation, true);
}
/**
* \fn EraseRelation()
* \brief erase relation
* \return void
*/
void Sketcher_SnapLineParallel::EraseRelation()
{
myContext->Remove(myParRelation, true);
}