7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-18 22:41:41 +00:00

Bug fixes for rotated tables.

This commit is contained in:
Jeff Young 2024-12-15 22:00:54 +00:00
parent 1e9d9adb09
commit 2926db778c
13 changed files with 210 additions and 134 deletions

View File

@ -2018,6 +2018,9 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer, bool aDimmed )
void SCH_PAINTER::draw( const SCH_TABLE* aTable, int aLayer, bool aDimmed )
{
if( aTable->GetCells().empty() )
return;
for( SCH_TABLECELL* cell : aTable->GetCells() )
draw( cell, aLayer, aDimmed );
@ -2108,6 +2111,9 @@ void SCH_PAINTER::draw( const SCH_TABLE* aTable, int aLayer, bool aDimmed )
SCH_TABLECELL* cell = aTable->GetCell( row, col );
VECTOR2I topRight( cell->GetEndX(), cell->GetStartY() );
if( !cell->GetTextAngle().IsHorizontal() )
topRight = VECTOR2I( cell->GetStartX(), cell->GetEndY() );
if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
strokeLine( topRight, cell->GetEnd() );
}
@ -2123,6 +2129,9 @@ void SCH_PAINTER::draw( const SCH_TABLE* aTable, int aLayer, bool aDimmed )
SCH_TABLECELL* cell = aTable->GetCell( row, col );
VECTOR2I botLeft( cell->GetStartX(), cell->GetEndY() );
if( !cell->GetTextAngle().IsHorizontal() )
botLeft = VECTOR2I( cell->GetEndX(), cell->GetStartY() );
if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
strokeLine( botLeft, cell->GetEnd() );
}
@ -2132,16 +2141,28 @@ void SCH_PAINTER::draw( const SCH_TABLE* aTable, int aLayer, bool aDimmed )
if( aTable->GetBorderStroke().GetWidth() >= 0 )
{
SCH_TABLECELL* first = aTable->GetCell( 0, 0 );
setupStroke( aTable->GetBorderStroke() );
if( aTable->StrokeHeader() )
{
SCH_TABLECELL* cell = aTable->GetCell( 0, 0 );
strokeLine( VECTOR2I( pos.x, cell->GetEndY() ), VECTOR2I( end.x, cell->GetEndY() ) );
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() )
{
if( !first->GetTextAngle().IsHorizontal() )
{
RotatePoint( pos, aTable->GetPosition(), ANGLE_90 );
RotatePoint( end, aTable->GetPosition(), ANGLE_90 );
}
strokeRect( pos, end );
}
}
}

View File

