Commit 60fb3fb7 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Pcbnew: added a priority level for zones: a zone with a hight priority can be...

Pcbnew: added a priority level for zones: a zone with a hight priority can be now inside an other low priority zone.
useful for complex zones.
fix in footprint copy.
minor enhancement in netlist/ Footprints Test.
parents c0d39da5 e6306723
Loading
Loading
Loading
Loading
+86 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
#include <vector>

#include <fctsys.h>
#include <polygons_defs.h>
#include <pcbnew.h>
#include <wxPcbStruct.h>
#include <trigo.h>
@@ -17,6 +18,7 @@
#include <class_track.h>
#include <class_drawsegment.h>
#include <class_pcb_text.h>
#include <class_zone.h>


/* Exported functions */
@@ -130,6 +132,90 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCo
    aCornerBuffer.back().end_contour = true;
}

 /* Function TransformShapeWithClearanceToPolygon
  * 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
  * param aAddClearance = true to add a clearance area to the polygon
  *                      false to create the outline polygon.
  * clearance when the circle is approximated by segment bigger or equal
  * to the real clearance value (usually near from 1.0)
  */
void ZONE_CONTAINER::TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
                                                      int                    aClearanceValue,
                                                      int                    aCircleToSegmentsCount,
                                                      double                 aCorrectionFactor,
                                                      bool                   aAddClearance )
{

    /* Creates the main polygon (i.e. the filled area using only one outline)
     * and reserve a clearance margin around the outlines and holes
     */
    std::vector <CPolyPt> zoneOutines;
    BuildFilledPolysListData( NULL, &zoneOutines );
    int clearance = 0;
    if( aAddClearance )
    {
        GetClearance();
        if( aClearanceValue > clearance )
            clearance = aClearanceValue;
    }

    // Calculate the polygon with clearance and holes
    // holes are linked to the main outline, so only one polygon should be created.
    KPolygonSet polyset_zone_solid_areas;
    std::vector<KPolyPoint> cornerslist;
    unsigned ic = 0;
    unsigned corners_count = zoneOutines.size();
    while( ic < corners_count )
    {
        cornerslist.clear();
        KPolygon poly;
        {
            for( ; ic < corners_count; ic++ )
            {
                CPolyPt* corner = &zoneOutines[ic];
                cornerslist.push_back( KPolyPoint( corner->x, corner->y ) );
                if( corner->end_contour )
                {
                    ic++;
                    break;
                }
            }

            bpl::set_points( poly, cornerslist.begin(), cornerslist.end() );
            polyset_zone_solid_areas.push_back( poly );
        }
    }

    polyset_zone_solid_areas += clearance;

    // Put the resultng polygon in buffer
    for( unsigned ii = 0; ii < polyset_zone_solid_areas.size(); ii++ )
    {
        KPolygon& poly = polyset_zone_solid_areas[ii];
        CPolyPt   corner( 0, 0, false );

        for( unsigned jj = 0; jj < poly.size(); jj++ )
        {
            KPolyPoint point = *(poly.begin() + jj);
            corner.x = point.x();
            corner.y = point.y();
            corner.end_contour = false;
            aCornerBuffer.push_back( corner );
        }

        corner.end_contour = true;
        aCornerBuffer.pop_back();
        aCornerBuffer.push_back( corner );
    }
}



/**
 * Function TransformShapeWithClearanceToPolygon
+3 −0
Original line number Diff line number Diff line
@@ -85,7 +85,9 @@ MODULE::MODULE( const MODULE& aModule ) :

    m_Pos = aModule.m_Pos;
    m_LibRef = aModule.m_LibRef;
    m_Layer  = aModule.m_Layer;
    m_Attributs = aModule.m_Attributs;
    m_ModuleStatus = aModule.m_ModuleStatus;
    m_Orient = aModule.m_Orient;
    m_BoundaryBox = aModule.m_BoundaryBox;
    m_PadNum = aModule.m_PadNum;
@@ -199,6 +201,7 @@ void MODULE::Copy( MODULE* aModule )
    m_Layer         = aModule->m_Layer;
    m_LibRef        = aModule->m_LibRef;
    m_Attributs     = aModule->m_Attributs;
    m_ModuleStatus  = aModule->m_ModuleStatus;
    m_Orient        = aModule->m_Orient;
    m_BoundaryBox   = aModule->m_BoundaryBox;
    m_PadNum        = aModule->m_PadNum;
+11 −4
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) :
    m_CornerSelection = -1;
    m_IsFilled = false;                         // fill status : true when the zone is filled
    m_FillMode = 0;                             // How to fill areas: 0 = use filled polygons, != 0 fill with segments
    m_priority = 0;
    smoothedPoly = NULL;
    cornerSmoothingType = ZONE_SETTING::SMOOTHING_NONE;
    cornerRadius = 0;
@@ -77,6 +78,7 @@ ZONE_CONTAINER::ZONE_CONTAINER( const ZONE_CONTAINER& aZone ) :
    m_ZoneClearance = aZone.m_ZoneClearance;     // clearance value
    m_ZoneMinThickness = aZone.m_ZoneMinThickness;
    m_FillMode = aZone.m_FillMode;               // Filling mode (segments/polygons)
    m_priority = aZone.m_priority;
    m_ArcToSegmentsCount = aZone.m_ArcToSegmentsCount;
    m_PadOption = aZone.m_PadOption;
    m_ThermalReliefGap = aZone.m_ThermalReliefGap;
@@ -677,16 +679,21 @@ void ZONE_CONTAINER::DisplayInfo( EDA_DRAW_FRAME* frame )
        }

        frame->AppendMsgPanel( _( "NetName" ), msg, RED );
#if 1
        // Display net code : (useful in test or debug)
        msg.Printf( wxT( "%d" ), GetNet() );
        frame->AppendMsgPanel( _( "NetCode" ), msg, RED );
#endif

        // Display priority level
        msg.Printf( wxT( "%d" ), GetPriority() );
        frame->AppendMsgPanel( _( "Priority" ), msg, BLUE );
    }
    else
    {
        frame->AppendMsgPanel( _( "Non Copper Zone" ), wxEmptyString, RED );
    }

    /* Display net code : (useful in test or debug) */
    msg.Printf( wxT( "%d" ), GetNet() );
    frame->AppendMsgPanel( _( "NetCode" ), msg, RED );

    msg = board->GetLayerName( m_Layer );
    frame->AppendMsgPanel( _( "Layer" ), msg, BROWN );

