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