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,
79 wxT( "Cannot swap data with invalid table." ) );
80
81 PCB_TABLE* table = static_cast<PCB_TABLE*>( aImage );
82
83 std::swap( m_layer, table->m_layer );
84 std::swap( m_isLocked, table->m_isLocked );
85
86 std::swap( m_strokeExternal, table->m_strokeExternal );
87 std::swap( m_StrokeHeaderSeparator, table->m_StrokeHeaderSeparator );
88 std::swap( m_borderStroke, table->m_borderStroke );
89 std::swap( m_strokeRows, table->m_strokeRows );
90 std::swap( m_strokeColumns, table->m_strokeColumns );
91 std::swap( m_separatorsStroke, table->m_separatorsStroke );
92
93 std::swap( m_colCount, table->m_colCount );
94 std::swap( m_colWidths, table->m_colWidths );
95 std::swap( m_rowHeights, table->m_rowHeights );
96
97 std::swap( m_cells, table->m_cells );
98
99 for( PCB_TABLECELL* cell : m_cells )
100 cell->SetParent( this );
101
102 for( PCB_TABLECELL* cell : table->m_cells )
103 cell->SetParent( table );
104}
105
106
108{
109 Move( aPos - GetPosition() );
110}
111
112
114{
115 return m_cells[0]->GetPosition();
116}
117
118
120{
121 VECTOR2I tableSize;
122
123 for( int ii = 0; ii < GetColCount(); ++ii )
124 tableSize.x += GetColWidth( ii );
125
126 for( int ii = 0; ii < GetRowCount(); ++ii )
127 tableSize.y += GetRowHeight( ii );
128
129 return GetPosition() + tableSize;
130}
131
132
134{
135 int y = GetPosition().y;
136
137 for( int row = 0; row < GetRowCount(); ++row )
138 {
139 int x = GetPosition().x;
140 int rowHeight = m_rowHeights[ row ];
141
142 for( int col = 0; col < GetColCount(); ++col )
143 {
144 int colWidth = m_colWidths[ col ];
145
146 PCB_TABLECELL* cell = GetCell( row, col );
147 VECTOR2I pos( x, y );
148
149 RotatePoint( pos, GetPosition(), cell->GetTextAngle() );
150
151 if( cell->GetPosition() != pos )
152 {
153 cell->SetPosition( pos );
154 cell->ClearRenderCache();
155 }
156
157 VECTOR2I end = VECTOR2I( x + colWidth, y + rowHeight );
158
159 if( cell->GetColSpan() > 1 || cell->GetRowSpan() > 1 )
160 {
161 for( int ii = col + 1; ii < col + cell->GetColSpan(); ++ii )
162 end.x += m_colWidths[ii];
163
164 for( int ii = row + 1; ii < row + cell->GetRowSpan(); ++ii )
165 end.y += m_rowHeights[ii];
166 }
167
169
170 if( cell->GetEnd() != end )
171 {
172 cell->SetEnd( end );
173 cell->ClearRenderCache();
174 }
175
176 x += colWidth;
177 }
178
179 y += rowHeight;
180 }
181}
182
183
185{
186 std::vector<std::vector<BOX2I>> extents;
187
188 for( int row = 0; row < GetRowCount(); ++row )
189 {
190 extents.push_back( std::vector<BOX2I>() );
191
192 for( int col = 0; col < GetColCount(); ++col )
193 {
194 SHAPE_POLY_SET textPoly;
195 GetCell( row, col )->TransformTextToPolySet( textPoly, 0, ARC_LOW_DEF, ERROR_INSIDE );
196 extents[row].push_back( textPoly.BBox() );
197 }
198 }
199
200 for( int col = 0; col < GetColCount(); ++col )
201 {
202 int colWidth = 0;
203
204 for( int row = 0; row < GetRowCount(); ++row )
205 {
206 PCB_TABLECELL* cell = GetCell( row, col );
207 int margins = cell->GetMarginLeft() + cell->GetMarginRight();
208 colWidth = std::max<int>( colWidth, extents[row][col].GetWidth() + ( margins * 1.5 ) );
209 }
210
211 SetColWidth( col, colWidth );
212 }
213
214 for( int row = 0; row < GetRowCount(); ++row )
215 {
216 int rowHeight = 0;
217
218 for( int col = 0; col < GetColCount(); ++col )
219 {
220 PCB_TABLECELL* cell = GetCell( row, col );
221 int margins = cell->GetMarginLeft() + cell->GetMarginRight();
222 rowHeight = std::max( rowHeight, (int) extents[row][col].GetHeight() + margins );
223 }
224
225 SetRowHeight( row, rowHeight );
226 }
227
228 Normalize();
229}
230
231
232void PCB_TABLE::Move( const VECTOR2I& aMoveVector )
233{
234 for( PCB_TABLECELL* cell : m_cells )
235 cell->Move( aMoveVector );
236}
237
238
239void PCB_TABLE::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
240{
241 if( GetCells().empty() )
242 return;
243
244 for( PCB_TABLECELL* cell : m_cells )
245 cell->Rotate( aRotCentre, aAngle );
246
247 Normalize();
248}
249
250
251void PCB_TABLE::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
252{
253 if( aFlipDirection == FLIP_DIRECTION::TOP_BOTTOM )
254 {
256 Rotate( aCentre, EDA_ANGLE( 180, DEGREES_T ) );
257 return;
258 }
259
260 EDA_ANGLE originalAngle = m_cells[0]->GetTextAngle();
261
262 Rotate( aCentre, -originalAngle );
263 Normalize();
264
265 for( PCB_TABLECELL* cell : m_cells )
266 cell->Flip( aCentre, aFlipDirection );
267
268 std::vector<PCB_TABLECELL*> oldCells = m_cells;
269 int rowOffset = 0;
270
271 for( int row = 0; row < GetRowCount(); ++row )
272 {
273 for( int col = 0; col < GetColCount(); ++col )
274 m_cells[ rowOffset + col ] = oldCells[ rowOffset + GetColCount() - 1 - col ];
275
276 rowOffset += GetColCount();
277 }
278
279 VECTOR2I currentPos = GetPosition();
280
281 int firstWidth = m_colWidths.begin()->second;
282 VECTOR2I translationVector = VECTOR2I( firstWidth, 0 );
283
284 VECTOR2I position = currentPos - translationVector;
285 SetPosition( position );
286
287 std::map<int, int> newColWidths;
288 for( int col = 0; col < GetColCount(); ++col )
289 {
290 newColWidths[col] = m_colWidths[GetColCount() - 1 - col];
291 }
292
293 m_colWidths = std::move( newColWidths );
294
296 Normalize();
297
298 Rotate( aCentre, originalAngle );
299 Normalize();
300}
301
302
303void PCB_TABLE::RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const
304{
305 for( PCB_TABLECELL* cell : m_cells )
306 {
307 aFunction( cell );
308
309 if( aMode == RECURSE_MODE::RECURSE )
310 cell->RunOnChildren( aFunction, aMode );
311 }
312}
313
314
316{
317 // Note: a table with no cells is not allowed
318 BOX2I bbox = m_cells[0]->GetBoundingBox();
319
320 bbox.Merge( m_cells[ m_cells.size() - 1 ]->GetBoundingBox() );
321
322 return bbox;
323}
324
325
326void PCB_TABLE::DrawBorders( const std::function<void( const VECTOR2I& aPt1, const VECTOR2I& aPt2,
327 const STROKE_PARAMS& aStroke )>& aCallback ) const
328{
329 EDA_ANGLE drawAngle = GetCell( 0, 0 )->GetDrawRotation();
330 std::vector<VECTOR2I> topLeft = GetCell( 0, 0 )->GetCornersInSequence( drawAngle );
331 std::vector<VECTOR2I> bottomLeft = GetCell( GetRowCount() - 1, 0 )->GetCornersInSequence( drawAngle );
332 std::vector<VECTOR2I> topRight = GetCell( 0, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
333 std::vector<VECTOR2I> bottomRight =
334 GetCell( GetRowCount() - 1, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
335 STROKE_PARAMS stroke;
336
337 for( int col = 0; col < GetColCount() - 1; ++col )
338 {
339 if( StrokeColumns() )
340 stroke = GetSeparatorsStroke();
341 else
342 continue;
343
344 for( int row = 0; row < GetRowCount(); ++row )
345 {
346 PCB_TABLECELL* cell = GetCell( row, col );
347
348 if( cell->GetColSpan() == 0 )
349 continue;
350
351 if( col + cell->GetColSpan() == GetColCount() )
352 continue;
353
354 std::vector<VECTOR2I> corners = cell->GetCornersInSequence( drawAngle );
355
356 if( corners.size() == 4 )
357 aCallback( corners[1], corners[2], stroke );
358 }
359 }
360
361 for( int row = 0; row < GetRowCount() - 1; ++row )
362 {
363 if( row == 0 && StrokeHeaderSeparator() )
364 stroke = GetBorderStroke();
365 else if( StrokeRows() )
366 stroke = GetSeparatorsStroke();
367 else
368 continue;
369
370 for( int col = 0; col < GetColCount(); ++col )
371 {
372 PCB_TABLECELL* cell = GetCell( row, col );
373
374 if( cell->GetRowSpan() == 0 )
375 continue;
376
377 if( row + cell->GetRowSpan() == GetRowCount() )
378 continue;
379
380 std::vector<VECTOR2I> corners = cell->GetCornersInSequence( drawAngle );
381
382 if( corners.size() == 4 )
383 aCallback( corners[2], corners[3], stroke );
384 }
385 }
386
387 if( StrokeExternal() && GetBorderStroke().GetWidth() >= 0 )
388 {
389 aCallback( topLeft[0], topRight[1], GetBorderStroke() );
390 aCallback( topRight[1], bottomRight[2], GetBorderStroke() );
391 aCallback( bottomRight[2], bottomLeft[3], GetBorderStroke() );
392 aCallback( bottomLeft[3], topLeft[0], GetBorderStroke() );
393 }
394}
395
396
397std::shared_ptr<SHAPE> PCB_TABLE::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
398{
399 EDA_ANGLE drawAngle = GetCell( 0, 0 )->GetDrawRotation();
400 std::vector<VECTOR2I> topLeft = GetCell( 0, 0 )->GetCornersInSequence( drawAngle );
401 std::vector<VECTOR2I> bottomLeft = GetCell( GetRowCount() - 1, 0 )->GetCornersInSequence( drawAngle );
402 std::vector<VECTOR2I> topRight = GetCell( 0, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
403 std::vector<VECTOR2I> bottomRight =
404 GetCell( GetRowCount() - 1, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
405
406 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
407
408 std::vector<VECTOR2I> pts;
409
410 pts.emplace_back( topLeft[3] );
411 pts.emplace_back( topRight[2] );
412 pts.emplace_back( bottomRight[2] );
413 pts.emplace_back( bottomLeft[3] );
414
415 shape->AddShape( new SHAPE_SIMPLE( pts ) );
416
418 [&shape]( const VECTOR2I& ptA, const VECTOR2I& ptB, const STROKE_PARAMS& stroke )
419 {
420 shape->AddShape( new SHAPE_SEGMENT( ptA, ptB, stroke.GetWidth() ) );
421 } );
422
423 return shape;
424}
425
426
428 int aClearance, int aMaxError, ERROR_LOC aErrorLoc,
429 bool aIgnoreLineWidth ) const
430{
431 int gap = aClearance;
432
433 if( StrokeColumns() || StrokeRows() )
434 gap = std::max( gap, aClearance + GetSeparatorsStroke().GetWidth() / 2 );
435
437 gap = std::max( gap, aClearance + GetBorderStroke().GetWidth() / 2 );
438
439 for( PCB_TABLECELL* cell : m_cells )
440 cell->TransformShapeToPolygon( aBuffer, aLayer, gap, aMaxError, aErrorLoc, false );
441}
442
443
445 KIGFX::RENDER_SETTINGS* aRenderSettings ) const
446{
447 // Convert graphic items (segments and texts) to a set of polygonal shapes
449 [&aBuffer, aMaxError, aErrorLoc, aRenderSettings]
450 ( const VECTOR2I& ptA, const VECTOR2I& ptB, const STROKE_PARAMS& stroke )
451 {
452 int lineWidth = stroke.GetWidth();
453 LINE_STYLE lineStyle = stroke.GetLineStyle();
454
455 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
456 TransformOvalToPolygon( aBuffer, ptA, ptB, lineWidth, aMaxError, aErrorLoc );
457 else
458 {
459 SHAPE_SEGMENT seg( ptA, ptB );
460 KIGFX::PCB_RENDER_SETTINGS defaultRenderSettings;
461
462 KIGFX::RENDER_SETTINGS* currSettings = aRenderSettings;
463
464 if( currSettings == nullptr )
465 currSettings = &defaultRenderSettings;
466
467 STROKE_PARAMS::Stroke( &seg, lineStyle, lineWidth, currSettings,
468 [&]( VECTOR2I a, VECTOR2I b )
469 {
470 if( a == b )
471 TransformCircleToPolygon( aBuffer, a, lineWidth/2, aMaxError, aErrorLoc );
472 else
473 TransformOvalToPolygon( aBuffer, a+1, b, lineWidth, aMaxError, aErrorLoc );
474 } );
475 }
476 } );
477
478 for( PCB_TABLECELL* cell : m_cells )
479 {
480 cell->TransformTextToPolySet( aBuffer, 0, aMaxError, ERROR_INSIDE );
481 }
482}
483
484
485INSPECT_RESULT PCB_TABLE::Visit( INSPECTOR aInspector, void* aTestData,
486 const std::vector<KICAD_T>& aScanTypes )
487{
488 for( KICAD_T scanType : aScanTypes )
489 {
490 if( scanType == PCB_TABLE_T )
491 {
492 if( INSPECT_RESULT::QUIT == aInspector( this, aTestData ) )
494 }
495
496 if( scanType == PCB_TABLECELL_T )
497 {
498 for( PCB_TABLECELL* cell : m_cells )
499 {
500 if( INSPECT_RESULT::QUIT == aInspector( cell, (void*) this ) )
502 }
503 }
504 }
505
507}
508
509
510wxString PCB_TABLE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
511{
512 return wxString::Format( _( "%d column table" ), m_colCount );
513}
514
515
517{
518 return BITMAPS::table;
519}
520
521
522bool PCB_TABLE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
523{
524 BOX2I rect = GetBoundingBox();
525
526 rect.Inflate( aAccuracy );
527
528 return rect.Contains( aPosition );
529}
530
531
532bool PCB_TABLE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
533{
534 BOX2I rect = aRect;
535
536 rect.Inflate( aAccuracy );
537
538 if( aContained )
539 return rect.Contains( GetBoundingBox() );
540
541 return rect.Intersects( GetBoundingBox() );
542}
543
544
545bool PCB_TABLE::HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
546{
547 return KIGEOM::ShapeHitTest( aPoly, *GetEffectiveShape(), aContained );
548}
549
550
551void PCB_TABLE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
552{
553 // Don't use GetShownText() here; we want to show the user the variable references
554 aList.emplace_back( _( "Table" ), wxString::Format( _( "%d Columns" ), m_colCount ) );
555}
556
557
558int PCB_TABLE::Compare( const PCB_TABLE* aTable, const PCB_TABLE* aOther )
559{
560 int diff;
561
562 if( ( diff = (int) aTable->GetCells().size() - (int) aOther->GetCells().size() ) != 0 )
563 return diff;
564
565 if( ( diff = aTable->GetColCount() - aOther->GetColCount() ) != 0 )
566 return diff;
567
568 for( int col = 0; col < aTable->GetColCount(); ++col )
569 {
570 if( ( diff = aTable->GetColWidth( col ) - aOther->GetColWidth( col ) ) != 0 )
571 return diff;
572 }
573
574 for( int row = 0; row < aTable->GetRowCount(); ++row )
575 {
576 if( ( diff = aTable->GetRowHeight( row ) - aOther->GetRowHeight( row ) ) != 0 )
577 return diff;
578 }
579
580 for( int row = 0; row < aTable->GetRowCount(); ++row )
581 {
582 for( int col = 0; col < aTable->GetColCount(); ++col )
583 {
584 PCB_TABLECELL* cell = aTable->GetCell( row, col );
585 PCB_TABLECELL* other = aOther->GetCell( row, col );
586
587 if( ( diff = cell->PCB_SHAPE::Compare( other ) ) != 0 )
588 return diff;
589
590 if( ( diff = cell->EDA_TEXT::Compare( other ) ) != 0 )
591 return diff;
592 }
593 }
594
595 return 0;
596}
597
598
599bool PCB_TABLE::operator==( const BOARD_ITEM& aBoardItem ) const
600{
601 if( Type() != aBoardItem.Type() )
602 return false;
603
604 const PCB_TABLE& other = static_cast<const PCB_TABLE&>( aBoardItem );
605
606 return *this == other;
607}
608
609
610bool PCB_TABLE::operator==( const PCB_TABLE& aOther ) const
611{
612 if( m_cells.size() != aOther.m_cells.size() )
613 return false;
614
615 if( m_strokeExternal != aOther.m_strokeExternal )
616 return false;
617
619 return false;
620
621 if( m_borderStroke != aOther.m_borderStroke )
622 return false;
623
624 if( m_strokeRows != aOther.m_strokeRows )
625 return false;
626
627 if( m_strokeColumns != aOther.m_strokeColumns )
628 return false;
629
631 return false;
632
633 if( m_colWidths != aOther.m_colWidths )
634 return false;
635
636 if( m_rowHeights != aOther.m_rowHeights )
637 return false;
638
639 for( int ii = 0; ii < (int) m_cells.size(); ++ii )
640 {
641 if( !( *m_cells[ii] == *aOther.m_cells[ii] ) )
642 return false;
643 }
644
645 return true;
646}
647
648
649double PCB_TABLE::Similarity( const BOARD_ITEM& aOther ) const
650{
651 if( aOther.Type() != Type() )
652 return 0.0;
653
654 const PCB_TABLE& other = static_cast<const PCB_TABLE&>( aOther );
655
656 if( m_cells.size() != other.m_cells.size() )
657 return 0.1;
658
659 double similarity = 1.0;
660
662 similarity *= 0.9;
663
665 similarity *= 0.9;
666
667 if( m_borderStroke != other.m_borderStroke )
668 similarity *= 0.9;
669
670 if( m_strokeRows != other.m_strokeRows )
671 similarity *= 0.9;
672
673 if( m_strokeColumns != other.m_strokeColumns )
674 similarity *= 0.9;
675
677 similarity *= 0.9;
678
679 if( m_colWidths != other.m_colWidths )
680 similarity *= 0.9;
681
682 if( m_rowHeights != other.m_rowHeights )
683 similarity *= 0.9;
684
685 for( int ii = 0; ii < (int) m_cells.size(); ++ii )
686 similarity *= m_cells[ii]->Similarity( *other.m_cells[ii] );
687
688 return similarity;
689}
690
691
692static struct PCB_TABLE_DESC
693{
695 {
697
698 if( lineStyleEnum.Choices().GetCount() == 0 )
699 {
700 lineStyleEnum.Map( LINE_STYLE::SOLID, _HKI( "Solid" ) )
701 .Map( LINE_STYLE::DASH, _HKI( "Dashed" ) )
702 .Map( LINE_STYLE::DOT, _HKI( "Dotted" ) )
703 .Map( LINE_STYLE::DASHDOT, _HKI( "Dash-Dot" ) )
704 .Map( LINE_STYLE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
705 }
706
709
714
715 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Start X" ),
718 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Start Y" ),
721
722 const wxString tableProps = _( "Table Properties" );
723
724 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "External Border" ),
726 tableProps );
727
728 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Header Border" ),
730 tableProps );
731
732 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Border Width" ),
735 tableProps );
736
737 propMgr.AddProperty( new PROPERTY_ENUM<PCB_TABLE, LINE_STYLE>( _HKI( "Border Style" ),
739 tableProps );
740
741 propMgr.AddProperty( new PROPERTY<PCB_TABLE, COLOR4D>( _HKI( "Border Color" ),
743 tableProps );
744
745 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Row Separators" ),
747 tableProps );
748
749 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Cell Separators" ),
751 tableProps );
752
753 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Separators Width" ),
756 tableProps );
757
758 propMgr.AddProperty( new PROPERTY_ENUM<PCB_TABLE, LINE_STYLE>( _HKI( "Separators Style" ),
760 tableProps );
761
762 propMgr.AddProperty( new PROPERTY<PCB_TABLE, COLOR4D>( _HKI( "Separators Color" ),
764 tableProps );
765 }
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:79
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:81
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition board_item.h:232
PCB_LAYER_ID m_layer
Definition board_item.h:453
bool m_isLocked
Definition board_item.h:456
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition board_item.h:280
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:682
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:104
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:281
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:286
void SetColWidth(int aCol, int aWidth)
Definition pcb_table.h:129
int m_colCount
Definition pcb_table.h:283
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:279
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:276
STROKE_PARAMS m_borderStroke
Definition pcb_table.h:278
bool m_strokeColumns
Definition pcb_table.h:280
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
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:284
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:277
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:285
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.
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.
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