46#include <google/protobuf/any.pb.h>
47#include <wx/filename.h>
54void buildHoles(
BOARD& aBoard )
58 for(
int i = 0; i < 2; ++i )
91void buildOutline(
BOARD& aBoard,
const BOX2I& aBox )
100 for(
int ii = 0; ii < 4; ++ii )
105 edge->
SetEnd( corners[( ii + 1 ) % 4] );
117 if( cell->GetText() == aText )
157 std::vector<KIID> before;
160 before.push_back( cell->m_Uuid );
164 std::vector<KIID> after;
167 after.push_back( cell->m_Uuid );
171 BOOST_CHECK( before == after );
228 if( !
pad->HasHole() )
231 const std::vector<int> layers =
pad->ViewGetLayers();
243 const std::vector<int> layers = track->ViewGetLayers();
259 <<
" VIEW_MAX=" << view_max_layers
260 <<
" symbolLayer=" << symbolLayer );
264 BOOST_CHECK_MESSAGE( symbolLayer < view_max_layers,
265 "layer " << symbolLayer <<
" exceeds VIEW_MAX_LAYERS "
266 << view_max_layers );
268 BOOST_CHECK_MESSAGE( reporting > 0,
"no hole reports layer " << symbolLayer );
283 const std::vector<int> layers = track->ViewGetLayers();
302 BOOST_CHECK( map->
HitTest( hole, 0 ) );
309 BOOST_CHECK( !map->
HitTest( hole, 0 ) );
310 BOOST_CHECK( map->
HitTest( hole + offset, 0 ) );
327 BOOST_CHECK( map.
GetOffset() == offset );
335 BOOST_CHECK( map.
GetOffset() == offset );
340 BOOST_CHECK( map.
GetOffset() == offset );
373 buildOutline( board, outlineBox );
383 BOOST_CHECK( map.
HitTest( outlineBox.GetOrigin() + offset, 0 ) );
384 BOOST_CHECK( map.
HitTest(
VECTOR2I( outlineBox.GetLeft(), outlineBox.GetCenter().y ) + offset, 0 ) );
387 BOOST_CHECK( !map.
HitTest( outlineBox.GetCenter() + offset, 0 ) );
388 BOOST_CHECK( !map.
HitTest( outlineBox.GetOrigin(), 0 ) );
402 std::set<wxString> names;
405 names.insert( property->Name() );
407 BOOST_CHECK( names.contains( wxT(
"Offset X" ) ) );
408 BOOST_CHECK( names.contains( wxT(
"Offset Y" ) ) );
409 BOOST_CHECK( names.contains( wxT(
"Symbol Size" ) ) );
410 BOOST_CHECK( !names.contains( wxT(
"Position X" ) ) );
411 BOOST_CHECK( !names.contains( wxT(
"Position Y" ) ) );
418 const int customSize =
pcbIUScale.mmToIU( 3.75 );
424 std::unique_ptr<EDA_ITEM> clone( map.
Clone() );
431 const int otherSize =
pcbIUScale.mmToIU( 1.25 );
437 google::protobuf::Any container;
449 const int customSize =
pcbIUScale.mmToIU( 4.25 );
456 const std::filesystem::path
path(
457 wxFileName::CreateTempFileName( wxT(
"qa_drill_map_roundtrip" ) ).
ToStdString() );
463 const std::vector<const PCB_DRILL_MAP*> maps = restored->DrillMapsOnLayer(
User_1 );
464 BOOST_REQUIRE_EQUAL( maps.size(), 1 );
483 BOOST_CHECK(
via->ViewBBox().Contains( displacedSymbol ) );
495 buildOutline( board, outlineBox );
501 const std::shared_ptr<const SHAPE_POLY_SET> outlines = map.
GetBoardOutlines();
503 BOOST_REQUIRE_EQUAL( outlines->OutlineCount(), 1 );
504 BOOST_CHECK( outlines->BBox() ==
BOX2I( outlineBox.GetOrigin() + offset, outlineBox.GetSize() ) );
526 BOOST_CHECK( map->
GetSpan() == spans[0] );
546 table.SetColCount( 1 );
547 table.ResizeCells( 1, 1 );
561 BOOST_CHECK(
text->Writeable( chart.
GetCells().front() ) );
594 BOOST_CHECK( smd->
ViewBBox() == unmapped );
600 board.
Add( segment );
624 BOOST_CHECK(
via->ViewBBox().Contains(
via->GetPosition() + map->
GetOffset() ) );
641 for(
int col = 0; col < chart.
GetColCount(); ++col )
663 if( cell->GetText() == aText )
664 return cell->GetRow();
685 for(
int col = 0; col < chart.
GetColCount(); ++col )
703 BOOST_CHECK_NE( after, before );
723 for(
int col = 0; col < chart.
GetColCount(); ++col )
728 std::vector<PCB_TRACK*> doomed;
735 doomed.push_back( track );
739 BOOST_REQUIRE_EQUAL( doomed.size(), 2 );
752 BOOST_REQUIRE_EQUAL( chart.
GetRowCount(), rowsBefore - 1 );
757 BOOST_REQUIRE_NE( after, before );
784 const std::map<int, std::string> keys = chart.
RowKeys();
785 std::set<std::string> distinct;
787 for(
const auto& [row, key] : keys )
788 distinct.insert( key );
791 BOOST_REQUIRE_EQUAL( keys.size(), 4 );
808 std::set<const PCB_TABLECELL*> seen;
813 BOOST_CHECK( seen.insert( cell ).second );
830 const std::map<int, std::string> keys = chart->
RowKeys();
834 const std::filesystem::path
path(
835 wxFileName::CreateTempFileName( wxT(
"qa_drill_chart_rowkeys" ) ).
ToStdString() );
843 for(
const BOARD_ITEM* item : restored->Drawings() )
853 BOOST_CHECK( reloaded->
RowKeys() == keys );
868 [&hits](
EDA_ITEM* aItem,
void* aTestData )
899 "chart origin is (" << bbox.
GetLeft() <<
"," << bbox.
GetTop()
900 <<
"), expected near 0" );
918 chart.
Move( placed );
939 std::unique_ptr<EDA_ITEM> clone( chart.
Clone() );
949 copy->SetPrecision( 2 );
966 const std::map<std::string, DRILL_SYMBOL_ASSIGNMENT> resolved =
ResolveDrillSymbols( board );
975 BOOST_CHECK_MESSAGE( resolved.count(
group.m_Key ),
"no symbol for " <<
group.m_Key );
998 for(
int col = 0; col < chart->
GetColCount(); ++col )
1004 const std::filesystem::path
path(
1005 wxFileName::CreateTempFileName( wxT(
"qa_drill_chart_cellfmt" ) ).
ToStdString() );
1013 for(
BOARD_ITEM* item : restored->Drawings() )
1034 buildHoles( board );
1041 const std::vector<DRILL_CHART_COLUMN> columns = chart->
Columns();
1043 const std::filesystem::path
path(
1044 wxFileName::CreateTempFileName( wxT(
"qa_drill_chart_coldefaults" ) ).
ToStdString() );
1052 for(
const BOARD_ITEM* item : restored->Drawings() )
1059 BOOST_REQUIRE_EQUAL( reloaded->
Columns().size(), columns.size() );
1061 for(
size_t ii = 0; ii < columns.size(); ++ii )
1063 BOOST_CHECK( reloaded->
Columns()[ii].m_Heading == columns[ii].m_Heading );
1064 BOOST_CHECK( reloaded->
Columns()[ii].m_Align == columns[ii].m_Align );
constexpr EDA_IU_SCALE pcbIUScale
General utilities for PCB file IO for QA programs.
DRILL_SYMBOL_PROFILE & GetDrillSymbolProfile()
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.
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Information pertinent to a Pcbnew printed circuit board.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
void RefreshDrillSymbolLayers()
const LSET & DrillSymbolLayers() const
Layers that currently have a drill map on them.
uint64_t GetDrillModelGeneration() const
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
void SetCopperLayerCount(int aCount)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
constexpr const Vec GetEnd() const
constexpr size_type GetWidth() const
constexpr size_type GetHeight() const
constexpr coord_type GetLeft() const
constexpr bool Contains(const Vec &aPoint) const
constexpr const Vec & GetOrigin() const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
const std::map< std::string, DRILL_SYMBOL_ASSIGNMENT > & Assignments() const
void SetSymbolSize(int aSize)
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
virtual int GetTextHeight() const
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
static constexpr int VIEW_MAX_LAYERS
Maximum number of layers that may be shown.
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
@ NORMAL
Shape is the same on all layers.
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
void SetAttribute(PAD_ATTRIB aAttribute)
void SetPosition(const VECTOR2I &aPos) override
void SetSize(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
A drill chart placed on the board, kept in step with the holes.
std::vector< DRILL_CHART_COLUMN > & Columns()
uint64_t GetBuiltGeneration() const
Board drill generation the cells were built at.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void RebuildCells(const BOARD &aBoard, DRILL_SYMBOL_PROFILE *aAssignedProfile=nullptr)
Regenerate the cells from the board.
const std::map< int, std::string > & RowKeys() const
Drill group each generated row reports on, by table row.
void SetPrecision(int aPrecision)
Clamped.
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...
bool IsDataRow(int aRow) const
True for a row that reports a drill group, false for the title, heading and totals.
void SetUnits(DRILL_CHART_UNITS aUnits)
Turns on drill symbols at the holes, for one layer.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void SetSpanChoice(int aIndex)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
int GetSymbolSize() const
void SetSymbolSize(int aSize)
int GetSymbolExtent() const
const DRILL_SPAN & GetSpan() const
void Rotate(const VECTOR2I &aCentre, const EDA_ANGLE &aAngle) override
Configuration operations, deliberately not geometry transforms.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
std::shared_ptr< const SHAPE_POLY_SET > GetBoardOutlines() const
The board outline displaced by this map's offset.
const VECTOR2I & GetOffset() const
void SetOffset(const VECTOR2I &aOffset)
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
int GetSpanChoice() const
The span as an index into the board's spans, with -1 for every span.
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
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
PCB_TABLECELL * GetCell(int aRow, int aCol) const
std::vector< PCB_TABLECELL * > GetCells() const
VECTOR2I GetPosition() const override
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true) override
void SetEnd(const VECTOR2I &aEnd)
void SetStart(const VECTOR2I &aStart)
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
const VECTOR2I & GetStart() const
virtual void SetWidth(int aWidth)
void SetDrill(int aDrill)
void SetPadstackMode(PADSTACK::MODE aMode)
void SetPosition(const VECTOR2I &aPoint) override
void SetLayerPair(PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer)
For a via m_layer contains the top layer, the other layer is in m_bottomLayer/.
void SetViaType(VIATYPE aViaType)
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
void SetWidth(int aWidth) override
Provide class metadata.Helper macro to map type hashes to names.
const std::vector< PROPERTY_BASE * > & GetProperties(TYPE_ID aType) const
Return all properties for a specific type.
bool IsWriteableFor(TYPE_ID aItemClass, PROPERTY_BASE *aProp, INSPECTABLE *aItem)
Checks overriden availability and original availability of a property, returns false if the property ...
static PROPERTY_MANAGER & Instance()
void Rebuild()
Rebuild the list of all registered properties.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
static bool empty(const wxTextEntryBase *aCtrl)
std::vector< DRILL_SPAN > EnumerateDrillSpans(const BOARD &aBoard)
Every drill span present on the board, through-holes first.
std::map< std::string, DRILL_SYMBOL_ASSIGNMENT > ResolveDrillSymbols(const BOARD &aBoard)
The symbol every hole should carry, without touching the board.
static std::string ToStdString(const wxString &aStr)
static const wxSize defaultSize(FRAME_T aFrameType, wxWindow *aWindow)
std::function< INSPECT_RESULT(EDA_ITEM *aItem, void *aTestData) > INSPECTOR_FUNC
Used to inspect and possibly collect the (search) results of iterating over a list or tree of KICAD_T...
Some functions to handle hotkeys in KiCad.
@ LAYER_DRILL_SYMBOL_START
Drill symbols, one channel per board layer.
#define DRILL_SYMBOL_LAYER_FOR(boardLayer)
@ LEFT_RIGHT
Flip left to right (around the Y axis)
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
void DumpBoardToFile(BOARD &board, const std::filesystem::path &aFilename)
Utility function to simply write a Board out to a file.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
@ SMD
Smd pad, appears on the solder paste layer (default)
void RefreshDrillCharts(BOARD &aBoard)
Bring every chart on the board up to date.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
int rowShowingDiameter(const PCB_DRILL_CHART &aChart, const wxString &aText)
The row reporting a given drill group, or -1.
BOOST_AUTO_TEST_CASE(GroupsHolesBySizeAndPlating)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
BOOST_CHECK_EQUAL(result, "25.4")
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
@ PCB_DRILL_CHART_T
class PCB_DRILL_CHART, a live drill chart derived from PCB_TABLE
VECTOR2< int32_t > VECTOR2I