-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathSketcher_CommandCircle3P.cxx
188 lines (159 loc) · 4.72 KB
/
Sketcher_CommandCircle3P.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/**
* \file Sketcher_CommandCircle3P.cxx
* \brief Implementation file for the class Sketcher_CommandCircle3P
* \author <a href="mailto:[email protected]?subject=Sketcher_CommandCircle3P.cxx">Sergei Maslov</a>
*/
#include "Sketcher_CommandCircle3P.hxx"
IMPLEMENT_STANDARD_RTTIEXT(Sketcher_CommandCircle3P, Sketcher_Command)
/**
* \fn Sketcher_CommandCircle3P()
* \brief Constructs a Sketcher_CommandCircle3P
*/
Sketcher_CommandCircle3P::Sketcher_CommandCircle3P()
: Sketcher_Command("Circle3P."),
tempCirc(curCoordinateSystem.Ax2(),SKETCHER_RADIUS)
{
myCircle3PAction = Nothing;
tempGeom_Circle = new Geom_Circle(curCoordinateSystem.Ax2(),SKETCHER_RADIUS);
myRubberCircle = new AIS_Circle(tempGeom_Circle);
myRubberCircle->SetColor(Quantity_NOC_LIGHTPINK1);
mySecondgp_Pnt2d = gp::Origin2d();
third_Pnt = gp::Origin();
}
/**
* \fn ~Sketcher_CommandCircle3P()
* \brief destructor
*/
Sketcher_CommandCircle3P::~Sketcher_CommandCircle3P()
{
}
/**
* \fn Action()
* \brief turn command to active state
*/
void Sketcher_CommandCircle3P::Action()
{
myCircle3PAction = Input_1CirclePoint;
tempCirc.SetPosition (curCoordinateSystem.Ax2());
}
/**
* \fn MouseInputEvent(const gp_Pnt2d& thePnt2d )
* \brief input event handler
* \return Standard_Boolean
* \param thePnt2d const gp_Pnt2d&
*/
Standard_Boolean Sketcher_CommandCircle3P::MouseInputEvent(const gp_Pnt2d& thePnt2d)
{
curPnt2d = myAnalyserSnap->MouseInput(thePnt2d);
switch (myCircle3PAction)
{
case Nothing: break;
case Input_1CirclePoint:
myFirstgp_Pnt2d = curPnt2d;
myFirstPoint->SetPnt(ElCLib::To3d(curCoordinateSystem.Ax2(),curPnt2d));
// myRubberLine->SetPoints(myFirstPoint,myFirstPoint);
// myContext->Display(myRubberLine,0,-1);
firstPoint=true;
myCircle3PAction = Input_2CirclePoint;
break;
case Input_2CirclePoint:
{
mySecondgp_Pnt2d = curPnt2d;
mySecondPoint->SetPnt(ElCLib::To3d(curCoordinateSystem.Ax2(),curPnt2d));
tempCirc.SetLocation(myFirstPoint->Pnt().Scaled(mySecondPoint->Pnt(),0.5));
tempCirc.SetRadius(myFirstgp_Pnt2d.Distance(curPnt2d) / 2);
tempGeom_Circle->SetCirc(tempCirc);
myRubberCircle->SetCircle(tempGeom_Circle);
myContext->Remove(myRubberLine, false);
myContext->Display(myRubberCircle,0,-1, false);
myContext->Redisplay(myRubberCircle, true);
myCircle3PAction = Input_3CirclePoint;
}
break;
case Input_3CirclePoint:
{
gce_MakeCirc2d tempMakeCirc2d(myFirstgp_Pnt2d,mySecondgp_Pnt2d,curPnt2d);
if (tempMakeCirc2d.Status() == gce_Done)
{
Handle(Geom2d_Circle) myGeom2d_Circle = new Geom2d_Circle(tempMakeCirc2d.Value());
Handle(Geom_Circle) Geom_Circle1 = new Geom_Circle(ElCLib::To3d(curCoordinateSystem.Ax2(),myGeom2d_Circle->Circ2d()));
Handle(AIS_Circle) myAIS_Circle = new AIS_Circle(Geom_Circle1);
AddObject(myGeom2d_Circle,myAIS_Circle,CircleSketcherObject);
myContext->Remove(myRubberCircle, false);
myContext->Display(myAIS_Circle, true);
myCircle3PAction = Input_1CirclePoint;
}
}
break;
default:break;
}
return Standard_False;
}
/**
* \fn MouseMoveEvent(const gp_Pnt2d& thePnt2d )
* \brief mouse move handler
* \return void
* \param thePnt2d const gp_Pnt2d&
*/
void Sketcher_CommandCircle3P::MouseMoveEvent(const gp_Pnt2d& thePnt2d)
{
curPnt2d = myAnalyserSnap->MouseMove(thePnt2d);
switch (myCircle3PAction)
{
case Nothing:break;
case Input_1CirclePoint: break;
case Input_2CirclePoint:
mySecondPoint->SetPnt(ElCLib::To3d(curCoordinateSystem.Ax2(),curPnt2d));
myRubberLine->SetPoints(myFirstPoint,mySecondPoint);
if(firstPoint)
{
myContext->Display(myRubberLine,0,-1, true);
firstPoint = false;
}else
{
myContext->Redisplay(myRubberLine, true);
}
break;
case Input_3CirclePoint:
{
third_Pnt = ElCLib::To3d(curCoordinateSystem.Ax2(),curPnt2d);
gce_MakeCirc tempMakeCirc = gce_MakeCirc(myFirstPoint->Pnt(),mySecondPoint->Pnt(),third_Pnt);
if (tempMakeCirc.Status() == gce_Done)
{
tempGeom_Circle->SetCirc(tempMakeCirc.Value());
// myRubberCircle->SetCircle(tempGeom_Circle);
myContext->Redisplay(myRubberCircle, true);
}
}
break;
default:break;
}
}
/**
* \fn CancelEvent()
* \brief cancel event handler, stop entering object
* \return void
*/
void Sketcher_CommandCircle3P::CancelEvent()
{
switch (myCircle3PAction)
{
case Nothing: break;
case Input_1CirclePoint: break;
case Input_2CirclePoint: myContext->Remove(myRubberLine, true);
break;
case Input_3CirclePoint: myContext->Remove(myRubberCircle, true);
break;
default: break;
}
myCircle3PAction = Nothing;
}
/**
* \fn GetTypeOfMethod()
* \brief get command Method
* \return Sketcher_ObjectTypeOfMethod
*/
Sketcher_ObjectTypeOfMethod Sketcher_CommandCircle3P::GetTypeOfMethod()
{
return Circle3P_Method;
}