Commit ab66f9ec authored by charras's avatar charras
Browse files

rework on zones:try to fix a filling problem with kbool

parent 9b2c6f04
Loading
Loading
Loading
Loading
+1.26 KiB (197 KiB)

File changed.

No diff preview for this file type.

+12 −15
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: kicad\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-11-13 17:41+0100\n"
"PO-Revision-Date: 2009-11-13 17:47+0100\n"
"PO-Revision-Date: 2009-11-13 20:06+0100\n"
"Last-Translator: \n"
"Language-Team: kicad team <jean-pierre.charras@ujf-grenoble.fr>\n"
"MIME-Version: 1.0\n"
@@ -286,7 +286,7 @@ msgstr "Inclure Modules"

#: pcbnew/block.cpp:128
msgid "Include tracks"
msgstr "Inclure Pistes"
msgstr "Inclure pistes"

#: pcbnew/block.cpp:133
msgid "Include zones"
@@ -3183,6 +3183,8 @@ msgid ""
"Set these values to 0\n"
"to use Parent footprint or global values"
msgstr ""
"Mettre ces valeurs à 0\n"
"pour utiliser les valeurs du module parent ou les valeurs globales"

#: pcbnew/dialog_pad_properties_base.cpp:237
msgid "Net pad clearance"
@@ -3936,7 +3938,7 @@ msgstr "NETCLASS: '%s' a une isolation:%s qui est moins que la valeur globale:%s
#: pcbnew/drc.cpp:340
#, c-format
msgid "NETCLASS: '%s' has TrackWidth:%s which is less than global:%s"
msgstr ""
msgstr "NETCLASS: '%s' a une largeur de piste: %s plust petite que la valeur globale:%s"

#: pcbnew/drc.cpp:354
#, c-format
@@ -4791,9 +4793,8 @@ msgid "Pads Mask Clearance"
msgstr "Marge Masque des Pads"

#: pcbnew/menubarpcb.cpp:232
#, fuzzy
msgid "Adjust the global clearance between pads and the solder resist mask"
msgstr "Ceci est l'espace entre pads et le masque"
msgstr "Ajuster la marge globale entre pads et le masque de vernis épargne"

#: pcbnew/menubarpcb.cpp:242
msgid "Texts and Drawings"
@@ -4990,7 +4991,7 @@ msgstr "<<<"

#: pcbnew/dialog_design_rules_base.cpp:114
msgid "Move the selected nets in the right list to the left list"
msgstr ""
msgstr "Déplacer les nets sélectionnés de la liste droite vers la liste gauche"

#: pcbnew/dialog_design_rules_base.cpp:118
msgid ">>>"
@@ -5356,7 +5357,7 @@ msgstr "Valeurs locales pour marges sur masques:"
#: pcbnew/dialog_edit_module_for_Modedit_base.cpp:116
#: pcbnew/dialog_edit_module_for_BoardEditor_base.cpp:145
msgid "Set these values to 0 to use global values"
msgstr ""
msgstr "Mettre ces valeurs à 0 pour utiliser les valeurs globales"

#: pcbnew/dialog_edit_module_for_Modedit_base.cpp:127
#: pcbnew/dialog_edit_module_for_BoardEditor_base.cpp:156
@@ -8183,9 +8184,8 @@ msgid "Library browser"
msgstr "Visualisateur des librairies"

#: eeschema/tool_sch.cpp:58
#, fuzzy
msgid "Navigate schematic hierarchy"
msgstr "Sauver le Projet schématique"
msgstr "Navigateur de hiérarchie"

#: eeschema/tool_sch.cpp:84
msgid "Print schematic"
@@ -8212,9 +8212,8 @@ msgid "Schematic Electric Rules Check"
msgstr "Contrôle des règles électriques"

#: eeschema/tool_sch.cpp:129
#, fuzzy
msgid "Bill of material and/or Cross references"
msgstr "Liste des composants et références croisées"
msgstr "Liste des composants ou/et références croisées"

#: eeschema/tool_sch.cpp:133
msgid "Backannotate footprint"
@@ -8261,9 +8260,8 @@ msgid "Place hierarchical sheet"
msgstr "Placer feuille hiérarchique"

#: eeschema/tool_sch.cpp:215
#, fuzzy
msgid "Place a pin sheet, imported from the corresponding hierarchical label in sheet"
msgstr "Placer une pin hiérarchique, importée d'un un label hiérarchique dans la feuille."
msgstr "Placer une pin hiérarchique, importée du label hiérarchique correspondant dans la feuille."

#: eeschema/tool_sch.cpp:220
msgid "Place hierarchical pin to sheet"
@@ -10417,9 +10415,8 @@ msgid "&Configuration"
msgstr "&Configuration"

