7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-02 00:26:45 +00:00

pcbnew: Plotting tables with non-90 degree rotation angles is not working

This commit is contained in:
Damjan 2025-03-04 12:08:18 +00:00 committed by Jeff Young
parent c61b6b8bdd
commit b419058df3
7 changed files with 96 additions and 42 deletions

View File

@ -250,6 +250,32 @@ bool DIALOG_TABLE_PROPERTIES::TransferDataToWindow()
return true;
}
void DIALOG_TABLE_PROPERTIES::onHeaderChecked( wxCommandEvent& aEvent )
{
BOARD_DESIGN_SETTINGS& bds = m_frame->GetDesignSettings();
PCB_LAYER_ID currentLayer = ToLAYER_ID( m_LayerSelectionCtrl->GetLayerSelection() );
int defaultLineThickness = bds.GetLineThickness( currentLayer );
bool border = m_borderCheckbox->GetValue();
bool header = m_headerBorder->GetValue();
if( ( border || header ) && m_borderWidth.GetValue() < 0 )
m_borderWidth.SetValue( defaultLineThickness );
m_borderWidth.Enable( border || header );
m_borderStyleLabel->Enable( border || header );
m_borderStyleCombo->Enable( border || header );
bool row = m_rowSeparators->GetValue();
bool col = m_colSeparators->GetValue();
if( ( row || col ) && m_separatorsWidth.GetValue() < 0 )
m_separatorsWidth.SetValue( defaultLineThickness );
m_separatorsWidth.Enable( row || col );
m_separatorsStyleLabel->Enable( row || col );
m_separatorsStyleCombo->Enable( row || col );
}
void DIALOG_TABLE_PROPERTIES::onBorderChecked( wxCommandEvent& aEvent )
{
@ -258,13 +284,14 @@ void DIALOG_TABLE_PROPERTIES::onBorderChecked( wxCommandEvent& aEvent )
int defaultLineThickness = bds.GetLineThickness( currentLayer );
bool border = m_borderCheckbox->GetValue();
bool header = m_headerBorder->GetValue();
if( border && m_borderWidth.GetValue() < 0 )
if( ( border || header ) && m_borderWidth.GetValue() < 0 )
m_borderWidth.SetValue( defaultLineThickness );
m_borderWidth.Enable( border );
m_borderStyleLabel->Enable( border );
m_borderStyleCombo->Enable( border );
m_borderWidth.Enable( border || header );
m_borderStyleLabel->Enable( border || header );
m_borderStyleCombo->Enable( border || header );
bool row = m_rowSeparators->GetValue();
bool col = m_colSeparators->GetValue();
@ -337,7 +364,7 @@ bool DIALOG_TABLE_PROPERTIES::TransferDataFromWindow()
{
STROKE_PARAMS stroke = m_table->GetBorderStroke();
if( m_borderCheckbox->GetValue() )
if( m_borderCheckbox->GetValue() || m_headerBorder->GetValue() )
stroke.SetWidth( std::max( 0, m_borderWidth.GetIntValue() ) );
else
stroke.SetWidth( -1 );

View File

@ -46,6 +46,7 @@ private:
bool TransferDataFromWindow() override;
void onBorderChecked( wxCommandEvent& aEvent ) override;
void onHeaderChecked( wxCommandEvent& aEvent ) override;
void onSize( wxSizeEvent& aEvent ) override;
private:

View File

@ -162,6 +162,7 @@ DIALOG_TABLE_PROPERTIES_BASE::DIALOG_TABLE_PROPERTIES_BASE( wxWindow* parent, wx
// Connect Events
this->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_TABLE_PROPERTIES_BASE::onSize ) );
m_borderCheckbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TABLE_PROPERTIES_BASE::onBorderChecked ), NULL, this );
m_headerBorder->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TABLE_PROPERTIES_BASE::onHeaderChecked ), NULL, this );
m_rowSeparators->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TABLE_PROPERTIES_BASE::onBorderChecked ), NULL, this );
m_colSeparators->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TABLE_PROPERTIES_BASE::onBorderChecked ), NULL, this );
}
@ -171,6 +172,7 @@ DIALOG_TABLE_PROPERTIES_BASE::~DIALOG_TABLE_PROPERTIES_BASE()
// Disconnect Events
this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_TABLE_PROPERTIES_BASE::onSize ) );
m_borderCheckbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TABLE_PROPERTIES_BASE::onBorderChecked ), NULL, this );
m_headerBorder->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TABLE_PROPERTIES_BASE::onHeaderChecked ), NULL, this );
m_rowSeparators->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TABLE_PROPERTIES_BASE::onBorderChecked ), NULL, this );
m_colSeparators->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TABLE_PROPERTIES_BASE::onBorderChecked ), NULL, this );

View File

@ -570,6 +570,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnCheckBox">onHeaderChecked</event>
</object>
</object>
<object class="gbsizeritem" expanded="true">

View File

@ -65,6 +65,7 @@ class DIALOG_TABLE_PROPERTIES_BASE : public DIALOG_SHIM
// Virtual event handlers, override them in your derived class
virtual void onSize( wxSizeEvent& event ) { event.Skip(); }
virtual void onBorderChecked( wxCommandEvent& event ) { event.Skip(); }
virtual void onHeaderChecked( wxCommandEvent& event ) { event.Skip(); }
public:

