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
191 if( !aContainer.PackFrom( table ) )
192 wxFAIL_MSG( wxT( "Failed to pack PCB_TABLE" ) );
193}
194
195
196bool PCB_TABLE::Deserialize( const google::protobuf::Any& aContainer )
197{
198 using namespace kiapi::board;
199 types::Table table;
200
201 if( !aContainer.UnpackTo( &table ) )
202 return false;
203
204 if( table.column_count() < 1 )
205 return false;
206
207 SetUuidDirect( KIID( table.id().value() ) );
209 SetLocked( table.locked() == kiapi::common::types::LockedState::LS_LOCKED );
210 kiapi::common::UnpackCustomProperties( table.custom_properties(), *this );
211
212 ClearCells();
213 m_colWidths.clear();
214 m_rowHeights.clear();
215
216 SetColCount( table.column_count() );
217
218 for( int i = 0; i < table.column_widths_size() && i < table.column_count(); ++i )
219 SetColWidth( i, table.column_widths( i ) );
220
221 for( const types::TableCell& protoCell : table.cells() )
222 {
223 PCB_TABLECELL* cell = new PCB_TABLECELL( this );
224
225 if( !cell->Deserialize( protoCell ) )
226 {
227 // Since cells are positional, we must add something to the table. Probably better
228 // to add a new, empy cell than a partially deserialized who-knows-what.
229 delete cell;
230 cell = new PCB_TABLECELL( this );
231 }
232
233 AddCell( cell );
234 }
235
236 int rowCount = m_colCount > 0 ? static_cast<int>( m_cells.size() ) / m_colCount : 0;
237
238 for( int i = 0; i < table.row_heights_size() && i < rowCount; ++i )
239 SetRowHeight( i, table.row_heights( i ) );
240
241 m_strokeExternal = table.external_border() == types::TSM_ENABLED;
242 m_StrokeHeaderSeparator = table.header_separator() == types::TSM_ENABLED;
243
244 if( table.has_border_stroke() )
246
247 m_strokeRows = table.row_separators() == types::TSM_ENABLED;
248 m_strokeColumns = table.column_separators() == types::TSM_ENABLED;
249
250 if( table.has_separators_stroke() )
252
253 Normalize();
254
255 return true;
256}
257
258
260{
261 wxCHECK_RET( aImage != nullptr && aImage->Type() == Type(), wxT( "Cannot swap data with invalid table." ) );
262
263 PCB_TABLE* table = static_cast<PCB_TABLE*>( aImage );
264
265 std::swap( m_layer, table->m_layer );
266 std::swap( m_isLocked, table->m_isLocked );
267
268 std::swap( m_strokeExternal, table->m_strokeExternal );
269 std::swap( m_StrokeHeaderSeparator, table->m_StrokeHeaderSeparator );
270 std::swap( m_borderStroke, table->m_borderStroke );
271 std::swap( m_strokeRows, table->m_strokeRows );
272 std::swap( m_strokeColumns, table->m_strokeColumns );
273 std::swap( m_separatorsStroke, table->m_separatorsStroke );
274
275 std::swap( m_colCount, table->m_colCount );
276 std::swap( m_colWidths, table->m_colWidths );
277 std::swap( m_rowHeights, table->m_rowHeights );
278
279 std::swap( m_cells, table->m_cells );
280
281 for( PCB_TABLECELL* cell : m_cells )
282 cell->SetParent( this );
283
284 for( PCB_TABLECELL* cell : table->m_cells )
285 cell->SetParent( table );
286
287 std::swap( m_customProperties, table->m_customProperties );
288}
289
290
291void PCB_TABLE::ResizeCells( int aRows, int aCols )
292{
293 const size_t wanted = static_cast<size_t>( aRows ) * static_cast<size_t>( aCols );
294
295 m_colCount = aCols;
296
297 while( m_cells.size() > wanted )
298 {
299 delete m_cells.back();
300 m_cells.pop_back();
301 }
302
303 while( m_cells.size() < wanted )
304 AddCell( new PCB_TABLECELL( this ) );
305}
306
307
309{
310 m_layer = aLayer;
311
312 for( PCB_TABLECELL* cell : m_cells )
313 cell->SetLayer( aLayer );
314}
315
316
318{
319 Move( aPos - GetPosition() );
320}
321
322
324{
325 if( m_cells.empty() )
326 return VECTOR2I( 0, 0 ); // Return origin if table has no cells
327
328 return m_cells[0]->GetPosition();
329}
330
331
333{
334 VECTOR2I tableSize;
335
336 for( int ii = 0; ii < GetColCount(); ++ii )
337 tableSize.x += GetColWidth( ii );
338
339 for( int ii = 0; ii < GetRowCount(); ++ii )
340 tableSize.y += GetRowHeight( ii );
341
342 return GetPosition() + tableSize;
343}
344
345
347{
348 if( m_cells.empty() )
349 return;
350
351 EDA_ANGLE cellAngle = m_cells[0]->GetTextAngle();
352
353 BOX2I cell0BBox = m_cells[0]->GetBoundingBox();
354 VECTOR2I stableCenter = cell0BBox.GetCenter();
355
356 int cell0Width = m_colWidths[0];
357 int cell0Height = m_rowHeights[0];
358
359 if( m_cells[0]->GetColSpan() > 1 )
360 {
361 for( int ii = 1; ii < m_cells[0]->GetColSpan(); ++ii )
362 cell0Width += m_colWidths[ii];
363 }
364
365 if( m_cells[0]->GetRowSpan() > 1 )
366 {
367 for( int ii = 1; ii < m_cells[0]->GetRowSpan(); ++ii )
368 cell0Height += m_rowHeights[ii];
369 }
370
371 VECTOR2I localCell0Center( cell0Width / 2, cell0Height / 2 );
372 RotatePoint( localCell0Center, cellAngle );
373
374 if( cellAngle != ANGLE_0 )
375 {
376 for( PCB_TABLECELL* cell : m_cells )
377 cell->Rotate( stableCenter, -cellAngle );
378 }
379
380 VECTOR2I unrotatedOrigin = stableCenter - VECTOR2I( cell0Width / 2, cell0Height / 2 );
381
382 int y = unrotatedOrigin.y;
383
384 for( int row = 0; row < GetRowCount(); ++row )
385 {
386 int x = unrotatedOrigin.x;
387 int rowHeight = m_rowHeights[row];
388
389 for( int col = 0; col < GetColCount(); ++col )
390 {
391 int colWidth = m_colWidths[col];
392
393 PCB_TABLECELL* cell = GetCell( row, col );
394
395 if( !cell )
396 continue;
397
398 int cellWidth = colWidth;
399 int cellHeight = rowHeight;
400
401 if( cell->GetColSpan() > 1 || cell->GetRowSpan() > 1 )
402 {
403 for( int ii = col + 1; ii < col + cell->GetColSpan(); ++ii )
404 cellWidth += m_colWidths[ii];
405
406 for( int ii = row + 1; ii < row + cell->GetRowSpan(); ++ii )
407 cellHeight += m_rowHeights[ii];
408 }
409
410 VECTOR2I pos( x, y );
411 VECTOR2I end( x + cellWidth, y + cellHeight );
412
413 if( cell->GetPosition() != pos )
414 {
415 cell->SetPosition( pos );
416 cell->ClearRenderCache();
417 }
418
419 if( cell->GetEnd() != end )
420 {
421 cell->SetEnd( end );
422 cell->ClearRenderCache();
423 }
424
425 x += colWidth;
426 }
427
428 y += rowHeight;
429 }
430
431 if( cellAngle != ANGLE_0 )
432 {
433 for( PCB_TABLECELL* cell : m_cells )
434 cell->Rotate( stableCenter, cellAngle );
435 }
436
437 BOX2I newCell0BBox = m_cells[0]->GetBoundingBox();
438 VECTOR2I newCenter = newCell0BBox.GetCenter();
439
440 if( newCenter != stableCenter )
441 {
442 VECTOR2I correction = stableCenter - newCenter;
443
444 for( PCB_TABLECELL* cell : m_cells )
445 cell->Move( correction );
446 }
447}
448
449
451{
452 std::vector<std::vector<BOX2I>> extents;
453
454 for( int row = 0; row < GetRowCount(); ++row )
455 {
456 extents.push_back( std::vector<BOX2I>() );
457
458 for( int col = 0; col < GetColCount(); ++col )
459 {
460 PCB_TABLECELL* cell = GetCell( row, col );
461 SHAPE_POLY_SET textPoly;
462 cell->TransformTextToPolySet( textPoly, 0, ARC_LOW_DEF, ERROR_INSIDE );
463
464 // Measured in the cell's own frame, or a rotated table swaps its widths and heights
465 textPoly.Rotate( -cell->GetDrawRotation(), cell->GetDrawPos() );
466 extents[row].push_back( textPoly.BBox() );
467 }
468 }
469
470 for( int col = 0; col < GetColCount(); ++col )
471 {
472 int colWidth = 0;
473
474 for( int row = 0; row < GetRowCount(); ++row )
475 {
476 PCB_TABLECELL* cell = GetCell( row, col );
477 int margins = cell->GetMarginLeft() + cell->GetMarginRight();
478 colWidth = std::max<int>( colWidth, extents[row][col].GetWidth() + ( margins * 1.5 ) );
479 }
480
481 SetColWidth( col, colWidth );
482 }
483
484 std::vector<int> needed;
485
486 for( int row = 0; row < GetRowCount(); ++row )
487 {
488 int rowHeight = 0;
489
490 for( int col = 0; col < GetColCount(); ++col )
491 {
492 PCB_TABLECELL* cell = GetCell( row, col );
493 int margins = cell->GetMarginTop() + cell->GetMarginBottom();
494 rowHeight = std::max( rowHeight, (int) extents[row][col].GetHeight() + margins );
495 }
496
497 needed.push_back( rowHeight );
498 }
499
500 setAutosizedRowHeights( needed );
501 Normalize();
502}
503
504
505void PCB_TABLE::setAutosizedRowHeights( const std::vector<int>& aNeeded )
506{
507 for( int row = 0; row < static_cast<int>( aNeeded.size() ); ++row )
508 SetRowHeight( row, aNeeded[row] );
509}
510
511
512void PCB_TABLE::Move( const VECTOR2I& aMoveVector )
513{
514 for( PCB_TABLECELL* cell : m_cells )
515 cell->Move( aMoveVector );
516}
517
518
519void PCB_TABLE::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
520{
521 if( GetCells().empty() )
522 return;
523
524 for( PCB_TABLECELL* cell : m_cells )
525 cell->Rotate( aRotCentre, aAngle );
526
527 Normalize();
528}
529
530
532{
533 for( PCB_TABLECELL* cell : m_cells )
534 cell->OnFootprintTransformed();
535}
536
537
538void PCB_TABLE::OnFootprintRescaled( double aRatioX, double aRatioY, double aLinearFactor, const VECTOR2I& aAnchor,
539 const EDA_ANGLE& aParentRotate )
540{
541 for( PCB_TABLECELL* cell : m_cells )
542 cell->OnFootprintRescaled( aRatioX, aRatioY, aLinearFactor, aAnchor, aParentRotate );
543}
544
545
546static void mirrorCellColumns( std::vector<PCB_TABLECELL*>& aCells, int aRowCount, int aColCount )
547{
548 const std::vector<PCB_TABLECELL*> oldCells = aCells;
549
550 for( int row = 0; row < aRowCount; ++row )
551 {
552 const int rowOffset = row * aColCount;
553
554 for( int col = 0; col < aColCount; )
555 {
556 const int span = std::clamp( oldCells[rowOffset + col]->GetColSpan(), 1, aColCount - col );
557
558 for( int ii = 0; ii < span; ++ii )
559 aCells[rowOffset + aColCount - col - span + ii] = oldCells[rowOffset + col + ii];
560
561 col += span;
562 }
563 }
564}
565
566
567void PCB_TABLE::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
568{
569 // FP-child path keeps cells in lib frame, the standalone path below
570 // would corrupt them because FOOTPRINT::Flip zeroes the FP rotation.
571 if( GetParentFootprint() )
572 {
573 for( PCB_TABLECELL* cell : m_cells )
574 cell->Flip( aCentre, aFlipDirection );
575
576 // Flipping a cell also turns its text 180 degrees, so in the frame the table reads in
577 // it always comes out mirrored left to right.
579
580 std::map<int, int> newColWidths;
581
582 for( int col = 0; col < GetColCount(); ++col )
583 newColWidths[col] = m_colWidths[GetColCount() - 1 - col];
584
585 m_colWidths = std::move( newColWidths );
586
588 return;
589 }
590
591 BOX2I originalBBox = GetBoundingBox();
592
593 VECTOR2I targetPos;
594
595 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
596 {
597 targetPos.x = 2 * aCentre.x - originalBBox.GetRight();
598 targetPos.y = originalBBox.GetTop();
599 }
600 else
601 {
602 targetPos.x = originalBBox.GetLeft();
603 targetPos.y = 2 * aCentre.y - originalBBox.GetBottom();
604 }
605
606 EDA_ANGLE originalAngle = m_cells[0]->GetTextAngle();
607
608 if( originalAngle != ANGLE_0 )
609 Rotate( GetPosition(), -originalAngle );
610
611 VECTOR2I tableOrigin = GetPosition();
612
613 for( PCB_TABLECELL* cell : m_cells )
614 cell->Flip( tableOrigin, aFlipDirection );
615
616 // Flipping a cell turns its text 180 degrees and the grid is laid out in the frame the
617 // cells read in, so that turn reverses the rows already. Only the columns are left.
619
620 std::map<int, int> newColWidths;
621
622 for( int col = 0; col < GetColCount(); ++col )
623 newColWidths[col] = m_colWidths[GetColCount() - 1 - col];
624
625 m_colWidths = std::move( newColWidths );
626
628 Normalize();
629
630 if( originalAngle != ANGLE_0 )
631 Rotate( GetPosition(), -originalAngle );
632
633 BOX2I newBBox = GetBoundingBox();
634 Move( targetPos - newBBox.GetPosition() );
635}
636
637
638void PCB_TABLE::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
639{
640 // Mirror is Flip with the layer restored. TOP_BOTTOM needs a 180 deg pre-rotation
641 // because rotate-then-LR-flip equals TB-flip.
642 PCB_LAYER_ID origLayer = GetLayer();
643 std::map<PCB_TABLECELL*, PCB_LAYER_ID> origCellLayers;
644 std::map<PCB_TABLECELL*, bool> origMirrorSettings;
645
646 for( PCB_TABLECELL* cell : m_cells )
647 {
648 origCellLayers[cell] = cell->GetLayer();
649 origMirrorSettings[cell] = cell->IsMirrored();
650 }
651
652 if( aFlipDirection == FLIP_DIRECTION::TOP_BOTTOM )
653 Rotate( aCentre, ANGLE_180 );
654
656
657 SetLayer( origLayer );
658
659 for( PCB_TABLECELL* cell : m_cells )
660 {
661 cell->SetLayer( origCellLayers[cell] );
662 cell->SetMirrored( origMirrorSettings[cell] );
663 }
664}
665
666
667void PCB_TABLE::RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const
668{
669 for( PCB_TABLECELL* cell : m_cells )
670 {
671 aFunction( cell );
672
673 if( aMode == RECURSE_MODE::RECURSE )
674 cell->RunOnChildren( aFunction, aMode );
675 }
676}
677
678
680{
681 BOX2I bbox;
682
683 for( PCB_TABLECELL* cell : m_cells )
684 bbox.Merge( cell->GetBoundingBox() );
685
686 if( m_strokeExternal )
687 bbox.Inflate( m_borderStroke.GetWidth() / 2 );
688
689 return bbox;
690}
691
692
693double PCB_TABLE::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
694{
695 // Hide the locked shadow when the table's own layer is not shown
696 if( aLayer == LAYER_LOCKED_ITEM_SHADOW && !aView->IsLayerVisibleCached( m_layer ) )
697 return LOD_HIDE;
698
699 return LOD_SHOW;
700}
701
702
703void PCB_TABLE::DrawBorders( const std::function<void( const VECTOR2I& aPt1, const VECTOR2I& aPt2,
704 const STROKE_PARAMS& aStroke )>& aCallback ) const
705{
706 if( m_cells.empty() ) // Shouldn't be possible....
707 return;
708
709 EDA_ANGLE drawAngle = GetCell( 0, 0 )->GetDrawRotation();
710 std::vector<VECTOR2I> topLeft = GetCell( 0, 0 )->GetCornersInSequence( drawAngle );
711 std::vector<VECTOR2I> bottomLeft = GetCell( GetRowCount() - 1, 0 )->GetCornersInSequence( drawAngle );
712 std::vector<VECTOR2I> topRight = GetCell( 0, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
713 std::vector<VECTOR2I> botRight = GetCell( GetRowCount() - 1, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
714 STROKE_PARAMS stroke;
715
716 for( int col = 0; col < GetColCount() - 1; ++col )
717 {
718 for( int row = 0; row < GetRowCount(); ++row )
719 {
720 if( row == 0 && StrokeHeaderSeparator() )
721 stroke = GetBorderStroke();
722 else if( StrokeColumns() )
723 stroke = GetSeparatorsStroke();
724 else
725 continue;
726
727 PCB_TABLECELL* cell = GetCell( row, col );
728
729 if( cell->GetColSpan() == 0 )
730 continue;
731
732 if( col + cell->GetColSpan() == GetColCount() )
733 continue;
734
735 std::vector<VECTOR2I> corners = cell->GetCornersInSequence( drawAngle );
736
737 if( corners.size() == 4 )
738 aCallback( corners[1], corners[2], stroke );
739 }
740 }
741
742 for( int row = 0; row < GetRowCount() - 1; ++row )
743 {
744 if( row == 0 && StrokeHeaderSeparator() )
745 stroke = GetBorderStroke();
746 else if( StrokeRows() )
747 stroke = GetSeparatorsStroke();
748 else
749 continue;
750
751 for( int col = 0; col < GetColCount(); ++col )
752 {
753 PCB_TABLECELL* cell = GetCell( row, col );
754
755 if( cell->GetRowSpan() == 0 )
756 continue;
757
758 if( row + cell->GetRowSpan() == GetRowCount() )
759 continue;
760
761 std::vector<VECTOR2I> corners = cell->GetCornersInSequence( drawAngle );
762
763 if( corners.size() == 4 )
764 aCallback( corners[2], corners[3], stroke );
765 }
766 }
767
768 if( StrokeExternal() && GetBorderStroke().GetWidth() >= 0 )
769 {
770 aCallback( topLeft[0], topRight[1], GetBorderStroke() );
771 aCallback( topRight[1], botRight[2], GetBorderStroke() );
772 aCallback( botRight[2], bottomLeft[3], GetBorderStroke() );
773 aCallback( bottomLeft[3], topLeft[0], GetBorderStroke() );
774 }
775}
776
777
779{
780 EDA_ANGLE angle = GetCell( 0, 0 )->GetDrawRotation();
781 std::vector<VECTOR2I> topLeft = GetCell( 0, 0 )->GetCornersInSequence( angle );
782 std::vector<VECTOR2I> bottomLeft = GetCell( GetRowCount() - 1, 0 )->GetCornersInSequence( angle );
783 std::vector<VECTOR2I> topRight = GetCell( 0, GetColCount() - 1 )->GetCornersInSequence( angle );
784 std::vector<VECTOR2I> bottomRight = GetCell( GetRowCount() - 1, GetColCount() - 1 )->GetCornersInSequence( angle );
785
786 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
787
788 std::vector<VECTOR2I> pts;
789
790 pts.emplace_back( topLeft[3] );
791 pts.emplace_back( topRight[2] );
792 pts.emplace_back( bottomRight[2] );
793 pts.emplace_back( bottomLeft[3] );
794
795 shape->AddShape( new SHAPE_SIMPLE( pts ) );
796
798 [&shape]( const VECTOR2I& ptA, const VECTOR2I& ptB, const STROKE_PARAMS& stroke )
799 {
800 shape->AddShape( new SHAPE_SEGMENT( ptA, ptB, stroke.GetWidth() ) );
801 } );
802
803 return shape;
804}
805
806
807void PCB_TABLE::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError,
808 ERROR_LOC aErrorLoc, bool aIgnoreLineWidth ) const
809{
810 int gap = aClearance;
811
812 if( StrokeColumns() || StrokeRows() )
813 gap = std::max( gap, aClearance + GetSeparatorsStroke().GetWidth() / 2 );
814
816 gap = std::max( gap, aClearance + GetBorderStroke().GetWidth() / 2 );
817
818 for( PCB_TABLECELL* cell : m_cells )
819 cell->TransformShapeToPolygon( aBuffer, aLayer, gap, aMaxError, aErrorLoc, false );
820}
821
822
824 KIGFX::RENDER_SETTINGS* aRenderSettings ) const
825{
826 // Convert graphic items (segments and texts) to a set of polygonal shapes
827 // aRenderSettings is used to draw lines when line style != LINE_STYLE::SOLID, so
828 // if nullptr line style will be ignored
830 [&aBuffer, aMaxError, aErrorLoc, aRenderSettings]( const VECTOR2I& ptA, const VECTOR2I& ptB,
831 const STROKE_PARAMS& stroke )
832 {
833 int lineWidth = stroke.GetWidth();
834 LINE_STYLE lineStyle = stroke.GetLineStyle();
835
836 if( lineStyle <= LINE_STYLE::FIRST_TYPE || aRenderSettings == nullptr )
837 TransformOvalToPolygon( aBuffer, ptA, ptB, lineWidth, aMaxError, aErrorLoc );
838 else
839 {
840 SHAPE_SEGMENT seg( ptA, ptB );
841 KIGFX::PCB_RENDER_SETTINGS defaultRenderSettings;
842
843 KIGFX::RENDER_SETTINGS* currSettings = aRenderSettings;
844
845 if( currSettings == nullptr )
846 currSettings = &defaultRenderSettings;
847
848 STROKE_PARAMS::Stroke( &seg, lineStyle, lineWidth, currSettings,
849 [&]( VECTOR2I a, VECTOR2I b )
850 {
851 if( a == b )
852 TransformCircleToPolygon( aBuffer, a, lineWidth / 2, aMaxError, aErrorLoc );
853 else
854 TransformOvalToPolygon( aBuffer, a + 1, b, lineWidth, aMaxError, aErrorLoc );
855 } );
856 }
857 } );
858
859 for( PCB_TABLECELL* cell : m_cells )
860 {
861 cell->TransformTextToPolySet( aBuffer, 0, aMaxError, ERROR_INSIDE );
862 }
863}
864
865
867 int aClearance, int aMaxError, ERROR_LOC aErrorLoc,
868 KIGFX::RENDER_SETTINGS* aRenderSettings ) const
869{
870 if( aClearance <= 0 )
871 TransformGraphicItemsToPolySet( aBuffer, aMaxError, aErrorLoc, aRenderSettings );
872 else
873 {
874 SHAPE_POLY_SET tmp;
875 TransformGraphicItemsToPolySet( tmp, aMaxError, aErrorLoc, aRenderSettings );
876 tmp.Inflate( aClearance, CORNER_STRATEGY::CHAMFER_ALL_CORNERS, aMaxError );
877 aBuffer.Append( tmp );
878 }
879}
880
881
882INSPECT_RESULT PCB_TABLE::Visit( INSPECTOR aInspector, void* aTestData, const std::vector<KICAD_T>& aScanTypes )
883{
884 for( KICAD_T scanType : aScanTypes )
885 {
886 if( scanType == PCB_TABLE_T )
887 {
888 if( INSPECT_RESULT::QUIT == aInspector( this, aTestData ) )
890 }
891
892 if( scanType == PCB_TABLECELL_T )
893 {
894 for( PCB_TABLECELL* cell : m_cells )
895 {
896 if( INSPECT_RESULT::QUIT == aInspector( cell, (void*) this ) )
898 }
899 }
900 }
901
903}
904
905
906wxString PCB_TABLE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
907{
908 return wxString::Format( _( "%d column table" ), m_colCount );
909}
910
911
913{
914 return BITMAPS::table;
915}
916
917
918bool PCB_TABLE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
919{
921
922 rect.Inflate( aAccuracy );
923
924 return rect.Contains( aPosition );
925}
926
927
928bool PCB_TABLE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
929{
930 BOX2I rect = aRect;
931
932 rect.Inflate( aAccuracy );
933
934 if( aContained )
935 return rect.Contains( GetBoundingBox() );
936
937 return rect.Intersects( GetBoundingBox() );
938}
939
940
941bool PCB_TABLE::HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
942{
943 return KIGEOM::ShapeHitTest( aPoly, *GetEffectiveShape(), aContained );
944}
945
946
947void PCB_TABLE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
948{
949 // Don't use GetShownText() here; we want to show the user the variable references
950 aList.emplace_back( _( "Table" ), wxString::Format( _( "%d Columns" ), m_colCount ) );
951}
952
953
954int PCB_TABLE::Compare( const PCB_TABLE* aTable, const PCB_TABLE* aOther )
955{
956 int diff;
957
958 if( ( diff = (int) aTable->GetCells().size() - (int) aOther->GetCells().size() ) != 0 )
959 return diff;
960
961 if( ( diff = aTable->GetColCount() - aOther->GetColCount() ) != 0 )
962 return diff;
963
964 for( int col = 0; col < aTable->GetColCount(); ++col )
965 {
966 if( ( diff = aTable->GetColWidth( col ) - aOther->GetColWidth( col ) ) != 0 )
967 return diff;
968 }
969
970 if( ( diff = aTable->GetRowCount() - aOther->GetRowCount() ) != 0 )
971 return diff;
972
973 for( int row = 0; row < aTable->GetRowCount(); ++row )
974 {
975 if( ( diff = aTable->GetRowHeight( row ) - aOther->GetRowHeight( row ) ) != 0 )
976 return diff;
977 }
978
979 for( int row = 0; row < aTable->GetRowCount(); ++row )
980 {
981 for( int col = 0; col < aTable->GetColCount(); ++col )
982 {
983 PCB_TABLECELL* cell = aTable->GetCell( row, col );
984 PCB_TABLECELL* other = aOther->GetCell( row, col );
985
986 if( ( diff = cell->PCB_SHAPE::Compare( other ) ) != 0 )
987 return diff;
988
989 if( ( diff = cell->EDA_TEXT::Compare( other ) ) != 0 )
990 return diff;
991 }
992 }
993
994 return 0;
995}
996
997
998bool PCB_TABLE::operator==( const BOARD_ITEM& aBoardItem ) const
999{
1000 if( Type() != aBoardItem.Type() )
1001 return false;
1002
1003 const PCB_TABLE& other = static_cast<const PCB_TABLE&>( aBoardItem );
1004
1005 return *this == other;
1006}
1007
1008
1009bool PCB_TABLE::operator==( const PCB_TABLE& aOther ) const
1010{
1011 if( m_cells.size() != aOther.m_cells.size() )
1012 return false;
1013
1014 if( m_strokeExternal != aOther.m_strokeExternal )
1015 return false;
1016
1018 return false;
1019
1020 if( m_borderStroke != aOther.m_borderStroke )
1021 return false;
1022
1023 if( m_strokeRows != aOther.m_strokeRows )
1024 return false;
1025
1026 if( m_strokeColumns != aOther.m_strokeColumns )
1027 return false;
1028
1030 return false;
1031
1032 if( m_colWidths != aOther.m_colWidths )
1033 return false;
1034
1035 if( m_rowHeights != aOther.m_rowHeights )
1036 return false;
1037
1038 for( int ii = 0; ii < (int) m_cells.size(); ++ii )
1039 {
1040 if( !( *m_cells[ii] == *aOther.m_cells[ii] ) )
1041 return false;
1042 }
1043
1044 return true;
1045}
1046
1047
1048double PCB_TABLE::Similarity( const BOARD_ITEM& aOther ) const
1049{
1050 if( aOther.Type() != Type() )
1051 return 0.0;
1052
1053 const PCB_TABLE& other = static_cast<const PCB_TABLE&>( aOther );
1054
1055 if( m_cells.size() != other.m_cells.size() )
1056 return 0.1;
1057
1058 double similarity = 1.0;
1059
1060 if( m_strokeExternal != other.m_strokeExternal )
1061 similarity *= 0.9;
1062
1064 similarity *= 0.9;
1065
1066 if( m_borderStroke != other.m_borderStroke )
1067 similarity *= 0.9;
1068
1069 if( m_strokeRows != other.m_strokeRows )
1070 similarity *= 0.9;
1071
1072 if( m_strokeColumns != other.m_strokeColumns )
1073 similarity *= 0.9;
1074
1076 similarity *= 0.9;
1077
1078 if( m_colWidths != other.m_colWidths )
1079 similarity *= 0.9;
1080
1081 if( m_rowHeights != other.m_rowHeights )
1082 similarity *= 0.9;
1083
1084 for( int ii = 0; ii < (int) m_cells.size(); ++ii )
1085 similarity *= m_cells[ii]->Similarity( *other.m_cells[ii] );
1086
1087 return similarity;
1088}
1089
1090
1091static struct PCB_TABLE_DESC
1092{
1094 {
1096
1097 if( lineStyleEnum.Choices().GetCount() == 0 )
1098 {
1099 lineStyleEnum.Map( LINE_STYLE::SOLID, _HKI( "Solid" ) )
1100 .Map( LINE_STYLE::DASH, _HKI( "Dashed" ) )
1101 .Map( LINE_STYLE::DOT, _HKI( "Dotted" ) )
1102 .Map( LINE_STYLE::DASHDOT, _HKI( "Dash-Dot" ) )
1103 .Map( LINE_STYLE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
1104 }
1105
1108
1113
1114 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Start X" ),
1117 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Start Y" ),
1120
1121 const wxString tableProps = _( "Table Properties" );
1122
1123 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "External Border" ),
1125 tableProps )
1126 .SetIsCopyable();
1127
1128 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Header Border" ),
1130 tableProps )
1131 .SetIsCopyable();
1132
1133 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Border Width" ),
1136 tableProps )
1137 .SetIsCopyable();
1138
1139 propMgr.AddProperty( new PROPERTY_ENUM<PCB_TABLE, LINE_STYLE>( _HKI( "Border Style" ),
1141 tableProps )
1142 .SetIsCopyable();
1143
1144 propMgr.AddProperty( new PROPERTY<PCB_TABLE, COLOR4D>( _HKI( "Border Color" ),
1146 tableProps )
1147 .SetIsCopyable();
1148
1149 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Row Separators" ),
1151 tableProps )
1152 .SetIsCopyable();
1153
1154 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Cell Separators" ),
1156 tableProps )
1157 .SetIsCopyable();
1158
1159 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Separators Width" ),
1162 tableProps )
1163 .SetIsCopyable();
1164
1165 propMgr.AddProperty( new PROPERTY_ENUM<PCB_TABLE, LINE_STYLE>( _HKI( "Separators Style" ),
1167 tableProps )
1168 .SetIsCopyable();
1169
1170 propMgr.AddProperty( new PROPERTY<PCB_TABLE, COLOR4D>( _HKI( "Separators Color" ),
1172 tableProps )
1173 .SetIsCopyable();
1174 }
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
Definition api_enums.cpp:56
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:917
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:99
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:101
void SetUuidDirect(const KIID &aUuid)
Raw UUID assignment.
void SetLocked(bool aLocked) override
Definition board_item.h:441
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:625
bool m_isLocked
Definition board_item.h:627
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:279
void ResetUuid()
Definition board_item.h:295
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
void CacheChildrenById(const BOARD_ITEM &aParent)
Definition board.h:1755
void UncacheChildrenById(const BOARD_ITEM &aParent)
Definition board.h:1761
constexpr const Vec & GetPosition() const
Definition box2.h:214
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:556
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition box2.h:597
constexpr const Vec GetCenter() const
Definition box2.h:233
constexpr coord_type GetLeft() const
Definition box2.h:231
constexpr coord_type GetRight() const
Definition box2.h:220
constexpr coord_type GetTop() const
Definition box2.h:232
constexpr coord_type GetBottom() const
Definition box2.h:225
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:334
virtual EDA_ANGLE GetDrawRotation() const
Definition eda_text.h:425
virtual void ClearRenderCache()
Definition eda_text.cpp:670
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition property.h:817
static ENUM_MAP< T > & Instance()
Definition property.h:811
wxPGChoices & Choices()
Definition property.h:862
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:343
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:348
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:345
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:341
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.
virtual void setAutosizedRowHeights(const std::vector< int > &aNeeded)
Give each row the height Autosize measured its text to need, margins included.
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:338
STROKE_PARAMS m_borderStroke
Definition pcb_table.h:340
bool m_strokeColumns
Definition pcb_table.h:342
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:346
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:339
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:347
int GetMarginBottom() const
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).
VECTOR2I GetDrawPos() const override
int GetMarginLeft() const
std::vector< VECTOR2I > GetCornersInSequence(EDA_ANGLE angle) const override
int GetMarginRight() const
int GetMarginTop() const
PROPERTY_BASE & SetIsCopyable(bool aIsCopyable=true)
Definition property.h:388
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 Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
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:472
static constexpr EDA_ANGLE ANGLE_180
Definition eda_angle.h:476
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:26
@ LEFT_RIGHT
Flip left to right (around the Y axis)
Definition mirror.h:27
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
Definition mirror.h:28
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 void mirrorCellColumns(std::vector< PCB_TABLECELL * > &aCells, int aRowCount, int aColCount)
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.
const std::string table
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
static PIECE rect(double aLeft, double aTop, double aRight, double aBottom, bool aMixed=false)