+39 −2
Original line number Diff line number Diff line
@@ -124,6 +124,10 @@ private:
    CPolyLine*            smoothedPoly;         // Corner-smoothed version of m_Poly
    int                   cornerSmoothingType;
    unsigned int          cornerRadius;
    // Priority: when a zone outline is inside and other zone, if its priority is highter
    // the other zone priority, it will be created inside.
    // if priorities are equal, a DRC erroc is set
    unsigned              m_priority;

public:
    ZONE_CONTAINER( BOARD* parent );
@@ -149,6 +153,18 @@ public:
    const wxPoint GetPosition() const;          // overload
    void SetPosition( const wxPoint& aPos );    // overload

    /**
     * Function SetPriority
     * @param aPriority = the priority level
     */
    void SetPriority( unsigned aPriority ) { m_priority = aPriority; }

    /**
     * Function GetPriority
     * @return the priority level of this zone
     */
    unsigned GetPriority() const { return m_priority; }

    /**
     * Function copy
     * copy useful data from the source.
@@ -305,11 +321,13 @@ public:
     * in order to have drawable (and plottable) filled polygons
     * drawable filled polygons are polygons without hole
     * @param aPcb: the current board (can be NULL for non copper zones)
     * @param aCornerBuffer: A reference to a buffer to put polygon corners, or NULL
     * if NULL (default), uses m_FilledPolysList and fill current zone.
     * @return number of polygons
     * This function does not add holes for pads and tracks but calls
     * AddClearanceAreasPolygonsToPolysList() to do that for copper layers
     */
    int BuildFilledPolysListData( BOARD* aPcb );
    int BuildFilledPolysListData( BOARD* aPcb, std::vector <CPolyPt>* aCornerBuffer = NULL );

    /**
     * Function AddClearanceAreasPolygonsToPolysList
@@ -484,6 +502,25 @@ public:
        return m_Poly->GetHatchStyle();
    }

     /**
     * Function TransformShapeWithClearanceToPolygon
     * 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
     * @param aAddClearance = true to add a clearance area to the polygon
     *                      false to create the outline polygon.
     * clearance when the circle is approximated by segment bigger or equal
     * to the real clearance value (usually near from 1.0)
     */
    void TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
                                               int                    aClearanceValue,
                                               int                    aCircleToSegmentsCount,
                                               double                 aCorrectionFactor,
                                               bool                   aAddClearance );
   /**
     * Function IsSame
     * tests if 2 zones are equivalent:
+4 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@

ZONE_SETTING::ZONE_SETTING( void )
{
    m_ZonePriority = 0;
    m_FillMode = 0;                                                 // Mode for filling zone : 1 use segments, 0 use polygons
    m_ZoneClearance      = 200;                                     // Clearance value
    m_ZoneMinThickness   = 100;                                     // Min thickness value in filled areas
@@ -50,6 +51,7 @@ ZONE_SETTING::ZONE_SETTING( void )
 */
void ZONE_SETTING::ImportSetting( const ZONE_CONTAINER& aSource )
{
    m_ZonePriority = aSource.GetPriority();
    m_FillMode     = aSource.m_FillMode;
    m_ZoneClearance      = aSource.m_ZoneClearance;
    m_ZoneMinThickness   = aSource.m_ZoneMinThickness;
@@ -88,6 +90,7 @@ void ZONE_SETTING::ExportSetting( ZONE_CONTAINER& aTarget, bool aFullExport )
    aTarget.SetCornerRadius( cornerRadius );
    if( aFullExport )
    {
        aTarget.SetPriority( m_ZonePriority );
        aTarget.SetNet( m_NetcodeSelection );
        aTarget.SetLayer( m_CurrentZone_Layer );
    }
Loading