Pcbnew: Bug fix: arcs in modules outlines (when flipped) were incorrectly saved and read in .brd files.

this was due to incorrect macro NORMALIZE_ANGLE (was the same as NORMALIZE_ANGLE_POS), now modified and renamed NORMALIZE_ANGLE_360
This commit is contained in:
jean-pierre charras 2011-01-05 18:28:55 +01:00
parent ff9cdca994
commit 9618c3a5f5
8 changed files with 24 additions and 21 deletions

View File

@ -126,8 +126,8 @@ bool LIB_ARC::Load( char* aLine, wxString& aErrorMsg )
if( tmp[0] == 'f' )
m_Fill = FILLED_WITH_BG_BODYCOLOR;
NORMALIZE_ANGLE( m_t1 );
NORMALIZE_ANGLE( m_t2 );
NORMALIZE_ANGLE_POS( m_t1 );
NORMALIZE_ANGLE_POS( m_t2 );
// Actual Coordinates of arc ends are read from file
if( cnt >= 13 )
@ -712,8 +712,8 @@ void LIB_ARC::calcRadiusAngles()
m_t2 = (int) ( atan2( (double) centerEndVector.y,
(double) centerEndVector.x ) * 1800 / M_PI );
NORMALIZE_ANGLE( m_t1 );
NORMALIZE_ANGLE( m_t2 ); // angles = 0 .. 3600
NORMALIZE_ANGLE_POS( m_t1 );
NORMALIZE_ANGLE_POS( m_t2 ); // angles = 0 .. 3600
// Restrict angle to less than 180 to avoid PBS display mirror Trace because it is
// assumed that the arc is less than 180 deg to find orientation after rotate or mirror.
@ -734,8 +734,8 @@ void LIB_ARC::calcRadiusAngles()
m_t1--;
}
NORMALIZE_ANGLE( m_t1 );
NORMALIZE_ANGLE_POS( m_t1 );
if( !IsMoving() )
NORMALIZE_ANGLE( m_t2 );
NORMALIZE_ANGLE_POS( m_t2 );
}

View File

@ -62,8 +62,8 @@ bool TRANSFORM::MapAngles( int* aAngle1, int* aAngle2 ) const
x = t;
*aAngle2 = (int) ( atan2( y, x ) * 1800.0 / M_PI + 0.5 );
NORMALIZE_ANGLE( *aAngle1 );
NORMALIZE_ANGLE( *aAngle2 );
NORMALIZE_ANGLE_POS( *aAngle1 );
NORMALIZE_ANGLE_POS( *aAngle2 );
if( *aAngle2 < *aAngle1 )
*aAngle2 += 3600;
@ -73,8 +73,8 @@ bool TRANSFORM::MapAngles( int* aAngle1, int* aAngle2 ) const
*aAngle1 = (*aAngle2);
*aAngle2 = Angle;
NORMALIZE_ANGLE( *aAngle1 );
NORMALIZE_ANGLE( *aAngle2 );
NORMALIZE_ANGLE_POS( *aAngle1 );
NORMALIZE_ANGLE_POS( *aAngle2 );
if( *aAngle2 < *aAngle1 )
*aAngle2 += 3600;
swap = true;

View File

@ -63,15 +63,16 @@ static inline const wxChar* GetChars( const wxString& s )
#define DEG2RAD( Deg ) ( (Deg) * M_PI / 180.0 )
#define RAD2DEG( Rad ) ( (Rad) * 180.0 / M_PI )
/* Normalize angle to be in the -360.0 .. 360.0 range or 0 .. 360.0: */
#define NORMALIZE_ANGLE( Angle ) { while( Angle < 0 ) \
// Normalize angle to be in the -360.0 .. 360.0:
#define NORMALIZE_ANGLE_360( Angle ) { while( Angle < -3600 ) \
Angle += 3600;\
while( Angle > 3600 ) \
Angle -= 3600;}
/* Normalize angle to be in the 0.0 .. 360.0 range: */
#define NORMALIZE_ANGLE_POS( Angle ) { while( Angle < 0 ) \
Angle += 3600;while( Angle >= 3600 ) \
Angle += 3600;\
while( Angle >= 3600 ) \
Angle -= 3600;}
#define NEGATE_AND_NORMALIZE_ANGLE_POS( Angle ) \
{ Angle = -Angle; while( Angle < 0 ) \

View File

@ -248,6 +248,8 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
}
DisplayToolMsg( wxEmptyString );
DrawPanel->SetCursor( DrawPanel->m_PanelCursor =
DrawPanel->m_PanelDefaultCursor );
}
@ -263,7 +265,7 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
*/
bool WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
{
bool nextcmd = false;
bool nextcmd = false; // Will be set to true if a block place is needed
bool cancelCmd = false;
// If coming here after cancel block, clean up and exit
@ -296,8 +298,8 @@ bool WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
// Exit if no items found
if( !GetScreen()->m_BlockLocate.GetCount() )
cancelCmd = true;
else
nextcmd = true;
// else
// nextcmd = true;
}
}

View File

@ -532,7 +532,7 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
NEGATE( pad->m_Offset.x );
NEGATE( pad->m_DeltaSize.x );
pad->m_Orient = 1800 - pad->m_Orient;
NORMALIZE_ANGLE( pad->m_Orient );
NORMALIZE_ANGLE_POS( pad->m_Orient );
}
item = module->m_Drawings;
@ -587,7 +587,7 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
ROTATE( pad->GetPosition() );
pad->m_Pos0 = pad->GetPosition();
pad->m_Orient += 900;
NORMALIZE_ANGLE( pad->m_Orient );
NORMALIZE_ANGLE_POS( pad->m_Orient );
}
item = module->m_Drawings;

View File

@ -421,7 +421,7 @@ int EDGE_MODULE::ReadDescr( char* Line, FILE* File,
&m_Start0.x, &m_Start0.y,
&m_End0.x, &m_End0.y,
&m_Angle, &m_Width, &m_Layer );
NORMALIZE_ANGLE( m_Angle );
NORMALIZE_ANGLE_360( m_Angle );
break;
case S_SEGMENT:

View File

@ -215,7 +215,7 @@ void DialogGraphicItemProperties::OnOkClick( wxCommandEvent& event )
{
long angle;
m_Angle_Ctrl->GetValue().ToLong(&angle);
NORMALIZE_ANGLE(angle);
NORMALIZE_ANGLE_360(angle);
m_Item->m_Angle = angle;
}

View File

@ -192,7 +192,7 @@ void WinEDA_PcbFrame::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
TextePcb->Draw( DrawPanel, DC, GR_XOR );
TextePcb->m_Orient += angle;
NORMALIZE_ANGLE( TextePcb->m_Orient );
NORMALIZE_ANGLE_POS( TextePcb->m_Orient );
/* Redraw text in new position. */
TextePcb->Draw( DrawPanel, DC, drawmode );