KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_table.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <pcb_edit_frame.h>
21#include <footprint.h>
22#include <pcb_table.h>
23#include <board.h>
30#include <pcb_painter.h> // for PCB_RENDER_SETTINGS
31#include <view/view.h>
32#include <properties/property.h>
34#include <api/api_enums.h>
35#include <api/api_utils.h>
36#include <api/api_pcb_utils.h>
37#include <api/board/board_types.pb.h>
38#include <board_commit.h>
39#include <eda_group.h>
40
41
42PCB_TABLE::PCB_TABLE( BOARD_ITEM* aParent, KICAD_T aType, int aLineWidth ) :
43 BOARD_ITEM_CONTAINER( aParent, aType ),
44 m_strokeExternal( true ),
47 m_strokeRows( true ),
48 m_strokeColumns( true ),
50 m_colCount( 0 )
51{
52}
53
54
55PCB_TABLE::PCB_TABLE( BOARD_ITEM* aParent, int aLineWidth ) :
56 PCB_TABLE( aParent, PCB_TABLE_T, aLineWidth )
57{
58}
59
60
62 PCB_TABLE( aParent, pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ) )
63{
64}
65
66
84
85
87{
88 // We own our cells; delete them
89 for( PCB_TABLECELL* cell : m_cells )
90 delete cell;
91}
92
93
94void PCB_TABLE::CopyFrom( const BOARD_ITEM* aOther )
95{
96 wxCHECK( aOther && aOther->Type() == PCB_TABLE_T, /* void */ );
97
98 const PCB_TABLE* other = static_cast<const PCB_TABLE*>( aOther );
99
100 BOARD_ITEM::CopyFrom( aOther );
101
105 m_strokeRows = other->m_strokeRows;
108
109 m_colCount = other->m_colCount;
110 m_colWidths = other->m_colWidths;
111 m_rowHeights = other->m_rowHeights;
112
113 ClearCells();
114
115 for( PCB_TABLECELL* cell : other->m_cells )
116 AddCell( static_cast<PCB_TABLECELL*>( cell->Clone() ) );
117}
118
119
120BOARD_ITEM* PCB_TABLE::Duplicate( bool addToParentGroup, BOARD_COMMIT* aCommit ) const
121{
122 BOARD_ITEM* dupe = static_cast<BOARD_ITEM*>( Clone() );
123 dupe->ResetUuid();
124
125 dupe->RunOnChildren( []( BOARD_ITEM* aChild )
126 {
127 aChild->ResetUuid();
128 },
130
131 if( addToParentGroup )
132 {
133 wxCHECK_MSG( aCommit, dupe, "Must supply a commit to update parent group" );
134
135 if( EDA_GROUP* group = dupe->GetParentGroup() )
136 {
137 aCommit->Modify( group->AsEdaItem(), nullptr, RECURSE_MODE::NO_RECURSE );
138 group->AddItem( dupe );
139 }
140 }
141
142 return dupe;
143}
144
145
146void PCB_TABLE::Serialize( google::protobuf::Any& aContainer ) const
147{
148 using namespace kiapi::board;
149 types::Table table;
150
151 table.mutable_id()->set_value( m_Uuid.AsStdString() );
153 table.set_locked( IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
154 : kiapi::common::types::LockedState::LS_UNLOCKED );
155
156 table.set_column_count( m_colCount );
157
158 for( int col = 0; col < m_colCount; ++col )
159 table.add_column_widths( GetColWidth( col ) );
160
161 for( int row = 0; row < GetRowCount(); ++row )
162 table.add_row_heights( GetRowHeight( row ) );
163
164 for( const PCB_TABLECELL* cell : m_cells )
165 cell->Serialize( *table.add_cells() );
166
167 table.set_external_border( m_strokeExternal ? types::TSM_ENABLED : types::TSM_DISABLED );
168 table.set_header_separator( m_StrokeHeaderSeparator ? types::TSM_ENABLED : types::TSM_DISABLED );
169 kiapi::common::PackStroke( *table.mutable_border_stroke(), m_borderStroke );
170
171 table.set_row_separators( m_strokeRows ? types::TSM_ENABLED : types::TSM_DISABLED );
172 table.set_column_separators( m_strokeColumns ? types::TSM_ENABLED : types::TSM_DISABLED );
173 kiapi::common::PackStroke( *table.mutable_separators_stroke(), m_separatorsStroke );
174
175 if( FOOTPRINT* parent = GetParentFootprint() )
176 table.mutable_parent()->set_value( parent->m_Uuid.AsStdString() );
177 else if( const BOARD* board = GetBoard() )
178 table.mutable_parent()->set_value( board->m_Uuid.AsStdString() );
179
180 kiapi::common::PackCustomProperties( table.mutable_custom_properties(), *this );
181 aContainer.PackFrom( table );
182}
183
184
185bool PCB_TABLE::Deserialize( const google::protobuf::Any& aContainer )
186{
187 using namespace kiapi::board;
188 types::Table table;
189
190 if( !aContainer.UnpackTo( &table ) )
191 return false;
192
193 if( table.column_count() < 1 )
194 return false;
195
196 SetUuidDirect( KIID( table.id().value() ) );
198 SetLocked( table.locked() == kiapi::common::types::LockedState::LS_LOCKED );
199 kiapi::common::UnpackCustomProperties( table.custom_properties(), *this );
200
201 ClearCells();
202 m_colWidths.clear();
203 m_rowHeights.clear();
204
205 SetColCount( table.column_count() );
206
207 for( int i = 0; i < table.column_widths_size() && i < table.column_count(); ++i )
208 SetColWidth( i, table.column_widths( i ) );
209
210 for( const types::TableCell& protoCell : table.cells() )
211 {
212 PCB_TABLECELL* cell = new PCB_TABLECELL( this );
213
214 if( !cell->Deserialize( protoCell ) )
215 {
216 // Since cells are positional, we must add something to the table. Probably better
217 // to add a new, empy cell than a partially deserialized who-knows-what.
218 delete cell;
219 cell = new PCB_TABLECELL( this );
220 }
221
222 AddCell( cell );
223 }
224
225 int rowCount = m_colCount > 0 ? static_cast<int>( m_cells.size() ) / m_colCount : 0;
226
227 for( int i = 0; i < table.row_heights_size() && i < rowCount; ++i )
228 SetRowHeight( i, table.row_heights( i ) );
229
230 m_strokeExternal = table.external_border() == types::TSM_ENABLED;
231 m_StrokeHeaderSeparator = table.header_separator() == types::TSM_ENABLED;
232
233 if( table.has_border_stroke() )
235
236 m_strokeRows = table.row_separators() == types::TSM_ENABLED;
237 m_strokeColumns = table.column_separators() == types::TSM_ENABLED;
238
239 if( table.has_separators_stroke() )
241
242 return true;
243}
244
245
247{
248 wxCHECK_RET( aImage != nullptr && aImage->Type() == Type(), wxT( "Cannot swap data with invalid table." ) );
249
250 PCB_TABLE* table = static_cast<PCB_TABLE*>( aImage );
251
252 std::swap( m_layer, table->m_layer );
253 std::swap( m_isLocked, table->m_isLocked );
254
255 std::swap( m_strokeExternal, table->m_strokeExternal );
256 std::swap( m_StrokeHeaderSeparator, table->m_StrokeHeaderSeparator );
257 std::swap( m_borderStroke, table->m_borderStroke );
258 std::swap( m_strokeRows, table->m_strokeRows );
259 std::swap( m_strokeColumns, table->m_strokeColumns );
260 std::swap( m_separatorsStroke, table->m_separatorsStroke );
261
262 std::swap( m_colCount, table->m_colCount );
263 std::swap( m_colWidths, table->m_colWidths );
264 std::swap( m_rowHeights, table->m_rowHeights );
265
266 std::swap( m_cells, table->m_cells );
267
268 for( PCB_TABLECELL* cell : m_cells )
269 cell->SetParent( this );
270
271 for( PCB_TABLECELL* cell : table->m_cells )
272 cell->SetParent( table );
273
274 std::swap( m_customProperties, table->m_customProperties );
275}
276
277
278void PCB_TABLE::ResizeCells( int aRows, int aCols )
279{
280 const size_t wanted = static_cast<size_t>( aRows ) * static_cast<size_t>( aCols );
281
282 m_colCount = aCols;
283
284 while( m_cells.size() > wanted )
285 {
286 delete m_cells.back();
287 m_cells.pop_back();
288 }
289
290 while( m_cells.size() < wanted )
291 AddCell( new PCB_TABLECELL( this ) );
292}
293
294
296{
297 m_layer = aLayer;
298
299 for( PCB_TABLECELL* cell : m_cells )
300 cell->SetLayer( aLayer );
301}
302
303
305{
306 Move( aPos - GetPosition() );
307}
308
309
311{
312 if( m_cells.empty() )
313 return VECTOR2I( 0, 0 ); // Return origin if table has no cells
314
315 return m_cells[0]->GetPosition();
316}
317
318
320{
321 VECTOR2I tableSize;
322
323 for( int ii = 0; ii < GetColCount(); ++ii )
324 tableSize.x += GetColWidth( ii );
325
326 for( int ii = 0; ii < GetRowCount(); ++ii )
327 tableSize.y += GetRowHeight( ii );
328
329 return GetPosition() + tableSize;
330}
331
332
334{
335 if( m_cells.empty() )
336 return;
337
338 EDA_ANGLE cellAngle = m_cells[0]->GetTextAngle();
339
340 BOX2I cell0BBox = m_cells[0]->GetBoundingBox();
341 VECTOR2I stableCenter = cell0BBox.GetCenter();
342
343 int cell0Width = m_colWidths[0];
344 int cell0Height = m_rowHeights[0];
345
346 if( m_cells[0]->GetColSpan() > 1 )
347 {
348 for( int ii = 1; ii < m_cells[0]->GetColSpan(); ++ii )
349 cell0Width += m_colWidths[ii];
350 }
351
352 if( m_cells[0]->GetRowSpan() > 1 )
353 {
354 for( int ii = 1; ii < m_cells[0]->GetRowSpan(); ++ii )
355 cell0Height += m_rowHeights[ii];
356 }
357
358 VECTOR2I localCell0Center( cell0Width / 2, cell0Height / 2 );
359 RotatePoint( localCell0Center, cellAngle );
360
361 if( cellAngle != ANGLE_0 )
362 {
363 for( PCB_TABLECELL* cell : m_cells )
364 cell->Rotate( stableCenter, -cellAngle );
365 }
366
367 VECTOR2I unrotatedOrigin = stableCenter - VECTOR2I( cell0Width / 2, cell0Height / 2 );
368
369 int y = unrotatedOrigin.y;
370
371 for( int row = 0; row < GetRowCount(); ++row )
372 {
373 int x = unrotatedOrigin.x;
374 int rowHeight = m_rowHeights[row];
375
376 for( int col = 0; col < GetColCount(); ++col )
377 {
378 int colWidth = m_colWidths[col];
379
380 PCB_TABLECELL* cell = GetCell( row, col );
381
382 if( !cell )
383 continue;
384
385 int cellWidth = colWidth;
386 int cellHeight = rowHeight;
387
388 if( cell->GetColSpan() > 1 || cell->GetRowSpan() > 1 )
389 {
390 for( int ii = col + 1; ii < col + cell->GetColSpan(); ++ii )
391 cellWidth += m_colWidths[ii];
392
393 for( int ii = row + 1; ii < row + cell->GetRowSpan(); ++ii )
394 cellHeight += m_rowHeights[ii];
395 }
396
397 VECTOR2I pos( x, y );
398 VECTOR2I end( x + cellWidth, y + cellHeight );
399
400 if( cell->GetPosition() != pos )
401 {
402 cell->SetPosition( pos );
403 cell->ClearRenderCache();
404 }
405
406 if( cell->GetEnd() != end )
407 {
408 cell->SetEnd( end );
409 cell->ClearRenderCache();
410 }
411
412 x += colWidth;
413 }
414
415 y += rowHeight;
416 }
417
418 if( cellAngle != ANGLE_0 )
419 {
420 for( PCB_TABLECELL* cell : m_cells )
421 cell->Rotate( stableCenter, cellAngle );
422 }
423
424 BOX2I newCell0BBox = m_cells[0]->GetBoundingBox();
425 VECTOR2I newCenter = newCell0BBox.GetCenter();
426
427 if( newCenter != stableCenter )
428 {
429 VECTOR2I correction = stableCenter - newCenter;
430
431 for( PCB_TABLECELL* cell : m_cells )
432 cell->Move( correction );
433 }
434}
435
436
438{
439 std::vector<std::vector<BOX2I>> extents;
440
441 for( int row = 0; row < GetRowCount(); ++row )
442 {
443 extents.push_back( std::vector<BOX2I>() );
444
445 for( int col = 0; col < GetColCount(); ++col )
446 {
447 SHAPE_POLY_SET textPoly;
448 GetCell( row, col )->TransformTextToPolySet( textPoly, 0, ARC_LOW_DEF, ERROR_INSIDE );
449 extents[row].push_back( textPoly.BBox() );
450 }
451 }
452
453 for( int col = 0; col < GetColCount(); ++col )
454 {
455 int colWidth = 0;
456
457 for( int row = 0; row < GetRowCount(); ++row )
458 {
459 PCB_TABLECELL* cell = GetCell( row, col );
460 int margins = cell->GetMarginLeft() + cell->GetMarginRight();
461 colWidth = std::max<int>( colWidth, extents[row][col].GetWidth() + ( margins * 1.5 ) );
462 }
463
464 SetColWidth( col, colWidth );
465 }
466
467 for( int row = 0; row < GetRowCount(); ++row )
468 {
469 int rowHeight = 0;
470
471 for( int col = 0; col < GetColCount(); ++col )
472 {
473 PCB_TABLECELL* cell = GetCell( row, col );
474 int margins = cell->GetMarginLeft() + cell->GetMarginRight();
475 rowHeight = std::max( rowHeight, (int) extents[row][col].GetHeight() + margins );
476 }
477
478 SetRowHeight( row, rowHeight );
479 }
480
481 Normalize();
482}
483
484
485void PCB_TABLE::Move( const VECTOR2I& aMoveVector )
486{
487 for( PCB_TABLECELL* cell : m_cells )
488 cell->Move( aMoveVector );
489}
490
491
492void PCB_TABLE::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
493{
494 if( GetCells().empty() )
495 return;
496
497 for( PCB_TABLECELL* cell : m_cells )
498 cell->Rotate( aRotCentre, aAngle );
499
500 Normalize();
501}
502
503
505{
506 for( PCB_TABLECELL* cell : m_cells )
507 cell->OnFootprintTransformed();
508}
509
510
511void PCB_TABLE::OnFootprintRescaled( double aRatioX, double aRatioY, double aLinearFactor, const VECTOR2I& aAnchor,
512 const EDA_ANGLE& aParentRotate )
513{
514 for( PCB_TABLECELL* cell : m_cells )
515 cell->OnFootprintRescaled( aRatioX, aRatioY, aLinearFactor, aAnchor, aParentRotate );
516}
517
518
519void PCB_TABLE::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
520{
521 // FP-child path keeps cells in lib frame, the standalone path below
522 // would corrupt them because FOOTPRINT::Flip zeroes the FP rotation.
523 if( GetParentFootprint() )
524 {
525 for( PCB_TABLECELL* cell : m_cells )
526 cell->Flip( aCentre, aFlipDirection );
527
528 // Flipping a cell also turns its text 180 degrees, so in the frame the table reads in
529 // it always comes out mirrored left to right.
530 std::vector<PCB_TABLECELL*> oldCells = m_cells;
531 int rowOffset = 0;
532
533 for( int row = 0; row < GetRowCount(); ++row )
534 {
535 for( int col = 0; col < GetColCount(); ++col )
536 m_cells[rowOffset + col] = oldCells[rowOffset + GetColCount() - 1 - col];
537
538 rowOffset += GetColCount();
539 }
540
541 std::map<int, int> newColWidths;
542
543 for( int col = 0; col < GetColCount(); ++col )
544 newColWidths[col] = m_colWidths[GetColCount() - 1 - col];
545
546 m_colWidths = std::move( newColWidths );
547
549 return;
550 }
551
552 BOX2I originalBBox = GetBoundingBox();
553
554 VECTOR2I targetPos;
555
556 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
557 {
558 targetPos.x = 2 * aCentre.x - originalBBox.GetRight();
559 targetPos.y = originalBBox.GetTop();
560 }
561 else
562 {
563 targetPos.x = originalBBox.GetLeft();
564 targetPos.y = 2 * aCentre.y - originalBBox.GetBottom();
565 }
566
567 EDA_ANGLE originalAngle = m_cells[0]->GetTextAngle();
568
569 if( originalAngle != ANGLE_0 )
570 Rotate( GetPosition(), -originalAngle );
571
572 VECTOR2I tableOrigin = GetPosition();
573
574 for( PCB_TABLECELL* cell : m_cells )
575 cell->Flip( tableOrigin, aFlipDirection );
576
577 // Flipping a cell turns its text 180 degrees and the grid is laid out in the frame the
578 // cells read in, so that turn reverses the rows already. Only the columns are left.
579 std::vector<PCB_TABLECELL*> oldCells = m_cells;
580 int rowOffset = 0;
581
582 for( int row = 0; row < GetRowCount(); ++row )
583 {
584 for( int col = 0; col < GetColCount(); ++col )
585 m_cells[rowOffset + col] = oldCells[rowOffset + GetColCount() - 1 - col];
586
587 rowOffset += GetColCount();
588 }
589
590 std::map<int, int> newColWidths;
591
592 for( int col = 0; col < GetColCount(); ++col )
593 newColWidths[col] = m_colWidths[GetColCount() - 1 - col];
594
595 m_colWidths = std::move( newColWidths );
596
598 Normalize();
599
600 if( originalAngle != ANGLE_0 )
601 Rotate( GetPosition(), -originalAngle );
602
603 BOX2I newBBox = GetBoundingBox();
604 Move( targetPos - newBBox.GetPosition() );
605}
606
607
608void PCB_TABLE::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
609{
610 // Mirror is Flip with the layer restored. TOP_BOTTOM needs a 180 deg pre-rotation
611 // because rotate-then-LR-flip equals TB-flip.
612 PCB_LAYER_ID origLayer = GetLayer();
613 std::vector<PCB_LAYER_ID> origCellLayers;
614 std::vector<bool> origMirrorSettings;
615
616 origCellLayers.reserve( m_cells.size() );
617 origMirrorSettings.reserve( m_cells.size() );
618
619 for( PCB_TABLECELL* cell : m_cells )
620 {
621 origCellLayers.push_back( cell->GetLayer() );
622 origMirrorSettings.push_back( cell->IsMirrored() );
623 }
624
625 if( aFlipDirection == FLIP_DIRECTION::TOP_BOTTOM )
626 Rotate( aCentre, ANGLE_180 );
627
629
630 SetLayer( origLayer );
631
632 for( size_t i = 0; i < m_cells.size(); ++i )
633 {
634 m_cells[i]->SetLayer( origCellLayers[i] );
635 m_cells[i]->SetMirrored( origMirrorSettings[i] );
636 }
637}
638
639
640void PCB_TABLE::RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const
641{
642 for( PCB_TABLECELL* cell : m_cells )
643 {
644 aFunction( cell );
645
646 if( aMode == RECURSE_MODE::RECURSE )
647 cell->RunOnChildren( aFunction, aMode );
648 }
649}
650
651
653{
654 BOX2I bbox;
655
656 for( PCB_TABLECELL* cell : m_cells )
657 bbox.Merge( cell->GetBoundingBox() );
658
659 if( m_strokeExternal )
660 bbox.Inflate( m_borderStroke.GetWidth() / 2 );
661
662 return bbox;
663}
664
665
666double PCB_TABLE::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
667{
668 // Hide the locked shadow when the table's own layer is not shown
669 if( aLayer == LAYER_LOCKED_ITEM_SHADOW && !aView->IsLayerVisibleCached( m_layer ) )
670 return LOD_HIDE;
671
672 return LOD_SHOW;
673}
674
675
676void PCB_TABLE::DrawBorders( const std::function<void( const VECTOR2I& aPt1, const VECTOR2I& aPt2,
677 const STROKE_PARAMS& aStroke )>& aCallback ) const
678{
679 if( m_cells.empty() ) // Shouldn't be possible....
680 return;
681
682 EDA_ANGLE drawAngle = GetCell( 0, 0 )->GetDrawRotation();
683 std::vector<VECTOR2I> topLeft = GetCell( 0, 0 )->GetCornersInSequence( drawAngle );
684 std::vector<VECTOR2I> bottomLeft = GetCell( GetRowCount() - 1, 0 )->GetCornersInSequence( drawAngle );
685 std::vector<VECTOR2I> topRight = GetCell( 0, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
686 std::vector<VECTOR2I> botRight = GetCell( GetRowCount() - 1, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
687 STROKE_PARAMS stroke;
688
689 for( int col = 0; col < GetColCount() - 1; ++col )
690 {
691 for( int row = 0; row < GetRowCount(); ++row )
692 {
693 if( row == 0 && StrokeHeaderSeparator() )
694 stroke = GetBorderStroke();
695 else if( StrokeColumns() )
696 stroke = GetSeparatorsStroke();
697 else
698 continue;
699
700 PCB_TABLECELL* cell = GetCell( row, col );
701
702 if( cell->GetColSpan() == 0 )
703 continue;
704
705 if( col + cell->GetColSpan() == GetColCount() )
706 continue;
707
708 std::vector<VECTOR2I> corners = cell->GetCornersInSequence( drawAngle );
709
710 if( corners.size() == 4 )
711 aCallback( corners[1], corners[2], stroke );
712 }
713 }
714
715 for( int row = 0; row < GetRowCount() - 1; ++row )
716 {
717 if( row == 0 && StrokeHeaderSeparator() )
718 stroke = GetBorderStroke();
719 else if( StrokeRows() )
720 stroke = GetSeparatorsStroke();
721 else
722 continue;
723
724 for( int col = 0; col < GetColCount(); ++col )
725 {
726 PCB_TABLECELL* cell = GetCell( row, col );
727
728 if( cell->GetRowSpan() == 0 )
729 continue;
730
731 if( row + cell->GetRowSpan() == GetRowCount() )
732 continue;
733
734 std::vector<VECTOR2I> corners = cell->GetCornersInSequence( drawAngle );
735
736 if( corners.size() == 4 )
737 aCallback( corners[2], corners[3], stroke );
738 }
739 }
740
741 if( StrokeExternal() && GetBorderStroke().GetWidth() >= 0 )
742 {
743 aCallback( topLeft[0], topRight[1], GetBorderStroke() );
744 aCallback( topRight[1], botRight[2], GetBorderStroke() );
745 aCallback( botRight[2], bottomLeft[3], GetBorderStroke() );
746 aCallback( bottomLeft[3], topLeft[0], GetBorderStroke() );
747 }
748}
749
750
752{
753 EDA_ANGLE angle = GetCell( 0, 0 )->GetDrawRotation();
754 std::vector<VECTOR2I> topLeft = GetCell( 0, 0 )->GetCornersInSequence( angle );
755 std::vector<VECTOR2I> bottomLeft = GetCell( GetRowCount() - 1, 0 )->GetCornersInSequence( angle );
756 std::vector<VECTOR2I> topRight = GetCell( 0, GetColCount() - 1 )->GetCornersInSequence( angle );
757 std::vector<VECTOR2I> bottomRight = GetCell( GetRowCount() - 1, GetColCount() - 1 )->GetCornersInSequence( angle );
758
759 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
760
761 std::vector<VECTOR2I> pts;
762
763 pts.emplace_back( topLeft[3] );
764 pts.emplace_back( topRight[2] );
765 pts.emplace_back( bottomRight[2] );
766 pts.emplace_back( bottomLeft[3] );
767
768 shape->AddShape( new SHAPE_SIMPLE( pts ) );
769
771 [&shape]( const VECTOR2I& ptA, const VECTOR2I& ptB, const STROKE_PARAMS& stroke )
772 {
773 shape->AddShape( new SHAPE_SEGMENT( ptA, ptB, stroke.GetWidth() ) );
774 } );
775
776 return shape;
777}
778
779
780void PCB_TABLE::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError,
781 ERROR_LOC aErrorLoc, bool aIgnoreLineWidth ) const
782{
783 int gap = aClearance;
784
785 if( StrokeColumns() || StrokeRows() )
786 gap = std::max( gap, aClearance + GetSeparatorsStroke().GetWidth() / 2 );
787
789 gap = std::max( gap, aClearance + GetBorderStroke().GetWidth() / 2 );
790
791 for( PCB_TABLECELL* cell : m_cells )
792 cell->TransformShapeToPolygon( aBuffer, aLayer, gap, aMaxError, aErrorLoc, false );
793}
794
795
797 KIGFX::RENDER_SETTINGS* aRenderSettings ) const
798{
799 // Convert graphic items (segments and texts) to a set of polygonal shapes
800 // aRenderSettings is used to draw lines when line style != LINE_STYLE::SOLID, so
801 // if nullptr line style will be ignored
803 [&aBuffer, aMaxError, aErrorLoc, aRenderSettings]( const VECTOR2I& ptA, const VECTOR2I& ptB,
804 const STROKE_PARAMS& stroke )
805 {
806 int lineWidth = stroke.GetWidth();
807 LINE_STYLE lineStyle = stroke.GetLineStyle();
808
809 if( lineStyle <= LINE_STYLE::FIRST_TYPE || aRenderSettings == nullptr )
810 TransformOvalToPolygon( aBuffer, ptA, ptB, lineWidth, aMaxError, aErrorLoc );
811 else
812 {
813 SHAPE_SEGMENT seg( ptA, ptB );
814 KIGFX::PCB_RENDER_SETTINGS defaultRenderSettings;
815
816 KIGFX::RENDER_SETTINGS* currSettings = aRenderSettings;
817
818 if( currSettings == nullptr )
819 currSettings = &defaultRenderSettings;
820
821 STROKE_PARAMS::Stroke( &seg, lineStyle, lineWidth, currSettings,
822 [&]( VECTOR2I a, VECTOR2I b )
823 {
824 if( a == b )
825 TransformCircleToPolygon( aBuffer, a, lineWidth / 2, aMaxError, aErrorLoc );
826 else
827 TransformOvalToPolygon( aBuffer, a + 1, b, lineWidth, aMaxError, aErrorLoc );
828 } );
829 }
830 } );
831
832 for( PCB_TABLECELL* cell : m_cells )
833 {
834 cell->TransformTextToPolySet( aBuffer, 0, aMaxError, ERROR_INSIDE );
835 }
836}
837
838
840 int aClearance, int aMaxError, ERROR_LOC aErrorLoc,
841 KIGFX::RENDER_SETTINGS* aRenderSettings ) const
842{
843 if( aClearance <= 0 )
844 TransformGraphicItemsToPolySet( aBuffer, aMaxError, aErrorLoc, aRenderSettings );
845 else
846 {
847 SHAPE_POLY_SET tmp;
848 TransformGraphicItemsToPolySet( tmp, aMaxError, aErrorLoc, aRenderSettings );
849 tmp.Inflate( aClearance, CORNER_STRATEGY::CHAMFER_ALL_CORNERS, aMaxError );
850 aBuffer.Append( tmp );
851 }
852}
853
854
855INSPECT_RESULT PCB_TABLE::Visit( INSPECTOR aInspector, void* aTestData, const std::vector<KICAD_T>& aScanTypes )
856{
857 for( KICAD_T scanType : aScanTypes )
858 {
859 if( scanType == PCB_TABLE_T )
860 {
861 if( INSPECT_RESULT::QUIT == aInspector( this, aTestData ) )
863 }
864
865 if( scanType == PCB_TABLECELL_T )
866 {
867 for( PCB_TABLECELL* cell : m_cells )
868 {
869 if( INSPECT_RESULT::QUIT == aInspector( cell, (void*) this ) )
871 }
872 }
873 }
874
876}
877
878
879wxString PCB_TABLE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
880{
881 return wxString::Format( _( "%d column table" ), m_colCount );
882}
883
884
886{
887 return BITMAPS::table;
888}
889
890
891bool PCB_TABLE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
892{
893 BOX2I rect = GetBoundingBox();
894
895 rect.Inflate( aAccuracy );
896
897 return rect.Contains( aPosition );
898}
899
900
901bool PCB_TABLE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
902{
903 BOX2I rect = aRect;
904
905 rect.Inflate( aAccuracy );
906
907 if( aContained )
908 return rect.Contains( GetBoundingBox() );
909
910 return rect.Intersects( GetBoundingBox() );
911}
912
913
914bool PCB_TABLE::HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
915{
916 return KIGEOM::ShapeHitTest( aPoly, *GetEffectiveShape(), aContained );
917}
918
919
920void PCB_TABLE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
921{
922 // Don't use GetShownText() here; we want to show the user the variable references
923 aList.emplace_back( _( "Table" ), wxString::Format( _( "%d Columns" ), m_colCount ) );
924}
925
926
927int PCB_TABLE::Compare( const PCB_TABLE* aTable, const PCB_TABLE* aOther )
928{
929 int diff;
930
931 if( ( diff = (int) aTable->GetCells().size() - (int) aOther->GetCells().size() ) != 0 )
932 return diff;
933
934 if( ( diff = aTable->GetColCount() - aOther->GetColCount() ) != 0 )
935 return diff;
936
937 for( int col = 0; col < aTable->GetColCount(); ++col )
938 {
939 if( ( diff = aTable->GetColWidth( col ) - aOther->GetColWidth( col ) ) != 0 )
940 return diff;
941 }
942
943 for( int row = 0; row < aTable->GetRowCount(); ++row )
944 {
945 if( ( diff = aTable->GetRowHeight( row ) - aOther->GetRowHeight( row ) ) != 0 )
946 return diff;
947 }
948
949 for( int row = 0; row < aTable->GetRowCount(); ++row )
950 {
951 for( int col = 0; col < aTable->GetColCount(); ++col )
952 {
953 PCB_TABLECELL* cell = aTable->GetCell( row, col );
954 PCB_TABLECELL* other = aOther->GetCell( row, col );
955
956 if( ( diff = cell->PCB_SHAPE::Compare( other ) ) != 0 )
957 return diff;
958
959 if( ( diff = cell->EDA_TEXT::Compare( other ) ) != 0 )
960 return diff;
961 }
962 }
963
964 return 0;
965}
966
967
968bool PCB_TABLE::operator==( const BOARD_ITEM& aBoardItem ) const
969{
970 if( Type() != aBoardItem.Type() )
971 return false;
972
973 const PCB_TABLE& other = static_cast<const PCB_TABLE&>( aBoardItem );
974
975 return *this == other;
976}
977
978
979bool PCB_TABLE::operator==( const PCB_TABLE& aOther ) const
980{
981 if( m_cells.size() != aOther.m_cells.size() )
982 return false;
983
984 if( m_strokeExternal != aOther.m_strokeExternal )
985 return false;
986
988 return false;
989
990 if( m_borderStroke != aOther.m_borderStroke )
991 return false;
992
993 if( m_strokeRows != aOther.m_strokeRows )
994 return false;
995
996 if( m_strokeColumns != aOther.m_strokeColumns )
997 return false;
998
1000 return false;
1001
1002 if( m_colWidths != aOther.m_colWidths )
1003 return false;
1004
1005 if( m_rowHeights != aOther.m_rowHeights )
1006 return false;
1007
1008 for( int ii = 0; ii < (int) m_cells.size(); ++ii )
1009 {
1010 if( !( *m_cells[ii] == *aOther.m_cells[ii] ) )
1011 return false;
1012 }
1013
1014 return true;
1015}
1016
1017
1018double PCB_TABLE::Similarity( const BOARD_ITEM& aOther ) const
1019{
1020 if( aOther.Type() != Type() )
1021 return 0.0;
1022
1023 const PCB_TABLE& other = static_cast<const PCB_TABLE&>( aOther );
1024
1025 if( m_cells.size() != other.m_cells.size() )
1026 return 0.1;
1027
1028 double similarity = 1.0;
1029
1030 if( m_strokeExternal != other.m_strokeExternal )
1031 similarity *= 0.9;
1032
1034 similarity *= 0.9;
1035
1036 if( m_borderStroke != other.m_borderStroke )
1037 similarity *= 0.9;
1038
1039 if( m_strokeRows != other.m_strokeRows )
1040 similarity *= 0.9;
1041
1042 if( m_strokeColumns != other.m_strokeColumns )
1043 similarity *= 0.9;
1044
1046 similarity *= 0.9;
1047
1048 if( m_colWidths != other.m_colWidths )
1049 similarity *= 0.9;
1050
1051 if( m_rowHeights != other.m_rowHeights )
1052 similarity *= 0.9;
1053
1054 for( int ii = 0; ii < (int) m_cells.size(); ++ii )
1055 similarity *= m_cells[ii]->Similarity( *other.m_cells[ii] );
1056
1057 return similarity;
1058}
1059
1060
1061static struct PCB_TABLE_DESC
1062{
1064 {
1066
1067 if( lineStyleEnum.Choices().GetCount() == 0 )
1068 {
1069 lineStyleEnum.Map( LINE_STYLE::SOLID, _HKI( "Solid" ) )
1070 .Map( LINE_STYLE::DASH, _HKI( "Dashed" ) )
1071 .Map( LINE_STYLE::DOT, _HKI( "Dotted" ) )
1072 .Map( LINE_STYLE::DASHDOT, _HKI( "Dash-Dot" ) )
1073 .Map( LINE_STYLE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
1074 }
1075
1078
1083
1084 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Start X" ),
1087 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Start Y" ),
1090
1091 const wxString tableProps = _( "Table Properties" );
1092
1093 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "External Border" ),
1095 tableProps ).SetIsCopyable();
1096
1097 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Header Border" ),
1099 tableProps ).SetIsCopyable();
1100
1101 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Border Width" ),
1104 tableProps ).SetIsCopyable();
1105
1106 propMgr.AddProperty( new PROPERTY_ENUM<PCB_TABLE, LINE_STYLE>( _HKI( "Border Style" ),
1108 tableProps ).SetIsCopyable();
1109
1110 propMgr.AddProperty( new PROPERTY<PCB_TABLE, COLOR4D>( _HKI( "Border Color" ),
1112 tableProps ).SetIsCopyable();
1113
1114 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Row Separators" ),
1116 tableProps ).SetIsCopyable();
1117
1118 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Cell Separators" ),
1120 tableProps ).SetIsCopyable();
1121
1122 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Separators Width" ),
1125 tableProps ).SetIsCopyable();
1126
1127 propMgr.AddProperty( new PROPERTY_ENUM<PCB_TABLE, LINE_STYLE>( _HKI( "Separators Style" ),
1129 tableProps ).SetIsCopyable();
1130
1131 propMgr.AddProperty( new PROPERTY<PCB_TABLE, COLOR4D>( _HKI( "Separators Color" ),
1133 tableProps ).SetIsCopyable();
1134 }
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
Definition api_enums.cpp:55
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
@ ERROR_INSIDE
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
constexpr int ARC_LOW_DEF
Definition base_units.h:143
BITMAPS
A list of all bitmap identifiers.
#define DEFAULT_LINE_WIDTH
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
Abstract interface for BOARD_ITEMs capable of storing other items inside.
BOARD_ITEM_CONTAINER(BOARD_ITEM *aParent, KICAD_T aType)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:86
friend class BOARD
Definition board_item.h:593
void SetUuidDirect(const KIID &aUuid)
Raw UUID assignment.
void SetLocked(bool aLocked) override
Definition board_item.h:418
PCB_LAYER_ID m_layer
Definition board_item.h:586
bool m_isLocked
Definition board_item.h:588
bool IsLocked() const override
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
FOOTPRINT * GetParentFootprint() const
virtual void CopyFrom(const BOARD_ITEM *aOther)
virtual void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const
Invoke a function on all children.
Definition board_item.h:264
void ResetUuid()
Definition board_item.h:280
constexpr const Vec & GetPosition() const
Definition box2.h:208
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:553
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition box2.h:594
constexpr const Vec GetCenter() const
Definition box2.h:227
constexpr coord_type GetLeft() const
Definition box2.h:225
constexpr bool Contains(const Vec &aPoint) const
Definition box2.h:165
constexpr coord_type GetRight() const
Definition box2.h:214
constexpr coord_type GetTop() const
Definition box2.h:226
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition box2.h:308
constexpr coord_type GetBottom() const
Definition box2.h:219
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:102
The base class for create windows for drawing purpose.
A set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:43
const KIID m_Uuid
Definition eda_item.h:599
virtual EDA_GROUP * GetParentGroup() const
Definition eda_item.h:116
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
std::map< wxString, wxString > m_customProperties
Definition eda_item.h:617
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:153
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:325
virtual EDA_ANGLE GetDrawRotation() const
Definition eda_text.h:425
virtual void ClearRenderCache()
Definition eda_text.cpp:669
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition property.h:789
static ENUM_MAP< T > & Instance()
Definition property.h:783
wxPGChoices & Choices()
Definition property.h:834
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
PCB specific render settings.
Definition pcb_painter.h:84
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
static constexpr double LOD_HIDE
Return this constant from ViewGetLOD() to hide the item unconditionally.
Definition view_item.h:176
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
Definition view_item.h:181
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
bool IsLayerVisibleCached(int aLayer) const
Definition view.h:441
Definition kiid.h:46
void SetPosition(const VECTOR2I &aPos) override
Definition pcb_shape.h:75
void SetEnd(const VECTOR2I &aEnd) override
VECTOR2I GetPosition() const override
Definition pcb_shape.h:76
int GetRowSpan() const
int GetColSpan() const
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
BOARD_ITEM * Duplicate(bool addToParentGroup, BOARD_COMMIT *aCommit=nullptr) const override
Create a copy of this BOARD_ITEM.
VECTOR2I GetEnd() const
void OnFootprintTransformed() override
Hook for items inside a footprint to refresh after the FP transform changes (translate,...
STROKE_PARAMS m_separatorsStroke
Definition pcb_table.h:336
bool StrokeRows() const
Definition pcb_table.h:110
void ClearCells()
Definition pcb_table.h:192
int GetRowCount() const
Definition pcb_table.h:128
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void TransformGraphicItemsToPolySet(SHAPE_POLY_SET &aBuffer, int aMaxError, ERROR_LOC aErrorLoc, KIGFX::RENDER_SETTINGS *aRenderSettings) const
Convert graphic items (segments and texts) to a set of polygonal shapes.
std::vector< PCB_TABLECELL * > m_cells
Definition pcb_table.h:341
void SetColWidth(int aCol, int aWidth)
Definition pcb_table.h:135
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
int m_colCount
Definition pcb_table.h:338
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
bool m_strokeRows
Definition pcb_table.h:334
void Move(const VECTOR2I &aMoveVector) override
Move this object.
int GetPositionY() const
Definition pcb_table.h:123
bool StrokeHeaderSeparator() const
Definition pcb_table.h:68
bool StrokeColumns() const
Definition pcb_table.h:107
void SetBorderStyle(const LINE_STYLE aStyle)
Definition pcb_table.h:76
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
void SetStrokeHeaderSeparator(bool aDoStroke)
Definition pcb_table.h:67
void SetSeparatorsColor(const COLOR4D &aColor)
Definition pcb_table.h:103
bool m_strokeExternal
Definition pcb_table.h:331
STROKE_PARAMS m_borderStroke
Definition pcb_table.h:333
bool m_strokeColumns
Definition pcb_table.h:335
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
void ResizeCells(int aRows, int aCols)
Grow or shrink to aRows x aCols, keeping the cells that already exist.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
bool StrokeExternal() const
Definition pcb_table.h:65
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
int GetSeparatorsWidth() const
Definition pcb_table.h:92
void SetPositionX(int x)
Definition pcb_table.h:120
void OnFootprintRescaled(double aRatioX, double aRatioY, double aLinearFactor, const VECTOR2I &aAnchor, const EDA_ANGLE &aParentRotate) override
Apply a parent footprint scale to this item.
void SetStrokeExternal(bool aDoStroke)
Definition pcb_table.h:64
PCB_TABLECELL * GetCell(int aRow, int aCol) const
Definition pcb_table.h:155
std::vector< PCB_TABLECELL * > GetCells() const
Definition pcb_table.h:165
void Autosize()
int GetBorderWidth() const
Definition pcb_table.h:74
COLOR4D GetBorderColor() const
Definition pcb_table.h:86
void TransformShapeToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, KIGFX::RENDER_SETTINGS *aRenderSettings=nullptr) const override
Convert the TABLE shape to a polyset.
bool operator==(const PCB_TABLE &aOther) const
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
int GetColCount() const
Definition pcb_table.h:126
void SetStrokeColumns(bool aDoStroke)
Definition pcb_table.h:106
const STROKE_PARAMS & GetSeparatorsStroke() const
Definition pcb_table.h:89
std::map< int, int > m_colWidths
Definition pcb_table.h:339
virtual void swapData(BOARD_ITEM *aImage) override
int GetPositionX() const
Definition pcb_table.h:122
void Normalize() override
Perform any normalization required after a user rotate and/or flip.
void AddCell(PCB_TABLECELL *aCell)
Definition pcb_table.h:170
const STROKE_PARAMS & GetBorderStroke() const
Definition pcb_table.h:71
void SetPositionY(int y)
Definition pcb_table.h:121
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void SetStrokeRows(bool aDoStroke)
Definition pcb_table.h:109
bool m_StrokeHeaderSeparator
Definition pcb_table.h:332
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const override
Invoke a function on all children.
void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition pcb_table.h:298
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the item shape to a closed polygon.
void DrawBorders(const std::function< void(const VECTOR2I &aPt1, const VECTOR2I &aPt2, const STROKE_PARAMS &aStroke)> &aCallback) const
LINE_STYLE GetBorderStyle() const
Definition pcb_table.h:77
static int Compare(const PCB_TABLE *aTable, const PCB_TABLE *aOther)
void SetColCount(int aCount)
Definition pcb_table.h:125
int GetColWidth(int aCol) const
Definition pcb_table.h:137
VECTOR2I GetPosition() const override
void SetSeparatorsWidth(int aWidth)
Definition pcb_table.h:91
COLOR4D GetSeparatorsColor() const
Definition pcb_table.h:104
void CopyFrom(const BOARD_ITEM *aOther) override
Definition pcb_table.cpp:94
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
LINE_STYLE GetSeparatorsStyle() const
Definition pcb_table.h:95
void SetBorderColor(const COLOR4D &aColor)
Definition pcb_table.h:85
PCB_TABLE(BOARD_ITEM *aParent, int aLineWidth)
Definition pcb_table.cpp:55
void SetSeparatorsStyle(const LINE_STYLE aStyle)
Definition pcb_table.h:94
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
void SetRowHeight(int aRow, int aHeight)
Definition pcb_table.h:145
void SetPosition(const VECTOR2I &aPos) override
void SetBorderWidth(int aWidth)
Definition pcb_table.h:73
int GetRowHeight(int aRow) const
Definition pcb_table.h:147
std::map< int, int > m_rowHeights
Definition pcb_table.h:340
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc) const
Convert the text to a polygonSet describing the actual character strokes (one per segment).
int GetMarginLeft() const
std::vector< VECTOR2I > GetCornersInSequence(EDA_ANGLE angle) const override
int GetMarginRight() const
PROPERTY_BASE & SetIsCopyable(bool aIsCopyable=true)
Definition property.h:359
Provide class metadata.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
Simple container to manage line stroke parameters.
int GetWidth() const
LINE_STYLE GetLineStyle() const
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, const std::function< void(const VECTOR2I &a, const VECTOR2I &b)> &aStroker)
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aBuffer, const VECTOR2I &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a circle to a polygon, using multiple straight lines.
void TransformOvalToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.
@ CHAMFER_ALL_CORNERS
All angles are chamfered.
static bool empty(const wxTextEntryBase *aCtrl)
DRC_CONSTRAINT_T
Definition drc_rule.h:49
#define _(s)
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:448
static constexpr EDA_ANGLE ANGLE_180
Definition eda_angle.h:452
RECURSE_MODE
Definition eda_item.h:50
@ RECURSE
Definition eda_item.h:51
@ NO_RECURSE
Definition eda_item.h:52
INSPECT_RESULT
Definition eda_item.h:44
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:91
a few functions useful in geometry calculations.
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition layer_id.cpp:179
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition layer_ids.h:180
@ LAYER_LOCKED_ITEM_SHADOW
Shadow layer for locked items.
Definition layer_ids.h:303
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
FLIP_DIRECTION
Definition mirror.h:23
@ LEFT_RIGHT
Flip left to right (around the Y axis)
Definition mirror.h:24
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
Definition mirror.h:25
bool ShapeHitTest(const SHAPE_LINE_CHAIN &aHitter, const SHAPE &aHittee, bool aHitteeContained)
Perform a shape-to-shape hit test.
KICOMMON_API void UnpackStroke(STROKE_PARAMS &aOutput, const types::StrokeAttributes &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
KICOMMON_API void PackStroke(types::StrokeAttributes &aOutput, const STROKE_PARAMS &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
#define _HKI(x)
Definition page_info.cpp:40
static struct PCB_TABLE_DESC _PCB_TABLE_DESC
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
Definition property.h:74
@ PT_COORD
Coordinate expressed in distance units (mm/inch)
Definition property.h:65
@ PT_SIZE
Size expressed in distance units (mm/inch)
Definition property.h:63
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
constexpr double correction
LINE_STYLE
Dashed line types.
VECTOR2I end
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition trigo.cpp:227
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
Definition typeinfo.h:87
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition typeinfo.h:86
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708