KiCad PCB EDA Suite
Loading...
Searching...
No Matches
board_test_utils.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 (C) 2019-2023 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
25
26#include <filesystem>
27
28#include <wx/filename.h>
29#include <board.h>
31#include <footprint.h>
32#include <pcb_shape.h>
33#include <zone.h>
34#include <pad.h>
37#include <tool/tool_manager.h>
38#include <zone_filler.h>
39
40#include <boost/test/unit_test.hpp>
41#include <board_commit.h>
42
43#define CHECK_ENUM_CLASS_EQUAL( L, R ) \
44 BOOST_CHECK_EQUAL( static_cast<int>( L ), static_cast<int>( R ) )
45
46
47namespace KI_TEST
48{
49
51 m_dump_boards( true )
52{
53}
54
55
56void BOARD_DUMPER::DumpBoardToFile( BOARD& aBoard, const std::string& aName ) const
57{
58 if( !m_dump_boards )
59 return;
60
61 auto path = std::filesystem::temp_directory_path() / aName;
62 path += ".kicad_pcb";
63
64 BOOST_TEST_MESSAGE( "Dumping board file: " << path.string() );
65 ::KI_TEST::DumpBoardToFile( aBoard, path.string() );
66}
67
68
69void LoadBoard( SETTINGS_MANAGER& aSettingsManager, const wxString& aRelPath,
70 std::unique_ptr<BOARD>& aBoard )
71{
72 if( aBoard )
73 {
74 aBoard->SetProject( nullptr );
75 aBoard = nullptr;
76 }
77
78 std::string absPath = GetPcbnewTestDataDir() + aRelPath.ToStdString();
79 wxFileName projectFile( absPath + ".kicad_pro" );
80 wxFileName legacyProject( absPath + ".pro" );
81 std::string boardPath = absPath + ".kicad_pcb";
82 wxFileName rulesFile( absPath + ".kicad_dru" );
83
84 if( projectFile.Exists() )
85 aSettingsManager.LoadProject( projectFile.GetFullPath() );
86 else if( legacyProject.Exists() )
87 aSettingsManager.LoadProject( legacyProject.GetFullPath() );
88
89 aBoard = ReadBoardFromFileOrStream( boardPath );
90
91 if( projectFile.Exists() || legacyProject.Exists() )
92 aBoard->SetProject( &aSettingsManager.Prj() );
93
94 auto m_DRCEngine = std::make_shared<DRC_ENGINE>( aBoard.get(), &aBoard->GetDesignSettings() );
95
96 if( rulesFile.Exists() )
97 m_DRCEngine->InitEngine( rulesFile );
98 else
99 m_DRCEngine->InitEngine( wxFileName() );
100
101 aBoard->GetDesignSettings().m_DRCEngine = m_DRCEngine;
102 aBoard->BuildListOfNets();
103 aBoard->BuildConnectivity();
104}
105
106
107void FillZones( BOARD* m_board )
108{
109 TOOL_MANAGER toolMgr;
110 toolMgr.SetEnvironment( m_board, nullptr, nullptr, nullptr, nullptr );
111
112 KI_TEST::DUMMY_TOOL* dummyTool = new KI_TEST::DUMMY_TOOL();
113 toolMgr.RegisterTool( dummyTool );
114
115 BOARD_COMMIT commit( dummyTool );
116 ZONE_FILLER filler( m_board, &commit );
117 std::vector<ZONE*> toFill;
118
119 for( ZONE* zone : m_board->Zones() )
120 toFill.push_back( zone );
121
122 if( filler.Fill( toFill, false, nullptr ) )
123 commit.Push( _( "Fill Zone(s)" ), SKIP_UNDO | SKIP_SET_DIRTY | ZONE_FILL_OP | SKIP_CONNECTIVITY );
124
125 m_board->BuildConnectivity();
126}
127
128
129#define TEST( a, b ) \
130 { \
131 if( a != b ) \
132 return a < b; \
133 }
134#define TEST_PT( a, b ) \
135 { \
136 if( a.x != b.x ) \
137 return a.x < b.x; \
138 if( a.y != b.y ) \
139 return a.y < b.y; \
140 }
141
142
144{
146
147 bool operator()( const BOARD_ITEM* itemA, const BOARD_ITEM* itemB ) const
148 {
149 TEST( itemA->Type(), itemB->Type() );
150
151 if( itemA->GetLayerSet() != itemB->GetLayerSet() )
152 return itemA->GetLayerSet().Seq() < itemB->GetLayerSet().Seq();
153
154 if( itemA->Type() == PCB_TEXT_T )
155 {
156 const PCB_TEXT* textA = static_cast<const PCB_TEXT*>( itemA );
157 const PCB_TEXT* textB = static_cast<const PCB_TEXT*>( itemB );
158
159 TEST_PT( textA->GetPosition(), textB->GetPosition() );
160 TEST( textA->GetTextAngle(), textB->GetTextAngle() );
161 }
162
163 return fp_comp( itemA, itemB );
164 }
165};
166
167
169{
170 CHECK_ENUM_CLASS_EQUAL( expected->Type(), fp->Type() );
171
172 // TODO: validate those informations match the importer
173 BOOST_CHECK_EQUAL( expected->GetPosition(), fp->GetPosition() );
174 BOOST_CHECK_EQUAL( expected->GetOrientation(), fp->GetOrientation() );
175
176 BOOST_CHECK_EQUAL( expected->GetReference(), fp->GetReference() );
177 BOOST_CHECK_EQUAL( expected->GetValue(), fp->GetValue() );
178 BOOST_CHECK_EQUAL( expected->GetLibDescription(), fp->GetLibDescription() );
179 BOOST_CHECK_EQUAL( expected->GetKeywords(), fp->GetKeywords() );
180 BOOST_CHECK_EQUAL( expected->GetAttributes(), fp->GetAttributes() );
181 BOOST_CHECK_EQUAL( expected->GetFlag(), fp->GetFlag() );
182 //BOOST_CHECK_EQUAL( expected->GetProperties(), fp->GetProperties() );
183 BOOST_CHECK_EQUAL( expected->GetTypeName(), fp->GetTypeName() );
184
185 // simple test if count matches
186 BOOST_CHECK_EQUAL( expected->Fields().size(), fp->Fields().size() );
187 BOOST_CHECK_EQUAL( expected->Pads().size(), fp->Pads().size() );
188 BOOST_CHECK_EQUAL( expected->GraphicalItems().size(), fp->GraphicalItems().size() );
189 BOOST_CHECK_EQUAL( expected->Zones().size(), fp->Zones().size() );
190 BOOST_CHECK_EQUAL( expected->Groups().size(), fp->Groups().size() );
191 BOOST_CHECK_EQUAL( expected->Models().size(), fp->Models().size() );
192
193 std::set<PAD*, FOOTPRINT::cmp_pads> expectedPads( expected->Pads().begin(),
194 expected->Pads().end() );
195 std::set<PAD*, FOOTPRINT::cmp_pads> fpPads( fp->Pads().begin(), fp->Pads().end() );
196
197 for( auto itExpected = expectedPads.begin(), itFp = fpPads.begin();
198 itExpected != expectedPads.end() && itFp != fpPads.end(); itExpected++, itFp++ )
199 {
200 CheckFpPad( *itExpected, *itFp );
201 }
202
203 std::set<BOARD_ITEM*, kitest_cmp_drawings> expectedGraphicalItems( expected->GraphicalItems().begin(),
204 expected->GraphicalItems().end() );
205 std::set<BOARD_ITEM*, kitest_cmp_drawings> fpGraphicalItems( fp->GraphicalItems().begin(),
206 fp->GraphicalItems().end() );
207
208 for( auto itExpected = expectedGraphicalItems.begin(), itFp = fpGraphicalItems.begin();
209 itExpected != expectedGraphicalItems.end() && itFp != fpGraphicalItems.end();
210 itExpected++, itFp++ )
211 {
212 BOOST_CHECK_EQUAL( ( *itExpected )->Type(), ( *itFp )->Type() );
213
214 switch( ( *itExpected )->Type() )
215 {
216 case PCB_TEXT_T:
217 {
218 const PCB_TEXT* expectedText = static_cast<const PCB_TEXT*>( *itExpected );
219 const PCB_TEXT* text = static_cast<const PCB_TEXT*>( *itFp );
220
221 CheckFpText( expectedText, text );
222 break;
223 }
224
225 case PCB_SHAPE_T:
226 {
227 const PCB_SHAPE* expectedShape = static_cast<const PCB_SHAPE*>( *itExpected );
228 const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( *itFp );
229
230 CheckFpShape( expectedShape, shape );
231 break;
232 }
233
235 case PCB_DIM_LEADER_T:
236 case PCB_DIM_CENTER_T:
237 case PCB_DIM_RADIAL_T:
239 // TODO
240 break;
241
242 default:
243 BOOST_ERROR( "KICAD_T not known" );
244 break;
245 }
246 }
247
248 std::set<ZONE*, FOOTPRINT::cmp_zones> expectedZones( expected->Zones().begin(),
249 expected->Zones().end() );
250 std::set<ZONE*, FOOTPRINT::cmp_zones> fpZones( fp->Zones().begin(), fp->Zones().end() );
251
252 for( auto itExpected = expectedZones.begin(), itFp = fpZones.begin();
253 itExpected != expectedZones.end() && itFp != fpZones.end(); itExpected++, itFp++ )
254 {
255 CheckFpZone( *itExpected, *itFp );
256 }
257
258 // TODO: Groups
259}
260
261
262void CheckFpPad( const PAD* expected, const PAD* pad )
263{
264 BOOST_TEST_CONTEXT( "Assert PAD with KIID=" << expected->m_Uuid.AsString() )
265 {
266 CHECK_ENUM_CLASS_EQUAL( expected->Type(), pad->Type() );
267
268 BOOST_CHECK_EQUAL( expected->GetNumber(), pad->GetNumber() );
269 CHECK_ENUM_CLASS_EQUAL( expected->GetAttribute(), pad->GetAttribute() );
270 CHECK_ENUM_CLASS_EQUAL( expected->GetProperty(), pad->GetProperty() );
271 CHECK_ENUM_CLASS_EQUAL( expected->GetShape(), pad->GetShape() );
272
273 BOOST_CHECK_EQUAL( expected->IsLocked(), pad->IsLocked() );
274
275 BOOST_CHECK_EQUAL( expected->GetPosition(), pad->GetPosition() );
276 BOOST_CHECK_EQUAL( expected->GetSize(), pad->GetSize() );
277 BOOST_CHECK_EQUAL( expected->GetOrientation(), pad->GetOrientation() );
278 BOOST_CHECK_EQUAL( expected->GetDelta(), pad->GetDelta() );
279 BOOST_CHECK_EQUAL( expected->GetOffset(), pad->GetOffset() );
280 BOOST_CHECK_EQUAL( expected->GetDrillSize(), pad->GetDrillSize() );
281 CHECK_ENUM_CLASS_EQUAL( expected->GetDrillShape(), pad->GetDrillShape() );
282
283 BOOST_CHECK_EQUAL( expected->GetLayerSet(), pad->GetLayerSet() );
284
285 BOOST_CHECK_EQUAL( expected->GetNetCode(), pad->GetNetCode() );
286 BOOST_CHECK_EQUAL( expected->GetPinFunction(), pad->GetPinFunction() );
287 BOOST_CHECK_EQUAL( expected->GetPinType(), pad->GetPinType() );
288 BOOST_CHECK_EQUAL( expected->GetPadToDieLength(), pad->GetPadToDieLength() );
289 BOOST_CHECK_EQUAL( expected->GetLocalSolderMaskMargin(), pad->GetLocalSolderMaskMargin() );
290 BOOST_CHECK_EQUAL( expected->GetLocalSolderPasteMargin(),
291 pad->GetLocalSolderPasteMargin() );
292 BOOST_CHECK_EQUAL( expected->GetLocalSolderPasteMarginRatio(),
293 pad->GetLocalSolderPasteMarginRatio() );
294 BOOST_CHECK_EQUAL( expected->GetLocalClearance(), pad->GetLocalClearance() );
295 CHECK_ENUM_CLASS_EQUAL( expected->GetZoneConnection(), pad->GetZoneConnection() );
296 BOOST_CHECK_EQUAL( expected->GetThermalSpokeWidth(), pad->GetThermalSpokeWidth() );
297 BOOST_CHECK_EQUAL( expected->GetThermalSpokeAngle(), pad->GetThermalSpokeAngle() );
298 BOOST_CHECK_EQUAL( expected->GetThermalGap(), pad->GetThermalGap() );
299 BOOST_CHECK_EQUAL( expected->GetRoundRectRadiusRatio(), pad->GetRoundRectRadiusRatio() );
300 BOOST_CHECK_EQUAL( expected->GetChamferRectRatio(), pad->GetChamferRectRatio() );
301 BOOST_CHECK_EQUAL( expected->GetChamferPositions(), pad->GetChamferPositions() );
302 BOOST_CHECK_EQUAL( expected->GetRemoveUnconnected(), pad->GetRemoveUnconnected() );
303 BOOST_CHECK_EQUAL( expected->GetKeepTopBottom(), pad->GetKeepTopBottom() );
304
305 // TODO: did we check everything for complex pad shapes?
306 CHECK_ENUM_CLASS_EQUAL( expected->GetAnchorPadShape(), pad->GetAnchorPadShape() );
307 CHECK_ENUM_CLASS_EQUAL( expected->GetCustomShapeInZoneOpt(),
308 pad->GetCustomShapeInZoneOpt() );
309
310 BOOST_CHECK_EQUAL( expected->GetPrimitives().size(), pad->GetPrimitives().size() );
311
312 if( expected->GetPrimitives().size() == pad->GetPrimitives().size() )
313 {
314 for( size_t i = 0; i < expected->GetPrimitives().size(); ++i )
315 {
316 CheckFpShape( expected->GetPrimitives().at( i ).get(),
317 pad->GetPrimitives().at( i ).get() );
318 }
319 }
320
321 }
322}
323
324
326{
327 BOOST_TEST_CONTEXT( "Assert PCB_TEXT with KIID=" << expected->m_Uuid.AsString() )
328 {
329 CHECK_ENUM_CLASS_EQUAL( expected->Type(), text->Type() );
330
331 BOOST_CHECK_EQUAL( expected->IsLocked(), text->IsLocked() );
332
333 BOOST_CHECK_EQUAL( expected->GetText(), text->GetText() );
334 BOOST_CHECK_EQUAL( expected->GetPosition(), text->GetPosition() );
335 BOOST_CHECK_EQUAL( expected->GetTextAngle(), text->GetTextAngle() );
336 BOOST_CHECK_EQUAL( expected->IsKeepUpright(), text->IsKeepUpright() );
337
338 BOOST_CHECK_EQUAL( expected->GetLayerSet(), text->GetLayerSet() );
339 BOOST_CHECK_EQUAL( expected->IsVisible(), text->IsVisible() );
340
341 BOOST_CHECK_EQUAL( expected->GetTextSize(), text->GetTextSize() );
342 BOOST_CHECK_EQUAL( expected->GetLineSpacing(), text->GetLineSpacing() );
343 BOOST_CHECK_EQUAL( expected->GetTextThickness(), text->GetTextThickness() );
344 BOOST_CHECK_EQUAL( expected->IsBold(), text->IsBold() );
345 BOOST_CHECK_EQUAL( expected->IsItalic(), text->IsItalic() );
346 BOOST_CHECK_EQUAL( expected->GetHorizJustify(), text->GetHorizJustify() );
347 BOOST_CHECK_EQUAL( expected->GetVertJustify(), text->GetVertJustify() );
348 BOOST_CHECK_EQUAL( expected->IsMirrored(), text->IsMirrored() );
349 BOOST_CHECK_EQUAL( expected->GetFontName(),
350 text->GetFontName() ); // TODO: bold/italic setting?
351
352 // TODO: render cache?
353 }
354}
355
356
357void CheckFpShape( const PCB_SHAPE* expected, const PCB_SHAPE* shape )
358{
359 BOOST_TEST_CONTEXT( "Assert PCB_SHAPE with KIID=" << expected->m_Uuid.AsString() )
360 {
361 CHECK_ENUM_CLASS_EQUAL( expected->Type(), shape->Type() );
362
363 CHECK_ENUM_CLASS_EQUAL( expected->GetShape(), shape->GetShape() );
364
365 BOOST_CHECK_EQUAL( expected->IsLocked(), shape->IsLocked() );
366
367 BOOST_CHECK_EQUAL( expected->GetStart(), shape->GetStart() );
368 BOOST_CHECK_EQUAL( expected->GetEnd(), shape->GetEnd() );
369
370 if( expected->GetShape() == SHAPE_T::ARC )
371 {
372 // center and position might differ as they are calculated from start/mid/end -> compare mid instead
373 BOOST_CHECK_EQUAL( expected->GetArcMid(), shape->GetArcMid() );
374 }
375 else
376 {
377 BOOST_CHECK_EQUAL( expected->GetCenter(), shape->GetCenter() );
378 BOOST_CHECK_EQUAL( expected->GetPosition(), shape->GetPosition() );
379 }
380
381 BOOST_CHECK_EQUAL( expected->GetBezierC1(), shape->GetBezierC1() );
382 BOOST_CHECK_EQUAL( expected->GetBezierC2(), shape->GetBezierC2() );
383
384 CheckShapePolySet( &expected->GetPolyShape(), &shape->GetPolyShape() );
385
386 BOOST_CHECK_EQUAL( expected->GetLayerSet(), shape->GetLayerSet() );
387
388 BOOST_CHECK_EQUAL( expected->GetStroke().GetWidth(), shape->GetStroke().GetWidth() );
389 CHECK_ENUM_CLASS_EQUAL( expected->GetStroke().GetPlotStyle(),
390 shape->GetStroke().GetPlotStyle() );
391 CHECK_ENUM_CLASS_EQUAL( expected->GetFillMode(), shape->GetFillMode() );
392 }
393}
394
395
396void CheckFpZone( const ZONE* expected, const ZONE* zone )
397{
398 BOOST_TEST_CONTEXT( "Assert ZONE with KIID=" << expected->m_Uuid.AsString() )
399 {
400 CHECK_ENUM_CLASS_EQUAL( expected->Type(), zone->Type() );
401
402 BOOST_CHECK_EQUAL( expected->IsLocked(), zone->IsLocked() );
403
404 BOOST_CHECK_EQUAL( expected->GetNetCode(), zone->GetNetCode() );
405 BOOST_CHECK_EQUAL( expected->GetAssignedPriority(), zone->GetAssignedPriority() );
406 CHECK_ENUM_CLASS_EQUAL( expected->GetPadConnection(), zone->GetPadConnection() );
407 BOOST_CHECK_EQUAL( expected->GetLocalClearance(), zone->GetLocalClearance() );
408 BOOST_CHECK_EQUAL( expected->GetMinThickness(), zone->GetMinThickness() );
409
410 BOOST_CHECK_EQUAL( expected->GetLayerSet(), zone->GetLayerSet() );
411
412 BOOST_CHECK_EQUAL( expected->IsFilled(), zone->IsFilled() );
413 CHECK_ENUM_CLASS_EQUAL( expected->GetFillMode(), zone->GetFillMode() );
414 BOOST_CHECK_EQUAL( expected->GetHatchThickness(), zone->GetHatchThickness() );
415 BOOST_CHECK_EQUAL( expected->GetHatchGap(), zone->GetHatchGap() );
416 BOOST_CHECK_EQUAL( expected->GetHatchOrientation(), zone->GetHatchOrientation() );
417 BOOST_CHECK_EQUAL( expected->GetHatchSmoothingLevel(), zone->GetHatchSmoothingLevel() );
418 BOOST_CHECK_EQUAL( expected->GetHatchSmoothingValue(), zone->GetHatchSmoothingValue() );
419 BOOST_CHECK_EQUAL( expected->GetHatchBorderAlgorithm(), zone->GetHatchBorderAlgorithm() );
420 BOOST_CHECK_EQUAL( expected->GetHatchHoleMinArea(), zone->GetHatchHoleMinArea() );
421 BOOST_CHECK_EQUAL( expected->GetThermalReliefGap(), zone->GetThermalReliefGap() );
422 BOOST_CHECK_EQUAL( expected->GetThermalReliefSpokeWidth(),
424 BOOST_CHECK_EQUAL( expected->GetCornerSmoothingType(), zone->GetCornerSmoothingType() );
425 BOOST_CHECK_EQUAL( expected->GetCornerRadius(), zone->GetCornerRadius() );
426 CHECK_ENUM_CLASS_EQUAL( expected->GetIslandRemovalMode(), zone->GetIslandRemovalMode() );
427 BOOST_CHECK_EQUAL( expected->GetMinIslandArea(), zone->GetMinIslandArea() );
428
429 BOOST_CHECK_EQUAL( expected->GetIsRuleArea(), zone->GetIsRuleArea() );
430 BOOST_CHECK_EQUAL( expected->GetDoNotAllowCopperPour(), zone->GetDoNotAllowCopperPour() );
431 BOOST_CHECK_EQUAL( expected->GetDoNotAllowVias(), zone->GetDoNotAllowVias() );
432 BOOST_CHECK_EQUAL( expected->GetDoNotAllowTracks(), zone->GetDoNotAllowTracks() );
433 BOOST_CHECK_EQUAL( expected->GetDoNotAllowPads(), zone->GetDoNotAllowPads() );
434 BOOST_CHECK_EQUAL( expected->GetDoNotAllowFootprints(), zone->GetDoNotAllowFootprints() );
435
436 BOOST_CHECK_EQUAL( expected->GetZoneName(), zone->GetZoneName() );
437 CHECK_ENUM_CLASS_EQUAL( expected->GetTeardropAreaType(), zone->GetTeardropAreaType() );
438 BOOST_CHECK_EQUAL( expected->GetZoneName(), zone->GetZoneName() );
439
440 CheckShapePolySet( expected->Outline(), zone->Outline() );
441 // TODO: filled zones
442 }
443}
444
445
447{
448 BOOST_TEST_CONTEXT( "Assert SHAPE_POLY_SET" )
449 {
450 BOOST_CHECK_EQUAL( expected->OutlineCount(), polyset->OutlineCount() );
451 BOOST_CHECK_EQUAL( expected->TotalVertices(), polyset->TotalVertices() );
452
453 if( expected->OutlineCount() != polyset->OutlineCount() )
454 return; // don't check the rest
455
456 if( expected->TotalVertices() != polyset->TotalVertices() )
457 return; // don't check the rest
458
459 // TODO: check all outlines and holes (just checking outlines for now)
460 for( int i = 0; i < expected->OutlineCount(); ++i )
461 {
462 BOOST_TEST_CONTEXT( "Outline " << i )
463 {
464 BOOST_CHECK_EQUAL( expected->Outline( i ).ArcCount(),
465 polyset->Outline( i ).ArcCount() );
466 BOOST_CHECK_EQUAL( expected->Outline( i ).PointCount(),
467 polyset->Outline( i ).PointCount() );
468
469
470 if( expected->Outline( i ).PointCount() != polyset->Outline( i ).PointCount() )
471 return; // don't check the rest
472
473 for( int j = 0; j < expected->Outline( i ).PointCount(); ++j )
474 {
475 BOOST_CHECK_EQUAL( expected->Outline( i ).GetPoint( j ),
476 polyset->Outline( i ).GetPoint( j ) );
477 }
478 }
479 }
480 }
481}
482
483} // namespace KI_TEST
#define ZONE_FILL_OP
Definition: board_commit.h:43
General utilities for PCB file IO for QA programs.
#define CHECK_ENUM_CLASS_EQUAL(L, R)
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:77
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:209
virtual bool IsLocked() const
Definition: board_item.cpp:73
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:271
ZONES & Zones()
Definition: board.h:319
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
Definition: board.cpp:168
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
const VECTOR2I & GetBezierC2() const
Definition: eda_shape.h:183
FILL_T GetFillMode() const
Definition: eda_shape.h:102
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:256
SHAPE_T GetShape() const
Definition: eda_shape.h:117
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:149
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:124
const VECTOR2I & GetBezierC1() const
Definition: eda_shape.h:180
VECTOR2I GetArcMid() const
Definition: eda_shape.cpp:558
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:131
wxString GetLibDescription() const
Definition: footprint.h:236
EDA_ANGLE GetOrientation() const
Definition: footprint.h:209
ZONES & Zones()
Definition: footprint.h:194
int GetAttributes() const
Definition: footprint.h:277
PADS & Pads()
Definition: footprint.h:188
wxString GetTypeName() const
Get the type of footprint.
Definition: footprint.cpp:925
GROUPS & Groups()
Definition: footprint.h:197
std::vector< FP_3DMODEL > & Models()
Definition: footprint.h:202
PCB_FIELDS & Fields()
Definition: footprint.h:185
const wxString & GetValue() const
Definition: footprint.h:578
const wxString & GetReference() const
Definition: footprint.h:556
int GetFlag() const
Definition: footprint.h:282
wxString GetKeywords() const
Definition: footprint.h:239
VECTOR2I GetPosition() const override
Definition: footprint.h:206
DRAWINGS & GraphicalItems()
Definition: footprint.h:191
void DumpBoardToFile(BOARD &aBoard, const std::string &aName) const
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
Definition: pad.h:58
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.h:72
STROKE_PARAMS GetStroke() const override
Definition: pcb_shape.h:82
VECTOR2I GetPosition() const override
Definition: pcb_shape.h:70
virtual VECTOR2I GetPosition() const override
Definition: pcb_text.h:79
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Loads a project or sets up a new project with a specified path.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
virtual const VECTOR2I GetPoint(int aIndex) const override
int PointCount() const
Return the number of points (vertices) in this line chain.
size_t ArcCount() const
Represent a set of closed polygons.
int TotalVertices() const
Return total number of vertices stored in the set.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int OutlineCount() const
Return the number of outlines in the set.
int GetWidth() const
Definition: stroke_params.h:91
PLOT_DASH_TYPE GetPlotStyle() const
Definition: stroke_params.h:94
Master controller class:
Definition: tool_manager.h:57
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
bool Fill(std::vector< ZONE * > &aZones, bool aCheck=false, wxWindow *aParent=nullptr)
Fills the given list of zones.
Definition: zone_filler.cpp:87
Handle a list of polygons defining a copper zone.
Definition: zone.h:72
int GetHatchBorderAlgorithm() const
Definition: zone.h:291
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:710
bool GetDoNotAllowVias() const
Definition: zone.h:712
bool GetDoNotAllowPads() const
Definition: zone.h:714
bool GetDoNotAllowTracks() const
Definition: zone.h:713
bool IsFilled() const
Definition: zone.h:249
ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Definition: zone.h:724
SHAPE_POLY_SET * Outline()
Definition: zone.h:325
long long int GetMinIslandArea() const
Definition: zone.h:727
int GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition: zone.cpp:501
const wxString & GetZoneName() const
Definition: zone.h:131
int GetMinThickness() const
Definition: zone.h:258
ZONE_CONNECTION GetPadConnection() const
Definition: zone.h:255
int GetHatchThickness() const
Definition: zone.h:273
double GetHatchHoleMinArea() const
Definition: zone.h:288
int GetThermalReliefSpokeWidth() const
Definition: zone.h:202
EDA_ANGLE GetHatchOrientation() const
Definition: zone.h:279
bool GetDoNotAllowFootprints() const
Definition: zone.h:715
ZONE_FILL_MODE GetFillMode() const
Definition: zone.h:181
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.h:129
bool GetDoNotAllowCopperPour() const
Definition: zone.h:711
int GetHatchGap() const
Definition: zone.h:276
TEARDROP_TYPE GetTeardropAreaType() const
Definition: zone.h:705
double GetHatchSmoothingValue() const
Definition: zone.h:285
int GetHatchSmoothingLevel() const
Definition: zone.h:282
unsigned int GetCornerRadius() const
Definition: zone.h:665
int GetCornerSmoothingType() const
Definition: zone.h:661
int GetThermalReliefGap() const
Definition: zone.h:191
unsigned GetAssignedPriority() const
Definition: zone.h:119
#define _(s)
#define TEST_PT(a, b)
#define TEST(a, b)
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
void CheckFootprint(const FOOTPRINT *expected, const FOOTPRINT *fp)
Helper method to check if two footprints are semantically the same.
void FillZones(BOARD *m_board)
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
void CheckFpShape(const PCB_SHAPE *expected, const PCB_SHAPE *shape)
void DumpBoardToFile(BOARD &board, const std::string &aFilename)
Utility function to simply write a Board out to a file.
void CheckFpPad(const PAD *expected, const PAD *pad)
void CheckFpZone(const ZONE *expected, const ZONE *zone)
void CheckFpText(const PCB_TEXT *expected, const PCB_TEXT *text)
void CheckShapePolySet(const SHAPE_POLY_SET *expected, const SHAPE_POLY_SET *polyset)
#define SKIP_CONNECTIVITY
Definition: sch_commit.h:43
#define SKIP_SET_DIRTY
Definition: sch_commit.h:42
#define SKIP_UNDO
Definition: sch_commit.h:40
FOOTPRINT::cmp_drawings fp_comp
bool operator()(const BOARD_ITEM *itemA, const BOARD_ITEM *itemB) const
VECTOR3I expected(15, 30, 45)
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:102
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:99
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:100
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:98
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:101
#define BOOST_TEST_CONTEXT(A)