Pcbnew: fix issues with 360 deg angle arcs.
Fixes: lp:1725943 https://bugs.launchpad.net/kicad/+bug/1725943
This commit is contained in:
parent
cdb577bbbc
commit
7418deb454
|
@ -601,6 +601,8 @@ void OPENGL_GAL::DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, d
|
||||||
SWAP( aStartAngle, >, aEndAngle );
|
SWAP( aStartAngle, >, aEndAngle );
|
||||||
|
|
||||||
const double alphaIncrement = calcAngleStep( aRadius );
|
const double alphaIncrement = calcAngleStep( aRadius );
|
||||||
|
printf( "st %f end %f alphaIncrement = %f\n",
|
||||||
|
aStartAngle * 180/M_PI, aEndAngle * 180/M_PI, alphaIncrement * 180/M_PI);
|
||||||
|
|
||||||
Save();
|
Save();
|
||||||
currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0 );
|
currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0 );
|
||||||
|
|
|
@ -263,14 +263,17 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy )
|
||||||
|
|
||||||
/* Move selected sheet with the cursor.
|
/* Move selected sheet with the cursor.
|
||||||
* Callback function used by m_mouseCaptureCallback.
|
* Callback function used by m_mouseCaptureCallback.
|
||||||
* Note also now this function is aclled only when resizing the sheet
|
* Note also now this function is called only when resizing the sheet
|
||||||
* But the (very small code) relative to sheet move is still present here
|
* But the (very small code) relative to sheet move is still present here
|
||||||
*/
|
*/
|
||||||
static void resizeSheetWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
static void resizeSheetWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
||||||
bool aErase )
|
bool aErase )
|
||||||
{
|
{
|
||||||
BASE_SCREEN* screen = aPanel->GetScreen();
|
BASE_SCREEN* screen = aPanel->GetScreen();
|
||||||
SCH_SHEET* sheet = (SCH_SHEET*) screen->GetCurItem();
|
SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( screen->GetCurItem() );
|
||||||
|
|
||||||
|
if( sheet == nullptr ) // Be sure we are using the right object
|
||||||
|
return;
|
||||||
|
|
||||||
if( aErase )
|
if( aErase )
|
||||||
sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
|
sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
|
||||||
|
|
|
@ -206,8 +206,20 @@ inline double RAD2DECIDEG( double rad ) { return rad * 1800.0 / M_PI; }
|
||||||
/* These are templated over T (and not simply double) because eeschema
|
/* These are templated over T (and not simply double) because eeschema
|
||||||
is still using int for angles in some place */
|
is still using int for angles in some place */
|
||||||
|
|
||||||
/// Normalize angle to be in the -360.0 .. 360.0:
|
/// Normalize angle to be >=-360.0 and <= 360.0
|
||||||
template <class T> inline T NormalizeAngle360( T Angle )
|
/// Angle can be equal to -360 or +360
|
||||||
|
template <class T> inline T NormalizeAngle360Max( T Angle )
|
||||||
|
{
|
||||||
|
while( Angle < -3600 )
|
||||||
|
Angle += 3600;
|
||||||
|
while( Angle > 3600 )
|
||||||
|
Angle -= 3600;
|
||||||
|
return Angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Normalize angle to be > -360.0 and < 360.0
|
||||||
|
/// Angle equal to -360 or +360 are set to 0
|
||||||
|
template <class T> inline T NormalizeAngle360Min( T Angle )
|
||||||
{
|
{
|
||||||
while( Angle <= -3600 )
|
while( Angle <= -3600 )
|
||||||
Angle += 3600;
|
Angle += 3600;
|
||||||
|
@ -216,7 +228,6 @@ template <class T> inline T NormalizeAngle360( T Angle )
|
||||||
return Angle;
|
return Angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Normalize angle to be in the 0.0 .. 360.0 range:
|
/// Normalize angle to be in the 0.0 .. 360.0 range:
|
||||||
/// angle is in 1/10 degees
|
/// angle is in 1/10 degees
|
||||||
template <class T> inline T NormalizeAnglePos( T Angle )
|
template <class T> inline T NormalizeAnglePos( T Angle )
|
||||||
|
@ -243,6 +254,8 @@ inline double NormalizeAngleDegreesPos( double Angle )
|
||||||
Angle -= 360.0;
|
Angle -= 360.0;
|
||||||
return Angle;
|
return Angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void NORMALIZE_ANGLE_DEGREES_POS( double& Angle )
|
inline void NORMALIZE_ANGLE_DEGREES_POS( double& Angle )
|
||||||
{
|
{
|
||||||
Angle = NormalizeAngleDegreesPos( Angle );
|
Angle = NormalizeAngleDegreesPos( Angle );
|
||||||
|
@ -258,6 +271,7 @@ template <class T, class T2> inline T AddAngles( T a1, T2 a2 )
|
||||||
return a1;
|
return a1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class T> inline T NegateAndNormalizeAnglePos( T Angle )
|
template <class T> inline T NegateAndNormalizeAnglePos( T Angle )
|
||||||
{
|
{
|
||||||
Angle = -Angle;
|
Angle = -Angle;
|
||||||
|
|
|
@ -299,7 +299,7 @@ public:
|
||||||
|
|
||||||
void SetTextAngle( double aAngle )
|
void SetTextAngle( double aAngle )
|
||||||
{
|
{
|
||||||
EDA_TEXT::SetTextAngle( NormalizeAngle360( aAngle ) );
|
EDA_TEXT::SetTextAngle( NormalizeAngle360Min( aAngle ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -186,7 +186,8 @@ double DRAWSEGMENT::GetArcAngleStart() const
|
||||||
|
|
||||||
void DRAWSEGMENT::SetAngle( double aAngle )
|
void DRAWSEGMENT::SetAngle( double aAngle )
|
||||||
{
|
{
|
||||||
m_Angle = NormalizeAngle360( aAngle );
|
// m_Angle must be >= -360 and <= +360 degrees
|
||||||
|
m_Angle = NormalizeAngle360Max( aAngle );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1120,7 +1120,7 @@ void D_PAD::Rotate( const wxPoint& aRotCentre, double aAngle )
|
||||||
{
|
{
|
||||||
RotatePoint( &m_Pos, aRotCentre, aAngle );
|
RotatePoint( &m_Pos, aRotCentre, aAngle );
|
||||||
|
|
||||||
m_Orient = NormalizeAngle360( m_Orient + aAngle );
|
m_Orient = NormalizeAngle360Min( m_Orient + aAngle );
|
||||||
|
|
||||||
SetLocalCoord();
|
SetLocalCoord();
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ TEXTE_PCB::~TEXTE_PCB()
|
||||||
|
|
||||||
void TEXTE_PCB::SetTextAngle( double aAngle )
|
void TEXTE_PCB::SetTextAngle( double aAngle )
|
||||||
{
|
{
|
||||||
EDA_TEXT::SetTextAngle( NormalizeAngle360( aAngle ) );
|
EDA_TEXT::SetTextAngle( NormalizeAngle360Min( aAngle ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ TEXTE_MODULE::~TEXTE_MODULE()
|
||||||
|
|
||||||
void TEXTE_MODULE::SetTextAngle( double aAngle )
|
void TEXTE_MODULE::SetTextAngle( double aAngle )
|
||||||
{
|
{
|
||||||
EDA_TEXT::SetTextAngle( NormalizeAngle360( aAngle ) );
|
EDA_TEXT::SetTextAngle( NormalizeAngle360Min( aAngle ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -290,11 +290,11 @@ bool DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::Validate()
|
||||||
// Check angle of arc.
|
// Check angle of arc.
|
||||||
double angle;
|
double angle;
|
||||||
m_AngleCtrl->GetValue().ToDouble( &angle );
|
m_AngleCtrl->GetValue().ToDouble( &angle );
|
||||||
angle = NormalizeAngle360( angle );
|
angle = NormalizeAngle360Max( angle );
|
||||||
|
|
||||||
if( angle == 0 )
|
if( angle == 0 )
|
||||||
{
|
{
|
||||||
error_msgs.Add( _( "The arc angle must be greater than zero." ) );
|
error_msgs.Add( _( "The arc angle cannot be zero." ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fall through.
|
// Fall through.
|
||||||
|
|
|
@ -1545,7 +1545,7 @@ void PCB_IO::format( TEXTE_MODULE* aText, int aNestLevel ) const
|
||||||
#else
|
#else
|
||||||
// Choose compatibility for now, even though this is only a 720 degree clamp
|
// Choose compatibility for now, even though this is only a 720 degree clamp
|
||||||
// with two possible values for every angle.
|
// with two possible values for every angle.
|
||||||
orient = NormalizeAngle360( orient + parent->GetOrientation() );
|
orient = NormalizeAngle360Min( orient + parent->GetOrientation() );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -301,7 +301,7 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCB_ZONE_AREA_T:
|
case PCB_ZONE_AREA_T:
|
||||||
draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
|
draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCB_DIMENSION_T:
|
case PCB_DIMENSION_T:
|
||||||
|
@ -931,6 +931,9 @@ void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment, int aLayer )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_ARC:
|
case S_ARC:
|
||||||
|
printf( "S_ARC st %f end %f angle %f\n",
|
||||||
|
aSegment->GetArcAngleStart()/10.0, (aSegment->GetArcAngleStart() + aSegment->GetAngle())/10.0,
|
||||||
|
aSegment->GetAngle()/10.0 );
|
||||||
m_gal->DrawArcSegment( start, aSegment->GetRadius(),
|
m_gal->DrawArcSegment( start, aSegment->GetRadius(),
|
||||||
DECIDEG2RAD( aSegment->GetArcAngleStart() ),
|
DECIDEG2RAD( aSegment->GetArcAngleStart() ),
|
||||||
DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ),
|
DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ),
|
||||||
|
@ -1082,15 +1085,15 @@ void PCB_PAINTER::draw( const MODULE* aModule, int aLayer )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone, int aLayer )
|
void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone, int aLayer )
|
||||||
{
|
{
|
||||||
|
|
||||||
if( !aZone->IsOnLayer( (PCB_LAYER_ID) aLayer ) )
|
if( !aZone->IsOnLayer( (PCB_LAYER_ID) aLayer ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const COLOR4D& color = m_pcbSettings.GetColor( aZone, aLayer );
|
const COLOR4D& color = m_pcbSettings.GetColor( aZone, aLayer );
|
||||||
std::deque<VECTOR2D> corners;
|
std::deque<VECTOR2D> corners;
|
||||||
PCB_RENDER_SETTINGS::DISPLAY_ZONE_MODE displayMode = m_pcbSettings.m_displayZone;
|
PCB_RENDER_SETTINGS::DISPLAY_ZONE_MODE displayMode = m_pcbSettings.m_displayZone;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue