RNC: EDF 1619, Added a constructor with end point for the arcs in the sketcher 2D.

This commit is contained in:
gdd 2010-10-28 12:21:52 +00:00
parent cacfca6348
commit 85fb1ecd0d
4 changed files with 57 additions and 4 deletions

View File

@ -396,7 +396,7 @@ void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
}
else if ( myConstructorId == 1 ) { // ARC
GroupD2->setEnabled( false );
MainWidget->RB_Dest1->setEnabled( false );
MainWidget->RB_Dest1->setEnabled( true );
MainWidget->RB_Dest2->setChecked( true );
DestClicked( 0 );
}
@ -440,7 +440,7 @@ void EntityGUI_SketcherDlg::PointClicked( int constructorId )
// Get setting of step value from file configuration
double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
if ( myConstructorId == 0 ) { // SEGMENT
if ( (myConstructorId == 0) || (myConstructorId == 1) ) { // SEGMENT OR ARC
if ( constructorId == 1 ) { // XY
mySketchType = PT_ABS;
initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
@ -1214,6 +1214,18 @@ void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
}
}
else if ( myConstructorId == 1 ) { // ARC
if ( mySketchType == PT_ABS ) {
myX = vx;
myY = vy;
myXStr = vxStr;
myYStr = vyStr;
}
else if ( mySketchType == PT_RELATIVE ) {
myDX = vx;
myDY = vy;
myDXStr = vxStr;
myDYStr = vyStr;
}
if ( mySketchType == DIR_ANGLE_LENGTH ) {
myAngle = vx;
myRadius = vy;
@ -1338,6 +1350,14 @@ QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters )
}
}
else if ( myConstructorId == 1 ) { // ARC
if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) {
myNewCommand = myNewCommand + "AA " + QString::number( myX ) + " " + QString::number( myY );
theParameters = myXStr + ":" + myYStr;
}
if ( mySketchType == PT_RELATIVE) {
myNewCommand = myNewCommand + "A " + QString::number( myDX ) + " " + QString::number( myDY );
theParameters = myDXStr + ":" + myDYStr;
}
if ( mySketchType == DIR_ANGLE_LENGTH ) {
myNewCommand = myNewCommand + "R " + QString::number( myAngle );
myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius ) + " " + QString::number( myLength );

View File

@ -47,12 +47,14 @@ import geompy
#To Make Arc
#"C radius length" : Create by direction, radius and length(in degree)
#"AA x y": Create by point at X & Y
#"A dx dy" : Create by point with DX & DY
#To finish
#"WW" : Close Wire
#Create Sketcher
Cmd = "Sketch:F 0 0:TT 0 100:C 100 180:WW"
Cmd = "Sketch:F 0 0:TT 0 100:C 100 180:AA -100 100:WW"
Sketcher = geompy.MakeSketcher(Cmd) #(string)->GEOM_Shape_ptr
#Add In Study

View File

@ -910,6 +910,8 @@ class geompyDC(GEOM._objref_GEOM_Gen):
# .
# \n
# - "C radius length" : Create arc by direction, radius and length(in degree)
# - "AA x y": Create arc by point at X & Y
# - "A dx dy" : Create arc by point with DX & DY
# .
# \n
# - "WW" : Close Wire (to finish)

View File

@ -244,7 +244,36 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd)
else
move = none;
break;
}
}
case 'A':
{
if (n1 != 3) goto badargs;
Standard_Real vx = a(1).RealValue();
Standard_Real vy = a(2).RealValue();
if (a(0) == "AA") {
vx -= x;
vy -= y;
}
Standard_Real det = (dx * vy - dy * vx);
if ( Abs(det) > Precision::Confusion()) {
Standard_Real c = (dx * vx + dy * vy) // Cosine of alpha = arc angle / 2
/ Sqrt((dx * dx + dy * dy)
* (vx * vx + vy * vy));
radius = (vx * vx + vy * vy) // radius = distance between start
* Sqrt(dx * dx + dy * dy) // and end point / 2 * sin(alpha)
/ (2.0 * det); // radius is > 0 or < 0
if (Abs(radius) > Precision::Confusion()) {
angle = 2.0 * acos(c); // angle in [0,Pi]
move = circle;
}
else
move = none;
break;
}
else
move = none;
break;
}
case 'I':
{
if (n1 != 2) goto badargs;