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_table.h"
21
22#include <pcb_edit_frame.h>
23#include <footprint.h>
24#include <bitmaps.h>
25#include <board.h>
32#include <pcb_painter.h> // for PCB_RENDER_SETTINGS
33#include <view/view.h>
34#include <properties/property.h>
36#include <api/api_enums.h>
37#include <api/api_utils.h>
38#include <api/api_pcb_utils.h>
39#include <api/board/board_types.pb.h>
40#include <board_commit.h>
41#include <eda_group.h>
42
43
44PCB_TABLE::PCB_TABLE( BOARD_ITEM* aParent, KICAD_T aType, int aLineWidth ) :
45 BOARD_ITEM_CONTAINER( aParent, aType ),
46 m_strokeExternal( true ),
49 m_strokeRows( true ),
50 m_strokeColumns( true ),
52 m_colCount( 0 )
53{
54}
55
56
57PCB_TABLE::PCB_TABLE( BOARD_ITEM* aParent, int aLineWidth ) :
58 PCB_TABLE( aParent, PCB_TABLE_T, aLineWidth )
59{
60}
61
62
64 PCB_TABLE( aParent, pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ) )
65{
66}
67
68
86
87
89{
90 // We own our cells; delete them
91 for( PCB_TABLECELL* cell : m_cells )
92 delete cell;
93}
94
95
96void PCB_TABLE::CopyFrom( const BOARD_ITEM* aOther )
97{
98 wxCHECK( aOther && aOther->Type() == PCB_TABLE_T, /* void */ );
99
100 BOARD* board = GetBoard();
101 const PCB_TABLE* other = static_cast<const PCB_TABLE*>( aOther );
102
103 BOARD_ITEM::CopyFrom( aOther );
104
108 m_strokeRows = other->m_strokeRows;
111
112 m_colCount = other->m_colCount;
113 m_colWidths = other->m_colWidths;
114 m_rowHeights = other->m_rowHeights;
115
116 if( board )
117 board->UncacheChildrenById( *this );
118
119 ClearCells();
120
121 for( PCB_TABLECELL* cell : other->m_cells )
122 AddCell( static_cast<PCB_TABLECELL*>( cell->Clone() ) );
123
124 if( board )
125 board->CacheChildrenById( *this );
126}
127
128
129BOARD_ITEM* PCB_TABLE::Duplicate( bool addToParentGroup, BOARD_COMMIT* aCommit ) const
130{
131 BOARD_ITEM* dupe = static_cast<BOARD_ITEM*>( Clone() );
132 dupe->ResetUuid();
133
134 dupe->RunOnChildren( []( BOARD_ITEM* aChild )
135 {
136 aChild->ResetUuid();
137 },
139
140 if( addToParentGroup )
141 {
142 wxCHECK_MSG( aCommit, dupe, "Must supply a commit to update parent group" );
143
144 if( EDA_GROUP* group = dupe->GetParentGroup() )
145 {
146 aCommit->Modify( group->AsEdaItem(), nullptr, RECURSE_MODE::NO_RECURSE );
147 group->AddItem( dupe );
148 }
149 }
150
151 return dupe;
152}
153
154
155void PCB_TABLE::Serialize( google::protobuf::Any& aContainer ) const
156{
157 using namespace kiapi::board;
158 types::Table table;
159
160 table.mutable_id()->set_value( m_Uuid.AsStdString() );
162 table.set_locked( IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
163 : kiapi::common::types::LockedState::LS_UNLOCKED );
164
165 table.set_column_count( m_colCount );
166
167 for( int col = 0; col < m_colCount; ++col )
168 table.add_column_widths( GetColWidth( col ) );
169
170 for( int row = 0; row < GetRowCount(); ++row )
171 table.add_row_heights( GetRowHeight( row ) );
172
173 for( const PCB_TABLECELL* cell : m_cells )
174 cell->Serialize( *table.add_cells() );
175
176 table.set_external_border( m_strokeExternal ? types::TSM_ENABLED : types::TSM_DISABLED );
177 table.set_header_separator( m_StrokeHeaderSeparator ? types::TSM_ENABLED : types::TSM_DISABLED );
178 kiapi::common::PackStroke( *table.mutable_border_stroke(), m_borderStroke );
179
180 table.set_row_separators( m_strokeRows ? types::TSM_ENABLED : types::TSM_DISABLED );
181 table.set_column_separators( m_strokeColumns ? types::TSM_ENABLED : types::TSM_DISABLED );
182 kiapi::common::PackStroke( *table.mutable_separators_stroke(), m_separatorsStroke );
183
184 if( FOOTPRINT* parent = GetParentFootprint() )
185 table.mutable_parent()->set_value( parent->m_Uuid.AsStdString() );
186 else if( const BOARD* board = GetBoard() )
187 table.mutable_parent()->set_value( board->m_Uuid.AsStdString() );
188
189 kiapi::common::PackCustomProperties( table.mutable_custom_properties(), *this );
190 aContainer.PackFrom( table );
191}
192
193
194bool PCB_TABLE::Deserialize( const google::protobuf::Any& aContainer )
195{
196 using namespace kiapi::board;
197 types::Table table;
198
199 if( !aContainer.UnpackTo( &table ) )
200 return false;
201
202 if( table.column_count() < 1 )
203 return false;
204
205 SetUuidDirect( KIID( table.id().value() ) );
207 SetLocked( table.locked() == kiapi::common::types::LockedState::LS_LOCKED );
208 kiapi::common::UnpackCustomProperties( table.custom_properties(), *this );
209
210 ClearCells();
211 m_colWidths.clear();
212 m_rowHeights.clear();
213
214 SetColCount( table.column_count() );
215
216 for( int i = 0; i < table.column_widths_size() && i < table.column_count(); ++i )
217 SetColWidth( i, table.column_widths( i ) );
218
219 for( const types::TableCell& protoCell : table.cells() )
220 {
221 PCB_TABLECELL* cell = new PCB_TABLECELL( this );
222
223 if( !cell->Deserialize( protoCell ) )
224 {
225 // Since cells are positional, we must add something to the table. Probably better
226 // to add a new, empy cell than a partially deserialized who-knows-what.
227 delete cell;
228 cell = new PCB_TABLECELL( this );
229 }
230
231 AddCell( cell );
232 }
233
234 int rowCount = m_colCount > 0 ? static_cast<int>( m_cells.size() ) / m_colCount : 0;
235
236 for( int i = 0; i < table.row_heights_size() && i < rowCount; ++i )
237 SetRowHeight( i, table.row_heights( i ) );
238
239 m_strokeExternal = table.external_border() == types::TSM_ENABLED;
240 m_StrokeHeaderSeparator = table.header_separator() == types::TSM_ENABLED;
241
242 if( table.has_border_stroke() )
244
245 m_strokeRows = table.row_separators() == types::TSM_ENABLED;
246 m_strokeColumns = table.column_separators() == types::TSM_ENABLED;
247
248 if( table.has_separators_stroke() )
250
251 Normalize();
252
253 return true;
254}
255
256
258{
259 wxCHECK_RET( aImage != nullptr && aImage->Type() == Type(), wxT( "Cannot swap data with invalid table." ) );
260
261 PCB_TABLE* table = static_cast<PCB_TABLE*>( aImage );
262
263 std::swap( m_layer, table->m_layer );
264 std::swap( m_isLocked, table->m_isLocked );
265
266 std::swap( m_strokeExternal, table->m_strokeExternal );
267 std::swap( m_StrokeHeaderSeparator, table->m_StrokeHeaderSeparator );
268 std::swap( m_borderStroke, table->m_borderStroke );
269 std::swap( m_strokeRows, table->m_strokeRows );
270 std::swap( m_strokeColumns, table->m_strokeColumns );
271 std::swap( m_separatorsStroke, table->m_separatorsStroke );
272
273 std::swap( m_colCount, table->m_colCount );
274 std::swap( m_colWidths, table->m_colWidths );
275 std::swap( m_rowHeights, table->m_rowHeights );
276
277 std::swap( m_cells, table->m_cells );
278
279 for( PCB_TABLECELL* cell : m_cells )
280 cell->SetParent( this );
281
282 for( PCB_TABLECELL* cell : table->m_cells )
283 cell->SetParent( table );
284
285 std::swap( m_customProperties, table->m_customProperties );
286}
287
288
289void PCB_TABLE::ResizeCells( int aRows, int aCols )
290{
291 const size_t wanted = static_cast<size_t>( aRows ) * static_cast<size_t>( aCols );
292
293 m_colCount = aCols;
294
295 while( m_cells.size() > wanted )
296 {
297 delete m_cells.back();
298 m_cells.pop_back();
299 }
300
301 while( m_cells.size() < wanted )
302 AddCell( new PCB_TABLECELL( this ) );
303}
304
305
307{
308 m_layer = aLayer;
309
310 for( PCB_TABLECELL* cell : m_cells )
311 cell->SetLayer( aLayer );
312}
313
314
316{
317 Move( aPos - GetPosition() );
318}
319
320
322{
323 if( m_cells.empty() )
324 return VECTOR2I( 0, 0 ); // Return origin if table has no cells
325
326 return m_cells[0]->GetPosition();
327}
328
329
331{
332 VECTOR2I tableSize;
333
334 for( int ii = 0; ii < GetColCount(); ++ii )
335 tableSize.x += GetColWidth( ii );
336
337 for( int ii = 0; ii < GetRowCount(); ++ii )
338 tableSize.y += GetRowHeight( ii );
339
340 return GetPosition() + tableSize;
341}
342
343
345{
346 if( m_cells.empty() )
347 return;
348
349 EDA_ANGLE cellAngle = m_cells[0]->GetTextAngle();
350
351 BOX2I cell0BBox = m_cells[0]->GetBoundingBox();
352 VECTOR2I stableCenter = cell0BBox.GetCenter();
353
354 int cell0Width = m_colWidths[0];
355 int cell0Height = m_rowHeights[0];
356
357 if( m_cells[0]->GetColSpan() > 1 )
358 {
359 for( int ii = 1; ii < m_cells[0]->GetColSpan(); ++ii )
360 cell0Width += m_colWidths[ii];
361 }
362
363 if( m_cells[0]->GetRowSpan() > 1 )
364 {
365 for( int ii = 1; ii < m_cells[0]->GetRowSpan(); ++ii )
366 cell0Height += m_rowHeights[ii];
367 }
368
369 VECTOR2I localCell0Center( cell0Width / 2, cell0Height / 2 );
370 RotatePoint( localCell0Center, cellAngle );
371
372 if( cellAngle != ANGLE_0 )
373 {
374 for( PCB_TABLECELL* cell : m_cells )
375 cell->Rotate( stableCenter, -cellAngle );
376 }
377
378 VECTOR2I unrotatedOrigin = stableCenter - VECTOR2I( cell0Width / 2, cell0Height / 2 );
379
380 int y = unrotatedOrigin.y;
381
382 for( int row = 0; row < GetRowCount(); ++row )
383 {
384 int x = unrotatedOrigin.x;
385 int rowHeight = m_rowHeights[row];
386
387 for( int col = 0; col < GetColCount(); ++col )
388 {
389 int colWidth = m_colWidths[col];
390
391 PCB_TABLECELL* cell = GetCell( row, col );
392
393 if( !cell )
394 continue;
395
396 int cellWidth = colWidth;
397 int cellHeight = rowHeight;
398
399 if( cell->GetColSpan() > 1 || cell->GetRowSpan() > 1 )
400 {
401 for( int ii = col + 1; ii < col + cell->GetColSpan(); ++ii )
402 cellWidth += m_colWidths[ii];
403
404 for( int ii = row + 1; ii < row + cell->GetRowSpan(); ++ii )
405 cellHeight += m_rowHeights[ii];
406 }
407
408 VECTOR2I pos( x, y );
409 VECTOR2I end( x + cellWidth, y + cellHeight );
410
411 if( cell->GetPosition() != pos )
412 {
413 cell->SetPosition( pos );
414 cell->ClearRenderCache();
415 }
416
417 if( cell->GetEnd() != end )
418 {
419 cell->SetEnd( end );
420 cell->ClearRenderCache();
421 }
422
423 x += colWidth;
424 }
425
426 y += rowHeight;
427 }
428
429 if( cellAngle != ANGLE_0 )
430 {
431 for( PCB_TABLECELL* cell : m_cells )
432 cell->Rotate( stableCenter, cellAngle );
433 }
434
435 BOX2I newCell0BBox = m_cells[0]->GetBoundingBox();
436 VECTOR2I newCenter = newCell0BBox.GetCenter();
437
438 if( newCenter != stableCenter )
439 {
440 VECTOR2I correction = stableCenter - newCenter;
441
442 for( PCB_TABLECELL* cell : m_cells )
443 cell->Move( correction );
444 }
445}
446
447
449{
450 std::vector<std::vector<BOX2I>> extents;
451
452 for( int row = 0; row < GetRowCount(); ++row )
453 {
454 extents.push_back( std::vector<BOX2I>() );
455
456 for( int col = 0; col < GetColCount(); ++col )
457 {
458 SHAPE_POLY_SET textPoly;
459 GetCell( row, col )->TransformTextToPolySet( textPoly, 0, ARC_LOW_DEF, ERROR_INSIDE );
460 extents[row].push_back( textPoly.BBox() );
461 }
462 }
463
464 for( int col = 0; col < GetColCount(); ++col )
465 {
466 int colWidth = 0;
467
468 for( int row = 0; row < GetRowCount(); ++row )
469 {
470 PCB_TABLECELL* cell = GetCell( row, col );
471 int margins = cell->GetMarginLeft() + cell->GetMarginRight();
472 colWidth = std::max<int>( colWidth, extents[row][col].GetWidth() + ( margins * 1.5 ) );
473 }
474
475 SetColWidth( col, colWidth );
476 }
477
478 for( int row = 0; row < GetRowCount(); ++row )
479 {
480 int rowHeight = 0;
481
482 for( int col = 0; col < GetColCount(); ++col )
483 {
484 PCB_TABLECELL* cell = GetCell( row, col );
485 int margins = cell->GetMarginLeft() + cell->GetMarginRight();
486 rowHeight = std::max( rowHeight, (int) extents[row][col].GetHeight() + margins );
487 }
488
489 SetRowHeight( row, rowHeight );
490 }
491
492 Normalize();
493}
494
495
496void PCB_TABLE::Move( const VECTOR2I& aMoveVector )
497{
498 for( PCB_TABLECELL* cell : m_cells )
499 cell->Move( aMoveVector );
500}
501
502
503void PCB_TABLE::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
504{
505 if( GetCells().empty() )
506 return;
507
508 for( PCB_TABLECELL* cell : m_cells )
509 cell->Rotate( aRotCentre, aAngle );
510
511 Normalize();
512}
513
514
516{
517 for( PCB_TABLECELL* cell : m_cells )
518 cell->OnFootprintTransformed();
519}
520
521
522void PCB_TABLE::OnFootprintRescaled( double aRatioX, double aRatioY, double aLinearFactor, const VECTOR2I& aAnchor,
523 const EDA_ANGLE& aParentRotate )
524{
525 for( PCB_TABLECELL* cell : m_cells )
526 cell->OnFootprintRescaled( aRatioX, aRatioY, aLinearFactor, aAnchor, aParentRotate );
527}
528
529
530void PCB_TABLE::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
531{
532 // FP-child path keeps cells in lib frame, the standalone path below
533 // would corrupt them because FOOTPRINT::Flip zeroes the FP rotation.
534 if( GetParentFootprint() )
535 {
536 for( PCB_TABLECELL* cell : m_cells )
537 cell->Flip( aCentre, aFlipDirection );
538
539 // Flipping a cell also turns its text 180 degrees, so in the frame the table reads in
540 // it always comes out mirrored left to right.
541 std::vector<PCB_TABLECELL*> oldCells = m_cells;
542 int rowOffset = 0;
543
544 for( int row = 0; row < GetRowCount(); ++row )
545 {
546 for( int col = 0; col < GetColCount(); ++col )
547 m_cells[rowOffset + col] = oldCells[rowOffset + GetColCount() - 1 - col];
548
549 rowOffset += GetColCount();
550 }
551
552 std::map<int, int> newColWidths;
553
554 for( int col = 0; col < GetColCount(); ++col )
555 newColWidths[col] = m_colWidths[GetColCount() - 1 - col];
556
557 m_colWidths = std::move( newColWidths );
558
560 return;
561 }
562
563 BOX2I originalBBox = GetBoundingBox();
564
565 VECTOR2I targetPos;
566
567 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
568 {
569 targetPos.x = 2 * aCentre.x - originalBBox.GetRight();
570 targetPos.y = originalBBox.GetTop();
571 }
572 else
573 {
574 targetPos.x = originalBBox.GetLeft();
575 targetPos.y = 2 * aCentre.y - originalBBox.GetBottom();
576 }
577
578 EDA_ANGLE originalAngle = m_cells[0]->GetTextAngle();
579
580 if( originalAngle != ANGLE_0 )
581 Rotate( GetPosition(), -originalAngle );
582
583 VECTOR2I tableOrigin = GetPosition();
584
585 for( PCB_TABLECELL* cell : m_cells )
586 cell->Flip( tableOrigin, aFlipDirection );
587
588 // Flipping a cell turns its text 180 degrees and the grid is laid out in the frame the
589 // cells read in, so that turn reverses the rows already. Only the columns are left.
590 std::vector<PCB_TABLECELL*> oldCells = m_cells;
591 int rowOffset = 0;
592
593 for( int row = 0; row < GetRowCount(); ++row )
594 {
595 for( int col = 0; col < GetColCount(); ++col )
596 m_cells[rowOffset + col] = oldCells[rowOffset + GetColCount() - 1 - col];
597
598 rowOffset += GetColCount();
599 }
600
601 std::map<int, int> newColWidths;
602
603 for( int col = 0; col < GetColCount(); ++col )
604 newColWidths[col] = m_colWidths[GetColCount() - 1 - col];
605
606 m_colWidths = std::move( newColWidths );
607
609 Normalize();
610
611 if( originalAngle != ANGLE_0 )
612 Rotate( GetPosition(), -originalAngle );
613
614 BOX2I newBBox = GetBoundingBox();
615 Move( targetPos - newBBox.GetPosition() );
616}
617
618
619void PCB_TABLE::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
620{
621 // Mirror is Flip with the layer restored. TOP_BOTTOM needs a 180 deg pre-rotation
622 // because rotate-then-LR-flip equals TB-flip.
623 PCB_LAYER_ID origLayer = GetLayer();
624 std::map<PCB_TABLECELL*, PCB_LAYER_ID> origCellLayers;
625 std::map<PCB_TABLECELL*, bool> origMirrorSettings;
626
627 for( PCB_TABLECELL* cell : m_cells )
628 {
629 origCellLayers[cell] = cell->GetLayer();
630 origMirrorSettings[cell] = cell->IsMirrored();
631 }
632
633 if( aFlipDirection == FLIP_DIRECTION::TOP_BOTTOM )
634 Rotate( aCentre, ANGLE_180 );
635
637
638 SetLayer( origLayer );
639
640 for( PCB_TABLECELL* cell : m_cells )
641 {
642 cell->SetLayer( origCellLayers[cell] );
643 cell->SetMirrored( origMirrorSettings[cell] );
644 }
645}
646
647
648void PCB_TABLE::RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const
649{
650 for( PCB_TABLECELL* cell : m_cells )
651 {
652 aFunction( cell );
653
654 if( aMode == RECURSE_MODE::RECURSE )
655 cell->RunOnChildren( aFunction, aMode );
656 }
657}
658
659
661{
662 BOX2I bbox;
663
664 for( PCB_TABLECELL* cell : m_cells )
665 bbox.Merge( cell->GetBoundingBox() );
666
667 if( m_strokeExternal )
668 bbox.Inflate( m_borderStroke.GetWidth() / 2 );
669
670 return bbox;
671}
672
673
674double PCB_TABLE::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
675{
676 // Hide the locked shadow when the table's own layer is not shown
677 if( aLayer == LAYER_LOCKED_ITEM_SHADOW && !aView->IsLayerVisibleCached( m_layer ) )
678 return LOD_HIDE;
679
680 return LOD_SHOW;
681}
682
683
684void PCB_TABLE::DrawBorders( const std::function<void( const VECTOR2I& aPt1, const VECTOR2I& aPt2,
685 const STROKE_PARAMS& aStroke )>& aCallback ) const
686{
687 if( m_cells.empty() ) // Shouldn't be possible....
688 return;
689
690 EDA_ANGLE drawAngle = GetCell( 0, 0 )->GetDrawRotation();
691 std::vector<VECTOR2I> topLeft = GetCell( 0, 0 )->GetCornersInSequence( drawAngle );
692 std::vector<VECTOR2I> bottomLeft = GetCell( GetRowCount() - 1, 0 )->GetCornersInSequence( drawAngle );
693 std::vector<VECTOR2I> topRight = GetCell( 0, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
694 std::vector<VECTOR2I> botRight = GetCell( GetRowCount() - 1, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
695 STROKE_PARAMS stroke;
696
697 for( int col = 0; col < GetColCount() - 1; ++col )
698 {
699 for( int row = 0; row < GetRowCount(); ++row )
700 {
701 if( row == 0 && StrokeHeaderSeparator() )
702 stroke = GetBorderStroke();
703 else if( StrokeColumns() )
704 stroke = GetSeparatorsStroke();
705 else
706 continue;
707
708 PCB_TABLECELL* cell = GetCell( row, col );
709
710 if( cell->GetColSpan() == 0 )
711 continue;
712
713 if( col + cell->GetColSpan() == GetColCount() )
714 continue;
715
716 std::vector<VECTOR2I> corners = cell->GetCornersInSequence( drawAngle );
717
718 if( corners.size() == 4 )
719 aCallback( corners[1], corners[2], stroke );
720 }
721 }
722
723 for( int row = 0; row < GetRowCount() - 1; ++row )
724 {
725 if( row == 0 && StrokeHeaderSeparator() )
726 stroke = GetBorderStroke();
727 else if( StrokeRows() )
728 stroke = GetSeparatorsStroke();
729 else
730 continue;
731
732 for( int col = 0; col < GetColCount(); ++col )
733 {
734 PCB_TABLECELL* cell = GetCell( row, col );
735
736 if( cell->GetRowSpan() == 0 )
737 continue;
738
739 if( row + cell->GetRowSpan() == GetRowCount() )
740 continue;
741
742 std::vector<VECTOR2I> corners = cell->GetCornersInSequence( drawAngle );
743
744 if( corners.size() == 4 )
745 aCallback( corners[2], corners[3], stroke );
746 }
747 }
748
749 if( StrokeExternal() && GetBorderStroke().GetWidth() >= 0 )
750 {
751 aCallback( topLeft[0], topRight[1], GetBorderStroke() );
752 aCallback( topRight[1], botRight[2], GetBorderStroke() );
753 aCallback( botRight[2], bottomLeft[3], GetBorderStroke() );
754 aCallback( bottomLeft[3], topLeft[0], GetBorderStroke() );
755 }
756}
757
758
760{
761 EDA_ANGLE angle = GetCell( 0, 0 )->GetDrawRotation();
762 std::vector<VECTOR2I> topLeft = GetCell( 0, 0 )->GetCornersInSequence( angle );
763 std::vector<VECTOR2I> bottomLeft = GetCell( GetRowCount() - 1, 0 )->GetCornersInSequence( angle );
764 std::vector<VECTOR2I> topRight = GetCell( 0, GetColCount() - 1 )->GetCornersInSequence( angle );
765 std::vector<VECTOR2I> bottomRight = GetCell( GetRowCount() - 1, GetColCount() - 1 )->GetCornersInSequence( angle );
766
767 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
768
769 std::vector<VECTOR2I> pts;
770
771 pts.emplace_back( topLeft[3] );
772 pts.emplace_back( topRight[2] );
773 pts.emplace_back( bottomRight[2] );
774 pts.emplace_back( bottomLeft[3] );
775
776 shape->AddShape( new SHAPE_SIMPLE( pts ) );
777
779 [&shape]( const VECTOR2I& ptA, const VECTOR2I& ptB, const STROKE_PARAMS& stroke )
780 {
781 shape->AddShape( new SHAPE_SEGMENT( ptA, ptB, stroke.GetWidth() ) );
782 } );
783
784 return shape;
785}
786
787
788void PCB_TABLE::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError,
789 ERROR_LOC aErrorLoc, bool aIgnoreLineWidth ) const
790{
791 int gap = aClearance;
792
793 if( StrokeColumns() || StrokeRows() )
794 gap = std::max( gap, aClearance + GetSeparatorsStroke().GetWidth() / 2 );
795
797 gap = std::max( gap, aClearance + GetBorderStroke().GetWidth() / 2 );
798
799 for( PCB_TABLECELL* cell : m_cells )
800 cell->TransformShapeToPolygon( aBuffer, aLayer, gap, aMaxError, aErrorLoc, false );
801}
802
803
805 KIGFX::RENDER_SETTINGS* aRenderSettings ) const
806{
807 // Convert graphic items (segments and texts) to a set of polygonal shapes
808 // aRenderSettings is used to draw lines when line style != LINE_STYLE::SOLID, so
809 // if nullptr line style will be ignored
811 [&aBuffer, aMaxError, aErrorLoc, aRenderSettings]( const VECTOR2I& ptA, const VECTOR2I& ptB,
812 const STROKE_PARAMS& stroke )
813 {
814 int lineWidth = stroke.GetWidth();
815 LINE_STYLE lineStyle = stroke.GetLineStyle();
816
817 if( lineStyle <= LINE_STYLE::FIRST_TYPE || aRenderSettings == nullptr )
818 TransformOvalToPolygon( aBuffer, ptA, ptB, lineWidth, aMaxError, aErrorLoc );
819 else
820 {
821 SHAPE_SEGMENT seg( ptA, ptB );
822 KIGFX::PCB_RENDER_SETTINGS defaultRenderSettings;
823
824 KIGFX::RENDER_SETTINGS* currSettings = aRenderSettings;
825
826 if( currSettings == nullptr )
827 currSettings = &defaultRenderSettings;
828
829 STROKE_PARAMS::Stroke( &seg, lineStyle, lineWidth, currSettings,
830 [&]( VECTOR2I a, VECTOR2I b )
831 {
832 if( a == b )
833 TransformCircleToPolygon( aBuffer, a, lineWidth / 2, aMaxError, aErrorLoc );
834 else
835 TransformOvalToPolygon( aBuffer, a + 1, b, lineWidth, aMaxError, aErrorLoc );
836 } );
837 }
838 } );
839
840 for( PCB_TABLECELL* cell : m_cells )
841 {
842 cell->TransformTextToPolySet( aBuffer, 0, aMaxError, ERROR_INSIDE );
843 }
844}
845
846
848 int aClearance, int aMaxError, ERROR_LOC aErrorLoc,
849 KIGFX::RENDER_SETTINGS* aRenderSettings ) const
850{
851 if( aClearance <= 0 )
852 TransformGraphicItemsToPolySet( aBuffer, aMaxError, aErrorLoc, aRenderSettings );
853 else
854 {
855 SHAPE_POLY_SET tmp;
856 TransformGraphicItemsToPolySet( tmp, aMaxError, aErrorLoc, aRenderSettings );
857 tmp.Inflate( aClearance, CORNER_STRATEGY::CHAMFER_ALL_CORNERS, aMaxError );
858 aBuffer.Append( tmp );
859 }
860}
861
862
863INSPECT_RESULT PCB_TABLE::Visit( INSPECTOR aInspector, void* aTestData, const std::vector<KICAD_T>& aScanTypes )
864{
865 for( KICAD_T scanType : aScanTypes )
866 {
867 if( scanType == PCB_TABLE_T )
868 {
869 if( INSPECT_RESULT::QUIT == aInspector( this, aTestData ) )
871 }
872
873 if( scanType == PCB_TABLECELL_T )
874 {
875 for( PCB_TABLECELL* cell : m_cells )
876 {
877 if( INSPECT_RESULT::QUIT == aInspector( cell, (void*) this ) )
879 }
880 }
881 }
882
884}
885
886
887wxString PCB_TABLE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
888{
889 return wxString::Format( _( "%d column table" ), m_colCount );
890}
891
892
894{
895 return BITMAPS::table;
896}
897
898
899bool PCB_TABLE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
900{
901 BOX2I rect = GetBoundingBox();
902
903 rect.Inflate( aAccuracy );
904
905 return rect.Contains( aPosition );
906}
907
908
909bool PCB_TABLE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
910{
911 BOX2I rect = aRect;
912
913 rect.Inflate( aAccuracy );
914
915 if( aContained )
916 return rect.Contains( GetBoundingBox() );
917
918 return rect.Intersects( GetBoundingBox() );
919}
920
921
922bool PCB_TABLE::HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
923{
924 return KIGEOM::ShapeHitTest( aPoly, *GetEffectiveShape(), aContained );
925}
926
927
928void PCB_TABLE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
929{
930 // Don't use GetShownText() here; we want to show the user the variable references
931 aList.emplace_back( _( "Table" ), wxString::Format( _( "%d Columns" ), m_colCount ) );
932}
933
934
935int PCB_TABLE::Compare( const PCB_TABLE* aTable, const PCB_TABLE* aOther )
936{
937 int diff;
938
939 if( ( diff = (int) aTable->GetCells().size() - (int) aOther->GetCells().size() ) != 0 )
940 return diff;
941
942 if( ( diff = aTable->GetColCount() - aOther->GetColCount() ) != 0 )
943 return diff;
944
945 for( int col = 0; col < aTable->GetColCount(); ++col )
946 {
947 if( ( diff = aTable->GetColWidth( col ) - aOther->GetColWidth( col ) ) != 0 )
948 return diff;
949 }
950
951 if( ( diff = aTable->GetRowCount() - aOther->GetRowCount() ) != 0 )
952 return diff;
953
954 for( int row = 0; row < aTable->GetRowCount(); ++row )
955 {
956 if( ( diff = aTable->GetRowHeight( row ) - aOther->GetRowHeight( row ) ) != 0 )
957 return diff;
958 }
959
960 for( int row = 0; row < aTable->GetRowCount(); ++row )
961 {
962 for( int col = 0; col < aTable->GetColCount(); ++col )
963 {
964 PCB_TABLECELL* cell = aTable->GetCell( row, col );
965 PCB_TABLECELL* other = aOther->GetCell( row, col );
966
967 if( ( diff = cell->PCB_SHAPE::Compare( other ) ) != 0 )
968 return diff;
969
970 if( ( diff = cell->EDA_TEXT::Compare( other ) ) != 0 )
971 return diff;
972 }
973 }
974
975 return 0;
976}
977
978
979bool PCB_TABLE::operator==( const BOARD_ITEM& aBoardItem ) const
980{
981 if( Type() != aBoardItem.Type() )
982 return false;
983
984 const PCB_TABLE& other = static_cast<const PCB_TABLE&>( aBoardItem );
985
986 return *this == other;
987}
988
989
990bool PCB_TABLE::operator==( const PCB_TABLE& aOther ) const
991{
992 if( m_cells.size() != aOther.m_cells.size() )
993 return false;
994
995 if( m_strokeExternal != aOther.m_strokeExternal )
996 return false;
997
999 return false;
1000
1001 if( m_borderStroke != aOther.m_borderStroke )
1002 return false;
1003
1004 if( m_strokeRows != aOther.m_strokeRows )
1005 return false;
1006
1007 if( m_strokeColumns != aOther.m_strokeColumns )
1008 return false;
1009
1011 return false;
1012
1013 if( m_colWidths != aOther.m_colWidths )
1014 return false;
1015
1016 if( m_rowHeights != aOther.m_rowHeights )
1017 return false;
1018
1019 for( int ii = 0; ii < (int) m_cells.size(); ++ii )
1020 {
1021 if( !( *m_cells[ii] == *aOther.m_cells[ii] ) )
1022 return false;
1023 }
1024
1025 return true;
1026}
1027
1028
1029double PCB_TABLE::Similarity( const BOARD_ITEM& aOther ) const
1030{
1031 if( aOther.Type() != Type() )
1032 return 0.0;
1033
1034 const PCB_TABLE& other = static_cast<const PCB_TABLE&>( aOther );
1035
1036 if( m_cells.size() != other.m_cells.size() )
1037 return 0.1;
1038
1039 double similarity = 1.0;
1040
1041 if( m_strokeExternal != other.m_strokeExternal )
1042 similarity *= 0.9;
1043
1045 similarity *= 0.9;
1046
1047 if( m_borderStroke != other.m_borderStroke )
1048 similarity *= 0.9;
1049
1050 if( m_strokeRows != other.m_strokeRows )
1051 similarity *= 0.9;
1052
1053 if( m_strokeColumns != other.m_strokeColumns )
1054 similarity *= 0.9;
1055
1057 similarity *= 0.9;
1058
1059 if( m_colWidths != other.m_colWidths )
1060 similarity *= 0.9;
1061
1062 if( m_rowHeights != other.m_rowHeights )
1063 similarity *= 0.9;
1064
1065 for( int ii = 0; ii < (int) m_cells.size(); ++ii )
1066 similarity *= m_cells[ii]->Similarity( *other.m_cells[ii] );
1067
1068 return similarity;
1069}
1070
1071
1072static struct PCB_TABLE_DESC
1073{
1075 {
1077
1078 if( lineStyleEnum.Choices().GetCount() == 0 )
1079 {
1080 lineStyleEnum.Map( LINE_STYLE::SOLID, _HKI( "Solid" ) )
1081 .Map( LINE_STYLE::DASH, _HKI( "Dashed" ) )
1082 .Map( LINE_STYLE::DOT, _HKI( "Dotted" ) )
1083 .Map( LINE_STYLE::DASHDOT, _HKI( "Dash-Dot" ) )
1084 .Map( LINE_STYLE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
1085 }
1086
1089
1094
1095 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Start X" ),
1098 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Start Y" ),
1101
1102 const wxString tableProps = _( "Table Properties" );
1103
1104 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "External Border" ),
1106 tableProps ).SetIsCopyable();
1107
1108 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Header Border" ),
1110 tableProps ).SetIsCopyable();
1111
1112 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Border Width" ),
1115 tableProps ).SetIsCopyable();
1116
1117 propMgr.AddProperty( new PROPERTY_ENUM<PCB_TABLE, LINE_STYLE>( _HKI( "Border Style" ),
1119 tableProps ).SetIsCopyable();
1120
1121 propMgr.AddProperty( new PROPERTY<PCB_TABLE, COLOR4D>( _HKI( "Border Color" ),
1123 tableProps ).SetIsCopyable();
1124
1125 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Row Separators" ),
1127 tableProps ).SetIsCopyable();
1128
1129 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Cell Separators" ),
1131 tableProps ).SetIsCopyable();
1132
1133 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Separators Width" ),
1136 tableProps ).SetIsCopyable();
1137
1138 propMgr.AddProperty( new PROPERTY_ENUM<PCB_TABLE, LINE_STYLE>( _HKI( "Separators Style" ),
1140 tableProps ).SetIsCopyable();
1141
1142 propMgr.AddProperty( new PROPERTY<PCB_TABLE, COLOR4D>( _HKI( "Separators Color" ),
1144 tableProps ).SetIsCopyable();
1145 }
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:85
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:87
void SetUuidDirect(const KIID &aUuid)
Raw UUID assignment.
void SetLocked(bool aLocked) override
Definition board_item.h:427
PCB_LAYER_ID GetFlippedLayer(PCB_LAYER_ID aLayer) const
Return the layer paired with aLayer on the opposite side of the board.
PCB_LAYER_ID m_layer
Definition board_item.h:600
bool m_isLocked
Definition board_item.h:602
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:265
void ResetUuid()
Definition board_item.h:281
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
void CacheChildrenById(const BOARD_ITEM &aParent)
Definition board.h:1731
void UncacheChildrenById(const BOARD_ITEM &aParent)
Definition board.h:1737
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:333
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:798
static ENUM_MAP< T > & Instance()
Definition property.h:792
wxPGChoices & Choices()
Definition property.h:843
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
PCB specific render settings.
Definition pcb_painter.h:94
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:68
bool IsLayerVisibleCached(int aLayer) const
Definition view.h:472
Definition kiid.h:46
void SetPosition(const VECTOR2I &aPos) override
Definition pcb_shape.h:77
void SetEnd(const VECTOR2I &aEnd) override
VECTOR2I GetPosition() const override
Definition pcb_shape.h:78
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:96
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:57
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:371
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.
#define UNSPECIFIED
static bool empty(const wxTextEntryBase *aCtrl)
#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.
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