@ -118,6 +118,20 @@ VECTOR2I SCH_TABLE::GetPosition() const
}
VECTOR2I SCH_TABLE::GetCenter() const
{
BOX2I bbox;
for( SCH_TABLECELL* cell : m_cells )
{
bbox.Merge( cell->GetPosition() );
bbox.Merge( cell->GetEnd() );
}
return bbox.GetCenter();
}
VECTOR2I SCH_TABLE::GetEnd() const
{
VECTOR2I tableSize;
@ -134,8 +148,6 @@ VECTOR2I SCH_TABLE::GetEnd() const
void SCH_TABLE::Normalize()
{
// JEY TODO: pukes on rotated tables...
int y = GetPosition().y;
for( int row = 0; row < GetRowCount(); ++row )
@ -150,13 +162,15 @@ void SCH_TABLE::Normalize()
SCH_TABLECELL* cell = GetCell( row, col );
VECTOR2I pos( x, y );
RotatePoint( pos, GetPosition(), cell->GetTextAngle() );
if( cell->GetPosition() != pos )
{
cell->SetPosition( pos );
cell->ClearRenderCache();
}
VECTOR2I end = cell->GetStart() + VECTOR2I( colWidth, rowHeight );
VECTOR2I end = VECTOR2I( x + colWidth, y + rowHeight );
if( cell->GetColSpan() > 1 || cell->GetRowSpan() > 1 )
{
@ -167,6 +181,8 @@ void SCH_TABLE::Normalize()
end.y += m_rowHeights[ii];
}
RotatePoint( end, GetPosition(), cell->GetTextAngle() );
if( cell->GetEnd() != end )
{
cell->SetEnd( end );

View File

@ -93,6 +93,7 @@ public:
void SetPosition( const VECTOR2I& aPos ) override;
VECTOR2I GetPosition() const override;
VECTOR2I GetEnd() const;
VECTOR2I GetCenter() const;
// For property manager:
void SetPositionX( int x ) { SetPosition( VECTOR2I( x, GetPosition().y ) ); }

View File

@ -354,8 +354,10 @@ private:
class SCH_TABLECELL_POINT_EDIT_BEHAVIOR : public EDA_TABLECELL_POINT_EDIT_BEHAVIOR
{
public:
SCH_TABLECELL_POINT_EDIT_BEHAVIOR( SCH_TABLECELL& aCell ) :
EDA_TABLECELL_POINT_EDIT_BEHAVIOR( aCell ), m_cell( aCell )
SCH_TABLECELL_POINT_EDIT_BEHAVIOR( SCH_TABLECELL& aCell, SCH_SCREEN& aScreen ) :
EDA_TABLECELL_POINT_EDIT_BEHAVIOR( aCell ),
m_cell( aCell ),
m_screen( aScreen )
{
}
@ -363,30 +365,60 @@ public:
std::vector<EDA_ITEM*>& aUpdatedItems ) override
{
SCH_TABLE& table = static_cast<SCH_TABLE&>( *m_cell.GetParent() );
aCommit.Modify( &table );
bool rotated = !m_cell.GetTextAngle().IsHorizontal();
aCommit.Modify( &table, &m_screen );
aUpdatedItems.push_back( &table );
if( isModified( aEditedPoint, aPoints.Point( COL_WIDTH ) ) )
if( rotated )
{
m_cell.SetEnd( VECTOR2I( aPoints.Point( 0 ).GetX(), m_cell.GetEndY() ) );
if( isModified( aEditedPoint, aPoints.Point( ROW_HEIGHT ) ) )
{
m_cell.SetEnd( VECTOR2I( m_cell.GetEndX(), aPoints.Point( ROW_HEIGHT ).GetY() ) );
int colWidth = m_cell.GetRectangleWidth();
int colWidth = std::abs( m_cell.GetRectangleHeight() );
for( int ii = 0; ii < m_cell.GetColSpan() - 1; ++ii )
colWidth -= table.GetColWidth( m_cell.GetColumn() + ii );
for( int ii = 0; ii < m_cell.GetColSpan() - 1; ++ii )
colWidth -= table.GetColWidth( m_cell.GetColumn() + ii );
table.SetColWidth( m_cell.GetColumn() + m_cell.GetColSpan() - 1, colWidth );
table.SetColWidth( m_cell.GetColumn() + m_cell.GetColSpan() - 1, colWidth );
}
else if( isModified( aEditedPoint, aPoints.Point( COL_WIDTH ) ) )
{
m_cell.SetEnd( VECTOR2I( aPoints.Point( COL_WIDTH ).GetX(), m_cell.GetEndY() ) );
int rowHeight = m_cell.GetRectangleWidth();
for( int ii = 0; ii < m_cell.GetRowSpan() - 1; ++ii )
rowHeight -= table.GetRowHeight( m_cell.GetRow() + ii );
table.SetRowHeight( m_cell.GetRow() + m_cell.GetRowSpan() - 1, rowHeight );
}
}
else if( isModified( aEditedPoint, aPoints.Point( ROW_HEIGHT ) ) )
else
{
m_cell.SetEnd( VECTOR2I( m_cell.GetEndX(), aPoints.Point( 1 ).GetY() ) );
if( isModified( aEditedPoint, aPoints.Point( COL_WIDTH ) ) )
{
m_cell.SetEnd( VECTOR2I( aPoints.Point( COL_WIDTH ).GetX(), m_cell.GetEndY() ) );
int rowHeight = m_cell.GetRectangleHeight();
int colWidth = m_cell.GetRectangleWidth();
for( int ii = 0; ii < m_cell.GetRowSpan() - 1; ++ii )
rowHeight -= table.GetRowHeight( m_cell.GetRow() + ii );
for( int ii = 0; ii < m_cell.GetColSpan() - 1; ++ii )
colWidth -= table.GetColWidth( m_cell.GetColumn() + ii );
table.SetRowHeight( m_cell.GetRow() + m_cell.GetRowSpan() - 1, rowHeight );
table.SetColWidth( m_cell.GetColumn() + m_cell.GetColSpan() - 1, colWidth );
}
else if( isModified( aEditedPoint, aPoints.Point( ROW_HEIGHT ) ) )
{
m_cell.SetEnd( VECTOR2I( m_cell.GetEndX(), aPoints.Point( ROW_HEIGHT ).GetY() ) );
int rowHeight = m_cell.GetRectangleHeight();
for( int ii = 0; ii < m_cell.GetRowSpan() - 1; ++ii )
rowHeight -= table.GetRowHeight( m_cell.GetRow() + ii );
table.SetRowHeight( m_cell.GetRow() + m_cell.GetRowSpan() - 1, rowHeight );
}
}
table.Normalize();
@ -394,6 +426,7 @@ public:
private:
SCH_TABLECELL& m_cell;
SCH_SCREEN& m_screen;
};
@ -902,7 +935,7 @@ void EE_POINT_EDITOR::makePointsAndBehavior( EDA_ITEM* aItem )
case SCH_TABLECELL_T:
{
SCH_TABLECELL* cell = static_cast<SCH_TABLECELL*>( aItem );
m_editBehavior = std::make_unique<SCH_TABLECELL_POINT_EDIT_BEHAVIOR>( *cell );
m_editBehavior = std::make_unique<SCH_TABLECELL_POINT_EDIT_BEHAVIOR>( *cell, *m_frame->GetScreen() );
break;
}
case SCH_SHEET_T:
@ -1082,8 +1115,8 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
bool snap = !evt->DisableGridSnapping();
cursorPos =
grid->Align( controls->GetMousePosition(), GRID_HELPER_GRIDS::GRID_GRAPHICS );
cursorPos = grid->Align( controls->GetMousePosition(),
GRID_HELPER_GRIDS::GRID_GRAPHICS );
controls->ForceCursorPosition( true, cursorPos );
m_editedPoint->SetPosition( controls->GetCursorPosition( snap ) );
@ -1167,9 +1200,8 @@ void EE_POINT_EDITOR::updateParentItem( bool aSnapToGrid, SCH_COMMIT& aCommit )
m_editBehavior->UpdateItem( *m_editedPoint, *m_editPoints, aCommit, updatedItems );
for( EDA_ITEM* updatedItem : updatedItems )
{
updateItem( updatedItem, true );
}
m_frame->SetMsgPanel( item );
}

View File

@ -873,10 +873,11 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
{
// Rotate the table on itself. Tables do not have an anchor point.
SCH_TABLE* table = static_cast<SCH_TABLE*>( head );
BOX2I box( table->GetPosition(), table->GetEnd() - table->GetPosition() );
rotPoint = m_frame->GetNearestHalfGridPosition( box.GetCenter() );
rotPoint = m_frame->GetNearestHalfGridPosition( table->GetCenter() );
head->Rotate( rotPoint, !clockwise );
table->Rotate( rotPoint, !clockwise );
table->Move( rotPoint - m_frame->GetNearestHalfGridPosition( table->GetCenter() ) );
break;
}
@ -967,6 +968,16 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
static_cast<SCH_ITEM*>( field->GetParent() )->ClearFieldsAutoplaced();
}
}
else if( item->Type() == SCH_TABLE_T )
{
SCH_TABLE* table = static_cast<SCH_TABLE*>( item );
VECTOR2I beforeCenter = table->GetCenter();
table->Rotate( rotPoint, !clockwise );
RotatePoint( beforeCenter, rotPoint, clockwise ? -ANGLE_90 : ANGLE_90 );
table->Move( beforeCenter - table->GetCenter() );
}
else
{
item->Rotate( rotPoint, !clockwise );

View File

@ -1101,16 +1101,14 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode, bool aSkipConnectivity
break;
}
// other types may use linked list
default:
{
wxString msg;
msg.Printf( wxT( "BOARD::Add() needs work: BOARD_ITEM type (%d) not handled" ),
aBoardItem->Type() );
wxFAIL_MSG( msg );
return;
}
case PCB_TABLECELL_T:
// Handled by parent table
break;
default:
wxFAIL_MSG( wxString::Format( wxT( "BOARD::Add() item type %s not handled" ),
aBoardItem->GetClass() ) );
return;
}
aBoardItem->SetParent( this );
@ -1120,9 +1118,7 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode, bool aSkipConnectivity
m_connectivity->Add( aBoardItem );
if( aMode != ADD_MODE::BULK_INSERT && aMode != ADD_MODE::BULK_APPEND )
{
InvokeListeners( &BOARD_LISTENER::OnBoardItemAdded, *this, aBoardItem );
}
}
@ -1225,9 +1221,14 @@ void BOARD::Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aRemoveMode )
break;
}
case PCB_TABLECELL_T:
// Handled by parent table
break;
// other types may use linked list
default:
wxFAIL_MSG( wxT( "BOARD::Remove() needs more ::Type() support" ) );
wxFAIL_MSG( wxString::Format( wxT( "BOARD::Remove() item type %s not handled" ),
aBoardItem->GetClass() ) );
}
aBoardItem->SetFlags( STRUCT_DELETED );

