forked from eryar/occSketcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSketcher_PropertyCircle.cxx
More file actions
108 lines (90 loc) · 2.97 KB
/
Sketcher_PropertyCircle.cxx
File metadata and controls
108 lines (90 loc) · 2.97 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
101
102
103
104
105
106
107
108
/**
* \file Sketcher_PropertyCircle.cxx
* \brief Implementation file for the class Sketcher_PropertyCircle
* \author <a href="mailto:sergmaslov@istel.ru?subject=Sketcher_PropertyCircle.cxx">Sergei Maslov</a>
*/
#include "Sketcher_PropertyCircle.hxx"
/**
* \fn Sketcher_PropertyCircle( QWidget* parent, const char* name, WFlags fl )
* \brief Constructs a Sketcher_PropertyCircle 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_PropertyCircle::Sketcher_PropertyCircle( QWidget* parent, const char* name)
: Sketcher_Property( parent, name)
{
if ( !name )
setWindowTitle( "Property of Circle" );
//setCaption( tr( "CircleProperties" ) );
////////////////////////////////////////////////////////////////////////////////
TextLabelPoint1->setText( tr( "Center" ) );
TextLabelRadius = new QLabel( "TextLabelRadius", GroupBoxGP);
TextLabelRadius->setText( tr( "Radius" ) );
LineEditRadius = new QLineEdit("LineEditRadius", GroupBoxGP);
GroupBoxGPLayout->addWidget( TextLabelRadius, 1, 0 );
GroupBoxGPLayout->addWidget( LineEditRadius, 1, 1 );
///////////////////////////////////////////////////////////////////////////////
Init();
////////////////////////////////////////////////////////////////////////////////////
}
/**
* \fn ~Sketcher_PropertyCircle()
* \brief destructor
*/
Sketcher_PropertyCircle::~Sketcher_PropertyCircle()
{
// 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_PropertyCircle::SetGeometry()
{
curGeom2d_Circle = Handle(Geom2d_Circle)::DownCast(mySObject->GetGeometry());
firstPnt2d = curGeom2d_Circle->Location();
myRadius = curGeom2d_Circle->Radius();
SetCoord(LineEditPoint1,firstPnt2d);
LineEditRadius->setText(QString::number(myRadius));
}
/**
* \fn CheckGeometry()
* \brief check geometry for change
* \return bool
*/
bool Sketcher_PropertyCircle::CheckGeometry()
{
if (CheckCoord(LineEditPoint1,tempPnt2d ))
{
NumName = LineEditRadius->text();
tempRadius = NumName.toDouble();
if(NumName.contains(NumberExpr) == 0 && !NumName.isNull() && tempRadius > 0)
return true;
else LineEditRadius->selectAll();
}
return false;
}
/**
* \fn GetGeometry()
* \brief create new object
* \return bool
*/
bool Sketcher_PropertyCircle::GetGeometry()
{
if(!firstPnt2d.IsEqual(tempPnt2d,1.0e-6) || myRadius !=tempRadius)
{
firstPnt2d = tempPnt2d;
myRadius = tempRadius;
curGeom2d_Circle->SetLocation(firstPnt2d);
curGeom2d_Circle->SetRadius(myRadius);
Handle(Geom_Circle) newGeom_Circle = new Geom_Circle(myCoordinateSystem.Ax2(),myRadius);
newGeom_Circle->SetLocation(ElCLib::To3d(myCoordinateSystem.Ax2(),firstPnt2d));
Handle(AIS_Circle) newAIS_Circle = new AIS_Circle(newGeom_Circle);
myContext->Remove(myAIS_Object, true);
myAIS_Object = newAIS_Circle;
return true;
}
return false;
}