forked from eryar/occSketcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSketcher_SnapEnd.cxx
More file actions
100 lines (93 loc) · 2.3 KB
/
Sketcher_SnapEnd.cxx
File metadata and controls
100 lines (93 loc) · 2.3 KB
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
/**
* \file Sketcher_SnapEnd.cxx
* \brief Implementation file for the class Sketcher_SnapEnd
* \author <a href="mailto:sergmaslov@istel.ru?subject=Sketcher_SnapEnd.cxx">Sergei Maslov</a>
*/
#include "Sketcher_SnapEnd.hxx"
IMPLEMENT_STANDARD_RTTIEXT(Sketcher_SnapEnd, Sketcher_Snap)
/**
* \fn Sketcher_SnapEnd()
* \brief Constructs a Sketcher_SnapEnd
*/
Sketcher_SnapEnd::Sketcher_SnapEnd()
{
}
/**
* \fn ~Sketcher_SnapEnd()
* \brief Destructor
*/
Sketcher_SnapEnd::~Sketcher_SnapEnd()
{
}
/**
* \fn SelectEvent()
* \brief find point nearest to end line
* \return void
*/
void Sketcher_SnapEnd::SelectEvent()
{
findbestPnt2d = Standard_False;
minDistance = minimumSnapDistance;
for( Standard_Integer i=1; i<=data->Length(); i++)
{
mySObject = Handle(Sketcher_Object)::DownCast(data->Value(i));
myGeometryType = mySObject->GetGeometryType();
switch (myGeometryType)
{
case PointSketcherObject:
curGeom2d_Point = Handle(Geom2d_CartesianPoint)::DownCast(mySObject->GetGeometry());
objectPnt2d = curGeom2d_Point->Pnt2d();
if(count())
{
bestPnt2d = objectPnt2d;
curHilightedObj = mySObject->GetAIS_Object();
}
break;
case LineSketcherObject:
curGeom2d_Edge = Handle(Geom2d_Edge)::DownCast(mySObject->GetGeometry());
objectPnt2d = curGeom2d_Edge->GetStart_Pnt();
if(count())
{
bestPnt2d = objectPnt2d;
curHilightedObj = mySObject->GetAIS_Object();
}
objectPnt2d = curGeom2d_Edge->GetEnd_Pnt();
if(count())
{
bestPnt2d = objectPnt2d;
curHilightedObj = mySObject->GetAIS_Object();
}
break;
case CircleSketcherObject:
break;
case ArcSketcherObject:
curGeom2d_Arc = Handle(Geom2d_Arc)::DownCast(mySObject->GetGeometry());
objectPnt2d = curGeom2d_Arc->FirstPnt();
if(count())
{
bestPnt2d = objectPnt2d;
curHilightedObj = mySObject->GetAIS_Object();
}
objectPnt2d = curGeom2d_Arc->LastPnt();
if(count())
{
bestPnt2d = objectPnt2d;
curHilightedObj = mySObject->GetAIS_Object();
}
break;
default:break;
}
}
if(minDistance == minimumSnapDistance)
bestPnt2d = curPnt2d;
else findbestPnt2d = Standard_True;
}
/**
* \fn GetSnapType()
* \brief get Snap type
* \return Sketcher_SnapType
*/
Sketcher_SnapType Sketcher_SnapEnd::GetSnapType()
{
return SnapEnd;
}