View File

@ -2103,17 +2103,6 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_TABLE* aTable ) const
if( aTable->IsLocked() )
KICAD_FORMAT::FormatBool( m_out, "locked", true );
EDA_ANGLE angle = aTable->GetOrientation();
if( FOOTPRINT* parentFP = aTable->GetParentFootprint() )
{
angle -= parentFP->GetOrientation();
angle.Normalize720();
}
if( !angle.IsZero() )
m_out->Print( "(angle %s)", EDA_UNIT_UTILS::FormatAngle( angle ).c_str() );
formatLayer( aTable->GetLayer() );
m_out->Print( "(border" );

View File

@ -3722,8 +3722,7 @@ PCB_TABLE* PCB_IO_KICAD_SEXPR_PARSER::parsePCB_TABLE( BOARD_ITEM* aParent )
NeedRIGHT();
break;
case T_angle:
table->SetOrientation( EDA_ANGLE( parseDouble( "table angle" ), DEGREES_T ) );
case T_angle: // legacy token no longer used
NeedRIGHT();
break;
@ -3854,9 +3853,6 @@ PCB_TABLE* PCB_IO_KICAD_SEXPR_PARSER::parsePCB_TABLE( BOARD_ITEM* aParent )
}
}
if( FOOTPRINT* parentFP = table->GetParentFootprint() )
table->SetOrientation( table->GetOrientation() + parentFP->GetOrientation() );
return table.release();
}

