@ -33,7 +33,7 @@
PCB_TABLE : : PCB_TABLE ( BOARD_ITEM * aParent , int aLineWidth ) :
BOARD_ITEM_CONTAINER ( aParent , PCB_TABLE_T ) ,
m_strokeExternal ( true ) ,
m_strokeHeade r ( true ) ,
m_StrokeHeaderSeparato r ( true ) ,
m_borderStroke ( aLineWidth , LINE_STYLE : : DEFAULT , COLOR4D : : UNSPECIFIED ) ,
m_strokeRows ( true ) ,
m_strokeColumns ( true ) ,
@ -47,7 +47,7 @@ PCB_TABLE::PCB_TABLE( const PCB_TABLE& aTable ) :
BOARD_ITEM_CONTAINER ( aTable )
{
m_strokeExternal = aTable . m_strokeExternal ;
m_strokeHeade r = aTable . m_strokeHeade r ;
m_StrokeHeaderSeparato r = aTable . m_StrokeHeaderSeparato r ;
m_borderStroke = aTable . m_borderStroke ;
m_strokeRows = aTable . m_strokeRows ;
m_strokeColumns = aTable . m_strokeColumns ;
@ -81,7 +81,7 @@ void PCB_TABLE::swapData( BOARD_ITEM* aImage )
std : : swap ( m_isLocked , table - > m_isLocked ) ;
std : : swap ( m_strokeExternal , table - > m_strokeExternal ) ;
std : : swap ( m_strokeHeade r , table - > m_strokeHeade r ) ;
std : : swap ( m_StrokeHeaderSeparato r , table - > m_StrokeHeaderSeparato r ) ;
std : : swap ( m_borderStroke , table - > m_borderStroke ) ;
std : : swap ( m_strokeRows , table - > m_strokeRows ) ;
std : : swap ( m_strokeColumns , table - > m_strokeColumns ) ;
@ -236,77 +236,93 @@ const BOX2I PCB_TABLE::GetBoundingBox() const
}
std : : shared_ptr < SHAPE > PCB_TABLE : : GetEffectiveShape ( PCB_LAYER_ID aLayer , FLASHING aFlash ) const
void PCB_TABLE : : DrawBorders ( const std : : function < void ( const VECTOR2I & aPt1 ,
const VECTOR2I & aPt2 ,
const STROKE_PARAMS & aStroke ) > & aCallback ) const
{
std : : vector < VECTOR2I > topLeft = GetCell ( 0 , 0 ) - > GetCornersInSequence ( ) ;
std : : vector < VECTOR2I > bottomLeft = GetCell ( GetRowCount ( ) - 1 , 0 ) - > GetCornersInSequence ( ) ;
std : : vector < VECTOR2I > topRight = GetCell ( 0 , GetColCount ( ) - 1 ) - > GetCornersInSequence ( ) ;
std : : vector < VECTOR2I > bottomRight = GetCell ( GetRowCount ( ) - 1 , GetColCount ( ) - 1 ) - > GetCornersInSequence ( ) ;
STROKE_PARAMS stroke ;
std : : shared_ptr < SHAPE_COMPOUND > shape = std : : make_shared < SHAPE_COMPOUND > ( ) ;
std : : vector < VECTOR2I > pts ;
pts . emplace_back ( topLeft [ 3 ] ) ;
pts . emplace_back ( topRight [ 2 ] ) ;
pts . emplace_back ( bottomRight [ 2 ] ) ;
pts . emplace_back ( bottomLeft [ 3 ] ) ;
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 col = 0 ; col < GetColCount ( ) - 1 ; + + col )
if ( StrokeColumns ( ) )
stroke = GetSeparatorsStroke ( ) ;
else
continue ;
for ( int row = 0 ; row < GetRowCount ( ) ; + + row )
{
int row = StrokeHeader ( ) ? 0 : 1 ;
PCB_TABLECELL * cell = GetCell ( row , col ) ;
for ( ; row < GetRowCount ( ) ; + + row )
{
PCB_TABLECELL * cell = GetCell ( row , col ) ;
std : : vector < VECTOR2I > corners = cell - > GetCornersInSequence ( ) ;
if ( cell - > GetColSpan ( ) = = 0 )
continue ;
if ( corners . size ( ) = = 4 )
addSeg ( corners [ 1 ] , corners [ 2 ] , GetSeparatorsStroke ( ) . GetWidth ( ) ) ;
}
std : : vector < VECTOR2I > corners = cell - > GetCornersInSequence ( ) ;
if ( corners . size ( ) = = 4 )
aCallback ( corners [ 1 ] , corners [ 2 ] , stroke ) ;
}
}
if ( StrokeRows ( ) & & GetSeparatorsStroke ( ) . GetWidth ( ) > = 0 )
for ( int row = 0 ; row < GetRowCount ( ) - 1 ; + + row )
{
for ( int row = 0 ; row < GetRowCount ( ) - 1 ; + + row )
if ( row = = 0 & & StrokeHeaderSeparator ( ) )
stroke = GetBorderStroke ( ) ;
else if ( StrokeRows ( ) )
stroke = GetSeparatorsStroke ( ) ;
else
continue ;
for ( int col = 0 ; col < GetColCount ( ) ; + + col )
{
for ( int col = 0 ; col < GetColCount ( ) ; + + col )
{
PCB_TABLECELL * cell = GetCell ( row , col ) ;
std : : vector < VECTOR2I > corners = cell - > GetCornersInSequence ( ) ;
PCB_TABLECELL * cell = GetCell ( row , col ) ;
if ( corners . size ( ) = = 4 )
addSeg ( corners [ 2 ] , corners [ 3 ] , GetSeparatorsStroke ( ) . GetWidth ( ) ) ;
}
}
}
if ( cell - > GetRowSpan ( ) = = 0 )
continue ;
if ( StrokeHeader ( ) & & GetBorderStroke ( ) . GetWidth ( ) > = 0 )
{
addSeg ( topLeft [ 0 ] , topRight [ 1 ] , GetBorderStroke ( ) . GetWidth ( ) ) ;
addSeg ( topLeft [ 0 ] , topLeft [ 3 ] , GetBorderStroke ( ) . GetWidth ( ) ) ;
addSeg ( topLeft [ 3 ] , topRight [ 2 ] , GetBorderStroke ( ) . GetWidth ( ) ) ;
addSeg ( topRight [ 1 ] , topRight [ 2 ] , GetBorderStroke ( ) . GetWidth ( ) ) ;
std : : vector < VECTOR2I > corners = cell - > GetCornersInSequence ( ) ;
if ( corners . size ( ) = = 4 )
aCallback ( corners [ 2 ] , corners [ 3 ] , stroke ) ;
}
}
if ( StrokeExternal ( ) & & GetBorderStroke ( ) . GetWidth ( ) > = 0 )
{
addSeg ( topLeft [ 3 ] , topRight [ 2 ] , GetBorderStroke ( ) . GetWidth ( ) ) ;
addSeg ( topRight [ 2 ] , bottomRight [ 2 ] , GetBorderStroke ( ) . GetWidth ( ) ) ;
addSeg ( bottomRight [ 2 ] , bottomLeft [ 3 ] , GetBorderStroke ( ) . GetWidth ( ) ) ;
addSeg ( bottomLeft [ 3 ] , topLeft [ 3 ] , GetBorderStroke ( ) . GetWidth ( ) ) ;
aCallback ( topLeft [ 0 ] , topRight [ 1 ] , GetBorderStroke ( ) ) ;
aCallback ( topRight [ 1 ] , bottomRight [ 2 ] , GetBorderStroke ( ) ) ;
aCallback ( bottomRight [ 2 ] , bottomLeft [ 3 ] , GetBorderStroke ( ) ) ;
aCallback ( bottomLeft [ 3 ] , topLeft [ 0 ] , GetBorderStroke ( ) ) ;
}
}
std : : shared_ptr < SHAPE > PCB_TABLE : : GetEffectiveShape ( PCB_LAYER_ID aLayer , FLASHING aFlash ) const
{
std : : vector < VECTOR2I > topLeft = GetCell ( 0 , 0 ) - > GetCornersInSequence ( ) ;
std : : vector < VECTOR2I > bottomLeft = GetCell ( GetRowCount ( ) - 1 , 0 ) - > GetCornersInSequence ( ) ;
std : : vector < VECTOR2I > topRight = GetCell ( 0 , GetColCount ( ) - 1 ) - > GetCornersInSequence ( ) ;
std : : vector < VECTOR2I > bottomRight = GetCell ( GetRowCount ( ) - 1 , GetColCount ( ) - 1 ) - > GetCornersInSequence ( ) ;
std : : shared_ptr < SHAPE_COMPOUND > shape = std : : make_shared < SHAPE_COMPOUND > ( ) ;
std : : vector < VECTOR2I > pts ;
pts . emplace_back ( topLeft [ 3 ] ) ;
pts . emplace_back ( topRight [ 2 ] ) ;
pts . emplace_back ( bottomRight [ 2 ] ) ;
pts . emplace_back ( bottomLeft [ 3 ] ) ;
shape - > AddShape ( new SHAPE_SIMPLE ( pts ) ) ;
DrawBorders (
[ & shape ] ( const VECTOR2I & ptA , const VECTOR2I & ptB , const STROKE_PARAMS & stroke )
{
shape - > AddShape ( new SHAPE_SEGMENT ( ptA , ptB , stroke . GetWidth ( ) ) ) ;
} ) ;
return shape ;
}
@ -321,7 +337,7 @@ void PCB_TABLE::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID a
if ( StrokeColumns ( ) | | StrokeRows ( ) )
gap = std : : max ( gap , aClearance + GetSeparatorsStroke ( ) . GetWidth ( ) / 2 ) ;
if ( StrokeExternal ( ) | | StrokeHeader ( ) )
if ( StrokeExternal ( ) | | StrokeHeaderSeparator ( ) )
gap = std : : max ( gap , aClearance + GetBorderStroke ( ) . GetWidth ( ) / 2 ) ;
for ( PCB_TABLECELL * cell : m_cells )
@ -456,7 +472,7 @@ bool PCB_TABLE::operator==( const PCB_TABLE& aOther ) const
if ( m_strokeExternal ! = aOther . m_strokeExternal )
return false ;
if ( m_strokeHeade r ! = aOther . m_strokeHeade r )
if ( m_StrokeHeaderSeparato r ! = aOther . m_StrokeHeaderSeparato r )
return false ;
if ( m_borderStroke ! = aOther . m_borderStroke )
@ -502,7 +518,7 @@ double PCB_TABLE::Similarity( const BOARD_ITEM& aOther ) const
if ( m_strokeExternal ! = other . m_strokeExternal )
similarity * = 0.9 ;
if ( m_strokeHeade r ! = other . m_strokeHeade r )
if ( m_StrokeHeaderSeparato r ! = other . m_StrokeHeaderSeparato r )
similarity * = 0.9 ;
if ( m_borderStroke ! = other . m_borderStroke )
@ -567,7 +583,7 @@ static struct PCB_TABLE_DESC
tableProps ) ;
propMgr . AddProperty ( new PROPERTY < PCB_TABLE , bool > ( _HKI ( " Header Border " ) ,
& PCB_TABLE : : SetStrokeHeader , & PCB_TABLE : : StrokeHeader ) ,
& PCB_TABLE : : SetStrokeHeaderSeparator , & PCB_TABLE : : StrokeHeaderSeparato r ) ,
tableProps ) ;
propMgr . AddProperty ( new PROPERTY < PCB_TABLE , int > ( _HKI ( " Border Width " ) ,