diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index db4033d7ca..60f8af7f99 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -2537,12 +2537,10 @@ void SCH_PAINTER::draw( const SCH_TABLE* aTable, int aLayer ) for( int row = 0; row < aTable->GetRowCount(); ++row ) { SCH_TABLECELL* cell = aTable->GetCell( row, col ); + VECTOR2I topRight( cell->GetEndX(), cell->GetStartY() ); if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 ) - { - strokeLine( VECTOR2I( cell->GetEndX(), cell->GetStartY() ), - VECTOR2I( cell->GetEndX(), cell->GetEndY() ) ); - } + strokeLine( topRight, cell->GetEnd() ); } } } @@ -2554,12 +2552,10 @@ void SCH_PAINTER::draw( const SCH_TABLE* aTable, int aLayer ) for( int col = 0; col < aTable->GetColCount(); ++col ) { SCH_TABLECELL* cell = aTable->GetCell( row, col ); + VECTOR2I botLeft( cell->GetStartX(), cell->GetEndY() ); if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 ) - { - strokeLine( VECTOR2I( cell->GetStartX(), cell->GetEndY() ), - VECTOR2I( cell->GetEndX(), cell->GetEndY() ) ); - } + strokeLine( botLeft, cell->GetEnd() ); } } } diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index 56be351367..a69f4b9fd2 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,7 @@ #include #include #include +#include using namespace std::placeholders; @@ -204,6 +206,15 @@ void FOOTPRINT_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem ) ShowTextBoxPropertiesDialog( static_cast( aItem ) ); break; + case PCB_TABLE_T: + { + DIALOG_TABLE_PROPERTIES dlg( this, static_cast( aItem ) ); + + //QuasiModal required for Scintilla auto-complete + dlg.ShowQuasiModal(); + break; + } + case PCB_SHAPE_T : ShowGraphicItemPropertiesDialog( static_cast( aItem ) ); break; diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 27e6598e4a..7dc2e97f34 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -2355,12 +2355,10 @@ void PCB_PAINTER::draw( const PCB_TABLE* aTable, int aLayer ) for( int row = 0; row < aTable->GetRowCount(); ++row ) { PCB_TABLECELL* cell = aTable->GetCell( row, col ); + VECTOR2I topRight( cell->GetEndX(), cell->GetStartY() ); if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 ) - { - strokeLine( VECTOR2I( cell->GetEndX(), cell->GetStartY() ), - VECTOR2I( cell->GetEndX(), cell->GetEndY() ) ); - } + strokeLine( topRight, cell->GetEnd() ); } } } @@ -2372,12 +2370,10 @@ void PCB_PAINTER::draw( const PCB_TABLE* aTable, int aLayer ) for( int col = 0; col < aTable->GetColCount(); ++col ) { PCB_TABLECELL* cell = aTable->GetCell( row, col ); + VECTOR2I botLeft( cell->GetStartX(), cell->GetEndY() ); if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 ) - { - strokeLine( VECTOR2I( cell->GetStartX(), cell->GetEndY() ), - VECTOR2I( cell->GetEndX(), cell->GetEndY() ) ); - } + strokeLine( botLeft, cell->GetEnd() ); } } } diff --git a/pcbnew/pcb_table.cpp b/pcbnew/pcb_table.cpp index 5177c1e871..56b818fd9e 100644 --- a/pcbnew/pcb_table.cpp +++ b/pcbnew/pcb_table.cpp @@ -23,7 +23,9 @@ #include #include - +#include +#include +#include PCB_TABLE::PCB_TABLE( BOARD_ITEM* aParent, int aLineWidth ) : @@ -224,12 +226,83 @@ const BOX2I PCB_TABLE::GetBoundingBox() const } +std::shared_ptr PCB_TABLE::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const +{ + VECTOR2I origin = GetPosition(); + VECTOR2I end = GetEnd(); + std::shared_ptr shape = std::make_shared(); + + std::vector pts; + + pts.emplace_back( origin ); + pts.emplace_back( end.x, origin.y ); + pts.emplace_back( end ); + pts.emplace_back( origin.x, end.y ); + + shape->AddShape( new SHAPE_SIMPLE( pts ) ); + + auto addSeg = + [&shape]( const VECTOR2I& ptA, const VECTOR2I& ptB, int width ) + { + shape->AddShape( new SHAPE_SEGMENT( ptA, ptB, width ) ); + }; + + if( StrokeColumns() && GetSeparatorsStroke().GetWidth() >= 0) + { + for( int col = 0; col < GetColCount() - 1; ++col ) + { + for( int row = 0; row < GetRowCount(); ++row ) + { + PCB_TABLECELL* cell = GetCell( row, col ); + VECTOR2I topRight( cell->GetEndX(), cell->GetStartY() ); + + if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 ) + addSeg( topRight, cell->GetEnd(), GetSeparatorsStroke().GetWidth() ); + } + } + } + + if( StrokeRows() && GetSeparatorsStroke().GetWidth() >= 0 ) + { + for( int row = 0; row < GetRowCount() - 1; ++row ) + { + for( int col = 0; col < GetColCount(); ++col ) + { + PCB_TABLECELL* cell = GetCell( row, col ); + VECTOR2I botLeft( cell->GetStartX(), cell->GetEndY() ); + + if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 ) + addSeg( botLeft, cell->GetEnd(), GetSeparatorsStroke().GetWidth() ); + } + } + } + + if( StrokeExternal() && GetBorderStroke().GetWidth() >= 0 ) + { + addSeg( pts[0], pts[1], GetBorderStroke().GetWidth() ); + addSeg( pts[1], pts[2], GetBorderStroke().GetWidth() ); + addSeg( pts[2], pts[3], GetBorderStroke().GetWidth() ); + addSeg( pts[3], pts[0], GetBorderStroke().GetWidth() ); + } + + return shape; +} + + void PCB_TABLE::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth ) const { + int gap = aClearance; + + if( StrokeColumns() || StrokeRows() ) + gap = std::max( gap, aClearance + GetSeparatorsStroke().GetWidth() / 2 ); + + if( StrokeExternal() || StrokeHeader() ) + gap = std::max( gap, aClearance + GetBorderStroke().GetWidth() / 2 ); + for( PCB_TABLECELL* cell : m_cells ) - cell->TransformShapeToPolygon( aBuffer, aLayer, aClearance, aMaxError, aErrorLoc, false ); + cell->TransformShapeToPolygon( aBuffer, aLayer, gap, aMaxError, aErrorLoc, false ); } diff --git a/pcbnew/pcb_table.h b/pcbnew/pcb_table.h index 66b6f2dadc..a243826ce2 100644 --- a/pcbnew/pcb_table.h +++ b/pcbnew/pcb_table.h @@ -191,6 +191,10 @@ public: const BOX2I GetBoundingBox() const override; + // @copydoc BOARD_ITEM::GetEffectiveShape + std::shared_ptr GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER, + FLASHING aFlash = FLASHING::DEFAULT ) const override; + void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth = false ) const override; diff --git a/pcbnew/pcb_textbox.h b/pcbnew/pcb_textbox.h index caf50bbc4b..05c9f9ac97 100644 --- a/pcbnew/pcb_textbox.h +++ b/pcbnew/pcb_textbox.h @@ -136,9 +136,8 @@ public: bool aIgnoreLineWidth = false ) const override; // @copydoc BOARD_ITEM::GetEffectiveShape - virtual std::shared_ptr - GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER, - FLASHING aFlash = FLASHING::DEFAULT ) const override; + std::shared_ptr GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER, + FLASHING aFlash = FLASHING::DEFAULT ) const override; wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override; diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index f9ec55e84f..24dba2925e 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -35,6 +35,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -46,7 +49,6 @@ #include #include // for KiROUND #include "zone_filler.h" -#include "pcb_dimension.h" ZONE_FILLER::ZONE_FILLER( BOARD* aBoard, COMMIT* aCommit ) : @@ -828,19 +830,7 @@ void ZONE_FILLER::addKnockout( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer, int aGap, } case PCB_TEXTBOX_T: - { - PCB_TEXTBOX* textbox = static_cast( aItem ); - - if( textbox->IsVisible() ) - textbox->TransformShapeToPolygon( aHoles, aLayer, aGap, m_maxError, ERROR_OUTSIDE ); - - break; - } - case PCB_TABLE_T: - // JEY TODO: tables - break; - case PCB_SHAPE_T: case PCB_TARGET_T: aItem->TransformShapeToPolygon( aHoles, aLayer, aGap, m_maxError, ERROR_OUTSIDE,