View File

@ -2435,12 +2435,14 @@ void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer )
void PCB_PAINTER::draw( const PCB_TABLE* aTable, int aLayer )
{
if( aTable->GetCells().empty() )
return;
for( PCB_TABLECELL* cell : aTable->GetCells() )
draw( static_cast<PCB_TEXTBOX*>( cell ), aLayer );
VECTOR2I pos = aTable->GetPosition();
VECTOR2I end = aTable->GetEnd();
EDA_ANGLE drawOrientation = aTable->GetOrientation();
// Selection for tables is done with a background wash, so pass in nullptr to GetColor()
// so we just get the "normal" (un-selected/un-brightened) color for the borders.
@ -2466,9 +2468,6 @@ void PCB_PAINTER::draw( const PCB_TABLE* aTable, int aLayer )
STROKE_PARAMS::Stroke( &shape, lineStyle, lineWidth, &m_pcbSettings,
[&]( VECTOR2I a, VECTOR2I b )
{
RotatePoint( a, pos, drawOrientation );
RotatePoint( b, pos, drawOrientation );
// DrawLine has problem with 0 length lines so enforce minimum
if( a == b )
m_gal->DrawLine( a+1, b );
@ -2480,9 +2479,6 @@ void PCB_PAINTER::draw( const PCB_TABLE* aTable, int aLayer )
auto strokeLine =
[&]( VECTOR2I ptA, VECTOR2I ptB )
{
RotatePoint( ptA, pos, drawOrientation );
RotatePoint( ptB, pos, drawOrientation );
if( lineStyle <= LINE_STYLE::FIRST_TYPE )
{
m_gal->DrawLine( ptA, ptB );
@ -2497,9 +2493,6 @@ void PCB_PAINTER::draw( const PCB_TABLE* aTable, int aLayer )
auto strokeRect =
[&]( VECTOR2I ptA, VECTOR2I ptB )
{
RotatePoint( ptA, pos, drawOrientation );
RotatePoint( ptB, pos, drawOrientation );
if( lineStyle <= LINE_STYLE::FIRST_TYPE )
{
m_gal->DrawRectangle( ptA, ptB );
@ -2524,6 +2517,9 @@ void PCB_PAINTER::draw( const PCB_TABLE* aTable, int aLayer )
PCB_TABLECELL* cell = aTable->GetCell( row, col );
VECTOR2I topRight( cell->GetEndX(), cell->GetStartY() );
if( !cell->GetTextAngle().IsHorizontal() )
topRight = VECTOR2I( cell->GetStartX(), cell->GetEndY() );
if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
strokeLine( topRight, cell->GetEnd() );
}
@ -2539,6 +2535,9 @@ void PCB_PAINTER::draw( const PCB_TABLE* aTable, int aLayer )
PCB_TABLECELL* cell = aTable->GetCell( row, col );
VECTOR2I botLeft( cell->GetStartX(), cell->GetEndY() );
if( !cell->GetTextAngle().IsHorizontal() )
botLeft = VECTOR2I( cell->GetEndX(), cell->GetStartY() );
if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
strokeLine( botLeft, cell->GetEnd() );
}
@ -2548,17 +2547,25 @@ 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() )
{
int headerBottom = pos.y + aTable->GetRowHeight( 0 );
strokeLine( VECTOR2I( pos.x, headerBottom ), VECTOR2I( end.x, headerBottom ) );
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 );
}
}
// Highlight selected tablecells with a background wash.

View File

@ -53,7 +53,6 @@ PCB_TABLE::PCB_TABLE( const PCB_TABLE& aTable ) :
m_strokeColumns = aTable.m_strokeColumns;
m_separatorsStroke = aTable.m_separatorsStroke;
m_orientation = aTable.m_orientation;
m_colCount = aTable.m_colCount;
m_colWidths = aTable.m_colWidths;
m_rowHeights = aTable.m_rowHeights;
@ -88,7 +87,6 @@ void PCB_TABLE::swapData( BOARD_ITEM* aImage )
std::swap( m_strokeColumns, table->m_strokeColumns );
std::swap( m_separatorsStroke, table->m_separatorsStroke );
std::swap( m_orientation, table->m_orientation );
std::swap( m_colCount, table->m_colCount );
std::swap( m_colWidths, table->m_colWidths );
std::swap( m_rowHeights, table->m_rowHeights );
@ -131,37 +129,11 @@ VECTOR2I PCB_TABLE::GetEnd() const
void PCB_TABLE::Normalize()
{
VECTOR2I origin = GetPosition();
auto setCellStart =
[&]( PCB_TABLECELL* cell, VECTOR2I pt )
{
RotatePoint( pt, origin, m_orientation );
if( cell->GetPosition() != pt )
{
cell->SetPosition( pt );
cell->ClearRenderCache();
}
};
auto setCellEnd =
[&]( PCB_TABLECELL* cell, VECTOR2I pt )
{
RotatePoint( pt, origin, m_orientation );
if( cell->GetEnd() != pt )
{
cell->SetEnd( pt );
cell->ClearRenderCache();
}
};
int y = origin.y;
int y = GetPosition().y;
for( int row = 0; row < GetRowCount(); ++row )
{
int x = origin.x;
int x = GetPosition().x;
int rowHeight = m_rowHeights[ row ];
for( int col = 0; col < GetColCount(); ++col )
@ -171,9 +143,15 @@ void PCB_TABLE::Normalize()
PCB_TABLECELL* cell = GetCell( row, col );
VECTOR2I pos( x, y );
setCellStart( cell, pos );
RotatePoint( pos, GetPosition(), cell->GetTextAngle() );
VECTOR2I end = pos + VECTOR2I( colWidth, rowHeight );
if( cell->GetPosition() != pos )
{
cell->SetPosition( pos );
cell->ClearRenderCache();
}
VECTOR2I end = VECTOR2I( x + colWidth, y + rowHeight );
if( cell->GetColSpan() > 1 || cell->GetRowSpan() > 1 )
{
@ -184,7 +162,14 @@ void PCB_TABLE::Normalize()
end.y += m_rowHeights[ii];
}
setCellEnd( cell, end );
RotatePoint( end, GetPosition(), cell->GetTextAngle() );
if( cell->GetEnd() != end )
{
cell->SetEnd( end );
cell->ClearRenderCache();
}
x += colWidth;
}
@ -202,11 +187,17 @@ void PCB_TABLE::Move( const VECTOR2I& aMoveVector )
void PCB_TABLE::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
{
m_orientation = ( m_orientation + aAngle ).Normalized();
if( GetCells().empty() )
return;
bool translate = GetCell( 0, 0 )->GetTextAngle() + aAngle == ANGLE_180;
for( PCB_TABLECELL* cell : m_cells )
cell->Rotate( aRotCentre, aAngle );
if( translate )
Move( GetPosition() - GetEnd() );
Normalize();
}
@ -472,9 +463,6 @@ bool PCB_TABLE::operator==( const PCB_TABLE& aOther ) const
if( m_separatorsStroke != aOther.m_separatorsStroke )
return false;
if( m_orientation != aOther.m_orientation )
return false;
if( m_colWidths != aOther.m_colWidths )
return false;
@ -521,9 +509,6 @@ double PCB_TABLE::Similarity( const BOARD_ITEM& aOther ) const
if( m_separatorsStroke != other.m_separatorsStroke )
similarity *= 0.9;
if( m_orientation != other.m_orientation )
similarity *= 0.9;
if( m_colWidths != other.m_colWidths )
similarity *= 0.9;
@ -568,10 +553,6 @@ static struct PCB_TABLE_DESC
&PCB_TABLE::SetPositionY, &PCB_TABLE::GetPositionY, PROPERTY_DISPLAY::PT_COORD,
ORIGIN_TRANSFORMS::ABS_Y_COORD ) );
propMgr.AddProperty( new PROPERTY<PCB_TABLE, EDA_ANGLE>( _HKI( "Orientation" ),
&PCB_TABLE::SetOrientation, &PCB_TABLE::GetOrientation,
PROPERTY_DISPLAY::PT_DEGREE ) );
const wxString tableProps = _( "Table Properties" );
propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "External Border" ),

