diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 989a28f372..56e171d51d 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -57,7 +57,8 @@ DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* aParent, KICAD_T idtype ) : m_Angle = 0; m_Flags = 0; m_Shape = S_SEGMENT; - m_Width = Millimeter2iu( 0.15 ); // Gives a decent width + // Gives a decent pen size to draw shape: + m_Width = m_Shape == S_POLYGON ? 0 : Millimeter2iu( 0.15 ); } @@ -317,6 +318,23 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, break; + case S_POLYGON: + { + SHAPE_POLY_SET& outline = GetPolyShape(); + // Draw the polygon: only one polygon is expected + // However we provide a multi polygon shape drawing + // ( for the future or to show a non expected shape ) + for( int jj = 0; jj < outline.OutlineCount(); ++jj ) + { + SHAPE_LINE_CHAIN& poly = outline.Outline( jj ); + + GRClosedPoly( panel->GetClipBox(), DC, poly.PointCount(), + (wxPoint*)&poly.Point( 0 ), FILLED, GetWidth(), + color, color ); + } + } + break; + default: if( filled ) { diff --git a/pcbnew/class_drawsegment.h b/pcbnew/class_drawsegment.h index 5348cc7ac1..51655c419d 100644 --- a/pcbnew/class_drawsegment.h +++ b/pcbnew/class_drawsegment.h @@ -57,8 +57,8 @@ protected: wxPoint m_BezierC1; ///< Bezier Control Point 1 wxPoint m_BezierC2; ///< Bezier Control Point 2 - std::vector m_BezierPoints; - SHAPE_POLY_SET m_Poly; + std::vector m_BezierPoints; + SHAPE_POLY_SET m_Poly; ///< Stores the S_POLYGON shape // Computes the bounding box for an arc void computeArcBBox( EDA_RECT& aBBox ) const; diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index d6a3055711..85f4f8e92c 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -920,8 +920,7 @@ void PCB_IO::format( DRAWSEGMENT* aSegment, int aNestLevel ) const formatLayer( aSegment ); - if( aSegment->GetWidth() != 0 ) - m_out->Print( 0, " (width %s)", FMT_IU( aSegment->GetWidth() ).c_str() ); + m_out->Print( 0, " (width %s)", FMT_IU( aSegment->GetWidth() ).c_str() ); if( aSegment->GetTimeStamp() ) m_out->Print( 0, " (tstamp %lX)", (unsigned long)aSegment->GetTimeStamp() ); @@ -1463,10 +1462,7 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const } } - if( primitive.m_Thickness != 0 ) - m_out->Print( 0, ") (width %s))", FMT_IU( primitive.m_Thickness ).c_str() ); - else - m_out->Print( 0, "))"); + m_out->Print( 0, ") (width %s))", FMT_IU( primitive.m_Thickness ).c_str() ); } break; diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index ded32c6de8..b96d9bb218 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -1438,6 +1438,7 @@ DRAWSEGMENT* PCB_PARSER::parseDRAWSEGMENT() case T_gr_poly: { segment->SetShape( S_POLYGON ); + segment->SetWidth( 0 ); // this is the default value. will be (perhaps) modified later NeedLEFT(); token = NextTok();