View File

@ -2538,7 +2538,13 @@ void PCB_PAINTER::draw( const PCB_TABLE* aTable, int aLayer )
{
for( int col = 0; col < aTable->GetColCount() - 1; ++col )
{
for( int row = 0; row < aTable->GetRowCount(); ++row )
int row = 1;
if( aTable->StrokeHeader() )
{
row = 0;
}
for( ; row < aTable->GetRowCount(); ++row )
{
PCB_TABLECELL* cell = aTable->GetCell( row, col );
std::vector<VECTOR2I> corners = cell->GetCornersInSequence();
@ -2581,10 +2587,21 @@ void PCB_PAINTER::draw( const PCB_TABLE* aTable, int aLayer )
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] );
if( aTable->StrokeHeader() )
{
strokeLine( topLeft[0], topRight[1] );
strokeLine( topLeft[0], topLeft[3] );
strokeLine( topLeft[3], topRight[2] );
strokeLine( topRight[1], topRight[2] );
}
if( aTable->StrokeExternal() )
{
strokeLine( topLeft[3], topRight[2] );
strokeLine( topRight[2], bottomRight[2] );
strokeLine( bottomRight[2], bottomLeft[3] );
strokeLine( bottomLeft[3], topLeft[3] );
}
}
// Highlight selected tablecells with a background wash.

View File

@ -1168,15 +1168,6 @@ void BRDITEMS_PLOTTER::PlotTableBorders( const PCB_TABLE* aTable )
}
};
auto strokeRect =
[&]( const VECTOR2I& ptA, const VECTOR2I& ptB )
{
strokeLine( VECTOR2I( ptA.x, ptA.y ), VECTOR2I( ptB.x, ptA.y ) );
strokeLine( VECTOR2I( ptB.x, ptA.y ), VECTOR2I( ptB.x, ptB.y ) );
strokeLine( VECTOR2I( ptB.x, ptB.y ), VECTOR2I( ptA.x, ptB.y ) );
strokeLine( VECTOR2I( ptA.x, ptB.y ), VECTOR2I( ptA.x, ptA.y ) );
};
if( aTable->GetSeparatorsStroke().GetWidth() >= 0 )
{
setupStroke( aTable->GetSeparatorsStroke() );
@ -1185,16 +1176,22 @@ void BRDITEMS_PLOTTER::PlotTableBorders( const PCB_TABLE* aTable )
{
for( int col = 0; col < aTable->GetColCount() - 1; ++col )
{
for( int row = 0; row < aTable->GetRowCount(); ++row )
int row = 1;
if( aTable->StrokeHeader() )
{
PCB_TABLECELL* cell = aTable->GetCell( row, col );
VECTOR2I topRight( cell->GetEndX(), cell->GetStartY() );
row = 0;
}
if( !cell->GetTextAngle().IsHorizontal() )
topRight = VECTOR2I( cell->GetStartX(), cell->GetEndY() );
for( ; row < aTable->GetRowCount(); ++row )
{
PCB_TABLECELL* cell = aTable->GetCell( row, col );
std::vector<VECTOR2I> corners = cell->GetCornersInSequence();
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] );
}
}
}
}
@ -1205,14 +1202,14 @@ void BRDITEMS_PLOTTER::PlotTableBorders( const PCB_TABLE* aTable )
{
for( int col = 0; col < aTable->GetColCount(); ++col )
{
PCB_TABLECELL* cell = aTable->GetCell( row, col );
VECTOR2I botLeft( cell->GetStartX(), cell->GetEndY() );
PCB_TABLECELL* cell = aTable->GetCell( row, col );
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] );
}
}
}
}
@ -1221,22 +1218,30 @@ void BRDITEMS_PLOTTER::PlotTableBorders( const PCB_TABLE* aTable )
if( aTable->GetBorderStroke().GetWidth() >= 0 )
{
setupStroke( aTable->GetBorderStroke() );
PCB_TABLECELL* cell = aTable->GetCell( 0, 0 );
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();
if( aTable->StrokeHeader() )
{
if( !cell->GetTextAngle().IsHorizontal() )
strokeLine( VECTOR2I( cell->GetEndX(), pos.y ), VECTOR2I( cell->GetEndX(), cell->GetEndY() ) );
else
strokeLine( VECTOR2I( pos.x, cell->GetEndY() ), VECTOR2I( end.x, cell->GetEndY() ) );
strokeLine( topLeft[0], topRight[1] );
strokeLine( topLeft[0], topLeft[3] );
strokeLine( topLeft[3], topRight[2] );
strokeLine( topRight[1], topRight[2] );
}
if( aTable->StrokeExternal() )
{
RotatePoint( pos, aTable->GetPosition(), cell->GetTextAngle() );
RotatePoint( end, aTable->GetPosition(), cell->GetTextAngle() );
strokeRect( pos, end );
strokeLine( topLeft[3], topRight[2] );
strokeLine( topRight[2], bottomRight[2] );
strokeLine( bottomRight[2], bottomLeft[3] );
strokeLine( bottomLeft[3], topLeft[3] );
}
}
}