Commit 3354bdde authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Pcbnew: fix bug #1272714 . Code cleanup: use 2 different enums for pad shapes...

Pcbnew: fix bug #1272714 . Code cleanup: use 2 different enums for pad shapes and pad drill shapes. Remove never used pad shape.
parent 179bb920
Loading
Loading
Loading
Loading
+7 −7
Original line number Original line Diff line number Diff line
@@ -203,7 +203,7 @@ static void InitKiCadAboutNew( AboutAppInfo& info )
     * which should be represented by the same icon.
     * which should be represented by the same icon.
     */
     */


    // The developers
    // The core developers
    info.AddDeveloper(
    info.AddDeveloper(
        new Contributor( wxT( "Jean-Pierre Charras" ),  wxT( "jp.charras@wanadoo.fr" ) ) );
        new Contributor( wxT( "Jean-Pierre Charras" ),  wxT( "jp.charras@wanadoo.fr" ) ) );
    info.AddDeveloper(
    info.AddDeveloper(
@@ -214,6 +214,8 @@ static void InitKiCadAboutNew( AboutAppInfo& info )
    // alphabetically by last name after main 3 above:
    // alphabetically by last name after main 3 above:
    info.AddDeveloper(
    info.AddDeveloper(
        new Contributor( wxT( "Frank Bennett" ),        wxT( "bennett78@lpbroadband.net" ) ) );
        new Contributor( wxT( "Frank Bennett" ),        wxT( "bennett78@lpbroadband.net" ) ) );
    info.AddDeveloper(
        new Contributor( wxT( "Cirilo Bernardo" ),      wxT( "cirilo_bernardo@yahoo.com" ) ) );
    info.AddDeveloper(
    info.AddDeveloper(
        new Contributor( wxT( "Jonas Diemer" ),         wxT( "diemer@gmx.de" ) ) );
        new Contributor( wxT( "Jonas Diemer" ),         wxT( "diemer@gmx.de" ) ) );
    info.AddDeveloper(
    info.AddDeveloper(
@@ -222,12 +224,6 @@ static void InitKiCadAboutNew( AboutAppInfo& info )
        new Contributor( wxT( "Hauptmech" ),            wxT( "hauptmech@gmail.com" ) ) );
        new Contributor( wxT( "Hauptmech" ),            wxT( "hauptmech@gmail.com" ) ) );
    info.AddDeveloper(
    info.AddDeveloper(
        new Contributor( wxT( "Jerry Jacobs" ),         wxT( "xor.gate.engineering@gmail.com" ) ) );
        new Contributor( wxT( "Jerry Jacobs" ),         wxT( "xor.gate.engineering@gmail.com" ) ) );

    /*
    info.AddDeveloper(
        new Contributor( wxT( "KBool Library" ),         wxT( "http://boolean.klaasholwerda.nl/bool.html" ) ) );
    */

    info.AddDeveloper(
    info.AddDeveloper(
        new Contributor( wxT( "Lorenzo Marcantonio" ),  wxT( "lomarcan@tin.it" ) ) );
        new Contributor( wxT( "Lorenzo Marcantonio" ),  wxT( "lomarcan@tin.it" ) ) );
    info.AddDeveloper(
    info.AddDeveloper(
@@ -240,10 +236,14 @@ static void InitKiCadAboutNew( AboutAppInfo& info )
        new Contributor( wxT( "Marco Serantoni" ),      wxT( "marco.serantoni@gmail.com" ) ) );
        new Contributor( wxT( "Marco Serantoni" ),      wxT( "marco.serantoni@gmail.com" ) ) );
    info.AddDeveloper(
    info.AddDeveloper(
        new Contributor( wxT( "Brian Sidebotham" ),     wxT( "brian.sidebotham@gmail.com" ) ) );
        new Contributor( wxT( "Brian Sidebotham" ),     wxT( "brian.sidebotham@gmail.com" ) ) );
    info.AddDeveloper(
        new Contributor( wxT( "Orson (Maciej Suminski)" ),    wxT( "maciej.suminski@cern.ch" ) ) );
    info.AddDeveloper(
    info.AddDeveloper(
        new Contributor( wxT( "Rafael Sokolowski" ),    wxT( "rafael.sokolowski@web.de" ) ) );
        new Contributor( wxT( "Rafael Sokolowski" ),    wxT( "rafael.sokolowski@web.de" ) ) );
    info.AddDeveloper(
    info.AddDeveloper(
        new Contributor( wxT( "Vesa Solonen" ),         wxT( "vesa.solonen@hut.fi" ) ) );
        new Contributor( wxT( "Vesa Solonen" ),         wxT( "vesa.solonen@hut.fi" ) ) );
    info.AddDeveloper(
        new Contributor( wxT( "Tomasz Wlostowski" ),    wxT( "tomasz.wlostowski@cern.ch" ) ) );


    // The document writers
    // The document writers
    info.AddDocWriter(
    info.AddDocWriter(
+11 −3
Original line number Original line Diff line number Diff line
@@ -11,13 +11,21 @@
 */
 */
enum PAD_SHAPE_T
enum PAD_SHAPE_T
{
{
    PAD_NONE,
    PAD_CIRCLE,
    PAD_CIRCLE,
    PAD_ROUND = PAD_CIRCLE,
    PAD_ROUND = PAD_CIRCLE,
    PAD_RECT,
    PAD_RECT,
    PAD_OVAL,
    PAD_OVAL,
    PAD_TRAPEZOID,
    PAD_TRAPEZOID
    PAD_OCTAGON         // Provided, but not existing in Pcbnew. waiting for a volunteer
};

/**
 * Enum PAD_DRILL_SHAPE_T
 * is the set of pad dtill shapes, used with D_PAD::{Set,Get}DrillShape()
 */
enum PAD_DRILL_SHAPE_T
{
    PAD_DRILL_CIRCLE,
    PAD_DRILL_OBLONG
};
};




+2 −4
Original line number Original line Diff line number Diff line
@@ -424,7 +424,7 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer
                                                     * trapezoidal pads are considered as rect
                                                     * trapezoidal pads are considered as rect
                                                     * pad shape having they boudary box size */
                                                     * pad shape having they boudary box size */


    switch( m_PadShape )
    switch( GetShape() )
    {
    {
    case PAD_CIRCLE:
    case PAD_CIRCLE:
        dx = KiROUND( dx * aCorrectionFactor );
        dx = KiROUND( dx * aCorrectionFactor );
@@ -459,7 +459,6 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( CPOLYGONS_LIST& aCornerBuffer
        }
        }
        break;
        break;


    default:
    case PAD_TRAPEZOID:
    case PAD_TRAPEZOID:
        psize.x += std::abs( m_DeltaSize.y );
        psize.x += std::abs( m_DeltaSize.y );
        psize.y += std::abs( m_DeltaSize.x );
        psize.y += std::abs( m_DeltaSize.x );
@@ -550,7 +549,7 @@ void D_PAD::BuildPadShapePolygon( CPOLYGONS_LIST& aCornerBuffer,
    wxPoint corners[4];
    wxPoint corners[4];
    wxPoint PadShapePos = ReturnShapePos();         /* Note: for pad having a shape offset,
    wxPoint PadShapePos = ReturnShapePos();         /* Note: for pad having a shape offset,
                                                     * the pad position is NOT the shape position */
                                                     * the pad position is NOT the shape position */
    switch( m_PadShape )
    switch( GetShape() )
    {
    {
    case PAD_CIRCLE:
    case PAD_CIRCLE:
    case PAD_OVAL:
    case PAD_OVAL:
@@ -558,7 +557,6 @@ void D_PAD::BuildPadShapePolygon( CPOLYGONS_LIST& aCornerBuffer,
                                              aSegmentsPerCircle, aCorrectionFactor );
                                              aSegmentsPerCircle, aCorrectionFactor );
        break;
        break;


    default:
    case PAD_TRAPEZOID:
    case PAD_TRAPEZOID:
    case PAD_RECT:
    case PAD_RECT:
        BuildPadPolygon( corners, aInflateValue, m_Orient );
        BuildPadPolygon( corners, aInflateValue, m_Orient );
+32 −11
Original line number Original line Diff line number Diff line
@@ -66,9 +66,9 @@ D_PAD::D_PAD( MODULE* parent ) :
        m_Pos = GetParent()->GetPosition();
        m_Pos = GetParent()->GetPosition();
    }
    }


    m_PadShape            = PAD_CIRCLE;      // Default pad shape is PAD_CIRCLE.
    SetShape( PAD_CIRCLE );                 // Default pad shape is PAD_CIRCLE.
    SetDrillShape( PAD_DRILL_CIRCLE );      // Default pad drill shape is a circle.
    m_Attribute           = PAD_STANDARD;   // Default pad type is NORMAL (thru hole)
    m_Attribute           = PAD_STANDARD;   // Default pad type is NORMAL (thru hole)
    m_DrillShape          = PAD_CIRCLE;      // Default pad drill shape is a circle.
    m_LocalClearance      = 0;
    m_LocalClearance      = 0;
    m_LocalSolderMaskMargin  = 0;
    m_LocalSolderMaskMargin  = 0;
    m_LocalSolderPasteMargin = 0;
    m_LocalSolderPasteMargin = 0;
@@ -382,13 +382,13 @@ void D_PAD::Copy( D_PAD* source )
    m_NumPadName = source->m_NumPadName;
    m_NumPadName = source->m_NumPadName;
    SetNet( source->GetNet() );
    SetNet( source->GetNet() );
    m_Drill = source->m_Drill;
    m_Drill = source->m_Drill;
    m_DrillShape = source->m_DrillShape;
    m_drillShape = source->m_drillShape;
    m_Offset     = source->m_Offset;
    m_Offset     = source->m_Offset;
    m_Size = source->m_Size;
    m_Size = source->m_Size;
    m_DeltaSize = source->m_DeltaSize;
    m_DeltaSize = source->m_DeltaSize;
    m_Pos0     = source->m_Pos0;
    m_Pos0     = source->m_Pos0;
    m_boundingRadius    = source->m_boundingRadius;
    m_boundingRadius    = source->m_boundingRadius;
    m_PadShape = source->m_PadShape;
    m_padShape = source->m_padShape;
    m_Attribute = source->m_Attribute;
    m_Attribute = source->m_Attribute;
    m_Orient   = source->m_Orient;
    m_Orient   = source->m_Orient;
    m_LengthPadToDie = source->m_LengthPadToDie;
    m_LengthPadToDie = source->m_LengthPadToDie;
@@ -601,7 +601,7 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList )


    Line = ::CoordinateToString( (unsigned) m_Drill.x );
    Line = ::CoordinateToString( (unsigned) m_Drill.x );


    if( m_DrillShape == PAD_CIRCLE )
    if( GetDrillShape() == PAD_DRILL_CIRCLE )
    {
    {
        aList.push_back( MSG_PANEL_ITEM( _( "Drill" ), Line, RED ) );
        aList.push_back( MSG_PANEL_ITEM( _( "Drill" ), Line, RED ) );
    }
    }
@@ -663,7 +663,7 @@ bool D_PAD::HitTest( const wxPoint& aPosition )
    dx = m_Size.x >> 1; // dx also is the radius for rounded pads
    dx = m_Size.x >> 1; // dx also is the radius for rounded pads
    dy = m_Size.y >> 1;
    dy = m_Size.y >> 1;


    switch( m_PadShape & 0x7F )
    switch( GetShape() )
    {
    {
    case PAD_CIRCLE:
    case PAD_CIRCLE:
        if( KiROUND( EuclideanNorm( delta ) ) <= dx )
        if( KiROUND( EuclideanNorm( delta ) ) <= dx )
@@ -679,7 +679,28 @@ bool D_PAD::HitTest( const wxPoint& aPosition )
        return TestPointInsidePolygon( poly, 4, delta );
        return TestPointInsidePolygon( poly, 4, delta );
    }
    }


    default:
    case PAD_OVAL:
    {
        RotatePoint( &delta, -m_Orient );
        // An oval pad has the same shape as a segment with rounded ends
        // After rotation, the test point is relative to an horizontal pad
        int dist;
        wxPoint offset;
        if( dy > dx )   // shape is a vertical oval
        {
            offset.y = dy - dx;
            dist = dx;
        }
        else    //if( dy <= dx ) shape is an horizontal oval
        {
            offset.x = dy - dx;
            dist = dy;
        }
        return TestSegmentHit( delta, - offset, offset, dist );
    }
        break;

    case PAD_RECT:
        RotatePoint( &delta, -m_Orient );
        RotatePoint( &delta, -m_Orient );


        if( (abs( delta.x ) <= dx ) && (abs( delta.y ) <= dy) )
        if( (abs( delta.x ) <= dx ) && (abs( delta.y ) <= dy) )
@@ -696,10 +717,10 @@ int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp )
{
{
    int diff;
    int diff;


    if( ( diff = padref->m_PadShape - padcmp->m_PadShape ) != 0 )
    if( ( diff = padref->GetShape() - padcmp->GetShape() ) != 0 )
        return diff;
        return diff;


    if( ( diff = padref->m_DrillShape - padcmp->m_DrillShape ) != 0)
    if( ( diff = padref->GetDrillShape() - padcmp->GetDrillShape() ) != 0)
        return diff;
        return diff;


    if( ( diff = padref->m_Drill.x - padcmp->m_Drill.x ) != 0 )
    if( ( diff = padref->m_Drill.x - padcmp->m_Drill.x ) != 0 )
@@ -737,7 +758,7 @@ int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp )


wxString D_PAD::ShowPadShape() const
wxString D_PAD::ShowPadShape() const
{
{
    switch( m_PadShape )
    switch( GetShape() )
    {
    {
    case PAD_CIRCLE:
    case PAD_CIRCLE:
        return _( "Circle" );
        return _( "Circle" );
+9 −7
Original line number Original line Diff line number Diff line
@@ -140,8 +140,8 @@ public:
     * Function GetShape
     * Function GetShape
     * @return the shape of this pad.
     * @return the shape of this pad.
     */
     */
    PAD_SHAPE_T GetShape() const                { return m_PadShape; }
    PAD_SHAPE_T GetShape() const                { return m_padShape; }
    void SetShape( PAD_SHAPE_T aShape )         { m_PadShape = aShape; m_boundingRadius = -1; }
    void SetShape( PAD_SHAPE_T aShape )         { m_padShape = aShape; m_boundingRadius = -1; }


    void SetPosition( const wxPoint& aPos )     { m_Pos = aPos; }   // was overload
    void SetPosition( const wxPoint& aPos )     { m_Pos = aPos; }   // was overload
    const wxPoint& GetPosition() const          { return m_Pos; }   // was overload
    const wxPoint& GetPosition() const          { return m_Pos; }   // was overload
@@ -183,8 +183,9 @@ public:
     */
     */
    double  GetOrientation() const { return m_Orient; }
    double  GetOrientation() const { return m_Orient; }


    void SetDrillShape( PAD_SHAPE_T aDrillShape ) { m_DrillShape = aDrillShape; }
    void SetDrillShape( PAD_DRILL_SHAPE_T aDrillShape )
    PAD_SHAPE_T GetDrillShape() const           { return m_DrillShape; }
        { m_drillShape = aDrillShape; }
    PAD_DRILL_SHAPE_T GetDrillShape() const     { return m_drillShape; }


    void SetLayerMask( LAYER_MSK aLayerMask )   { m_layerMask = aLayerMask; }
    void SetLayerMask( LAYER_MSK aLayerMask )   { m_layerMask = aLayerMask; }
    LAYER_MSK GetLayerMask() const              { return m_layerMask; }
    LAYER_MSK GetLayerMask() const              { return m_layerMask; }
@@ -362,7 +363,7 @@ public:
    {
    {
        // Any member function which would affect this calculation should set
        // Any member function which would affect this calculation should set
        // m_boundingRadius to -1 to re-trigger the calculation from here.
        // m_boundingRadius to -1 to re-trigger the calculation from here.
        // Currently that is only m_Size, m_DeltaSize, and m_PadShape accessors.
        // Currently that is only m_Size, m_DeltaSize, and m_padShape accessors.
        if( m_boundingRadius == -1 )
        if( m_boundingRadius == -1 )
        {
        {
            m_boundingRadius = boundingRadius();
            m_boundingRadius = boundingRadius();
@@ -484,7 +485,7 @@ private:


    wxPoint     m_Pos;              ///< pad Position on board
    wxPoint     m_Pos;              ///< pad Position on board


    PAD_SHAPE_T m_PadShape;         ///< Shape: PAD_CIRCLE, PAD_RECT, PAD_OVAL, PAD_TRAPEZOID
    PAD_SHAPE_T m_padShape;         ///< Shape: PAD_CIRCLE, PAD_RECT, PAD_OVAL, PAD_TRAPEZOID




    int         m_SubRatsnest;      ///< variable used in rats nest computations
    int         m_SubRatsnest;      ///< variable used in rats nest computations
@@ -496,7 +497,8 @@ private:


    wxSize      m_Size;             ///< X and Y size ( relative to orient 0)
    wxSize      m_Size;             ///< X and Y size ( relative to orient 0)


    PAD_SHAPE_T m_DrillShape;       ///< Shape PAD_CIRCLE, PAD_OVAL
    PAD_DRILL_SHAPE_T m_drillShape; ///< PAD_DRILL_NONE, PAD_DRILL_CIRCLE, PAD_DRILL_OBLONG



    /**
    /**
     * m_Offset is useful only for oblong pads (it can be used for other
     * m_Offset is useful only for oblong pads (it can be used for other
Loading