69 m_text.SetParentGroup(
nullptr );
106 table->SetColCount( 2 );
107 table->SetColWidth( 0, colWidths[0] );
108 table->SetColWidth( 1, colWidths[1] );
109 table->SetRowHeight( 0, rowHeights[0] );
110 table->SetRowHeight( 1, rowHeights[1] );
114 for(
int row = 0; row < 2; ++row )
118 for(
int col = 0; col < 2; ++col )
124 cell->
SetEnd(
VECTOR2I( x + colWidths[col], y + rowHeights[row] ) );
125 table->AddCell( cell );
130 y += rowHeights[row];
165 for(
int row = 0; row < 2; ++row )
169 for(
int col = 0; col < 2; ++col )
175 cell->
SetEnd(
VECTOR2I( x + colWidths[col], y + rowHeights[row] ) );
181 y += rowHeights[row];
219 BOOST_FAIL( wxString::Format(
"Unhandled type: %d (if you created a new type you need to handle it in "
220 "this switch statement)",
246 auto item = std::unique_ptr<BOARD_ITEM>( Instantiate( type ) );
248 if( item ==
nullptr )
265 auto item = std::unique_ptr<BOARD_ITEM>( Instantiate( type ) );
267 if( item ==
nullptr )
277 if( PCB_DIMENSION_BASE* dimension = dynamic_cast<PCB_DIMENSION_BASE*>( aOriginalItem ) )
280 auto item = std::unique_ptr<BOARD_ITEM>( aOriginalItem->Duplicate( IGNORE_PARENT_GROUP ) );
281 VECTOR2I originalPos = item->GetPosition();
287 BOOST_CHECK_EQUAL( item->GetPosition(), originalPos + aRef );
290 CompareItems( item.get(), aOriginalItem );
303 auto item = std::unique_ptr<BOARD_ITEM>( Instantiate( type ) );
305 if( item ==
nullptr )
317 if( PCB_DIMENSION_BASE* dimension = dynamic_cast<PCB_DIMENSION_BASE*>( aOriginalItem ) )
319 else if( PCB_BARCODE* barcode = dynamic_cast<PCB_BARCODE*>( aOriginalItem ) )
320 barcode->AssembleBarcode();
322 auto item = std::unique_ptr<BOARD_ITEM>( aOriginalItem->Duplicate( IGNORE_PARENT_GROUP ) );
326 item->Rotate( aRef, EDA_ANGLE( 90.0, DEGREES_T ) );
327 item->Rotate( aRef, EDA_ANGLE( 90.0, DEGREES_T ) );
328 item->Rotate( aRef, EDA_ANGLE( 90.0, DEGREES_T ) );
329 item->Rotate( aRef, EDA_ANGLE( 90.0, DEGREES_T ) );
331 CompareItems( item.get(), aOriginalItem );
344 auto item = std::unique_ptr<BOARD_ITEM>( Instantiate( type ) );
346 if( item ==
nullptr )
356 if( PCB_DIMENSION_BASE* dimension = dynamic_cast<PCB_DIMENSION_BASE*>( aOriginalItem ) )
359 auto item = std::unique_ptr<BOARD_ITEM>( aOriginalItem->Duplicate( IGNORE_PARENT_GROUP ) );
363 item->Flip( aRef, FLIP_DIRECTION::LEFT_RIGHT );
364 item->Flip( aRef, FLIP_DIRECTION::LEFT_RIGHT );
366 CompareItems( item.get(), aOriginalItem );
379 auto item = std::unique_ptr<BOARD_ITEM>( Instantiate( type ) );
381 if( item ==
nullptr )
391 if( PCB_DIMENSION_BASE* dimension = dynamic_cast<PCB_DIMENSION_BASE*>( aOriginalItem ) )
394 auto item = std::unique_ptr<BOARD_ITEM>( aOriginalItem->Duplicate( IGNORE_PARENT_GROUP ) );
398 item->Flip( aRef, FLIP_DIRECTION::TOP_BOTTOM );
399 item->Flip( aRef, FLIP_DIRECTION::TOP_BOTTOM );
401 CompareItems( item.get(), aOriginalItem );
415 table->SetColCount( 2 );
417 for(
int ii = 0; ii < 2; ++ii )
419 table->SetColWidth( ii, aColWidths[ii] );
420 table->SetRowHeight( ii, aRowHeights[ii] );
425 for(
int row = 0; row < 2; ++row )
429 for(
int col = 0; col < 2; ++col )
433 cell->
SetEnd(
VECTOR2I( x + aColWidths[col], y + aRowHeights[row] ) );
434 cell->
SetText( wxString::Format( wxT(
"%c%d" ),
'A' + col, row + 1 ) );
435 table->AddCell( cell );
437 x += aColWidths[col];
440 y += aRowHeights[row];
446 if( aDegrees != 0.0 )
462 auto textAt = [](
PCB_TABLE* aTable,
bool aRight,
bool aBottom )
468 box.
Merge( cell->GetStart() );
469 box.
Merge( cell->GetEnd() );
476 VECTOR2I centre = ( cell->GetStart() + cell->GetEnd() ) / 2;
478 if( ( centre.
x > mid.
x ) == aRight && ( centre.
y > mid.
y ) == aBottom )
479 return cell->GetText();
518 for(
double degrees : { 0.0, 30.0, 45.0, 90.0 } )
528 box.
Contains( cell->GetBoundingBox() ),
529 "cell ( " << cell->GetBoundingBox().GetLeft() <<
", " << cell->GetBoundingBox().GetTop()
530 <<
" ) to ( " << cell->GetBoundingBox().GetRight() <<
", "
531 << cell->GetBoundingBox().GetBottom() <<
" ) sticks out of the table box ( "
545 for(
double degrees : { 0.0, 30.0, 45.0, 90.0 } )
561 BOOST_CHECK_MESSAGE( bbox.
Contains( corner ),
562 "corner ( " << corner.x <<
", " << corner.y <<
" ) is outside the box ( "
584 double apart = std::fmod(
std::abs( aFirst.
AsDegrees() - aSecond.AsDegrees() ), 180.0 );
585 return apart < 0.01 || apart > 179.99;
588 for(
double degrees : { 30.0, 45.0 } )
599 std::vector<VECTOR2I> before;
602 before.push_back( cell->GetStart() );
604 table->Flip( point, dir );
606 BOOST_CHECK_MESSAGE( sameLine(
table->GetCell( 0, 0 )->GetTextAngle(), reflected ),
607 "table came back at " <<
table->GetCell( 0, 0 )->GetTextAngle().AsDegrees()
608 <<
" degrees, expected " << reflected.
AsDegrees() );
611 table->Flip( point, dir );
613 for(
size_t ii = 0; ii < before.size(); ++ii )
615 BOOST_CHECK_MESSAGE( (
table->GetCells()[ii]->GetStart() - before[ii] ).EuclideanNorm()
617 "cell " << ii <<
" did not come back" );
645 pad.SetLayerSet( smd_layers );
673 ZONE live( &m_board );
684 BOOST_CHECK(
image.GetParentGroup() == &
group );
686 image.SetParentGroup(
nullptr );
714 board.
Add( footprint );
717 footprint->
Pads().push_back(
pad );
720 const KIID padId =
pad->m_Uuid;
729 std::deque<PAD*>& pads = footprint->
Pads();
730 pads.erase( std::find( pads.begin(), pads.end(),
pad ) );
733 BOOST_CHECK( board.
ResolveItem( padId,
true ) ==
nullptr );
748 BOOST_CHECK_NO_THROW(
delete dummy );
760 board->
Add( footprint );
763 footprint->
Pads().push_back(
pad );
770 std::deque<PAD*>& pads = footprint->
Pads();
771 pads.erase( std::find( pads.begin(), pads.end(),
pad ) );
775 BOOST_CHECK( !
pad->IsIndexedInBoard() );
776 BOOST_CHECK_NO_THROW(
delete pad );
constexpr EDA_IU_SCALE pcbIUScale
BASE_SET & set(size_t pos)
std::set< DRC_EXCLUSION, DRC_EXCLUSION_COMPARE > m_DrcExclusions
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
void SwapItemData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
Information pertinent to a Pcbnew printed circuit board.
void CacheItemById(BOARD_ITEM *aItem) const
Add an item to the item-by-id cache.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
void RecordDRCExclusions()
Scan existing markers and record data from any that are Excluded.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
bool IsItemIndexedById(const BOARD_ITEM *aItem) const
BOARD_ITEM * ResolveItem(const KIID &aID, bool aAllowNullptrReturn=false) const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr const Vec GetCenter() const
constexpr coord_type GetLeft() const
constexpr bool Contains(const Vec &aPoint) const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
virtual VECTOR2I GetPosition() const
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
virtual EDA_GROUP * GetParentGroup() const
virtual void SetParentGroup(EDA_GROUP *aGroup)
void SetRectangleHeight(const int &aHeight)
void SetRectangleWidth(const int &aWidth)
virtual void SetText(const wxString &aText)
static ENUM_MAP< T > & Instance()
LSET is a set of PCB_LAYER_IDs.
void SetExcluded(bool aExcluded, const wxString &aComment=wxEmptyString)
@ NORMAL
Shape is the same on all layers.
@ CUSTOM
Shapes can be defined on arbitrary layers.
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
void AssembleBarcode() const
Assemble the barcode polygon and text polygons into a single polygonal representation.
void SetText(const wxString &aText)
Set the barcode content text to encode.
For better understanding of the points that make a dimension:
Mark the center of a circle or arc with a cross shape.
A leader is a dimension-like object pointing to a specific point.
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
A radial dimension indicates either the radius or diameter of an arc or circle.
A drill chart placed on the board, kept in step with the holes.
A set of BOARD_ITEMs (i.e., without duplicates).
A PCB_POINT is a 0-dimensional point that is used to mark a position on a PCB, or more usually a foot...
Object to handle a bitmap image that can be inserted in a PCB.
void SetEnd(const VECTOR2I &aEnd) override
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetStart(const VECTOR2I &aStart) override
void SetColWidth(int aCol, int aWidth)
std::vector< PCB_TABLECELL * > GetCells() const
void AddCell(PCB_TABLECELL *aCell)
void SetColCount(int aCount)
void SetRowHeight(int aRow, int aHeight)
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void SetTextAngle(const EDA_ANGLE &aAngle) override
std::vector< VECTOR2I > GetCorners() const override
Return 4 corners for a rectangle or rotated rectangle (stored as a poly).
BOARD_ITEM * Instantiate(KICAD_T aType)
static void CompareItems(BOARD_ITEM *aItem, BOARD_ITEM *aOriginalItem)
TEST_BOARD_ITEM_FIXTURE()
~TEST_BOARD_ITEM_FIXTURE()
std::shared_ptr< DRC_ITEM > m_drcItem
Handle a list of polygons defining a copper zone.
bool AppendCorner(const VECTOR2I &aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
@ DRCE_MALFORMED_COURTYARD
static constexpr EDA_ANGLE ANGLE_180
static void IterateOverPositionsAndReferences(T *aItem, void(*aCallback)(T *, VECTOR2I))
@ LEFT_RIGHT
Flip left to right (around the Y axis)
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ SMD
Smd pad, appears on the solder paste layer (default)
BARCODE class definition.
Class to handle a set of BOARD_ITEMs.
std::vector< FAB_LAYER_COLOR > dummy
@ USER
The field ID hasn't been set yet; field is invalid.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
static PCB_TABLE * makeTable(BOARD &aBoard, const int aColWidths[2], const int aRowHeights[2], double aDegrees)
BOOST_AUTO_TEST_CASE(Type)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST_CONTEXT("Test Clearance")
BOOST_CHECK_EQUAL(result, "25.4")
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ PCB_CONSTRAINT_T
a geometric constraint between board items
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_DRILL_MAP_T
class PCB_DRILL_MAP, drill symbols drawn at the holes
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
@ PCB_ITEM_LIST_T
class BOARD_ITEM_LIST, a list of board items
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_GRID_ITEM_T
a subgrid placed on a board
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_BOARD_OUTLINE_T
class PCB_BOARD_OUTLINE_T, a pcb board outline item
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
@ PCB_NETINFO_T
class NETINFO_ITEM, a description of a net
@ PCB_POINT_T
class PCB_POINT, a 0-dimensional point
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
@ PCB_DRILL_CHART_T
class PCB_DRILL_CHART, a live drill chart derived from PCB_TABLE
constexpr bool IsPcbnewType(const KICAD_T aType)
constexpr bool IsInstantiableType(const KICAD_T aType)
VECTOR2< int32_t > VECTOR2I