-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathSketcher_PropertyArc.cxx
150 lines (127 loc) · 4.72 KB
/
Sketcher_PropertyArc.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
/**
* \file Sketcher_PropertyArc.cxx
* \brief Implementation file for the class Sketcher_PropertyArc
* \author <a href="mailto:[email protected]?subject=Sketcher_PropertyArc.cxx">Sergei Maslov</a>
*/
#include "Sketcher_PropertyArc.hxx"
/**
* \fn Sketcher_PropertyArc( QWidget* parent, const char* name, WFlags fl )
* \brief Constructs a Sketcher_PropertyArc which is a child of 'parent', with the name 'name' and widget flags set to 'f'
* \param parent QWidget*
* \param name const char*
* \param fl WFlags
*/
Sketcher_PropertyArc::Sketcher_PropertyArc( QWidget* parent, const char* name)
: Sketcher_Property( parent, name)
{
if ( !name )
setWindowTitle( tr( "ArcProperties" ) );
////////////////////////////////////////////////////////////////////////////////
TextLabelPoint1->setText( tr( "Center" ) );
TextLabelRadius = new QLabel("TextLabelRadius", GroupBoxGP );
TextLabelRadius->setText( tr( "Radius" ) );
LineEditRadius = new QLineEdit( "LineEditRadius", GroupBoxGP);
TextLabelStartArc = new QLabel( "TextLabelStartArc", GroupBoxGP);
TextLabelStartArc->setText( tr( "Start" ) );
LineEditStartArc = new QLineEdit( "LineEditStartArc", GroupBoxGP);
TextLabelEndArc = new QLabel("TextLabelEndArc", GroupBoxGP);
TextLabelEndArc->setText( tr( "End" ) );
LineEditEndArc = new QLineEdit( "LineEditEndArc", GroupBoxGP);
GroupBoxGPLayout->addWidget( TextLabelRadius, 1, 0 );
GroupBoxGPLayout->addWidget( LineEditRadius, 1, 1 );
GroupBoxGPLayout->addWidget( TextLabelStartArc, 2, 0 );
GroupBoxGPLayout->addWidget( LineEditStartArc, 2, 1 );
GroupBoxGPLayout->addWidget( TextLabelEndArc, 3, 0 );
GroupBoxGPLayout->addWidget( LineEditEndArc, 3, 1 );
///////////////////////////////////////////////////////////////////////////////
Init();
////////////////////////////////////////////////////////////////////////////////////
}
/**
* \fn ~Sketcher_PropertyArc()
* \brief destructor
*/
Sketcher_PropertyArc::~Sketcher_PropertyArc()
{
// no need to delete child widgets, Qt does it all for us
}
/**
* \fn SetGeometry()
* \brief show object geometry in dialog window
* \return void
*/
void Sketcher_PropertyArc::SetGeometry()
{
curGeom2d_Arc = Handle(Geom2d_Arc)::DownCast(mySObject->GetGeometry());
firstPnt2d = curGeom2d_Arc->Location();
myRadius = curGeom2d_Arc->Radius();
myFirstParameter = curGeom2d_Arc->FirstParameter() / (2*M_PI);
myLastParameter = curGeom2d_Arc->LastParameter() / (2*M_PI);
SetCoord(LineEditPoint1,firstPnt2d);
LineEditRadius->setText(QString::number(myRadius));
LineEditStartArc->setText(QString::number(myFirstParameter ));
LineEditEndArc->setText(QString::number(myLastParameter));
}
/**
* \fn CheckGeometry()
* \brief check geometry for change
* \return bool
*/
bool Sketcher_PropertyArc::CheckGeometry()
{
if (CheckCoord(LineEditPoint1,tempPnt2d ))
{
NumName = LineEditRadius->text();
tempRadius = NumName.toDouble();
if(NumName.contains(NumberExpr) == 0 && !NumName.isNull() && tempRadius > 0)
{
NumName = LineEditStartArc->text();
tempFirstParameter = NumName.toDouble();
if(NumName.contains(NumberExpr) == 0 && !NumName.isNull())
{
NumName = LineEditEndArc->text();
tempLastParameter = NumName.toDouble();
if(NumName.contains(NumberExpr) == 0 && !NumName.isNull())
return true;
else LineEditEndArc->selectAll();
}
else LineEditStartArc->selectAll();
}
else LineEditRadius->selectAll();
}
return false;
}
/**
* \fn GetGeometry()
* \brief create new object
* \return bool
*/
bool Sketcher_PropertyArc::GetGeometry()
{
if(!firstPnt2d.IsEqual(tempPnt2d,1.0e-6) || myRadius != tempRadius || myFirstParameter != tempFirstParameter || myLastParameter != tempLastParameter )
{
gce_MakeCirc2d tempMakeCirc2d(tempPnt2d,tempRadius);
if (tempMakeCirc2d.Status() == gce_Done)
{
firstPnt2d = tempPnt2d;
myRadius = tempRadius;
curGeom2d_Arc->SetCirc2d(tempMakeCirc2d.Value());
curGeom2d_Arc->SetFirstParam(tempFirstParameter * 2*M_PI);
curGeom2d_Arc->SetLastParam(tempLastParameter * 2*M_PI);
myFirstParameter = curGeom2d_Arc->FirstParameter();
myLastParameter = curGeom2d_Arc->LastParameter();
Handle(Geom_Circle) newGeom_Circle = new Geom_Circle(ElCLib::To3d(myCoordinateSystem.Ax2(),curGeom2d_Arc->Circ2d()));
Handle(AIS_Circle) newAIS_Circle = new AIS_Circle(newGeom_Circle);
newAIS_Circle->SetFirstParam(myFirstParameter);
newAIS_Circle->SetLastParam (myLastParameter);
myFirstParameter /= (2*M_PI);
myLastParameter /= (2*M_PI);
myContext->Remove(myAIS_Object, true);
myAIS_Object = newAIS_Circle;
LineEditStartArc->setText(QString::number(myFirstParameter));
LineEditEndArc->setText(QString::number(myLastParameter));
return true;
}
}
return false;
}