KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_footprint.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, see <https://www.gnu.org/licenses/>.
18 */
19
22
23#include <utility>
24
25#include <board.h>
26#include <board_commit.h>
27#include <core/kicad_algo.h>
28#include <core/mirror.h>
29#include <embedded_files.h>
31#include <footprint.h>
32#include <mmh3_hash.h>
33#include <pad.h>
34#include <pcb_field.h>
35#include <pcb_shape.h>
37#include <tool/tool_manager.h>
38
39
40static bool CourtyardEqualPredicate( const SHAPE_POLY_SET& a, const SHAPE_POLY_SET& b )
41{
42 // The courtyards get a tiny epsilon to handle polygonisaton errors
43 const int courtyardEpsilon = pcbIUScale.mmToIU( 0.005 );
44
45 if( a.OutlineCount() != b.OutlineCount() )
46 return false;
47
48 // We can only use this predicate on single-outline polys unless we do more work.
49 // Because we don't know the sub-outlines are in the same order.
50 BOOST_REQUIRE( a.OutlineCount() == 1 );
51
52 return KI_TEST::ChainsAreCyclicallyEqual( a.Outline( 0 ), b.Outline( 0 ), courtyardEpsilon );
53};
54
55
56BOOST_AUTO_TEST_SUITE( Footprint )
57
58
59BOOST_AUTO_TEST_CASE( FootprintCourtyardAndHull )
60{
61 // Footprint courtyards are cached internally. Some operations manipulate the
62 // cache efficiently, some rebuild it. In any case, the courtyard should always
63 // be consistent with the geometry of the footprint. Same for the bounding hull.
64
65 BOARD board;
66 FOOTPRINT fp( &board );
67
68 const int lineW = pcbIUScale.mmToIU( 0.05 );
69 const int courtyardH = pcbIUScale.mmToIU( 1.0 );
70 const int courtyardW = pcbIUScale.mmToIU( 2.0 );
71
72 const std::vector<VECTOR2I> courtyardPoints = {
73 { 0, 0 },
74 { courtyardW, 0 },
75 { courtyardW, courtyardH },
76 { 0, courtyardH },
77 };
78
79 const auto assertCourtyardMatches = [&]( PCB_LAYER_ID layer, const SHAPE_LINE_CHAIN& aExpectedCourtyard )
80 {
81 const SHAPE_POLY_SET& courtyard = fp.GetCourtyard( layer );
82
83 BOOST_REQUIRE( courtyard.OutlineCount() == 1 );
84 BOOST_CHECK_PREDICATE( CourtyardEqualPredicate, ( courtyard.Outline( 0 ) )( aExpectedCourtyard ) );
85 };
86
87 const auto assertNoCourtyard = [&]( PCB_LAYER_ID layer )
88 {
89 const SHAPE_POLY_SET& courtyard = fp.GetCourtyard( layer );
90
91 BOOST_TEST( courtyard.OutlineCount() == 0 );
92 };
93
94 const auto assertHullMatch = [&]( const SHAPE_LINE_CHAIN& aExpectedHull )
95 {
96 const SHAPE_POLY_SET& hull = fp.GetBoundingHull();
97
98 BOOST_REQUIRE( hull.OutlineCount() == 1 );
99 BOOST_CHECK_PREDICATE( KI_TEST::ChainsAreCyclicallyEqual, ( hull.Outline( 0 ) )(aExpectedHull) ( 0 ) );
100 };
101
102 {
103 std::unique_ptr<PCB_SHAPE> courtyardPoly = std::make_unique<PCB_SHAPE>( &fp, SHAPE_T::POLY );
104 courtyardPoly->SetLayer( F_CrtYd );
105 courtyardPoly->SetPolyPoints( courtyardPoints );
106 courtyardPoly->SetWidth( lineW );
107
108 fp.Add( courtyardPoly.release() );
109 }
110
111 // We'll modify this in lock-step with the footprint
112 SHAPE_LINE_CHAIN expectedCourtyard( courtyardPoints, true );
113 // The hull is hard to calculate - we'll take the initial one as a given
114 SHAPE_LINE_CHAIN expectedHull = fp.GetBoundingHull().Outline( 0 );
115
116 BOOST_TEST_CONTEXT( "Initial courtyard" )
117 {
118 assertCourtyardMatches( F_CrtYd, expectedCourtyard );
119 assertNoCourtyard( B_CrtYd );
120 }
121
122 const VECTOR2I moveVector = VECTOR2I( courtyardW, 0 );
123
124 fp.Move( moveVector );
125 expectedCourtyard.Move( moveVector );
126 expectedHull.Move( moveVector );
127
128 BOOST_TEST_CONTEXT( "Moved courtyard" )
129 {
130 assertCourtyardMatches( F_CrtYd, expectedCourtyard );
131 assertNoCourtyard( B_CrtYd );
132 assertHullMatch( expectedHull );
133 }
134
135 fp.Rotate( VECTOR2I( 0, 0 ), EDA_ANGLE( 90.0 ) );
136 expectedCourtyard.Rotate( EDA_ANGLE( 90.0 ), VECTOR2I( 0, 0 ) );
137 expectedHull.Rotate( EDA_ANGLE( 90.0 ), VECTOR2I( 0, 0 ) );
138
139 BOOST_TEST_CONTEXT( "Rotated courtyard" )
140 {
141 assertCourtyardMatches( F_CrtYd, expectedCourtyard );
142 assertNoCourtyard( B_CrtYd );
143 assertHullMatch( expectedHull );
144 }
145
147 expectedCourtyard.Mirror( VECTOR2I( 0, 0 ), FLIP_DIRECTION::LEFT_RIGHT );
148 expectedHull.Mirror( VECTOR2I( 0, 0 ), FLIP_DIRECTION::LEFT_RIGHT );
149
150 const BOX2I flippedExpectedBox = BOX2I::ByCorners( VECTOR2I( -courtyardW, 0 ), VECTOR2I( 0, courtyardH ) );
151
152 BOOST_TEST_CONTEXT( "Flipped courtyard" )
153 {
154 assertCourtyardMatches( B_CrtYd, expectedCourtyard );
155 assertNoCourtyard( F_CrtYd );
156 assertHullMatch( expectedHull );
157 }
158}
159
160
161// Regression test for GitLab issue #24345. Cloning a footprint with embedded files (3D models,
162// fonts, etc.) must not duplicate the embedded payloads. BOARD_NETLIST_UPDATER clones each
163// footprint up to four times per "Update PCB from schematic" pass, so deep-copying embedded
164// data per clone blows up memory on boards with hundreds of footprints carrying large
165// (multi-megabyte) embedded 3D models.
166BOOST_AUTO_TEST_CASE( FootprintCloneSharesEmbeddedFiles )
167{
168 BOARD board;
169 FOOTPRINT fp( &board );
170
171 auto* file = new EMBEDDED_FILES::EMBEDDED_FILE();
172 file->name = wxS( "model.step" );
174
175 // Keep the test payload small so the suite stays fast, but use enough data to exercise
176 // the compression/encode path.
177 std::string payload( 4096, 'k' );
178 file->decompressedData.assign( payload.begin(), payload.end() );
179
181 hash.add( file->decompressedData );
182 file->data_hash = hash.digest().ToString();
183
185
186 fp.AddFile( file );
187
188 EMBEDDED_FILES::EMBEDDED_FILE* originalFile = fp.GetEmbeddedFile( wxS( "model.step" ) );
189 BOOST_REQUIRE( originalFile );
190
191 // Clone the footprint several times, mimicking the BOARD_NETLIST_UPDATER undo-snapshot
192 // pattern. Each clone must reference the same payload, not allocate a fresh copy.
193 std::vector<std::unique_ptr<FOOTPRINT>> clones;
194
195 for( int ii = 0; ii < 4; ++ii )
196 {
197 clones.emplace_back( static_cast<FOOTPRINT*>( fp.Clone() ) );
199 clones.back()->GetEmbeddedFile( wxS( "model.step" ) );
200 BOOST_REQUIRE( cloneFile );
201 BOOST_CHECK_EQUAL( cloneFile, originalFile );
202 }
203
204 // Releasing all clones must leave the source footprint's embedded file intact.
205 clones.clear();
206 BOOST_CHECK( fp.HasFile( wxS( "model.step" ) ) );
207 BOOST_CHECK_EQUAL( fp.GetEmbeddedFile( wxS( "model.step" ) ), originalFile );
208}
209
210
211// Moving a footprint leaves the source with no fields at all, and the damage bounding box is
212// computed for footprints in that state
213BOOST_AUTO_TEST_CASE( FootprintBoundingBoxWithoutMandatoryFields )
214{
215 BOARD board;
216 FOOTPRINT fp( &board );
217
218 const int shapeSize = pcbIUScale.mmToIU( 3.0 );
219
220 {
221 std::unique_ptr<PCB_SHAPE> shape = std::make_unique<PCB_SHAPE>( &fp, SHAPE_T::RECTANGLE );
222 shape->SetLayer( F_Cu );
223 shape->SetStart( VECTOR2I( 0, 0 ) );
224 shape->SetEnd( VECTOR2I( shapeSize, shapeSize ) );
225 shape->SetWidth( pcbIUScale.mmToIU( 0.1 ) );
226
227 fp.Add( shape.release() );
228 }
229
230 // Keep the annotations out of the bounding box so that dropping them cannot change it for
231 // a legitimate reason.
233 fp.GetField( id )->SetVisible( false );
234
235 const BOX2I withFields = fp.GetBoundingBox();
236
238 {
239 std::unique_ptr<PCB_FIELD> field( fp.GetField( id ) );
240 BOOST_REQUIRE( field );
241 fp.Remove( field.get() );
242 }
243
244 const FOOTPRINT& constFp = fp;
247
248 BOOST_CHECK( fp.GetBoundingBox() == withFields );
249
250 // Text variables resolve against the same fields, and are read while the footprint is in
251 // this state to draw it.
252 wxString token = wxS( "VALUE" );
253 BOOST_CHECK( fp.ResolveTextVar( &token ) );
254 BOOST_CHECK( token.IsEmpty() );
255}
256
257
258// The properties dialogs write the whole grid back at once, and the mandatory fields have to
259// come through it as the same objects
260BOOST_AUTO_TEST_CASE( FootprintUpdateFieldsReusesMandatoryFields )
261{
262 BOARD board;
263 FOOTPRINT* fp = new FOOTPRINT( &board );
264
265 board.Add( fp );
266
267 fp->GetField( FIELD_T::VALUE )->SetText( wxS( "old value" ) );
268
269 PCB_FIELD* userField = new PCB_FIELD( fp, FIELD_T::USER, wxS( "MPN" ) );
270 userField->SetText( wxS( "PESD5V0S1BL" ) );
271 fp->Add( userField );
272
273 PCB_FIELD* reference = fp->GetField( FIELD_T::REFERENCE );
274 PCB_FIELD* value = fp->GetField( FIELD_T::VALUE );
275 const KIID referenceId = reference->m_Uuid;
276 const KIID userFieldId = userField->m_Uuid;
277
278 // What the grid hands back: the mandatory fields edited, the user field dropped and a
279 // different one added
280 std::vector<PCB_FIELD> newFields;
281
284 {
285 newFields.push_back( *fp->GetField( id ) );
286 }
287
288 newFields[1].SetText( wxS( "new value" ) );
289 newFields.emplace_back( fp, FIELD_T::USER, wxS( "LCSC" ) );
290
291 std::vector<PCB_FIELD*> added;
292 std::vector<PCB_FIELD*> detached;
293
294 fp->UpdateFields( newFields, added, detached );
295
296 BOOST_CHECK( fp->GetField( FIELD_T::REFERENCE ) == reference );
297 BOOST_CHECK( fp->GetField( FIELD_T::VALUE ) == value );
298 BOOST_CHECK_EQUAL( value->GetText(), wxS( "new value" ) );
299 BOOST_CHECK( value->GetParent() == fp );
300
301 BOOST_REQUIRE_EQUAL( added.size(), 1 );
302 BOOST_CHECK_EQUAL( added.front()->GetName(), wxS( "LCSC" ) );
303 BOOST_CHECK( added.front()->GetParent() == fp );
304
305 BOOST_REQUIRE_EQUAL( detached.size(), 1 );
306 BOOST_CHECK( detached.front() == userField );
307
308 BOOST_CHECK_EQUAL( fp->GetFields().size(), newFields.size() );
309 BOOST_CHECK( !alg::contains( fp->GetFields(), userField ) );
310
311 // The board indexes items by KIID, so it has to learn about the new field and forget the
312 // dropped one. ResolveItem falls back to a linear scan, so the index itself is what tells
313 // us the new field was registered.
314 BOOST_CHECK( board.ResolveItem( referenceId, true ) == reference );
315 BOOST_CHECK( added.front()->IsIndexedInBoard() );
316 BOOST_CHECK( board.ResolveItem( userFieldId, true ) == nullptr );
317
318 for( PCB_FIELD* field : detached )
319 delete field;
320}
321
322
323// A grid write that only edits the mandatory fields adds and removes nothing, so nothing else
324// bumps the board timestamp the bounding box cache is keyed on
325BOOST_AUTO_TEST_CASE( FootprintUpdateFieldsInvalidatesGeometryCache )
326{
327 BOARD board;
328 FOOTPRINT* fp = new FOOTPRINT( &board );
329
330 board.Add( fp );
331
332 fp->GetField( FIELD_T::VALUE )->SetText( wxS( "V" ) );
333
334 const BOX2I before = fp->GetBoundingBox();
335
336 std::vector<PCB_FIELD> newFields;
337
338 for( PCB_FIELD* field : fp->GetFields() )
339 newFields.push_back( *field );
340
341 for( PCB_FIELD& field : newFields )
342 {
343 if( field.GetId() == FIELD_T::VALUE )
344 field.SetPosition( VECTOR2I( pcbIUScale.mmToIU( 50.0 ), 0 ) );
345 }
346
347 std::vector<PCB_FIELD*> added;
348 std::vector<PCB_FIELD*> detached;
349
350 fp->UpdateFields( newFields, added, detached );
351
352 BOOST_REQUIRE( added.empty() );
353 BOOST_REQUIRE( detached.empty() );
354 BOOST_CHECK( fp->GetBoundingBox() != before );
355}
356
357
358// A footprint that has already lost a mandatory field gets it back as a new object, which the
359// caller has to hand to the view itself
360BOOST_AUTO_TEST_CASE( FootprintUpdateFieldsRestoresMissingMandatoryField )
361{
362 BOARD board;
363 FOOTPRINT fp( &board );
364
365 std::vector<PCB_FIELD> newFields;
366
369 {
370 newFields.push_back( *fp.GetField( id ) );
371 }
372
373 std::unique_ptr<PCB_FIELD> orphan( fp.GetField( FIELD_T::VALUE ) );
374 fp.Remove( orphan.get() );
375 BOOST_REQUIRE( !std::as_const( fp ).GetField( FIELD_T::VALUE ) );
376
377 std::vector<PCB_FIELD*> added;
378 std::vector<PCB_FIELD*> detached;
379
380 fp.UpdateFields( newFields, added, detached );
381
382 BOOST_CHECK( detached.empty() );
383 BOOST_REQUIRE_EQUAL( added.size(), 1 );
384 BOOST_CHECK( added.front() == std::as_const( fp ).GetField( FIELD_T::VALUE ) );
385 BOOST_CHECK( added.front() != orphan.get() );
386}
387
388
389BOOST_AUTO_TEST_CASE( FootprintRotationKeepsPolygonArcs )
390{
391 BOARD board;
392 FOOTPRINT footprint( &board );
393
394 PCB_SHAPE* poly = new PCB_SHAPE( &footprint, SHAPE_T::POLY );
395
397 circle.Append( SHAPE_ARC( VECTOR2I( 0, 0 ), VECTOR2I( pcbIUScale.mmToIU( 1 ), 0 ), ANGLE_360 ) );
398 circle.SetClosed( true );
399
401 poly->SetLayer( Cmts_User );
402 footprint.Add( poly );
403
404 footprint.SetOrientation( ANGLE_180 );
405
406 BOOST_CHECK_EQUAL( poly->GetPolyShape().Outline( 0 ).ArcCount(), 1 );
408
409 footprint.SetOrientation( ANGLE_0 );
410
411 BOOST_CHECK_EQUAL( poly->GetPolyShape().Outline( 0 ).ArcCount(), 1 );
412
413 // flipping mirrors the library copy, which must keep its arc for the next rotation
414 footprint.Flip( footprint.GetPosition(), FLIP_DIRECTION::LEFT_RIGHT );
415
417}
418
419
423BOOST_AUTO_TEST_CASE( ExchangeFootprintPadOverridesFollowResetOption )
424{
425 BOARD board;
426 TOOL_MANAGER mgr;
427 mgr.SetEnvironment( &board, nullptr, nullptr, nullptr, nullptr );
428 KI_TEST::DUMMY_TOOL* dummyTool = new KI_TEST::DUMMY_TOOL();
429 mgr.RegisterTool( dummyTool );
430
431 auto addPad = []( FOOTPRINT* aFootprint )
432 {
433 PAD* pad = new PAD( aFootprint );
434 pad->SetNumber( "1" );
436 pad->SetSize( PADSTACK::ALL_LAYERS, VECTOR2I( pcbIUScale.mmToIU( 1 ), pcbIUScale.mmToIU( 1 ) ) );
437 aFootprint->Add( pad );
438 return pad;
439 };
440
441 // Update a board footprint whose pad has overrides with a library one that has none.
442 auto update = [&]( bool aResetClearanceOverrides )
443 {
444 FOOTPRINT* existing = new FOOTPRINT( &board );
445 existing->SetFPID( LIB_ID( "Lib", "Part" ) );
446
447 PAD* pad = addPad( existing );
448 pad->SetLocalClearance( pcbIUScale.mmToIU( 0.4 ) );
449 pad->SetLocalZoneConnection( ZONE_CONNECTION::FULL );
450
451 board.Add( existing );
452 board.BuildConnectivity();
453
454 FOOTPRINT* fromLibrary = new FOOTPRINT( &board );
455 fromLibrary->SetFPID( existing->GetFPID() );
456 addPad( fromLibrary );
457
458 BOARD_COMMIT commit( dummyTool );
459
460 board.ExchangeFootprint( existing, fromLibrary, commit, FLIP_DIRECTION::TOP_BOTTOM, true, true, true, true,
461 true, true, true, aResetClearanceOverrides, true, false );
462 commit.Push( wxT( "Update Footprint" ) );
463
464 // An unmatched pad would carry nothing over and pass the kept case by accident.
465 BOOST_REQUIRE_EQUAL( fromLibrary->Pads().size(), 1u );
466 BOOST_REQUIRE( fromLibrary->Pads()[0]->m_Uuid == pad->m_Uuid );
467
468 return fromLibrary->Pads()[0];
469 };
470
471 const PAD* kept = update( false );
472
473 BOOST_REQUIRE( kept->GetLocalClearance().has_value() );
474 BOOST_CHECK_EQUAL( kept->GetLocalClearance().value(), pcbIUScale.mmToIU( 0.4 ) );
476
477 const PAD* reset = update( true );
478
479 BOOST_CHECK( !reset->GetLocalClearance().has_value() );
481}
482
483
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
BOARD_ITEM_CONTAINER * GetParent() const
Definition board_item.h:281
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition board.cpp:1548
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:369
void ExchangeFootprint(FOOTPRINT *aExisting, FOOTPRINT *aNew, BOARD_COMMIT &aCommit, FLIP_DIRECTION aFlipDirection, bool aMatchPadPositions, bool aDeleteExtraTexts=true, bool aResetTextLayers=true, bool aResetTextEffects=true, bool aResetTextPositions=true, bool aResetTextContent=true, bool aResetFabricationAttrs=true, bool aResetClearanceOverrides=true, bool aReset3DModels=true, bool aResetTransform=false, bool *aUpdated=nullptr, bool *aShifted=nullptr)
Replace aExisting with aNew, preserving connectivity and metadata.
BOARD_ITEM * ResolveItem(const KIID &aID, bool aAllowNullptrReturn=false) const
Definition board.cpp:2176
static constexpr BOX2< VECTOR2I > ByCorners(const VECTOR2I &aCorner1, const VECTOR2I &aCorner2)
Definition box2.h:67
const KIID m_Uuid
Definition eda_item.h:599
SHAPE_POLY_SET & GetPolyShape()
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:118
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:348
virtual void SetText(const wxString &aText)
Definition eda_text.cpp:237
EMBEDDED_FILE * GetEmbeddedFile(const wxString &aName) const
Returns the embedded file with the given name or nullptr if it does not exist.
bool HasFile(const wxString &name) const
EMBEDDED_FILE * AddFile(const wxFileName &aName, bool aOverwrite)
Load a file from disk and adds it to the collection.
static uint32_t Seed()
static RETURN_CODE CompressAndEncode(EMBEDDED_FILE &aFile)
Take data from the decompressedData buffer and compresses it using ZSTD into the compressedEncodedDat...
void SetFPID(const LIB_ID &aFPID)
Definition footprint.h:418
void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
void SetOrientation(const EDA_ANGLE &aNewAngle)
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
void UpdateFields(const std::vector< PCB_FIELD > &aFields, std::vector< PCB_FIELD * > &aAdded, std::vector< PCB_FIELD * > &aDetached)
Replace the fields with aFields, reusing the existing mandatory field objects.
PCB_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this footprint.
std::deque< PAD * > & Pads()
Definition footprint.h:355
bool ResolveTextVar(wxString *aToken, int aDepth=0) const
Resolve any references to system tokens supported by the component.
SHAPE_POLY_SET GetBoundingHull() const
Return a bounding polygon for the shapes and pads in the footprint.
const LIB_ID & GetFPID() const
Definition footprint.h:417
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Adds an item to the container.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
void GetFields(std::vector< PCB_FIELD * > &aVector, bool aVisibleOnly) const
Populate a std::vector with PCB_TEXTs.
const SHAPE_POLY_SET & GetCourtyard(PCB_LAYER_ID aLayer) const
Used in DRC to test the courtyard area (a complex polygon).
VECTOR2I GetPosition() const override
Definition footprint.h:379
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition kiid.h:46
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
A streaming C++ equivalent for MurmurHash3_x64_128.
Definition mmh3_hash.h:61
FORCE_INLINE void add(const std::string &input)
Definition mmh3_hash.h:138
FORCE_INLINE HASH_128 digest()
Definition mmh3_hash.h:157
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
Definition padstack.h:184
Definition pad.h:61
std::optional< int > GetLocalClearance() const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition pad.h:605
ZONE_CONNECTION GetLocalZoneConnection() const
Definition pad.h:633
void SetPolyShape(const SHAPE_POLY_SET &aShape) override
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
SHAPE_POLY_SET GetLibraryPolyShape() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void Move(const VECTOR2I &aVector) override
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
void Mirror(const VECTOR2I &aRef, FLIP_DIRECTION aFlipDirection)
Mirror the line points about y or x (or both).
size_t ArcCount() const
Represent a set of closed polygons.
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.
Master controller class:
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).
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:472
static constexpr EDA_ANGLE ANGLE_360
Definition eda_angle.h:478
static constexpr EDA_ANGLE ANGLE_180
Definition eda_angle.h:476
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition eda_shape.h:58
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ F_CrtYd
Definition layer_ids.h:112
@ Cmts_User
Definition layer_ids.h:104
@ B_CrtYd
Definition layer_ids.h:111
@ F_Cu
Definition layer_ids.h:60
@ LEFT_RIGHT
Flip left to right (around the Y axis)
Definition mirror.h:27
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
Definition mirror.h:28
bool ChainsAreCyclicallyEqual(const SHAPE_LINE_CHAIN &aChainA, const SHAPE_LINE_CHAIN &aChainB, int aTol)
Check that two chains are cyclically equal.
Definition geometry.cpp:40
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition kicad_algo.h:96
@ RECTANGLE
Definition padstack.h:55
Utility functions for working with shapes.
std::string ToString() const
Definition hash_128.h:44
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ USER
The field ID hasn't been set yet; field is invalid.
@ DESCRIPTION
Field Description of part, i.e. "1/4W 1% Metal Film Resistor".
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_CHECK(res.column_datatype(0)==SQL_NUMERIC||res.column_datatype(0)==SQL_DECIMAL)
BOOST_REQUIRE_EQUAL(rows.size(), 1)
BOOST_CHECK_EQUAL(std::any_cast< std::string >(rows[0].at("val")), "12345678901234567.89")
BOOST_REQUIRE(res.columns()==1)
BOOST_AUTO_TEST_CASE(FootprintCourtyardAndHull)
static bool CourtyardEqualPredicate(const SHAPE_POLY_SET &a, const SHAPE_POLY_SET &b)
BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST(netlist.find("R_G1 ARM_OUT1 DIE_B R='0.001 / ((SW_STATE)") !=std::string::npos)
BOOST_CHECK_PREDICATE(ArePolylineEndPointsNearCircle,(chain)(c.m_geom.m_center_point)(radius)(accuracy+epsilon))
BOOST_TEST_CONTEXT("Test Clearance")
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
@ FULL
pads are covered by copper
Definition zones.h:47