#: cvpcb/menucfg.cpp:49
#, fuzzy
msgid "Set libraries and library search paths"
msgstr "Librairie modules PCB %s non trouvée dans les chemins de recherche"
msgstr "Sélectionner les librairie et les chemins de recherche des librairies"

#: cvpcb/menucfg.cpp:56
msgid "Keep Open On Save"
+3 −2
Original line number Diff line number Diff line
@@ -11,10 +11,11 @@ set(PCBNEW_SRCS
    automove.cpp
    autoplac.cpp
    autorout.cpp
    block.cpp
    block_module_editor.cpp
    board.cpp
    board_items_to_polygon_shape_transform.cpp
    board_undo_redo.cpp
    block.cpp
    block_module_editor.cpp
    build_BOM_from_board.cpp
    clean.cpp
#   cleaningoptions_dialog.cpp
+318 −0
Original line number Diff line number Diff line
/**********************************************/
/* board_items_to_polygon_shape_transform.cpp */
/**********************************************/

/* Function to convert pads and tranck shapes to polygons
 * Used to fill zones areas
 */
#include <vector>

#include "fctsys.h"
#include "common.h"
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "trigo.h"

/* Exported functions */

/** Function TransformRoundedEndsSegmentToPolygon
 * convert a segment with rounded ends to a polygon
 * Convert arcs to multiple straight lines
 * @param aCornerBuffer = a buffer to store the polygon
 * @param aStart = the segment start point coordinate
 * @param aEnd = the segment end point coordinate
 * @param aWidth = the segment width
 * @param aCircleToSegmentsCount = the number of segments to approximate a circle
 */
void TransformRoundedEndsSegmentToPolygon( std::vector <wxPoint>& aCornerBuffer,
                                           wxPoint aStart, wxPoint aEnd,
                                           int aCircleToSegmentsCount,
                                           int aWidth );


/** Function TransformTrackWithClearanceToPolygon
 * Convert the track shape to a closed polygon
 * Used in filling zones calculations
 * Circles (vias) and arcs (ends of tracks) are approximated by segments
 * @param aCornerBuffer = a buffer to store the polygon
 * @param aClearanceValue = the clearance around the pad
 * @param aCircleToSegmentsCount = the number of segments to approximate a circle
 * @param aCorrectionFactor = the correction to apply to circles radius to keep
 * clearance when the circle is approxiamted by segment bigger or equal
 * to the real clearance value (usually near from 1.0)
 */
void TRACK::TransformTrackWithClearanceToPolygon( std::vector <wxPoint>& aCornerBuffer,
                                                  int                    aClearanceValue,
                                                  int                    aCircleToSegmentsCount,
                                                  double                 aCorrectionFactor )
{
    wxPoint corner_position;
    int     ii, angle;
    int     dx = (m_Width / 2) + aClearanceValue;

    int     delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree

    switch( Type() )
    {
    case TYPE_VIA:
        dx = (int) ( dx * aCorrectionFactor );
        for( ii = 0; ii < aCircleToSegmentsCount; ii++ )
        {
            corner_position = wxPoint( dx, 0 );
            RotatePoint( &corner_position, (1800 / aCircleToSegmentsCount) );
            angle = ii * delta;
            RotatePoint( &corner_position, angle );
            corner_position += m_Start;
            aCornerBuffer.push_back( corner_position );
        }

        break;

    default:
        TransformRoundedEndsSegmentToPolygon( aCornerBuffer,
                                             m_Start, m_End, aCircleToSegmentsCount,
                                             m_Width + (2 * aClearanceValue) );
        break;
    }
}


/* Function TransformRoundedEndsSegmentToPolygon
 */
void TransformRoundedEndsSegmentToPolygon( std::vector <wxPoint>& aCornerBuffer,
                                           wxPoint aStart, wxPoint aEnd,
                                           int aCircleToSegmentsCount,
                                           int aWidth )
{
    int     rayon  = aWidth / 2;
    wxPoint endp   = aEnd - aStart; // end point coordinate for the same segment starting at (0,0)
    wxPoint startp = aStart;
    wxPoint corner;
    int     seg_len;

    // normalize the position in order to have endp.x >= 0;
    if( endp.x < 0 )
    {
        endp   = aStart - aEnd;
        startp = aEnd;
    }
    int delta_angle = ArcTangente( endp.y, endp.x );    // delta_angle is in 0.1 degrees
    seg_len = (int) sqrt( ( (double) endp.y * endp.y ) + ( (double) endp.x * endp.x ) );

    int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree

    // Compute the outlines of the segment, and creates a polygon
    corner = wxPoint( 0, rayon );
    RotatePoint( &corner, -delta_angle );
    corner += startp;
    aCornerBuffer.push_back( corner );

    corner = wxPoint( seg_len, rayon );
    RotatePoint( &corner, -delta_angle );
    corner += startp;
    aCornerBuffer.push_back( corner );

    // add right rounded end:
    for( int ii = delta; ii < 1800; ii += delta )
    {
        corner = wxPoint( 0, rayon );
        RotatePoint( &corner, ii );
        corner.x += seg_len;
        RotatePoint( &corner, -delta_angle );
        corner += startp;
        aCornerBuffer.push_back( corner );
    }

    corner = wxPoint( seg_len, -rayon );
    RotatePoint( &corner, -delta_angle );
    corner += startp;
    aCornerBuffer.push_back( corner );

    corner = wxPoint( 0, -rayon );
    RotatePoint( &corner, -delta_angle );
    corner += startp;
    aCornerBuffer.push_back( corner );

    // add left rounded end:
    for( int ii = delta; ii < 1800; ii += delta )
    {
        corner = wxPoint( 0, -rayon );
        RotatePoint( &corner, ii );
        RotatePoint( &corner, -delta_angle );
        corner += startp;
        aCornerBuffer.push_back( corner );
    }
}


/** function TransformPadWithClearanceToPolygon
 * Convert the pad shape to a closed polygon
 * Used in filling zones calculations
 * Circles and arcs are approximated by segments
 * @param aCornerBuffer = a buffer to store the polygon
 * @param aClearanceValue = the clearance around the pad
 * @param aCircleToSegmentsCount = the number of segments to approximate a circle
 * @param aCorrectionFactor = the correction to apply to circles radius to keep
 * clearance when the circle is approxiamted by segment bigger or equal
 * to the real clearance value (usually near from 1.0)
 */
void D_PAD::TransformPadWithClearanceToPolygon( std::vector <wxPoint>& aCornerBuffer,
                                                int                    aClearanceValue,
                                                int                    aCircleToSegmentsCount,
                                                double                 aCorrectionFactor )
{
    wxPoint corner_position;
    int     ii, angle;
    int     dx = (m_Size.x / 2) + aClearanceValue;
    int     dy = (m_Size.y / 2) + aClearanceValue;

    int     delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree
    wxPoint PadShapePos = ReturnShapePos();    /* Note: for pad having a shape offset,
                                                * the pad position is NOT the shape position */
    wxSize  psize = m_Size;                    /* pad size unsed in RECT and TRAPEZOIDAL pads
                                                *  trapezoidal pads are considered as rect pad shape having they boudary box size
                                                */

    switch( m_PadShape )
    {
    case PAD_CIRCLE:
        dx = (int) ( dx * aCorrectionFactor );
        for( ii = 0; ii < aCircleToSegmentsCount; ii++ )
        {
            corner_position = wxPoint( dx, 0 );
            RotatePoint( &corner_position, (1800 / aCircleToSegmentsCount) );    // Half increment offset to get more space between
            angle = ii * delta;
            RotatePoint( &corner_position, angle );
            corner_position += PadShapePos;
            aCornerBuffer.push_back( corner_position );
        }

        break;

    case PAD_OVAL:
        angle = m_Orient;
        if( dy > dx )     // Oval pad X/Y ratio for choosing translation axles
        {
            dy = (int) ( dy * aCorrectionFactor );
            int     angle_pg;                                           // Polygon angle
            wxPoint shape_offset = wxPoint( 0, (dy - dx) );
            RotatePoint( &shape_offset, angle );                        // Rotating shape offset vector with component

            for( ii = 0; ii < aCircleToSegmentsCount / 2 + 1; ii++ )    // Half circle end cap...
            {
                corner_position = wxPoint( dx, 0 );                     // Coordinate translation +dx
                RotatePoint( &corner_position, (1800 / aCircleToSegmentsCount) );
                RotatePoint( &corner_position, angle );
                angle_pg = ii * delta;
                RotatePoint( &corner_position, angle_pg );
                corner_position += PadShapePos - shape_offset;
                aCornerBuffer.push_back( corner_position );
            }

            for( ii = 0; ii < aCircleToSegmentsCount / 2 + 1; ii++ )    // Second half circle end cap...
            {
                corner_position = wxPoint( -dx, 0 );                    // Coordinate translation -dx
                RotatePoint( &corner_position, (1800 / aCircleToSegmentsCount) );
                RotatePoint( &corner_position, angle );
                angle_pg = ii * delta;
                RotatePoint( &corner_position, angle_pg );
                corner_position += PadShapePos + shape_offset;
                aCornerBuffer.push_back( corner_position );
            }

            break;
        }
        else    //if( dy <= dx )
        {
            dx = (int) ( dx * aCorrectionFactor );
            int     angle_pg; // Polygon angle
            wxPoint shape_offset = wxPoint( (dy - dx), 0 );
            RotatePoint( &shape_offset, angle );

            for( ii = 0; ii < aCircleToSegmentsCount / 2 + 1; ii++ )
            {
                corner_position = wxPoint( 0, dy );
                RotatePoint( &corner_position, (1800 / aCircleToSegmentsCount) );
                RotatePoint( &corner_position, angle );
                angle_pg = ii * delta;
                RotatePoint( &corner_position, angle_pg );
                corner_position += PadShapePos - shape_offset;
                aCornerBuffer.push_back( corner_position );
            }

            for( ii = 0; ii < aCircleToSegmentsCount / 2 + 1; ii++ )
            {
                corner_position = wxPoint( 0, -dy );
                RotatePoint( &corner_position, (1800 / aCircleToSegmentsCount) );
                RotatePoint( &corner_position, angle );
                angle_pg = ii * delta;
                RotatePoint( &corner_position, angle_pg );
                corner_position += PadShapePos + shape_offset;
                aCornerBuffer.push_back( corner_position );
            }

            break;
        }

    default:
    case PAD_TRAPEZOID:
        psize.x += ABS( m_DeltaSize.y );
        psize.y += ABS( m_DeltaSize.x );

    // fall through
    case PAD_RECT:                                                                          // Easy implementation for rectangular cutouts with rounded corners                                                                  // Easy implementation for rectangular cutouts with rounded corners
        angle = m_Orient;
        int rounding_radius = (int) ( aClearanceValue * aCorrectionFactor );                // Corner rounding radius
        int angle_pg;                                                                       // Polygon increment angle

        for( int i = 0; i < aCircleToSegmentsCount / 4 + 1; i++ )
        {
            corner_position = wxPoint( 0, -rounding_radius );
            RotatePoint( &corner_position, (1800 / aCircleToSegmentsCount) );       // Start at half increment offset
            angle_pg = i * delta;
            RotatePoint( &corner_position, angle_pg );                              // Rounding vector rotation
            corner_position -= psize / 2;                                           // Rounding vector + Pad corner offset
            RotatePoint( &corner_position, angle );                                 // Rotate according to module orientation
            corner_position += PadShapePos;                                         // Shift origin to position
            aCornerBuffer.push_back( corner_position );
        }

        for( int i = 0; i < aCircleToSegmentsCount / 4 + 1; i++ )
        {
            corner_position = wxPoint( -rounding_radius, 0 );
            RotatePoint( &corner_position, (1800 / aCircleToSegmentsCount) );
            angle_pg = i * delta;
            RotatePoint( &corner_position, angle_pg );
            corner_position -= wxPoint( psize.x / 2, -psize.y / 2 );
            RotatePoint( &corner_position, angle );
            corner_position += PadShapePos;
            aCornerBuffer.push_back( corner_position );
        }

        for( int i = 0; i < aCircleToSegmentsCount / 4 + 1; i++ )
        {
            corner_position = wxPoint( 0, rounding_radius );
            RotatePoint( &corner_position, (1800 / aCircleToSegmentsCount) );
            angle_pg = i * delta;
            RotatePoint( &corner_position, angle_pg );
            corner_position += psize / 2;
            RotatePoint( &corner_position, angle );
            corner_position += PadShapePos;
            aCornerBuffer.push_back( corner_position );
        }

        for( int i = 0; i < aCircleToSegmentsCount / 4 + 1; i++ )
        {
            corner_position = wxPoint( rounding_radius, 0 );
            RotatePoint( &corner_position, (1800 / aCircleToSegmentsCount) );
            angle_pg = i * delta;
            RotatePoint( &corner_position, angle_pg );
            corner_position -= wxPoint( -psize.x / 2, psize.y / 2 );
            RotatePoint( &corner_position, angle );
            corner_position += PadShapePos;
            aCornerBuffer.push_back( corner_position );
        }

        break;
    }
}
+13 −0
Original line number Diff line number Diff line
@@ -141,6 +141,19 @@ public:
        m_Pos = aPos;
    }

    /** function TransformPadWithClearanceToPolygon
     * Convert the pad shape to a closed polygon
     * Used in filling zones calculations
     * Circles and arcs are approximated by segments
     * @param aCornerBuffer = a buffer to store the polygon
     * @param aClearanceValue = the clearance around the pad
     * @param aCircleToSegmentsCount = the number of segments to approximate a circle
     * @param aCorrectionFactor = the correction to apply to circles radius to keep
     * clearance when the circle is approxiamted by segment bigger or equal
     * to the real clearance value (usually near from 1.0)
    */
    void TransformPadWithClearanceToPolygon( std::vector <wxPoint>& aCornerBuffer,
            int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor );

     /**
     * Function GetClearance
Loading