View File

@ -97,9 +97,6 @@ public:
int GetPositionX() const { return GetPosition().x; }
int GetPositionY() const { return GetPosition().y; }
void SetOrientation( const EDA_ANGLE& aAngle ) { m_orientation = aAngle; }
EDA_ANGLE GetOrientation() const { return m_orientation; }
void SetColCount( int aCount ) { m_colCount = aCount; }
int GetColCount() const { return m_colCount; }
@ -249,7 +246,6 @@ protected:
bool m_strokeColumns;
STROKE_PARAMS m_separatorsStroke;
EDA_ANGLE m_orientation;
int m_colCount;
std::map<int, int> m_colWidths;
std::map<int, int> m_rowHeights;

View File

@ -515,7 +515,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 ).Normalized() );
EDA_TEXT::SetTextAngle( ( GetTextAngle() + aAngle ).Normalize90() );
if( GetTextAngle().IsCardinal() && GetShape() != SHAPE_T::RECTANGLE )
{
@ -556,10 +556,7 @@ void PCB_TEXTBOX::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
{
PCB_SHAPE::Flip( aCentre, aFlipDirection );
if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
EDA_TEXT::SetTextAngle( -GetTextAngle() );
else
EDA_TEXT::SetTextAngle( ANGLE_180 - GetTextAngle() );
EDA_TEXT::SetTextAngle( -GetTextAngle() );
if( IsSideSpecific() )
SetMirrored( !IsMirrored() );

View File

@ -964,27 +964,55 @@ public:
aCommit.Modify( &table );
aUpdatedItems.push_back( &table );
if( isModified( aEditedPoint, aPoints.Point( COL_WIDTH ) ) )
if( !m_cell.GetTextAngle().IsHorizontal() )
{
m_cell.SetEnd( VECTOR2I( aPoints.Point( 0 ).GetX(), m_cell.GetEndY() ) );
if( isModified( aEditedPoint, aPoints.Point( ROW_HEIGHT ) ) )
{
m_cell.SetEnd( VECTOR2I( m_cell.GetEndX(), aPoints.Point( ROW_HEIGHT ).GetY() ) );
int colWidth = m_cell.GetRectangleWidth();
int colWidth = std::abs( m_cell.GetRectangleHeight() );
for( int ii = 0; ii < m_cell.GetColSpan() - 1; ++ii )
colWidth -= table.GetColWidth( m_cell.GetColumn() + ii );
for( int ii = 0; ii < m_cell.GetColSpan() - 1; ++ii )
colWidth -= table.GetColWidth( m_cell.GetColumn() + ii );
table.SetColWidth( m_cell.GetColumn() + m_cell.GetColSpan() - 1, colWidth );
table.SetColWidth( m_cell.GetColumn() + m_cell.GetColSpan() - 1, colWidth );
}
else if( isModified( aEditedPoint, aPoints.Point( COL_WIDTH ) ) )
{
m_cell.SetEnd( VECTOR2I( aPoints.Point( COL_WIDTH ).GetX(), m_cell.GetEndY() ) );
int rowHeight = m_cell.GetRectangleWidth();
for( int ii = 0; ii < m_cell.GetRowSpan() - 1; ++ii )
rowHeight -= table.GetRowHeight( m_cell.GetRow() + ii );
table.SetRowHeight( m_cell.GetRow() + m_cell.GetRowSpan() - 1, rowHeight );
}
}
else if( isModified( aEditedPoint, aPoints.Point( ROW_HEIGHT ) ) )
else
{
m_cell.SetEnd( VECTOR2I( m_cell.GetEndX(), aPoints.Point( 1 ).GetY() ) );
if( isModified( aEditedPoint, aPoints.Point( COL_WIDTH ) ) )
{
m_cell.SetEnd( VECTOR2I( aPoints.Point( COL_WIDTH ).GetX(), m_cell.GetEndY() ) );
int rowHeight = m_cell.GetRectangleHeight();
int colWidth = m_cell.GetRectangleWidth();
for( int ii = 0; ii < m_cell.GetRowSpan() - 1; ++ii )
rowHeight -= table.GetRowHeight( m_cell.GetRow() + ii );
for( int ii = 0; ii < m_cell.GetColSpan() - 1; ++ii )
colWidth -= table.GetColWidth( m_cell.GetColumn() + ii );
table.SetRowHeight( m_cell.GetRow() + m_cell.GetRowSpan() - 1, rowHeight );
table.SetColWidth( m_cell.GetColumn() + m_cell.GetColSpan() - 1, colWidth );
}
else if( isModified( aEditedPoint, aPoints.Point( ROW_HEIGHT ) ) )
{
m_cell.SetEnd( VECTOR2I( m_cell.GetEndX(), aPoints.Point( ROW_HEIGHT ).GetY() ) );
int rowHeight = m_cell.GetRectangleHeight();
for( int ii = 0; ii < m_cell.GetRowSpan() - 1; ++ii )
rowHeight -= table.GetRowHeight( m_cell.GetRow() + ii );
table.SetRowHeight( m_cell.GetRow() + m_cell.GetRowSpan() - 1, rowHeight );
}
}
table.Normalize();