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

Start work on a better support of polygons in Kicad (code cleaning).

Some coding style policy fix.
parent 9259b21f
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -305,7 +305,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
            {
            {
                CPolyPt* endcorner = &polysList[ic];
                CPolyPt* endcorner = &polysList[ic];


                if( begincorner->utility == 0 )
                if( begincorner->m_utility == 0 )
                {
                {
                    // Draw only basic outlines, not extra segments
                    // Draw only basic outlines, not extra segments
                    dummysegment.m_Start.x = begincorner->x;
                    dummysegment.m_Start.x = begincorner->x;
@@ -318,7 +318,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
                if( (endcorner->end_contour) || (ic == imax) )
                if( (endcorner->end_contour) || (ic == imax) )
                {
                {
                    // the last corner of a filled area is found: draw it
                    // the last corner of a filled area is found: draw it
                    if( endcorner->utility == 0 )
                    if( endcorner->m_utility == 0 )
                    {
                    {
                        // Draw only basic outlines, not extra segments
                        // Draw only basic outlines, not extra segments
                        dummysegment.m_Start.x = endcorner->x;
                        dummysegment.m_Start.x = endcorner->x;

pcb_calculator/bitmaps/Thumbs.db

deleted100644 → 0
−36 KiB

File deleted.

+6 −6
Original line number Original line Diff line number Diff line
@@ -167,19 +167,19 @@ void ZONE_CONTAINER::TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>


    // Calculate the polygon with clearance and holes
    // Calculate the polygon with clearance and holes
    // holes are linked to the main outline, so only one polygon should be created.
    // holes are linked to the main outline, so only one polygon should be created.
    KPolygonSet polyset_zone_solid_areas;
    KI_POLYGON_SET polyset_zone_solid_areas;
    std::vector<KPolyPoint> cornerslist;
    std::vector<KI_POLY_POINT> cornerslist;
    unsigned ic = 0;
    unsigned ic = 0;
    unsigned corners_count = zoneOutines.size();
    unsigned corners_count = zoneOutines.size();
    while( ic < corners_count )
    while( ic < corners_count )
    {
    {
        cornerslist.clear();
        cornerslist.clear();
        KPolygon poly;
        KI_POLYGON poly;
        {
        {
            for( ; ic < corners_count; ic++ )
            for( ; ic < corners_count; ic++ )
            {
            {
                CPolyPt* corner = &zoneOutines[ic];
                CPolyPt* corner = &zoneOutines[ic];
                cornerslist.push_back( KPolyPoint( corner->x, corner->y ) );
                cornerslist.push_back( KI_POLY_POINT( corner->x, corner->y ) );
                if( corner->end_contour )
                if( corner->end_contour )
                {
                {
                    ic++;
                    ic++;
@@ -197,12 +197,12 @@ void ZONE_CONTAINER::TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>
    // Put the resultng polygon in buffer
    // Put the resultng polygon in buffer
    for( unsigned ii = 0; ii < polyset_zone_solid_areas.size(); ii++ )
    for( unsigned ii = 0; ii < polyset_zone_solid_areas.size(); ii++ )
    {
    {
        KPolygon& poly = polyset_zone_solid_areas[ii];
        KI_POLYGON& poly = polyset_zone_solid_areas[ii];
        CPolyPt   corner( 0, 0, false );
        CPolyPt   corner( 0, 0, false );


        for( unsigned jj = 0; jj < poly.size(); jj++ )
        for( unsigned jj = 0; jj < poly.size(); jj++ )
        {
        {
            KPolyPoint point = *(poly.begin() + jj);
            KI_POLY_POINT point = *(poly.begin() + jj);
            corner.x = point.x();
            corner.x = point.x();
            corner.y = point.y();
            corner.y = point.y();
            corner.end_contour = false;
            corner.end_contour = false;
+25 −25
Original line number Original line Diff line number Diff line
@@ -210,7 +210,7 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, const
    {
    {
        seg_start = GetCornerPosition( ic ) + offset;
        seg_start = GetCornerPosition( ic ) + offset;


        if( m_Poly->corner[ic].end_contour == false && ic < GetNumCorners() - 1 )
        if( m_Poly->m_CornersList[ic].end_contour == false && ic < GetNumCorners() - 1 )
        {
        {
            seg_end = GetCornerPosition( ic + 1 ) + offset;
            seg_end = GetCornerPosition( ic + 1 ) + offset;
        }
        }
@@ -306,7 +306,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel,


        CornersBuffer.push_back( coord );
        CornersBuffer.push_back( coord );


        CornersTypeBuffer.push_back( (char) corner->utility );
        CornersTypeBuffer.push_back( (char) corner->m_utility );


        if( (corner->end_contour) || (ic == imax) ) // the last corner of a filled area is found: draw it
        if( (corner->end_contour) || (ic == imax) ) // the last corner of a filled area is found: draw it
        {
        {
@@ -432,13 +432,13 @@ void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC, in
        int yi = GetCornerPosition( ic ).y;
        int yi = GetCornerPosition( ic ).y;
        int xf, yf;
        int xf, yf;


        if( m_Poly->corner[ic].end_contour == false && ic < icmax )
        if( m_Poly->m_CornersList[ic].end_contour == false && ic < icmax )
        {
        {
            is_close_segment = false;
            is_close_segment = false;
            xf = GetCornerPosition( ic + 1 ).x;
            xf = GetCornerPosition( ic + 1 ).x;
            yf = GetCornerPosition( ic + 1 ).y;
            yf = GetCornerPosition( ic + 1 ).y;


            if( (m_Poly->corner[ic + 1].end_contour) || (ic == icmax - 1) )
            if( (m_Poly->m_CornersList[ic + 1].end_contour) || (ic == icmax - 1) )
                current_gr_mode = GR_XOR;
                current_gr_mode = GR_XOR;
            else
            else
                current_gr_mode = draw_mode;
                current_gr_mode = draw_mode;
@@ -507,12 +507,12 @@ bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos )
    int min_dist = MIN_DIST_IN_MILS*IU_PER_MILS;
    int min_dist = MIN_DIST_IN_MILS*IU_PER_MILS;


    wxPoint delta;
    wxPoint delta;
    unsigned lim = m_Poly->corner.size();
    unsigned lim = m_Poly->m_CornersList.size();


    for( unsigned item_pos = 0; item_pos < lim; item_pos++ )
    for( unsigned item_pos = 0; item_pos < lim; item_pos++ )
    {
    {
        delta.x = refPos.x - m_Poly->corner[item_pos].x;
        delta.x = refPos.x - m_Poly->m_CornersList[item_pos].x;
        delta.y = refPos.y - m_Poly->corner[item_pos].y;
        delta.y = refPos.y - m_Poly->m_CornersList[item_pos].y;


        // Calculate a distance:
        // Calculate a distance:
        int dist = MAX( abs( delta.x ), abs( delta.y ) );
        int dist = MAX( abs( delta.x ), abs( delta.y ) );
@@ -530,7 +530,7 @@ bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos )


bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
{
{
    unsigned lim = m_Poly->corner.size();
    unsigned lim = m_Poly->m_CornersList.size();


    m_CornerSelection = -1;     // Set to not found
    m_CornerSelection = -1;     // Set to not found


@@ -547,7 +547,7 @@ bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
         * the last segment of the current outline starts at current corner, and ends
         * the last segment of the current outline starts at current corner, and ends
         * at the first corner of the outline
         * at the first corner of the outline
         */
         */
        if( m_Poly->corner[item_pos].end_contour || end_segm >= lim )
        if( m_Poly->m_CornersList[item_pos].end_contour || end_segm >= lim )
        {
        {
            unsigned tmp = first_corner_pos;
            unsigned tmp = first_corner_pos;
            first_corner_pos = end_segm;    // first_corner_pos is now the beginning of the next outline
            first_corner_pos = end_segm;    // first_corner_pos is now the beginning of the next outline
@@ -557,10 +557,10 @@ bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
        /* test the dist between segment and ref point */
        /* test the dist between segment and ref point */
        int dist = (int) GetPointToLineSegmentDistance( refPos.x,
        int dist = (int) GetPointToLineSegmentDistance( refPos.x,
                                                        refPos.y,
                                                        refPos.y,
                                                        m_Poly->corner[item_pos].x,
                                                        m_Poly->m_CornersList[item_pos].x,
                                                        m_Poly->corner[item_pos].y,
                                                        m_Poly->m_CornersList[item_pos].y,
                                                        m_Poly->corner[end_segm].x,
                                                        m_Poly->m_CornersList[end_segm].x,
                                                        m_Poly->corner[end_segm].y );
                                                        m_Poly->m_CornersList[end_segm].y );


        if( dist < min_dist )
        if( dist < min_dist )
        {
        {
@@ -703,7 +703,7 @@ void ZONE_CONTAINER::DisplayInfo( EDA_DRAW_FRAME* frame )
    msg = board->GetLayerName( m_Layer );
    msg = board->GetLayerName( m_Layer );
    frame->AppendMsgPanel( _( "Layer" ), msg, BROWN );
    frame->AppendMsgPanel( _( "Layer" ), msg, BROWN );


    msg.Printf( wxT( "%d" ), (int) m_Poly->corner.size() );
    msg.Printf( wxT( "%d" ), (int) m_Poly->m_CornersList.size() );
    frame->AppendMsgPanel( _( "Corners" ), msg, BLUE );
    frame->AppendMsgPanel( _( "Corners" ), msg, BLUE );


    if( m_FillMode )
    if( m_FillMode )
@@ -730,7 +730,7 @@ void ZONE_CONTAINER::DisplayInfo( EDA_DRAW_FRAME* frame )
void ZONE_CONTAINER::Move( const wxPoint& offset )
void ZONE_CONTAINER::Move( const wxPoint& offset )
{
{
    /* move outlines */
    /* move outlines */
    for( unsigned ii = 0; ii < m_Poly->corner.size(); ii++ )
    for( unsigned ii = 0; ii < m_Poly->m_CornersList.size(); ii++ )
    {
    {
        SetCornerPosition( ii, GetCornerPosition( ii ) + offset );
        SetCornerPosition( ii, GetCornerPosition( ii ) + offset );
    }
    }
@@ -761,7 +761,7 @@ void ZONE_CONTAINER::MoveEdge( const wxPoint& offset )
    SetCornerPosition( ii, GetCornerPosition( ii ) + offset );
    SetCornerPosition( ii, GetCornerPosition( ii ) + offset );


    // Move the end point of the selected edge:
    // Move the end point of the selected edge:
    if( m_Poly->corner[ii].end_contour || ii == GetNumCorners() - 1 )
    if( m_Poly->m_CornersList[ii].end_contour || ii == GetNumCorners() - 1 )
    {
    {
        int icont = m_Poly->GetContour( ii );
        int icont = m_Poly->GetContour( ii );
        ii = m_Poly->GetContourStart( icont );
        ii = m_Poly->GetContourStart( icont );
@@ -781,13 +781,13 @@ void ZONE_CONTAINER::Rotate( const wxPoint& centre, double angle )
{
{
    wxPoint pos;
    wxPoint pos;


    for( unsigned ii = 0; ii < m_Poly->corner.size(); ii++ )
    for( unsigned ii = 0; ii < m_Poly->m_CornersList.size(); ii++ )
    {
    {
        pos.x = m_Poly->corner[ii].x;
        pos.x = m_Poly->m_CornersList[ii].x;
        pos.y = m_Poly->corner[ii].y;
        pos.y = m_Poly->m_CornersList[ii].y;
        RotatePoint( &pos, centre, angle );
        RotatePoint( &pos, centre, angle );
        m_Poly->corner[ii].x = pos.x;
        m_Poly->m_CornersList[ii].x = pos.x;
        m_Poly->corner[ii].y = pos.y;
        m_Poly->m_CornersList[ii].y = pos.y;
    }
    }


    m_Poly->Hatch();
    m_Poly->Hatch();
@@ -820,11 +820,11 @@ void ZONE_CONTAINER::Flip( const wxPoint& aCentre )


void ZONE_CONTAINER::Mirror( const wxPoint& mirror_ref )
void ZONE_CONTAINER::Mirror( const wxPoint& mirror_ref )
{
{
    for( unsigned ii = 0; ii < m_Poly->corner.size(); ii++ )
    for( unsigned ii = 0; ii < m_Poly->m_CornersList.size(); ii++ )
    {
    {
        m_Poly->corner[ii].y -= mirror_ref.y;
        m_Poly->m_CornersList[ii].y -= mirror_ref.y;
        NEGATE( m_Poly->corner[ii].y );
        NEGATE( m_Poly->m_CornersList[ii].y );
        m_Poly->corner[ii].y += mirror_ref.y;
        m_Poly->m_CornersList[ii].y += mirror_ref.y;
    }
    }


    m_Poly->Hatch();
    m_Poly->Hatch();
+1 −1
Original line number Original line Diff line number Diff line
@@ -1059,7 +1059,7 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const


    m_out->Print( 0, ")\n" );
    m_out->Print( 0, ")\n" );


    const std::vector< CPolyPt >& cv = aZone->m_Poly->corner;
    const std::vector< CPolyPt >& cv = aZone->m_Poly->m_CornersList;
    int newLine = 0;
    int newLine = 0;


    if( cv.size() )
    if( cv.size() )
Loading