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>
32
33
34PCB_TABLE::PCB_TABLE( BOARD_ITEM* aParent, int aLineWidth ) :
36 m_strokeExternal( true ),
37 m_StrokeHeaderSeparator( true ),
38 m_borderStroke( aLineWidth, LINE_STYLE::DEFAULT, COLOR4D::UNSPECIFIED ),
39 m_strokeRows( true ),
40 m_strokeColumns( true ),
41 m_separatorsStroke( aLineWidth, LINE_STYLE::DEFAULT, COLOR4D::UNSPECIFIED ),
42 m_colCount( 0 )
43{
44}
45
46
48 BOARD_ITEM_CONTAINER( aTable )
49{
56
57 m_colCount = aTable.m_colCount;
58 m_colWidths = aTable.m_colWidths;
60
61 for( PCB_TABLECELL* src : aTable.m_cells )
62 AddCell( new PCB_TABLECELL( *src ) );
63}
64
65
67{
68 // We own our cells; delete them
69 for( PCB_TABLECELL* cell : m_cells )
70 delete cell;
71}
72
73
75{
76 wxCHECK_RET( aImage != nullptr && aImage->Type() == PCB_TABLE_T,
77 wxT( "Cannot swap data with invalid table." ) );
78
79 PCB_TABLE* table = static_cast<PCB_TABLE*>( aImage );
80
81 std::swap( m_layer, table->m_layer );
82 std::swap( m_isLocked, table->m_isLocked );
83
84 std::swap( m_strokeExternal, table->m_strokeExternal );
85 std::swap( m_StrokeHeaderSeparator, table->m_StrokeHeaderSeparator );
86 std::swap( m_borderStroke, table->m_borderStroke );
87 std::swap( m_strokeRows, table->m_strokeRows );
88 std::swap( m_strokeColumns, table->m_strokeColumns );
89 std::swap( m_separatorsStroke, table->m_separatorsStroke );
90
91 std::swap( m_colCount, table->m_colCount );
92 std::swap( m_colWidths, table->m_colWidths );
93 std::swap( m_rowHeights, table->m_rowHeights );
94
95 std::swap( m_cells, table->m_cells );
96
97 for( PCB_TABLECELL* cell : m_cells )
98 cell->SetParent( this );
99
100 for( PCB_TABLECELL* cell : table->m_cells )
101 cell->SetParent( table );
102}
103
104
106{
107 Move( aPos - GetPosition() );
108}
109
110
112{
113 return m_cells[0]->GetPosition();
114}
115
116
118{
119 VECTOR2I tableSize;
120
121 for( int ii = 0; ii < GetColCount(); ++ii )
122 tableSize.x += GetColWidth( ii );
123
124 for( int ii = 0; ii < GetRowCount(); ++ii )
125 tableSize.y += GetRowHeight( ii );
126
127 return GetPosition() + tableSize;
128}
129
130
132{
133 int y = GetPosition().y;
134
135 for( int row = 0; row < GetRowCount(); ++row )
136 {
137 int x = GetPosition().x;
138 int rowHeight = m_rowHeights[ row ];
139
140 for( int col = 0; col < GetColCount(); ++col )
141 {
142 int colWidth = m_colWidths[ col ];
143
144 PCB_TABLECELL* cell = GetCell( row, col );
145 VECTOR2I pos( x, y );
146
147 RotatePoint( pos, GetPosition(), cell->GetTextAngle() );
148
149 if( cell->GetPosition() != pos )
150 {
151 cell->SetPosition( pos );
152 cell->ClearRenderCache();
153 }
154
155 VECTOR2I end = VECTOR2I( x + colWidth, y + rowHeight );
156
157 if( cell->GetColSpan() > 1 || cell->GetRowSpan() > 1 )
158 {
159 for( int ii = col + 1; ii < col + cell->GetColSpan(); ++ii )
160 end.x += m_colWidths[ii];
161
162 for( int ii = row + 1; ii < row + cell->GetRowSpan(); ++ii )
163 end.y += m_rowHeights[ii];
164 }
165
167
168 if( cell->GetEnd() != end )
169 {
170 cell->SetEnd( end );
171 cell->ClearRenderCache();
172 }
173
174 x += colWidth;
175 }
176
177 y += rowHeight;
178 }
179}
180
181
183{
184 std::vector<std::vector<BOX2I>> extents;
185
186 for( int row = 0; row < GetRowCount(); ++row )
187 {
188 extents.push_back( std::vector<BOX2I>() );
189
190 for( int col = 0; col < GetColCount(); ++col )
191 {
192 SHAPE_POLY_SET textPoly;
193 GetCell( row, col )->TransformTextToPolySet( textPoly, 0, ARC_LOW_DEF, ERROR_INSIDE );
194 extents[row].push_back( textPoly.BBox() );
195 }
196 }
197
198 for( int col = 0; col < GetColCount(); ++col )
199 {
200 int colWidth = 0;
201
202 for( int row = 0; row < GetRowCount(); ++row )
203 {
204 PCB_TABLECELL* cell = GetCell( row, col );
205 int margins = cell->GetMarginLeft() + cell->GetMarginRight();
206 colWidth = std::max<int>( colWidth, extents[row][col].GetWidth() + ( margins * 1.5 ) );
207 }
208
209 SetColWidth( col, colWidth );
210 }
211
212 for( int row = 0; row < GetRowCount(); ++row )
213 {
214 int rowHeight = 0;
215
216 for( int col = 0; col < GetColCount(); ++col )
217 {
218 PCB_TABLECELL* cell = GetCell( row, col );
219 int margins = cell->GetMarginLeft() + cell->GetMarginRight();
220 rowHeight = std::max( rowHeight, (int) extents[row][col].GetHeight() + margins );
221 }
222
223 SetRowHeight( row, rowHeight );
224 }
225
226 Normalize();
227}
228
229
230void PCB_TABLE::Move( const VECTOR2I& aMoveVector )
231{
232 for( PCB_TABLECELL* cell : m_cells )
233 cell->Move( aMoveVector );
234}
235
236
237void PCB_TABLE::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
238{
239 if( GetCells().empty() )
240 return;
241
242 for( PCB_TABLECELL* cell : m_cells )
243 cell->Rotate( aRotCentre, aAngle );
244
245 Normalize();
246}
247
248
249void PCB_TABLE::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
250{
251 EDA_ANGLE originalAngle = m_cells[0]->GetTextAngle();
252
253 Rotate( aCentre, -originalAngle );
254 Normalize();
255
256 for( PCB_TABLECELL* cell : m_cells )
257 cell->Flip( aCentre, aFlipDirection );
258
259 std::vector<PCB_TABLECELL*> oldCells = m_cells;
260 int rowOffset = 0;
261
262 for( int row = 0; row < GetRowCount(); ++row )
263 {
264 for( int col = 0; col < GetColCount(); ++col )
265 m_cells[ rowOffset + col ] = oldCells[ rowOffset + GetColCount() - 1 - col ];
266
267 rowOffset += GetColCount();
268 }
269
270 VECTOR2I currentPos = GetPosition();
271
272 int firstWidth = m_colWidths.begin()->second;
273 VECTOR2I translationVector = VECTOR2I( firstWidth, 0 );
274
275 VECTOR2I position = currentPos - translationVector;
276 SetPosition( position );
277
278 std::map<int, int> newColWidths;
279 for( int col = 0; col < GetColCount(); ++col )
280 {
281 newColWidths[col] = m_colWidths[GetColCount() - 1 - col];
282 }
283
284 m_colWidths = std::move( newColWidths );
285
287 Normalize();
288
289 Rotate( aCentre, originalAngle );
290 Normalize();
291}
292
293
294void PCB_TABLE::RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const
295{
296 for( PCB_TABLECELL* cell : m_cells )
297 {
298 aFunction( cell );
299
300 if( aMode == RECURSE_MODE::RECURSE )
301 cell->RunOnChildren( aFunction, aMode );
302 }
303}
304
305
307{
308 // Note: a table with no cells is not allowed
309 BOX2I bbox = m_cells[0]->GetBoundingBox();
310
311 bbox.Merge( m_cells[ m_cells.size() - 1 ]->GetBoundingBox() );
312
313 return bbox;
314}
315
316
317void PCB_TABLE::DrawBorders( const std::function<void( const VECTOR2I& aPt1, const VECTOR2I& aPt2,
318 const STROKE_PARAMS& aStroke )>& aCallback ) const
319{
320 EDA_ANGLE drawAngle = GetCell( 0, 0 )->GetDrawRotation();
321 std::vector<VECTOR2I> topLeft = GetCell( 0, 0 )->GetCornersInSequence( drawAngle );
322 std::vector<VECTOR2I> bottomLeft = GetCell( GetRowCount() - 1, 0 )->GetCornersInSequence( drawAngle );
323 std::vector<VECTOR2I> topRight = GetCell( 0, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
324 std::vector<VECTOR2I> bottomRight =
325 GetCell( GetRowCount() - 1, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
326 STROKE_PARAMS stroke;
327
328 for( int col = 0; col < GetColCount() - 1; ++col )
329 {
330 if( StrokeColumns() )
331 stroke = GetSeparatorsStroke();
332 else
333 continue;
334
335 for( int row = 0; row < GetRowCount(); ++row )
336 {
337 PCB_TABLECELL* cell = GetCell( row, col );
338
339 if( cell->GetColSpan() == 0 )
340 continue;
341
342 if( col + cell->GetColSpan() == GetColCount() )
343 continue;
344
345 std::vector<VECTOR2I> corners = cell->GetCornersInSequence( drawAngle );
346
347 if( corners.size() == 4 )
348 aCallback( corners[1], corners[2], stroke );
349 }
350 }
351
352 for( int row = 0; row < GetRowCount() - 1; ++row )
353 {
354 if( row == 0 && StrokeHeaderSeparator() )
355 stroke = GetBorderStroke();
356 else if( StrokeRows() )
357 stroke = GetSeparatorsStroke();
358 else
359 continue;
360
361 for( int col = 0; col < GetColCount(); ++col )
362 {
363 PCB_TABLECELL* cell = GetCell( row, col );
364
365 if( cell->GetRowSpan() == 0 )
366 continue;
367
368 if( row + cell->GetRowSpan() == GetRowCount() )
369 continue;
370
371 std::vector<VECTOR2I> corners = cell->GetCornersInSequence( drawAngle );
372
373 if( corners.size() == 4 )
374 aCallback( corners[2], corners[3], stroke );
375 }
376 }
377
378 if( StrokeExternal() && GetBorderStroke().GetWidth() >= 0 )
379 {
380 aCallback( topLeft[0], topRight[1], GetBorderStroke() );
381 aCallback( topRight[1], bottomRight[2], GetBorderStroke() );
382 aCallback( bottomRight[2], bottomLeft[3], GetBorderStroke() );
383 aCallback( bottomLeft[3], topLeft[0], GetBorderStroke() );
384 }
385}
386
387
388std::shared_ptr<SHAPE> PCB_TABLE::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
389{
390 EDA_ANGLE drawAngle = GetCell( 0, 0 )->GetDrawRotation();
391 std::vector<VECTOR2I> topLeft = GetCell( 0, 0 )->GetCornersInSequence( drawAngle );
392 std::vector<VECTOR2I> bottomLeft = GetCell( GetRowCount() - 1, 0 )->GetCornersInSequence( drawAngle );
393 std::vector<VECTOR2I> topRight = GetCell( 0, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
394 std::vector<VECTOR2I> bottomRight =
395 GetCell( GetRowCount() - 1, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
396
397 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
398
399 std::vector<VECTOR2I> pts;
400
401 pts.emplace_back( topLeft[3] );
402 pts.emplace_back( topRight[2] );
403 pts.emplace_back( bottomRight[2] );
404 pts.emplace_back( bottomLeft[3] );
405
406 shape->AddShape( new SHAPE_SIMPLE( pts ) );
407
409 [&shape]( const VECTOR2I& ptA, const VECTOR2I& ptB, const STROKE_PARAMS& stroke )
410 {
411 shape->AddShape( new SHAPE_SEGMENT( ptA, ptB, stroke.GetWidth() ) );
412 } );
413
414 return shape;
415}
416
417
419 int aClearance, int aMaxError, ERROR_LOC aErrorLoc,
420 bool aIgnoreLineWidth ) const
421{
422 int gap = aClearance;
423
424 if( StrokeColumns() || StrokeRows() )
425 gap = std::max( gap, aClearance + GetSeparatorsStroke().GetWidth() / 2 );
426
428 gap = std::max( gap, aClearance + GetBorderStroke().GetWidth() / 2 );
429
430 for( PCB_TABLECELL* cell : m_cells )
431 cell->TransformShapeToPolygon( aBuffer, aLayer, gap, aMaxError, aErrorLoc, false );
432}
433
434
435INSPECT_RESULT PCB_TABLE::Visit( INSPECTOR aInspector, void* aTestData,
436 const std::vector<KICAD_T>& aScanTypes )
437{
438 for( KICAD_T scanType : aScanTypes )
439 {
440 if( scanType == PCB_TABLE_T )
441 {
442 if( INSPECT_RESULT::QUIT == aInspector( this, aTestData ) )
443 return INSPECT_RESULT::QUIT;
444 }
445
446 if( scanType == PCB_TABLECELL_T )
447 {
448 for( PCB_TABLECELL* cell : m_cells )
449 {
450 if( INSPECT_RESULT::QUIT == aInspector( cell, (void*) this ) )
451 return INSPECT_RESULT::QUIT;
452 }
453 }
454 }
455
456 return INSPECT_RESULT::CONTINUE;
457}
458
459
460wxString PCB_TABLE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
461{
462 return wxString::Format( _( "%d Column Table" ), m_colCount );
463}
464
465
467{
468 return BITMAPS::table;
469}
470
471
472bool PCB_TABLE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
473{
474 BOX2I rect = GetBoundingBox();
475
476 rect.Inflate( aAccuracy );
477
478 return rect.Contains( aPosition );
479}
480
481
482bool PCB_TABLE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
483{
484 BOX2I rect = aRect;
485
486 rect.Inflate( aAccuracy );
487
488 if( aContained )
489 return rect.Contains( GetBoundingBox() );
490
491 return rect.Intersects( GetBoundingBox() );
492}
493
494
495bool PCB_TABLE::HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
496{
497 return KIGEOM::ShapeHitTest( aPoly, *GetEffectiveShape(), aContained );
498}
499
500
501void PCB_TABLE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
502{
503 // Don't use GetShownText() here; we want to show the user the variable references
504 aList.emplace_back( _( "Table" ), wxString::Format( _( "%d Columns" ), m_colCount ) );
505}
506
507
508int PCB_TABLE::Compare( const PCB_TABLE* aTable, const PCB_TABLE* aOther )
509{
510 int diff;
511
512 if( ( diff = (int) aTable->GetCells().size() - (int) aOther->GetCells().size() ) != 0 )
513 return diff;
514
515 if( ( diff = aTable->GetColCount() - aOther->GetColCount() ) != 0 )
516 return diff;
517
518 for( int col = 0; col < aTable->GetColCount(); ++col )
519 {
520 if( ( diff = aTable->GetColWidth( col ) - aOther->GetColWidth( col ) ) != 0 )
521 return diff;
522 }
523
524 for( int row = 0; row < aTable->GetRowCount(); ++row )
525 {
526 if( ( diff = aTable->GetRowHeight( row ) - aOther->GetRowHeight( row ) ) != 0 )
527 return diff;
528 }
529
530 for( int row = 0; row < aTable->GetRowCount(); ++row )
531 {
532 for( int col = 0; col < aTable->GetColCount(); ++col )
533 {
534 PCB_TABLECELL* cell = aTable->GetCell( row, col );
535 PCB_TABLECELL* other = aOther->GetCell( row, col );
536
537 if( ( diff = cell->PCB_SHAPE::Compare( other ) ) != 0 )
538 return diff;
539
540 if( ( diff = cell->EDA_TEXT::Compare( other ) ) != 0 )
541 return diff;
542 }
543 }
544
545 return 0;
546}
547
548
549bool PCB_TABLE::operator==( const BOARD_ITEM& aBoardItem ) const
550{
551 if( Type() != aBoardItem.Type() )
552 return false;
553
554 const PCB_TABLE& other = static_cast<const PCB_TABLE&>( aBoardItem );
555
556 return *this == other;
557}
558
559
560bool PCB_TABLE::operator==( const PCB_TABLE& aOther ) const
561{
562 if( m_cells.size() != aOther.m_cells.size() )
563 return false;
564
565 if( m_strokeExternal != aOther.m_strokeExternal )
566 return false;
567
569 return false;
570
571 if( m_borderStroke != aOther.m_borderStroke )
572 return false;
573
574 if( m_strokeRows != aOther.m_strokeRows )
575 return false;
576
577 if( m_strokeColumns != aOther.m_strokeColumns )
578 return false;
579
581 return false;
582
583 if( m_colWidths != aOther.m_colWidths )
584 return false;
585
586 if( m_rowHeights != aOther.m_rowHeights )
587 return false;
588
589 for( int ii = 0; ii < (int) m_cells.size(); ++ii )
590 {
591 if( !( *m_cells[ii] == *aOther.m_cells[ii] ) )
592 return false;
593 }
594
595 return true;
596}
597
598
599double PCB_TABLE::Similarity( const BOARD_ITEM& aOther ) const
600{
601 if( aOther.Type() != Type() )
602 return 0.0;
603
604 const PCB_TABLE& other = static_cast<const PCB_TABLE&>( aOther );
605
606 if( m_cells.size() != other.m_cells.size() )
607 return 0.1;
608
609 double similarity = 1.0;
610
612 similarity *= 0.9;
613
615 similarity *= 0.9;
616
617 if( m_borderStroke != other.m_borderStroke )
618 similarity *= 0.9;
619
620 if( m_strokeRows != other.m_strokeRows )
621 similarity *= 0.9;
622
623 if( m_strokeColumns != other.m_strokeColumns )
624 similarity *= 0.9;
625
627 similarity *= 0.9;
628
629 if( m_colWidths != other.m_colWidths )
630 similarity *= 0.9;
631
632 if( m_rowHeights != other.m_rowHeights )
633 similarity *= 0.9;
634
635 for( int ii = 0; ii < (int) m_cells.size(); ++ii )
636 similarity *= m_cells[ii]->Similarity( *other.m_cells[ii] );
637
638 return similarity;
639}
640
641
642static struct PCB_TABLE_DESC
643{
645 {
647
648 if( lineStyleEnum.Choices().GetCount() == 0 )
649 {
650 lineStyleEnum.Map( LINE_STYLE::SOLID, _HKI( "Solid" ) )
651 .Map( LINE_STYLE::DASH, _HKI( "Dashed" ) )
652 .Map( LINE_STYLE::DOT, _HKI( "Dotted" ) )
653 .Map( LINE_STYLE::DASHDOT, _HKI( "Dash-Dot" ) )
654 .Map( LINE_STYLE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
655 }
656
659
664
665 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Start X" ),
666 &PCB_TABLE::SetPositionX, &PCB_TABLE::GetPositionX, PROPERTY_DISPLAY::PT_COORD,
668 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Start Y" ),
669 &PCB_TABLE::SetPositionY, &PCB_TABLE::GetPositionY, PROPERTY_DISPLAY::PT_COORD,
671
672 const wxString tableProps = _( "Table Properties" );
673
674 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "External Border" ),
676 tableProps );
677
678 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Header Border" ),
680 tableProps );
681
682 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Border Width" ),
684 PROPERTY_DISPLAY::PT_SIZE ),
685 tableProps );
686
687 propMgr.AddProperty( new PROPERTY_ENUM<PCB_TABLE, LINE_STYLE>( _HKI( "Border Style" ),
689 tableProps );
690
691 propMgr.AddProperty( new PROPERTY<PCB_TABLE, COLOR4D>( _HKI( "Border Color" ),
693 tableProps );
694
695 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Row Separators" ),
697 tableProps );
698
699 propMgr.AddProperty( new PROPERTY<PCB_TABLE, bool>( _HKI( "Cell Separators" ),
701 tableProps );
702
703 propMgr.AddProperty( new PROPERTY<PCB_TABLE, int>( _HKI( "Separators Width" ),
705 PROPERTY_DISPLAY::PT_SIZE ),
706 tableProps );
707
708 propMgr.AddProperty( new PROPERTY_ENUM<PCB_TABLE, LINE_STYLE>( _HKI( "Separators Style" ),
710 tableProps );
711
712 propMgr.AddProperty( new PROPERTY<PCB_TABLE, COLOR4D>( _HKI( "Separators Color" ),
714 tableProps );
715 }
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
Definition: approximation.h:32
@ ERROR_INSIDE
Definition: approximation.h:34
constexpr int ARC_LOW_DEF
Definition: base_units.h:128
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:79
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.
Definition: board_item.cpp:79
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
Definition: eda_shape.cpp:1614
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:144
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:374
virtual void ClearRenderCache()
Definition: eda_text.cpp:663
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:703
static ENUM_MAP< T > & Instance()
Definition: property.h:697
wxPGChoices & Choices()
Definition: property.h:746
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
void SetPosition(const VECTOR2I &aPos) override
Definition: pcb_shape.h:78
VECTOR2I GetPosition() const override
Definition: pcb_shape.h:79
int GetRowSpan() const
Definition: pcb_tablecell.h:71
int GetColSpan() const
Definition: pcb_tablecell.h:68
VECTOR2I GetEnd() const
Definition: pcb_table.cpp:117
STROKE_PARAMS m_separatorsStroke
Definition: pcb_table.h:270
bool StrokeRows() const
Definition: pcb_table.h:102
int GetRowCount() const
Definition: pcb_table.h:119
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_table.cpp:306
std::vector< PCB_TABLECELL * > m_cells
Definition: pcb_table.h:275
void SetColWidth(int aCol, int aWidth)
Definition: pcb_table.h:124
int m_colCount
Definition: pcb_table.h:272
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: pcb_table.cpp:472
bool m_strokeRows
Definition: pcb_table.h:268
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pcb_table.cpp:230
int GetPositionY() const
Definition: pcb_table.h:114
bool StrokeHeaderSeparator() const
Definition: pcb_table.h:60
bool StrokeColumns() const
Definition: pcb_table.h:99
void SetBorderStyle(const LINE_STYLE aStyle)
Definition: pcb_table.h:68
void SetStrokeHeaderSeparator(bool aDoStroke)
Definition: pcb_table.h:59
void SetSeparatorsColor(const COLOR4D &aColor)
Definition: pcb_table.h:95
bool m_strokeExternal
Definition: pcb_table.h:265
STROKE_PARAMS m_borderStroke
Definition: pcb_table.h:267
bool m_strokeColumns
Definition: pcb_table.h:269
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: pcb_table.cpp:460
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.
Definition: pcb_table.cpp:388
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: pcb_table.cpp:249
bool StrokeExternal() const
Definition: pcb_table.h:57
int GetSeparatorsWidth() const
Definition: pcb_table.h:84
void SetPositionX(int x)
Definition: pcb_table.h:111
void SetStrokeExternal(bool aDoStroke)
Definition: pcb_table.h:56
PCB_TABLECELL * GetCell(int aRow, int aCol) const
Definition: pcb_table.h:144
std::vector< PCB_TABLECELL * > GetCells() const
Definition: pcb_table.h:154
void Autosize()
Definition: pcb_table.cpp:182
int GetBorderWidth() const
Definition: pcb_table.h:66
COLOR4D GetBorderColor() const
Definition: pcb_table.h:78
bool operator==(const PCB_TABLE &aOther) const
Definition: pcb_table.cpp:560
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...
Definition: pcb_table.cpp:435
int GetColCount() const
Definition: pcb_table.h:117
void SetStrokeColumns(bool aDoStroke)
Definition: pcb_table.h:98
const STROKE_PARAMS & GetSeparatorsStroke() const
Definition: pcb_table.h:81
std::map< int, int > m_colWidths
Definition: pcb_table.h:273
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pcb_table.cpp:74
int GetPositionX() const
Definition: pcb_table.h:113
void Normalize() override
Perform any normalization required after a user rotate and/or flip.
Definition: pcb_table.cpp:131
void AddCell(PCB_TABLECELL *aCell)
Definition: pcb_table.h:159
const STROKE_PARAMS & GetBorderStroke() const
Definition: pcb_table.h:63
void SetPositionY(int y)
Definition: pcb_table.h:112
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_table.cpp:466
void SetStrokeRows(bool aDoStroke)
Definition: pcb_table.h:101
bool m_StrokeHeaderSeparator
Definition: pcb_table.h:266
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const override
Invoke a function on all children.
Definition: pcb_table.cpp:294
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition: pcb_table.cpp:599
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.
Definition: pcb_table.cpp:418
void DrawBorders(const std::function< void(const VECTOR2I &aPt1, const VECTOR2I &aPt2, const STROKE_PARAMS &aStroke)> &aCallback) const
Definition: pcb_table.cpp:317
LINE_STYLE GetBorderStyle() const
Definition: pcb_table.h:69
static int Compare(const PCB_TABLE *aTable, const PCB_TABLE *aOther)
Definition: pcb_table.cpp:508
int GetColWidth(int aCol) const
Definition: pcb_table.h:126
VECTOR2I GetPosition() const override
Definition: pcb_table.cpp:111
void SetSeparatorsWidth(int aWidth)
Definition: pcb_table.h:83
COLOR4D GetSeparatorsColor() const
Definition: pcb_table.h:96
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_table.cpp:237
LINE_STYLE GetSeparatorsStyle() const
Definition: pcb_table.h:87
void SetBorderColor(const COLOR4D &aColor)
Definition: pcb_table.h:77
PCB_TABLE(BOARD_ITEM *aParent, int aLineWidth)
Definition: pcb_table.cpp:34
void SetSeparatorsStyle(const LINE_STYLE aStyle)
Definition: pcb_table.h:86
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.
Definition: pcb_table.cpp:501
void SetRowHeight(int aRow, int aHeight)
Definition: pcb_table.h:134
void SetPosition(const VECTOR2I &aPos) override
Definition: pcb_table.cpp:105
void SetBorderWidth(int aWidth)
Definition: pcb_table.h:65
int GetRowHeight(int aRow) const
Definition: pcb_table.h:136
std::map< int, int > m_rowHeights
Definition: pcb_table.h:274
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.
Definition: property_mgr.h:74
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:76
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.
Definition: shape_simple.h:42
Simple container to manage line stroke parameters.
Definition: stroke_params.h:94
int GetWidth() const
#define _HKI(x)
static bool empty(const wxTextEntryBase *aCtrl)
#define _(s)
RECURSE_MODE
Definition: eda_item.h:50
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:170
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
bool ShapeHitTest(const SHAPE_LINE_CHAIN &aHitter, const SHAPE &aHittee, bool aHitteeContained)
Perform a shape-to-shape hit test.
static struct PCB_TABLE_DESC _PCB_TABLE_DESC
#define TYPE_HASH(x)
Definition: property.h:72
#define REGISTER_TYPE(x)
Definition: property_mgr.h:351
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:46
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