From 85fb1ecd0d53dbed2fd325d6e12e855271639f1c Mon Sep 17 00:00:00 2001 From: gdd Date: Thu, 28 Oct 2010 12:21:52 +0000 Subject: [PATCH] RNC: EDF 1619, Added a constructor with end point for the arcs in the sketcher 2D. --- src/EntityGUI/EntityGUI_SketcherDlg.cxx | 24 +++++++++++++++++-- src/GEOM_SWIG/GEOM_Sketcher.py | 4 +++- src/GEOM_SWIG/geompyDC.py | 2 ++ src/SKETCHER/Sketcher_Profile.cxx | 31 ++++++++++++++++++++++++- 4 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/EntityGUI/EntityGUI_SketcherDlg.cxx b/src/EntityGUI/EntityGUI_SketcherDlg.cxx index 8538d514f..4d7574e5d 100644 --- a/src/EntityGUI/EntityGUI_SketcherDlg.cxx +++ b/src/EntityGUI/EntityGUI_SketcherDlg.cxx @@ -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 ); diff --git a/src/GEOM_SWIG/GEOM_Sketcher.py b/src/GEOM_SWIG/GEOM_Sketcher.py index 61d601e22..5a8edface 100644 --- a/src/GEOM_SWIG/GEOM_Sketcher.py +++ b/src/GEOM_SWIG/GEOM_Sketcher.py @@ -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 diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index a873fc9c8..eaf571bef 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -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) diff --git a/src/SKETCHER/Sketcher_Profile.cxx b/src/SKETCHER/Sketcher_Profile.cxx index 69b72731f..5e04c891e 100644 --- a/src/SKETCHER/Sketcher_Profile.cxx +++ b/src/SKETCHER/Sketcher_Profile.cxx @@ -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; -- 2.39.2