Fix arc angle calculation and python API for it

1. It's impossible to use methods that modify parameters in swig so
I extend it in wrapper
2. Simplify GetArcAngle() and fix the bug where it lies about 360
degree arc to be 0 degrees.
This commit is contained in:
qu1ck 2021-10-19 22:28:06 -07:00 committed by Jeff Young
parent 463b82cf46
commit 09a2701136
2 changed files with 16 additions and 11 deletions

View File

@ -494,15 +494,12 @@ void EDA_SHAPE::SetArcGeometry( const wxPoint& aStart, const wxPoint& aMid, cons
double EDA_SHAPE::GetArcAngle() const
{
VECTOR2D startLine = m_start - m_arcCenter;
VECTOR2D endLine = m_end - m_arcCenter;
double startAngle;
double endAngle;
double arcAngle = RAD2DECIDEG( endLine.Angle() - startLine.Angle() );
CalcArcAngles( startAngle, endAngle );
if( arcAngle < 0.0 )
arcAngle += 3600.0;
return arcAngle;
return ( endAngle - startAngle ) * 10;
}

View File

@ -1,18 +1,26 @@
%{
#include <eda_shape.h>
#include <pcb_shape.h>
%}
%include eda_shape.h
%include pcb_shape.h
%extend PCB_SHAPE
{
double GetArcAngleStart()
{
double startAngle;
double endAngle;
$self->CalcArcAngles( startAngle, endAngle );
return startAngle * 10;
}
%pythoncode
%{
def GetShapeStr(self):
return self.ShowShape(self.GetShape())
%}
}
%{
#include <eda_shape.h>
#include <pcb_shape.h>
%}
/* Only for compatibility with old python scripts: */
const int S_SEGMENT = (const int)SHAPE_T::SEGMENT;