mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-11 16:10:10 +00:00
pcbnew: Table Rotation
This commit is contained in:
parent
4123f75d5a
commit
5771467ca3
@ -2455,7 +2455,6 @@ void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PCB_PAINTER::draw( const PCB_TABLE* aTable, int aLayer )
|
||||
{
|
||||
if( aTable->GetCells().empty() )
|
||||
@ -2531,6 +2530,7 @@ void PCB_PAINTER::draw( const PCB_TABLE* aTable, int aLayer )
|
||||
{
|
||||
setupStroke( aTable->GetSeparatorsStroke() );
|
||||
|
||||
// Stroke column edges
|
||||
if( aTable->StrokeColumns() )
|
||||
{
|
||||
for( int col = 0; col < aTable->GetColCount() - 1; ++col )
|
||||
@ -2538,17 +2538,18 @@ 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() );
|
||||
std::vector<VECTOR2I> corners = cell->GetCornersInSequence();
|
||||
|
||||
if( !cell->GetTextAngle().IsHorizontal() )
|
||||
topRight = VECTOR2I( cell->GetStartX(), cell->GetEndY() );
|
||||
|
||||
if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
|
||||
strokeLine( topRight, cell->GetEnd() );
|
||||
if( corners.size() == 4 )
|
||||
{
|
||||
// Draw right edge (between adjacent cells)
|
||||
strokeLine( corners[1], corners[2] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Stroke row edges
|
||||
if( aTable->StrokeRows() )
|
||||
{
|
||||
for( int row = 0; row < aTable->GetRowCount() - 1; ++row )
|
||||
@ -2556,13 +2557,13 @@ 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() );
|
||||
std::vector<VECTOR2I> corners = cell->GetCornersInSequence();
|
||||
|
||||
if( !cell->GetTextAngle().IsHorizontal() )
|
||||
botLeft = VECTOR2I( cell->GetEndX(), cell->GetStartY() );
|
||||
|
||||
if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
|
||||
strokeLine( botLeft, cell->GetEnd() );
|
||||
if( corners.size() == 4 )
|
||||
{
|
||||
// Draw bottom edge (between adjacent cells)
|
||||
strokeLine( corners[2], corners[3] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2570,25 +2571,20 @@ void PCB_PAINTER::draw( const PCB_TABLE* aTable, int aLayer )
|
||||
|
||||
if( aTable->GetBorderStroke().GetWidth() >= 0 )
|
||||
{
|
||||
PCB_TABLECELL* first = aTable->GetCell( 0, 0 );
|
||||
|
||||
setupStroke( aTable->GetBorderStroke() );
|
||||
|
||||
if( aTable->StrokeHeader() )
|
||||
{
|
||||
if( !first->GetTextAngle().IsHorizontal() )
|
||||
strokeLine( VECTOR2I( first->GetEndX(), pos.y ), VECTOR2I( first->GetEndX(), first->GetEndY() ) );
|
||||
else
|
||||
strokeLine( VECTOR2I( pos.x, first->GetEndY() ), VECTOR2I( end.x, first->GetEndY() ) );
|
||||
}
|
||||
|
||||
if( aTable->StrokeExternal() )
|
||||
{
|
||||
RotatePoint( pos, aTable->GetPosition(), first->GetTextAngle() );
|
||||
RotatePoint( end, aTable->GetPosition(), first->GetTextAngle() );
|
||||
|
||||
strokeRect( pos, end );
|
||||
}
|
||||
std::vector<VECTOR2I> topLeft = aTable->GetCell( 0, 0 )->GetCornersInSequence();
|
||||
std::vector<VECTOR2I> bottomLeft =
|
||||
aTable->GetCell( aTable->GetRowCount() - 1, 0 )->GetCornersInSequence();
|
||||
std::vector<VECTOR2I> topRight =
|
||||
aTable->GetCell( 0, aTable->GetColCount() - 1 )->GetCornersInSequence();
|
||||
std::vector<VECTOR2I> bottomRight =
|
||||
aTable->GetCell( aTable->GetRowCount() - 1, aTable->GetColCount() - 1 )
|
||||
->GetCornersInSequence();
|
||||
strokeLine( topLeft[0], topRight[1] );
|
||||
strokeLine( topRight[1], bottomRight[2] );
|
||||
strokeLine( bottomRight[2], bottomLeft[3] );
|
||||
strokeLine( bottomLeft[3], topLeft[0] );
|
||||
}
|
||||
|
||||
// Highlight selected tablecells with a background wash.
|
||||
|
@ -57,12 +57,10 @@ PCB_TEXTBOX::PCB_TEXTBOX( BOARD_ITEM* aParent, KICAD_T aType ) :
|
||||
m_marginBottom = defaultMargin;
|
||||
}
|
||||
|
||||
|
||||
PCB_TEXTBOX::~PCB_TEXTBOX()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void PCB_TEXTBOX::Serialize( google::protobuf::Any &aContainer ) const
|
||||
{
|
||||
using namespace kiapi::common::types;
|
||||
@ -589,7 +587,7 @@ void PCB_TEXTBOX::Move( const VECTOR2I& aMoveVector )
|
||||
void PCB_TEXTBOX::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||
{
|
||||
PCB_SHAPE::Rotate( aRotCentre, aAngle );
|
||||
EDA_TEXT::SetTextAngle( ( GetTextAngle() + aAngle ).Normalize90() );
|
||||
EDA_TEXT::SetTextAngle( ( GetTextAngle() + aAngle ).Normalize() );
|
||||
|
||||
if( GetTextAngle().IsCardinal() && GetShape() != SHAPE_T::RECTANGLE )
|
||||
{
|
||||
@ -600,8 +598,6 @@ void PCB_TEXTBOX::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
|
||||
SetShape( SHAPE_T::RECTANGLE );
|
||||
SetStart( corners[0] );
|
||||
|
||||
angle.Normalize();
|
||||
|
||||
if( angle == ANGLE_90 )
|
||||
SetEnd( VECTOR2I( corners[0].x + abs( diag.x ), corners[0].y - abs( diag.y ) ) );
|
||||
else if( angle == ANGLE_180 )
|
||||
@ -752,6 +748,7 @@ void PCB_TEXTBOX::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID
|
||||
{
|
||||
// Don't use PCB_SHAPE::TransformShapeToPolygon. We want to treat the textbox as filled even
|
||||
// if there's no background colour.
|
||||
|
||||
int width = GetWidth() + ( 2 * aClearance );
|
||||
|
||||
if( GetShape() == SHAPE_T::RECTANGLE )
|
||||
|
Loading…
Reference in New Issue
Block a user