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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <pcb_edit_frame.h>
25#include <footprint.h>
26#include <pcb_table.h>
27#include <board.h>
33#include <pcb_painter.h> // for PCB_RENDER_SETTINGS
34
35
36PCB_TABLE::PCB_TABLE( BOARD_ITEM* aParent, int aLineWidth ) :
38 m_strokeExternal( true ),
41 m_strokeRows( true ),
42 m_strokeColumns( true ),
44 m_colCount( 0 )
45{
46}
47
48
66
67
69{
70 // We own our cells; delete them
71 for( PCB_TABLECELL* cell : m_cells )
72 delete cell;
73}
74
75
77{
78 wxCHECK_RET( aImage != nullptr && aImage->Type() == PCB_TABLE_T, wxT( "Cannot swap data with invalid table." ) );
79
80 PCB_TABLE* table = static_cast<PCB_TABLE*>( aImage );
81
82 std::swap( m_layer, table->m_layer );
83 std::swap( m_isLocked, table->m_isLocked );
84
85 std::swap( m_strokeExternal, table->m_strokeExternal );
86 std::swap( m_StrokeHeaderSeparator, table->m_StrokeHeaderSeparator );
87 std::swap( m_borderStroke, table->m_borderStroke );
88 std::swap( m_strokeRows, table->m_strokeRows );
89 std::swap( m_strokeColumns, table->m_strokeColumns );
90 std::swap( m_separatorsStroke, table->m_separatorsStroke );
91
92 std::swap( m_colCount, table->m_colCount );
93 std::swap( m_colWidths, table->m_colWidths );
94 std::swap( m_rowHeights, table->m_rowHeights );
95
96 std::swap( m_cells, table->m_cells );
97
98 for( PCB_TABLECELL* cell : m_cells )
99 cell->SetParent( this );
100
101 for( PCB_TABLECELL* cell : table->m_cells )
102 cell->SetParent( table );
103}
104
105
107{
108 Move( aPos - GetPosition() );
109}
110
111
113{
114 if( m_cells.empty() )
115 return VECTOR2I( 0, 0 ); // Return origin if table has no cells
116
117 return m_cells[0]->GetPosition();
118}
119
120
122{
123 VECTOR2I tableSize;
124
125 for( int ii = 0; ii < GetColCount(); ++ii )
126 tableSize.x += GetColWidth( ii );
127
128 for( int ii = 0; ii < GetRowCount(); ++ii )
129 tableSize.y += GetRowHeight( ii );
130
131 return GetPosition() + tableSize;
132}
133
134
136{
137 int y = GetPosition().y;
138
139 for( int row = 0; row < GetRowCount(); ++row )
140 {
141 int x = GetPosition().x;
142 int rowHeight = m_rowHeights[row];
143
144 for( int col = 0; col < GetColCount(); ++col )
145 {
146 int colWidth = m_colWidths[col];
147
148 PCB_TABLECELL* cell = GetCell( row, col );
149
150 if( !cell )
151 continue; // Skip if cell doesn't exist (shouldn't happen, but be defensive)
152
153 VECTOR2I pos( x, y );
154
155 RotatePoint( pos, GetPosition(), cell->GetTextAngle() );
156
157 if( cell->GetPosition() != pos )
158 {
159 cell->SetPosition( pos );
160 cell->ClearRenderCache();
161 }
162
163 VECTOR2I end = VECTOR2I( x + colWidth, y + rowHeight );
164
165 if( cell->GetColSpan() > 1 || cell->GetRowSpan() > 1 )
166 {
167 for( int ii = col + 1; ii < col + cell->GetColSpan(); ++ii )
168 end.x += m_colWidths[ii];
169
170 for( int ii = row + 1; ii < row + cell->GetRowSpan(); ++ii )
171 end.y += m_rowHeights[ii];
172 }
173
175
176 if( cell->GetEnd() != end )
177 {
178 cell->SetEnd( end );
179 cell->ClearRenderCache();
180 }
181
182 x += colWidth;
183 }
184
185 y += rowHeight;
186 }
187}
188
189
191{
192 std::vector<std::vector<BOX2I>> extents;
193
194 for( int row = 0; row < GetRowCount(); ++row )
195 {
196 extents.push_back( std::vector<BOX2I>() );
197
198 for( int col = 0; col < GetColCount(); ++col )
199 {
200 SHAPE_POLY_SET textPoly;
201 GetCell( row, col )->TransformTextToPolySet( textPoly, 0, ARC_LOW_DEF, ERROR_INSIDE );
202 extents[row].push_back( textPoly.BBox() );
203 }
204 }
205
206 for( int col = 0; col < GetColCount(); ++col )
207 {
208 int colWidth = 0;
209
210 for( int row = 0; row < GetRowCount(); ++row )
211 {
212 PCB_TABLECELL* cell = GetCell( row, col );
213 int margins = cell->GetMarginLeft() + cell->GetMarginRight();
214 colWidth = std::max<int>( colWidth, extents[row][col].GetWidth() + ( margins * 1.5 ) );
215 }
216
217 SetColWidth( col, colWidth );
218 }
219
220 for( int row = 0; row < GetRowCount(); ++row )
221 {
222 int rowHeight = 0;
223
224 for( int col = 0; col < GetColCount(); ++col )
225 {
226 PCB_TABLECELL* cell = GetCell( row, col );
227 int margins = cell->GetMarginLeft() + cell->GetMarginRight();
228 rowHeight = std::max( rowHeight, (int) extents[row][col].GetHeight() + margins );
229 }
230
231 SetRowHeight( row, rowHeight );
232 }
233
234 Normalize();
235}
236
237
238void PCB_TABLE::Move( const VECTOR2I& aMoveVector )
239{
240 for( PCB_TABLECELL* cell : m_cells )
241 cell->Move( aMoveVector );
242}
243
244
245void PCB_TABLE::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
246{
247 if( GetCells().empty() )
248 return;
249
250 for( PCB_TABLECELL* cell : m_cells )
251 cell->Rotate( aRotCentre, aAngle );
252
253 Normalize();
254}
255
256
257void PCB_TABLE::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
258{
259 if( aFlipDirection == FLIP_DIRECTION::TOP_BOTTOM )
260 {
262 Rotate( aCentre, EDA_ANGLE( 180, DEGREES_T ) );
263 return;
264 }
265
266 EDA_ANGLE originalAngle = m_cells[0]->GetTextAngle();
267
268 Rotate( aCentre, -originalAngle );
269 Normalize();
270
271 for( PCB_TABLECELL* cell : m_cells )
272 cell->Flip( aCentre, aFlipDirection );
273
274 std::vector<PCB_TABLECELL*> oldCells = m_cells;
275 int rowOffset = 0;
276
277 for( int row = 0; row < GetRowCount(); ++row )
278 {
279 for( int col = 0; col < GetColCount(); ++col )
280 m_cells[rowOffset + col] = oldCells[rowOffset + GetColCount() - 1 - col];
281
282 rowOffset += GetColCount();
283 }
284
285 VECTOR2I currentPos = GetPosition();
286
287 int firstWidth = m_colWidths.begin()->second;
288 VECTOR2I translationVector = VECTOR2I( firstWidth, 0 );
289
290 VECTOR2I position = currentPos - translationVector;
291 SetPosition( position );
292
293 std::map<int, int> newColWidths;
294 for( int col = 0; col < GetColCount(); ++col )
295 {
296 newColWidths[col] = m_colWidths[GetColCount() - 1 - col];
297 }
298
299 m_colWidths = std::move( newColWidths );
300
302 Normalize();
303
304 Rotate( aCentre, originalAngle );
305 Normalize();
306}
307
308
309void PCB_TABLE::RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const
310{
311 for( PCB_TABLECELL* cell : m_cells )
312 {
313 aFunction( cell );
314
315 if( aMode == RECURSE_MODE::RECURSE )
316 cell->RunOnChildren( aFunction, aMode );
317 }
318}
319
320
322{
323 // Note: a table with no cells is not allowed
324 BOX2I bbox = m_cells[0]->GetBoundingBox();
325
326 bbox.Merge( m_cells[m_cells.size() - 1]->GetBoundingBox() );
327
328 return bbox;
329}
330
331
332void PCB_TABLE::DrawBorders( const std::function<void( const VECTOR2I& aPt1, const VECTOR2I& aPt2,
333 const STROKE_PARAMS& aStroke )>& aCallback ) const
334{
335 EDA_ANGLE drawAngle = GetCell( 0, 0 )->GetDrawRotation();
336 std::vector<VECTOR2I> topLeft = GetCell( 0, 0 )->GetCornersInSequence( drawAngle );
337 std::vector<VECTOR2I> bottomLeft = GetCell( GetRowCount() - 1, 0 )->GetCornersInSequence( drawAngle );
338 std::vector<VECTOR2I> topRight = GetCell( 0, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
339 std::vector<VECTOR2I> bottomRight =
340 GetCell( GetRowCount() - 1, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
341 STROKE_PARAMS stroke;
342
343 for( int col = 0; col < GetColCount() - 1; ++col )
344 {
345 for( int row = 0; row < GetRowCount(); ++row )
346 {
347 if( row == 0 && StrokeHeaderSeparator() )
348 stroke = GetBorderStroke();
349 else if( StrokeColumns() )
350 stroke = GetSeparatorsStroke();
351 else
352 continue;
353
354 PCB_TABLECELL* cell = GetCell( row, col );
355
356 if( cell->GetColSpan() == 0 )
357 continue;
358
359 if( col + cell->GetColSpan() == GetColCount() )
360 continue;
361
362 std::vector<VECTOR2I> corners = cell->GetCornersInSequence( drawAngle );
363
364 if( corners.size() == 4 )
365 aCallback( corners[1], corners[2], stroke );
366 }
367 }
368
369 for( int row = 0; row < GetRowCount() - 1; ++row )
370 {
371 if( row == 0 && StrokeHeaderSeparator() )
372 stroke = GetBorderStroke();
373 else if( StrokeRows() )
374 stroke = GetSeparatorsStroke();
375 else
376 continue;
377
378 for( int col = 0; col < GetColCount(); ++col )
379 {
380 PCB_TABLECELL* cell = GetCell( row, col );
381
382 if( cell->GetRowSpan() == 0 )
383 continue;
384
385 if( row + cell->GetRowSpan() == GetRowCount() )
386 continue;
387
388 std::vector<VECTOR2I> corners = cell->GetCornersInSequence( drawAngle );
389
390 if( corners.size() == 4 )
391 aCallback( corners[2], corners[3], stroke );
392 }
393 }
394
395 if( StrokeExternal() && GetBorderStroke().GetWidth() >= 0 )
396 {
397 aCallback( topLeft[0], topRight[1], GetBorderStroke() );
398 aCallback( topRight[1], bottomRight[2], GetBorderStroke() );
399 aCallback( bottomRight[2], bottomLeft[3], GetBorderStroke() );
400 aCallback( bottomLeft[3], topLeft[0], GetBorderStroke() );
401 }
402}
403
404
405std::shared_ptr<SHAPE> PCB_TABLE::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
406{
407 EDA_ANGLE angle = GetCell( 0, 0 )->GetDrawRotation();
408 std::vector<VECTOR2I> topLeft = GetCell( 0, 0 )->GetCornersInSequence( angle );
409 std::vector<VECTOR2I> bottomLeft = GetCell( GetRowCount() - 1, 0 )->GetCornersInSequence( angle );
410 std::vector<VECTOR2I> topRight = GetCell( 0, GetColCount() - 1 )->GetCornersInSequence( angle );
411 std::vector<VECTOR2I> bottomRight = GetCell( GetRowCount() - 1, GetColCount() - 1 )->GetCornersInSequence( angle );
412
413 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
414
415 std::vector<VECTOR2I> pts;
416
417 pts.emplace_back( topLeft[3] );
418 pts.emplace_back( topRight[2] );
419 pts.emplace_back( bottomRight[2] );
420 pts.emplace_back( bottomLeft[3] );
421
422 shape->AddShape( new SHAPE_SIMPLE( pts ) );
423
425 [&shape]( const VECTOR2I& ptA, const VECTOR2I& ptB, const STROKE_PARAMS& stroke )
426 {
427 shape->AddShape( new SHAPE_SEGMENT( ptA, ptB, stroke.GetWidth() ) );
428 } );
429
430 return shape;
431}
432
433
434void PCB_TABLE::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError,
435 ERROR_LOC aErrorLoc, bool aIgnoreLineWidth ) const
436{
437 int gap = aClearance;
438
439 if( StrokeColumns() || StrokeRows() )
440 gap = std::max( gap, aClearance + GetSeparatorsStroke().GetWidth() / 2 );
441
443 gap = std::max( gap, aClearance + GetBorderStroke().GetWidth() / 2 );
444
445 for( PCB_TABLECELL* cell : m_cells )
446 cell->TransformShapeToPolygon( aBuffer, aLayer, gap, aMaxError, aErrorLoc, false );
447}
448
449
451 KIGFX::RENDER_SETTINGS* aRenderSettings ) const
452{
453 // Convert graphic items (segments and texts) to a set of polygonal shapes
454 // aRenderSettings is used to draw lines when line style != LINE_STYLE::SOLID, so
455 // if nullptr line style will be ignored
457 [&aBuffer, aMaxError, aErrorLoc, aRenderSettings]( const VECTOR2I& ptA, const VECTOR2I& ptB,
458 const STROKE_PARAMS& stroke )
459 {
460 int lineWidth = stroke.GetWidth();
461 LINE_STYLE lineStyle = stroke.GetLineStyle();
462
463 if( lineStyle <= LINE_STYLE::FIRST_TYPE || aRenderSettings == nullptr )
464 TransformOvalToPolygon( aBuffer, ptA, ptB, lineWidth, aMaxError, aErrorLoc );
465 else
466 {
467 SHAPE_SEGMENT seg( ptA, ptB );
468 KIGFX::PCB_RENDER_SETTINGS defaultRenderSettings;
469
470 KIGFX::RENDER_SETTINGS* currSettings = aRenderSettings;
471
472 if( currSettings == nullptr )
473 currSettings = &defaultRenderSettings;
474
475 STROKE_PARAMS::Stroke( &seg, lineStyle, lineWidth, currSettings,
476 [&]( VECTOR2I a, VECTOR2I b )
477 {
478 if( a == b )
479 TransformCircleToPolygon( aBuffer, a, lineWidth / 2, aMaxError, aErrorLoc );
480 else
481 TransformOvalToPolygon( aBuffer, a + 1, b, lineWidth, aMaxError, aErrorLoc );
482 } );
483 }
484 } );
485
486 for( PCB_TABLECELL* cell : m_cells )
487 {
488 cell->TransformTextToPolySet( aBuffer, 0, aMaxError, ERROR_INSIDE );
489 }
490}
491
492
494 int aClearance, int aMaxError, ERROR_LOC aErrorLoc,
495 KIGFX::RENDER_SETTINGS* aRenderSettings ) const
496{
497 if( aClearance <= 0 )
498 TransformGraphicItemsToPolySet( aBuffer, aMaxError, aErrorLoc, aRenderSettings );
499 else
500 {
501 SHAPE_POLY_SET tmp;
502 TransformGraphicItemsToPolySet( tmp, aMaxError, aErrorLoc, aRenderSettings );
503 tmp.Inflate( aClearance, CORNER_STRATEGY::CHAMFER_ALL_CORNERS, aMaxError );
504 aBuffer.Append( tmp );
505 }
506}
507
508
509INSPECT_RESULT PCB_TABLE::Visit( INSPECTOR aInspector, void* aTestData, const std::vector<KICAD_T>& aScanTypes )
510{
511 for( KICAD_T scanType : aScanTypes )
512 {
513 if( scanType == PCB_TABLE_T )
514 {
515 if( INSPECT_RESULT::QUIT == aInspector( this, aTestData ) )
517 }
518
519 if( scanType == PCB_TABLECELL_T )
520 {
521 for( PCB_TABLECELL* cell : m_cells )
522 {
523 if( INSPECT_RESULT::QUIT == aInspector( cell, (void*) this ) )
525 }
526 }
527 }
528
530}
531
532
533wxString PCB_TABLE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
534{
535 return wxString::Format( _( "%d column table" ), m_colCount );
536}
537
538
540{
541 return BITMAPS::table;
542}
543
544
545bool PCB_TABLE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
546{
547 BOX2I rect = GetBoundingBox();
548
549 rect.Inflate( aAccuracy );
550
551 return rect.Contains( aPosition );
552}
553
554
555bool PCB_TABLE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
556{
557 BOX2I rect = aRect;
558
559 rect.Inflate( aAccuracy );
560
561 if( aContained )
562 return rect.Contains( GetBoundingBox() );
563
564 return rect.Intersects( GetBoundingBox() );
565}
566
567
568bool PCB_TABLE::HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
569{
570 return KIGEOM::ShapeHitTest( aPoly, *GetEffectiveShape(), aContained );
571}
572
573
574void PCB_TABLE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
575{
576 // Don't use GetShownText() here; we want to show the user the variable references
577 aList.emplace_back( _( "Table" ), wxString::Format( _( "%d Columns" ), m_colCount ) );
578}
579
580
581int PCB_TABLE::Compare( const PCB_TABLE* aTable, const PCB_TABLE* aOther )
582{
583 int diff;
584
585 if( ( diff = (int) aTable->GetCells().size() - (int) aOther->GetCells().size() ) != 0 )
586 return diff;
587
588 if( ( diff = aTable->GetColCount() - aOther->GetColCount() ) != 0 )
589 return diff;
590
591 for( int col = 0; col < aTable->GetColCount(); ++col )
592 {
593 if( ( diff = aTable->GetColWidth( col ) - aOther->GetColWidth( col ) ) != 0 )
594 return diff;
595 }
596
597 for( int row = 0; row < aTable->GetRowCount(); ++row )
598 {
599 if( ( diff = aTable->GetRowHeight( row ) - aOther->GetRowHeight( row ) ) != 0 )
600 return diff;
601 }
602
603 for( int row = 0; row < aTable->GetRowCount(); ++row )
604 {
605 for( int col = 0; col < aTable->GetColCount(); ++col )
606 {
607 PCB_TABLECELL* cell = aTable->GetCell( row, col );
608 PCB_TABLECELL* other = aOther->GetCell( row, col );
609
610 if( ( diff = cell->PCB_SHAPE::Compare( other ) ) != 0 )
611 return diff;
612
613 if( ( diff = cell->EDA_TEXT::Compare( other ) ) != 0 )
614 return diff;
615 }
616 }
617
618 return 0;
619}
620
621
622bool PCB_TABLE::operator==( const BOARD_ITEM& aBoardItem ) const
623{
624 if( Type() != aBoardItem.Type() )
625 return false;
626
627 const PCB_TABLE& other = static_cast<const PCB_TABLE&>( aBoardItem );
628
629 return *this == other;
630}
631
632
633bool PCB_TABLE::operator==( const PCB_TABLE& aOther ) const
634{
635 if( m_cells.size() != aOther.m_cells.size() )
636 return false;
637
638 if( m_strokeExternal != aOther.m_strokeExternal )
639 return false;
640
642 return false;
643
644 if( m_borderStroke != aOther.m_borderStroke )
645 return false;
646
647 if( m_strokeRows != aOther.m_strokeRows )
648 return false;
649
650 if( m_strokeColumns != aOther.m_strokeColumns )
651 return false;
652
654 return false;
655
656 if( m_colWidths != aOther.m_colWidths )
657 return false;
658
659 if( m_rowHeights != aOther.m_rowHeights )
660 return false;
661
662 for( int ii = 0; ii < (int) m_cells.size(); ++ii )
663 {
664 if( !( *m_cells[ii] == *aOther.m_cells[ii] ) )
665 return false;
666 }
667
668 return true;
669}
670
671
672double PCB_TABLE::Similarity( const BOARD_ITEM& aOther ) const
673{
674 if( aOther.Type() != Type() )
675 return 0.0;
676
677 const PCB_TABLE& other = static_cast<const PCB_TABLE&>( aOther );
678
679 if( m_cells.size() != other.m_cells.size() )
680 return 0.1;
681
682 double similarity = 1.0;
683
685 similarity *= 0.9;
686
688 similarity *= 0.9;
689
690 if( m_borderStroke != other.m_borderStroke )
691 similarity *= 0.9;
692
693 if( m_strokeRows != other.m_strokeRows )
694 similarity *= 0.9;
695
696 if( m_strokeColumns != other.m_strokeColumns )
697 similarity *= 0.9;
698
700 similarity *= 0.9;
701
702 if( m_colWidths != other.m_colWidths )
703 similarity *= 0.9;
704
705 if( m_rowHeights != other.m_rowHeights )
706 similarity *= 0.9;
707
708 for( int ii = 0; ii < (int) m_cells.size(); ++ii )
709 similarity *= m_cells[ii]->Similarity( *other.m_cells[ii] );
710
711 return similarity;
712}
713
714
715static struct PCB_TABLE_DESC
716{
718 {
720
721 if( lineStyleEnum.Choices().GetCount() == 0 )
722 {
723 lineStyleEnum.Map( LINE_STYLE::SOLID, _HKI( "Solid" ) )
724 .Map( LINE_STYLE::DASH, _HKI( "Dashed" ) )
725 .Map( LINE_STYLE::DOT, _HKI( "Dotted" ) )
726 .Map( LINE_STYLE::DASHDOT, _HKI( "Dash-Dot" ) )
727 .Map( LINE_STYLE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
728 }
729
732
737
738 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Start X" ),
741 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Start Y" ),
744
745 const wxString tableProps = _( "Table Properties" );
746
747 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "External Border" ),
749 tableProps );
750
751 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Header Border" ),
753 tableProps );
754
755 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Border Width" ),
758 tableProps );
759
760 propMgr.AddProperty( new PROPERTY_ENUM<PCB_TABLE, LINE_STYLE>( _HKI( "Border Style" ),
762 tableProps );
763
764 propMgr.AddProperty( new PROPERTY<PCB_TABLE, COLOR4D>( _HKI( "Border Color" ),
766 tableProps );
767
768 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Row Separators" ),
770 tableProps );
771
772 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Cell Separators" ),
774 tableProps );
775
776 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Separators Width" ),
779 tableProps );
780
781 propMgr.AddProperty( new PROPERTY_ENUM<PCB_TABLE, LINE_STYLE>( _HKI( "Separators Style" ),
783 tableProps );
784
785 propMgr.AddProperty( new PROPERTY<PCB_TABLE, COLOR4D>( _HKI( "Separators Color" ),
787 tableProps );
788 }
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
@ ERROR_INSIDE
constexpr int ARC_LOW_DEF
Definition base_units.h:128
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
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:83
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:85
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition board_item.h:236
PCB_LAYER_ID m_layer
Definition board_item.h:458
bool m_isLocked
Definition board_item.h:461
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition board_item.h:284
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:558
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition box2.h:658
constexpr bool Contains(const Vec &aPoint) const
Definition box2.h:168
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition box2.h:311
The base class for create windows for drawing purpose.
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.h:113
std::vector< VECTOR2I > GetCornersInSequence(EDA_ANGLE angle) const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:215
void SetEnd(const VECTOR2I &aEnd)
Definition eda_shape.h:219
const EDA_ANGLE & GetTextAngle() const
Definition eda_text.h:147
virtual EDA_ANGLE GetDrawRotation() const
Definition eda_text.h:377
virtual void ClearRenderCache()
Definition eda_text.cpp:677
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition property.h:727
static ENUM_MAP< T > & Instance()
Definition property.h:721
wxPGChoices & Choices()
Definition property.h:770
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:105
PCB specific render settings.
Definition pcb_painter.h:82
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void SetPosition(const VECTOR2I &aPos) override
Definition pcb_shape.h:78
VECTOR2I GetPosition() const override
Definition pcb_shape.h:79
int GetRowSpan() const
int GetColSpan() const
VECTOR2I GetEnd() const
STROKE_PARAMS m_separatorsStroke
Definition pcb_table.h:300
bool StrokeRows() const
Definition pcb_table.h:107
int GetRowCount() const
Definition pcb_table.h:124
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:305
void SetColWidth(int aCol, int aWidth)
Definition pcb_table.h:129
int m_colCount
Definition pcb_table.h:302
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:298
void Move(const VECTOR2I &aMoveVector) override
Move this object.
int GetPositionY() const
Definition pcb_table.h:119
bool StrokeHeaderSeparator() const
Definition pcb_table.h:65
bool StrokeColumns() const
Definition pcb_table.h:104
void SetBorderStyle(const LINE_STYLE aStyle)
Definition pcb_table.h:73
void SetStrokeHeaderSeparator(bool aDoStroke)
Definition pcb_table.h:64
void SetSeparatorsColor(const COLOR4D &aColor)
Definition pcb_table.h:100
bool m_strokeExternal
Definition pcb_table.h:295
STROKE_PARAMS m_borderStroke
Definition pcb_table.h:297
bool m_strokeColumns
Definition pcb_table.h:299
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
bool StrokeExternal() const
Definition pcb_table.h:62
int GetSeparatorsWidth() const
Definition pcb_table.h:89
void SetPositionX(int x)
Definition pcb_table.h:116
void SetStrokeExternal(bool aDoStroke)
Definition pcb_table.h:61
PCB_TABLECELL * GetCell(int aRow, int aCol) const
Definition pcb_table.h:149
std::vector< PCB_TABLECELL * > GetCells() const
Definition pcb_table.h:159
void Autosize()
int GetBorderWidth() const
Definition pcb_table.h:71
COLOR4D GetBorderColor() const
Definition pcb_table.h:83
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:122
void SetStrokeColumns(bool aDoStroke)
Definition pcb_table.h:103
const STROKE_PARAMS & GetSeparatorsStroke() const
Definition pcb_table.h:86
std::map< int, int > m_colWidths
Definition pcb_table.h:303
virtual void swapData(BOARD_ITEM *aImage) override
Definition pcb_table.cpp:76
int GetPositionX() const
Definition pcb_table.h:118
void Normalize() override
Perform any normalization required after a user rotate and/or flip.
void AddCell(PCB_TABLECELL *aCell)
Definition pcb_table.h:164
const STROKE_PARAMS & GetBorderStroke() const
Definition pcb_table.h:68
void SetPositionY(int y)
Definition pcb_table.h:117
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void SetStrokeRows(bool aDoStroke)
Definition pcb_table.h:106
bool m_StrokeHeaderSeparator
Definition pcb_table.h:296
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const override
Invoke a function on all children.
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:74
static int Compare(const PCB_TABLE *aTable, const PCB_TABLE *aOther)
int GetColWidth(int aCol) const
Definition pcb_table.h:131
VECTOR2I GetPosition() const override
void SetSeparatorsWidth(int aWidth)
Definition pcb_table.h:88
COLOR4D GetSeparatorsColor() const
Definition pcb_table.h:101
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
LINE_STYLE GetSeparatorsStyle() const
Definition pcb_table.h:92
void SetBorderColor(const COLOR4D &aColor)
Definition pcb_table.h:82
PCB_TABLE(BOARD_ITEM *aParent, int aLineWidth)
Definition pcb_table.cpp:36
void SetSeparatorsStyle(const LINE_STYLE aStyle)
Definition pcb_table.h:91
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:139
void SetPosition(const VECTOR2I &aPos) override
void SetBorderWidth(int aWidth)
Definition pcb_table.h:70
int GetRowHeight(int aRow) const
Definition pcb_table.h:141
std::map< int, int > m_rowHeights
Definition pcb_table.h:304
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
Definition pcb_textbox.h:89
int GetMarginRight() const
Definition pcb_textbox.h:91
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)
#define _(s)
@ DEGREES_T
Definition eda_angle.h:31
RECURSE_MODE
Definition eda_item.h:50
@ RECURSE
Definition eda_item.h:51
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:172
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition layer_ids.h:184
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
FLIP_DIRECTION
Definition mirror.h:27
@ LEFT_RIGHT
Flip left to right (around the Y axis)
Definition mirror.h:28
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
Definition mirror.h:29
bool ShapeHitTest(const SHAPE_LINE_CHAIN &aHitter, const SHAPE &aHittee, bool aHitteeContained)
Perform a shape-to-shape hit test.
#define _HKI(x)
Definition page_info.cpp:44
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)
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:229
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:78
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
Definition typeinfo.h:95
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition typeinfo.h:94
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695