Commit 9618c3a5 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: Bug fix: arcs in modules outlines (when flipped) were incorrectly...

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
parent ff9cdca9
...@@ -126,8 +126,8 @@ bool LIB_ARC::Load( char* aLine, wxString& aErrorMsg ) ...@@ -126,8 +126,8 @@ bool LIB_ARC::Load( char* aLine, wxString& aErrorMsg )
if( tmp[0] == 'f' ) if( tmp[0] == 'f' )
m_Fill = FILLED_WITH_BG_BODYCOLOR; m_Fill = FILLED_WITH_BG_BODYCOLOR;
NORMALIZE_ANGLE( m_t1 ); NORMALIZE_ANGLE_POS( m_t1 );
NORMALIZE_ANGLE( m_t2 ); NORMALIZE_ANGLE_POS( m_t2 );
// Actual Coordinates of arc ends are read from file // Actual Coordinates of arc ends are read from file
if( cnt >= 13 ) if( cnt >= 13 )
...@@ -712,8 +712,8 @@ void LIB_ARC::calcRadiusAngles() ...@@ -712,8 +712,8 @@ void LIB_ARC::calcRadiusAngles()
m_t2 = (int) ( atan2( (double) centerEndVector.y, m_t2 = (int) ( atan2( (double) centerEndVector.y,
(double) centerEndVector.x ) * 1800 / M_PI ); (double) centerEndVector.x ) * 1800 / M_PI );
NORMALIZE_ANGLE( m_t1 ); NORMALIZE_ANGLE_POS( m_t1 );
NORMALIZE_ANGLE( m_t2 ); // angles = 0 .. 3600 NORMALIZE_ANGLE_POS( m_t2 ); // angles = 0 .. 3600
// Restrict angle to less than 180 to avoid PBS display mirror Trace because it is // 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. // assumed that the arc is less than 180 deg to find orientation after rotate or mirror.
...@@ -734,8 +734,8 @@ void LIB_ARC::calcRadiusAngles() ...@@ -734,8 +734,8 @@ void LIB_ARC::calcRadiusAngles()
m_t1--; m_t1--;
} }
NORMALIZE_ANGLE( m_t1 ); NORMALIZE_ANGLE_POS( m_t1 );
if( !IsMoving() ) if( !IsMoving() )
NORMALIZE_ANGLE( m_t2 ); NORMALIZE_ANGLE_POS( m_t2 );
} }
...@@ -62,8 +62,8 @@ bool TRANSFORM::MapAngles( int* aAngle1, int* aAngle2 ) const ...@@ -62,8 +62,8 @@ bool TRANSFORM::MapAngles( int* aAngle1, int* aAngle2 ) const
x = t; x = t;
*aAngle2 = (int) ( atan2( y, x ) * 1800.0 / M_PI + 0.5 ); *aAngle2 = (int) ( atan2( y, x ) * 1800.0 / M_PI + 0.5 );
NORMALIZE_ANGLE( *aAngle1 ); NORMALIZE_ANGLE_POS( *aAngle1 );
NORMALIZE_ANGLE( *aAngle2 ); NORMALIZE_ANGLE_POS( *aAngle2 );
if( *aAngle2 < *aAngle1 ) if( *aAngle2 < *aAngle1 )
*aAngle2 += 3600; *aAngle2 += 3600;
...@@ -73,8 +73,8 @@ bool TRANSFORM::MapAngles( int* aAngle1, int* aAngle2 ) const ...@@ -73,8 +73,8 @@ bool TRANSFORM::MapAngles( int* aAngle1, int* aAngle2 ) const
*aAngle1 = (*aAngle2); *aAngle1 = (*aAngle2);
*aAngle2 = Angle; *aAngle2 = Angle;
NORMALIZE_ANGLE( *aAngle1 ); NORMALIZE_ANGLE_POS( *aAngle1 );
NORMALIZE_ANGLE( *aAngle2 ); NORMALIZE_ANGLE_POS( *aAngle2 );
if( *aAngle2 < *aAngle1 ) if( *aAngle2 < *aAngle1 )
*aAngle2 += 3600; *aAngle2 += 3600;
swap = true; swap = true;
......
...@@ -63,15 +63,16 @@ static inline const wxChar* GetChars( const wxString& s ) ...@@ -63,15 +63,16 @@ static inline const wxChar* GetChars( const wxString& s )
#define DEG2RAD( Deg ) ( (Deg) * M_PI / 180.0 ) #define DEG2RAD( Deg ) ( (Deg) * M_PI / 180.0 )
#define RAD2DEG( Rad ) ( (Rad) * 180.0 / M_PI ) #define RAD2DEG( Rad ) ( (Rad) * 180.0 / M_PI )
/* Normalize angle to be in the -360.0 .. 360.0 range or 0 .. 360.0: */ // Normalize angle to be in the -360.0 .. 360.0:
#define NORMALIZE_ANGLE( Angle ) { while( Angle < 0 ) \ #define NORMALIZE_ANGLE_360( Angle ) { while( Angle < -3600 ) \
Angle += 3600;\ Angle += 3600;\
while( Angle > 3600 ) \ while( Angle > 3600 ) \
Angle -= 3600;} Angle -= 3600;}
/* Normalize angle to be in the 0.0 .. 360.0 range: */ /* Normalize angle to be in the 0.0 .. 360.0 range: */
#define NORMALIZE_ANGLE_POS( Angle ) { while( Angle < 0 ) \ #define NORMALIZE_ANGLE_POS( Angle ) { while( Angle < 0 ) \
Angle += 3600;while( Angle >= 3600 ) \ Angle += 3600;\
while( Angle >= 3600 ) \
Angle -= 3600;} Angle -= 3600;}
#define NEGATE_AND_NORMALIZE_ANGLE_POS( Angle ) \ #define NEGATE_AND_NORMALIZE_ANGLE_POS( Angle ) \
{ Angle = -Angle; while( Angle < 0 ) \ { Angle = -Angle; while( Angle < 0 ) \
......
...@@ -248,6 +248,8 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC ) ...@@ -248,6 +248,8 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
} }
DisplayToolMsg( wxEmptyString ); DisplayToolMsg( wxEmptyString );
DrawPanel->SetCursor( DrawPanel->m_PanelCursor =
DrawPanel->m_PanelDefaultCursor );
} }
...@@ -263,7 +265,7 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC ) ...@@ -263,7 +265,7 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
*/ */
bool WinEDA_PcbFrame::HandleBlockEnd( 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; bool cancelCmd = false;
// If coming here after cancel block, clean up and exit // If coming here after cancel block, clean up and exit
...@@ -296,8 +298,8 @@ bool WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -296,8 +298,8 @@ bool WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
// Exit if no items found // Exit if no items found
if( !GetScreen()->m_BlockLocate.GetCount() ) if( !GetScreen()->m_BlockLocate.GetCount() )
cancelCmd = true; cancelCmd = true;
else // else
nextcmd = true; // nextcmd = true;
} }
} }
......
...@@ -532,7 +532,7 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset ) ...@@ -532,7 +532,7 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
NEGATE( pad->m_Offset.x ); NEGATE( pad->m_Offset.x );
NEGATE( pad->m_DeltaSize.x ); NEGATE( pad->m_DeltaSize.x );
pad->m_Orient = 1800 - pad->m_Orient; pad->m_Orient = 1800 - pad->m_Orient;
NORMALIZE_ANGLE( pad->m_Orient ); NORMALIZE_ANGLE_POS( pad->m_Orient );
} }
item = module->m_Drawings; item = module->m_Drawings;
...@@ -587,7 +587,7 @@ void RotateMarkedItems( MODULE* module, wxPoint offset ) ...@@ -587,7 +587,7 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
ROTATE( pad->GetPosition() ); ROTATE( pad->GetPosition() );
pad->m_Pos0 = pad->GetPosition(); pad->m_Pos0 = pad->GetPosition();
pad->m_Orient += 900; pad->m_Orient += 900;
NORMALIZE_ANGLE( pad->m_Orient ); NORMALIZE_ANGLE_POS( pad->m_Orient );
} }
item = module->m_Drawings; item = module->m_Drawings;
......
...@@ -421,7 +421,7 @@ int EDGE_MODULE::ReadDescr( char* Line, FILE* File, ...@@ -421,7 +421,7 @@ int EDGE_MODULE::ReadDescr( char* Line, FILE* File,
&m_Start0.x, &m_Start0.y, &m_Start0.x, &m_Start0.y,
&m_End0.x, &m_End0.y, &m_End0.x, &m_End0.y,
&m_Angle, &m_Width, &m_Layer ); &m_Angle, &m_Width, &m_Layer );
NORMALIZE_ANGLE( m_Angle ); NORMALIZE_ANGLE_360( m_Angle );
break; break;
case S_SEGMENT: case S_SEGMENT:
......
...@@ -215,7 +215,7 @@ void DialogGraphicItemProperties::OnOkClick( wxCommandEvent& event ) ...@@ -215,7 +215,7 @@ void DialogGraphicItemProperties::OnOkClick( wxCommandEvent& event )
{ {
long angle; long angle;
m_Angle_Ctrl->GetValue().ToLong(&angle); m_Angle_Ctrl->GetValue().ToLong(&angle);
NORMALIZE_ANGLE(angle); NORMALIZE_ANGLE_360(angle);
m_Item->m_Angle = angle; m_Item->m_Angle = angle;
} }
......
...@@ -192,7 +192,7 @@ void WinEDA_PcbFrame::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) ...@@ -192,7 +192,7 @@ void WinEDA_PcbFrame::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
TextePcb->Draw( DrawPanel, DC, GR_XOR ); TextePcb->Draw( DrawPanel, DC, GR_XOR );
TextePcb->m_Orient += angle; TextePcb->m_Orient += angle;
NORMALIZE_ANGLE( TextePcb->m_Orient ); NORMALIZE_ANGLE_POS( TextePcb->m_Orient );
/* Redraw text in new position. */ /* Redraw text in new position. */
TextePcb->Draw( DrawPanel, DC, drawmode ); TextePcb->Draw( DrawPanel, DC, drawmode );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment