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

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
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -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()
    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()
        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 );
}
}
+4 −4
Original line number Original line Diff line number Diff line
@@ -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
        *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;
+4 −3
Original line number Original line Diff line number Diff line
@@ -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 ) \
+5 −3
Original line number Original line Diff line number Diff line
@@ -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 )
 */
 */
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 )
            // 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;
        }
        }
    }
    }


+2 −2
Original line number Original line Diff line number Diff line
@@ -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 )
        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;
Loading