KiCad PCB EDA Suite
Loading...
Searching...
No Matches
multichannel_tool.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
25#include <board_commit.h>
26#include <tools/pcb_actions.h>
27#include <tools/pcb_selection.h>
28
31
32#include "multichannel_tool.h"
33
34#include <pcbexpr_evaluator.h>
35
36#include <zone.h>
39#include <pcb_group.h>
40#include <pcb_generator.h>
41#include <footprint.h>
42#include <pad.h>
43#include <pcb_text.h>
47#include <algorithm>
48#include <pcb_track.h>
49#include <tool/tool_manager.h>
51#include <chrono>
52#include <core/profile.h>
53#include <thread_pool.h>
55#include <string_utils.h>
56#include <wx/log.h>
57#include <wx/richmsgdlg.h>
58#include <pgm_base.h>
59
60
61#define MULTICHANNEL_EXTRA_DEBUG
62
63static const wxString traceMultichannelTool = wxT( "MULTICHANNEL_TOOL" );
64
65
66static wxString FormatComponentList( const std::set<FOOTPRINT*>& aComponents )
67{
68 std::vector<wxString> refs;
69
70 for( FOOTPRINT* fp : aComponents )
71 {
72 if( !fp )
73 continue;
74
75 refs.push_back( fp->GetReferenceAsString() );
76 }
77
78 std::sort( refs.begin(), refs.end(),
79 []( const wxString& aLhs, const wxString& aRhs )
80 {
81 return aLhs.CmpNoCase( aRhs ) < 0;
82 } );
83
84 if( refs.empty() )
85 return _( "(none)" );
86
87 wxString result;
88 wxString line;
89 size_t componentsOnLine = 0;
90
91 for( const wxString& ref : refs )
92 {
93 if( componentsOnLine == 10 )
94 {
95 if( !result.IsEmpty() )
96 result += wxT( "\n" );
97
98 result += line;
99 line.clear();
100 componentsOnLine = 0;
101 }
102
103 AccumulateDescription( line, ref );
104 componentsOnLine++;
105 }
106
107 if( !line.IsEmpty() )
108 {
109 if( !result.IsEmpty() )
110 result += wxT( "\n" );
111
112 result += line;
113 }
114
115 return result;
116}
117
118
119static void ShowTopologyMismatchReasons( wxWindow* aParent, const wxString& aSummary,
120 const std::vector<wxString>& aReasons )
121{
122 if( !aParent || aReasons.empty() )
123 return;
124
125 wxString reasonText;
126
127 for( size_t idx = 0; idx < aReasons.size(); ++idx )
128 {
129 if( idx > 0 )
130 reasonText += wxT( "\n" );
131
132 reasonText += aReasons[idx];
133 }
134
135 wxRichMessageDialog dlg( aParent, aSummary, _( "Topology mismatch" ), wxICON_ERROR | wxOK );
136 dlg.ShowDetailedText( reasonText );
137 dlg.ShowModal();
138}
139
140
142{
143}
144
145
150
151void MULTICHANNEL_TOOL::ShowMismatchDetails( wxWindow* aParent, const wxString& aSummary,
152 const std::vector<wxString>& aReasons ) const
153{
154 wxWindow* parent = aParent ? aParent : frame();
155 ShowTopologyMismatchReasons( parent, aSummary, aReasons );
156}
157
158
164
165
167 std::set<FOOTPRINT*>& aComponents )
168{
169 if( !aRuleArea || !aRuleArea->m_zone )
170 return false;
171
172 // When we're copying the layout of a design block, we are provided an exact list of items
173 // rather than querying the board for items that are inside the area.
175 {
176 // Get all board connected items that are from the design bloc
177 for( EDA_ITEM* item : aRuleArea->m_designBlockItems )
178 {
179 if( item->Type() == PCB_FOOTPRINT_T )
180 aComponents.insert( static_cast<FOOTPRINT*>( item ) );
181 }
182
183 return (int) aComponents.size();
184 }
185
186
188 PCBEXPR_UCODE ucode;
189 PCBEXPR_CONTEXT ctx, preflightCtx;
190
191 auto reportError =
192 [&]( const wxString& aMessage, int aOffset )
193 {
194 wxLogTrace( traceMultichannelTool, wxT( "ERROR: %s"), aMessage );
195 };
196
197 ctx.SetErrorCallback( reportError );
198 preflightCtx.SetErrorCallback( reportError );
199 compiler.SetErrorCallback( reportError );
200 //compiler.SetDebugReporter( m_reporter );
201
202 wxLogTrace( traceMultichannelTool, wxT( "rule area '%s'" ), aRuleArea->m_zone->GetZoneName() );
203
204 wxString ruleText;
205
206 switch( aRuleArea->m_zone->GetPlacementAreaSourceType() )
207 {
209 ruleText = wxT( "A.memberOfSheetOrChildren('" ) + aRuleArea->m_zone->GetPlacementAreaSource() + wxT( "')" );
210 break;
212 ruleText = wxT( "A.hasComponentClass('" ) + aRuleArea->m_zone->GetPlacementAreaSource() + wxT( "')" );
213 break;
215 ruleText = wxT( "A.memberOfGroup('" ) + aRuleArea->m_zone->GetPlacementAreaSource() + wxT( "')" );
216 break;
218 // For design blocks, handled above outside the rules system
219 break;
220 }
221
222 auto ok = compiler.Compile( ruleText, &ucode, &preflightCtx );
223
224 if( !ok )
225 return false;
226
227 for( FOOTPRINT* fp : board()->Footprints() )
228 {
229 ctx.SetItems( fp, fp );
230 LIBEVAL::VALUE* val = ucode.Run( &ctx );
231
232 if( val->AsDouble() != 0.0 )
233 {
234 wxLogTrace( traceMultichannelTool, wxT( " - %s [sheet %s]" ),
235 fp->GetReference(),
236 fp->GetSheetname() );
237
238 aComponents.insert( fp );
239 }
240 }
241
242 return true;
243}
244
245
246bool MULTICHANNEL_TOOL::findOtherItemsInRuleArea( RULE_AREA* aRuleArea, std::set<BOARD_ITEM*>& aItems )
247{
248 if( !aRuleArea || !aRuleArea->m_zone )
249 return false;
250
251 // When we're copying the layout of a design block, we are provided an exact list of items
252 // rather than querying the board for items that are inside the area.
254 {
255 // Get all board items that aren't footprints. Connected items are usually handled by the
256 // routing path, except zones which are copied via "other items".
257 for( EDA_ITEM* item : aRuleArea->m_designBlockItems )
258 {
259 if( item->Type() == PCB_FOOTPRINT_T )
260 continue;
261
262 // TODO: Preserve nested groups when applying design block layout.
263 if( item->Type() == PCB_GROUP_T )
264 continue;
265
266 if( BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item ) )
267 {
268 if( !boardItem->IsConnected() || boardItem->Type() == PCB_ZONE_T )
269 aItems.insert( boardItem );
270 }
271 }
272
273 return aItems.size() > 0;
274 }
275
277 PCBEXPR_UCODE ucode;
278 PCBEXPR_CONTEXT ctx, preflightCtx;
279
280 auto reportError =
281 [&]( const wxString& aMessage, int aOffset )
282 {
283 wxLogTrace( traceMultichannelTool, wxT( "ERROR: %s"), aMessage );
284 };
285
286 ctx.SetErrorCallback( reportError );
287 preflightCtx.SetErrorCallback( reportError );
288 compiler.SetErrorCallback( reportError );
289
290 // Use the zone's UUID to identify it uniquely. Using the zone name could match other zones
291 // with the same name (e.g., a copper fill zone with the same name as a rule area).
292 wxString ruleText = wxString::Format( wxT( "A.enclosedByArea('%s')" ),
293 aRuleArea->m_zone->m_Uuid.AsString() );
294
295 if( !compiler.Compile( ruleText, &ucode, &preflightCtx ) )
296 return false;
297
298 auto testAndAdd =
299 [&]( BOARD_ITEM* aItem )
300 {
301 ctx.SetItems( aItem, aItem );
302 auto val = ucode.Run( &ctx );
303
304 if( val->AsDouble() != 0.0 )
305 aItems.insert( aItem );
306 };
307
308 for( ZONE* zone : board()->Zones() )
309 {
310 if( zone == aRuleArea->m_zone )
311 continue;
312
313 testAndAdd( zone );
314 }
315
316 for( BOARD_ITEM* drawing : board()->Drawings() )
317 {
318 if( !drawing->IsConnected() )
319 testAndAdd( drawing );
320 }
321
322 return true;
323}
324
325
326std::set<FOOTPRINT*> MULTICHANNEL_TOOL::queryComponentsInSheet( wxString aSheetName ) const
327{
328 std::set<FOOTPRINT*> rv;
329
330 if( aSheetName.EndsWith( wxT( "/" ) ) )
331 aSheetName.RemoveLast();
332
333 wxString childPrefix = aSheetName + wxT( "/" );
334
335 for( FOOTPRINT* fp : board()->Footprints() )
336 {
337 auto sn = fp->GetSheetname();
338
339 if( sn.EndsWith( wxT( "/" ) ) )
340 sn.RemoveLast();
341
342 if( sn == aSheetName || sn.StartsWith( childPrefix ) )
343 rv.insert( fp );
344 }
345
346 return rv;
347}
348
349
350std::set<FOOTPRINT*>
351MULTICHANNEL_TOOL::queryComponentsInComponentClass( const wxString& aComponentClassName ) const
352{
353 std::set<FOOTPRINT*> rv;
354
355 for( FOOTPRINT* fp : board()->Footprints() )
356 {
357 if( fp->GetComponentClass()->ContainsClassName( aComponentClassName ) )
358 rv.insert( fp );
359 }
360
361 return rv;
362}
363
364
365std::set<FOOTPRINT*> MULTICHANNEL_TOOL::queryComponentsInGroup( const wxString& aGroupName ) const
366{
367 std::set<FOOTPRINT*> rv;
368
369 for( PCB_GROUP* group : board()->Groups() )
370 {
371 if( group->GetName() == aGroupName )
372 {
373 for( EDA_ITEM* item : group->GetItems() )
374 {
375 if( item->Type() == PCB_FOOTPRINT_T )
376 rv.insert( static_cast<FOOTPRINT*>( item ) );
377 }
378 }
379 }
380
381 return rv;
382}
383
384
385std::set<BOARD_ITEM*> MULTICHANNEL_TOOL::queryBoardItemsInGroup( const wxString& aGroupName ) const
386{
387 std::set<BOARD_ITEM*> rv;
388
389 for( PCB_GROUP* group : board()->Groups() )
390 {
391 if( group->GetName() != aGroupName )
392 continue;
393
394 for( EDA_ITEM* item : group->GetItems() )
395 {
396 if( item->IsBOARD_ITEM() )
397 rv.insert( static_cast<BOARD_ITEM*>( item ) );
398 }
399 }
400
401 return rv;
402}
403
404
405const SHAPE_LINE_CHAIN MULTICHANNEL_TOOL::buildRAOutline( std::set<FOOTPRINT*>& aFootprints, int aMargin )
406{
407 std::vector<VECTOR2I> bbCorners;
408 bbCorners.reserve( aFootprints.size() * 4 );
409
410 for( FOOTPRINT* fp : aFootprints )
411 {
412 const BOX2I bb = fp->GetBoundingBox( false ).GetInflated( aMargin );
413 KIGEOM::CollectBoxCorners( bb, bbCorners );
414 }
415
416 std::vector<VECTOR2I> hullVertices;
417 BuildConvexHull( hullVertices, bbCorners );
418
419 SHAPE_LINE_CHAIN hull( hullVertices );
420
421 // Make the newly computed convex hull use only 90 degree segments
422 return KIGEOM::RectifyPolygon( hull );
423}
424
425const SHAPE_LINE_CHAIN MULTICHANNEL_TOOL::buildRAOutline( const std::set<BOARD_ITEM*>& aItems, int aMargin )
426{
427 std::vector<VECTOR2I> bbCorners;
428 bbCorners.reserve( aItems.size() * 4 );
429
430 for( BOARD_ITEM* item : aItems )
431 {
432 BOX2I bb = item->GetBoundingBox();
433
434 if( item->Type() == PCB_FOOTPRINT_T )
435 bb = static_cast<FOOTPRINT*>( item )->GetBoundingBox( false );
436
437 KIGEOM::CollectBoxCorners( bb.GetInflated( aMargin ), bbCorners );
438 }
439
440 std::vector<VECTOR2I> hullVertices;
441 BuildConvexHull( hullVertices, bbCorners );
442
443 SHAPE_LINE_CHAIN hull( hullVertices );
444
445 // Make the newly computed convex hull use only 90 degree segments
446 return KIGEOM::RectifyPolygon( hull );
447}
448
449
451{
452 using PathAndName = std::pair<wxString, wxString>;
453 std::set<PathAndName> uniqueSheets;
454 std::set<wxString> uniqueComponentClasses;
455 std::set<wxString> uniqueGroups;
456
457 m_areas.m_areas.clear();
458
459 for( const FOOTPRINT* fp : board()->Footprints() )
460 {
461 uniqueSheets.insert( PathAndName( fp->GetSheetname(), fp->GetSheetfile() ) );
462
463 const COMPONENT_CLASS* compClass = fp->GetComponentClass();
464
465 for( const COMPONENT_CLASS* singleClass : compClass->GetConstituentClasses() )
466 uniqueComponentClasses.insert( singleClass->GetName() );
467
468 if( fp->GetParentGroup() && !fp->GetParentGroup()->GetName().IsEmpty() )
469 uniqueGroups.insert( fp->GetParentGroup()->GetName() );
470 }
471
472 for( const PathAndName& sheet : uniqueSheets )
473 {
474 RULE_AREA ent;
475
477 ent.m_generateEnabled = false;
478 ent.m_sheetPath = sheet.first;
479 ent.m_sheetName = sheet.second;
481 m_areas.m_areas.push_back( ent );
482
483 wxLogTrace( traceMultichannelTool, wxT("found sheet '%s' @ '%s' s %d\n"),
484 ent.m_sheetName,
485 ent.m_sheetPath,
486 (int) m_areas.m_areas.size() );
487 }
488
489 for( const wxString& compClass : uniqueComponentClasses )
490 {
491 RULE_AREA ent;
492
494 ent.m_generateEnabled = false;
495 ent.m_componentClass = compClass;
497 m_areas.m_areas.push_back( ent );
498
499 wxLogTrace( traceMultichannelTool, wxT( "found component class '%s' s %d\n" ),
501 static_cast<int>( m_areas.m_areas.size() ) );
502 }
503
504 for( const wxString& groupName : uniqueGroups )
505 {
506 RULE_AREA ent;
507
509 ent.m_generateEnabled = false;
510 ent.m_groupName = groupName;
512 m_areas.m_areas.push_back( ent );
513
514 wxLogTrace( traceMultichannelTool, wxT( "found group '%s' s %d\n" ),
516 static_cast<int>( m_areas.m_areas.size() ) );
517 }
518}
519
520
522{
523 m_areas.m_areas.clear();
524
525 for( ZONE* zone : board()->Zones() )
526 {
527 if( !zone->GetIsRuleArea() )
528 continue;
529
530 if( !zone->GetPlacementAreaEnabled() )
531 continue;
532
533 RULE_AREA area;
534
535 area.m_existsAlready = true;
536 area.m_zone = zone;
537 area.m_ruleName = zone->GetZoneName();
538 area.m_center = zone->Outline()->COutline( 0 ).Centre();
539
541
542 m_areas.m_areas.push_back( area );
543
544 wxLogTrace( traceMultichannelTool, wxT( "RA '%s', %d footprints\n" ), area.m_ruleName,
545 (int) area.m_components.size() );
546 }
547
548 wxLogTrace( traceMultichannelTool, wxT( "Total RAs found: %d\n" ), (int) m_areas.m_areas.size() );
549}
550
551
553{
554 for( RULE_AREA& ra : m_areas.m_areas )
555 {
556 if( ra.m_ruleName == aName )
557 return &ra;
558 }
559
560 return nullptr;
561}
562
563
565{
567}
568
569
571{
572 std::vector<ZONE*> refRAs;
573
574 auto isSelectedItemAnRA =
575 []( EDA_ITEM* aItem ) -> ZONE*
576 {
577 if( !aItem || aItem->Type() != PCB_ZONE_T )
578 return nullptr;
579
580 ZONE* zone = static_cast<ZONE*>( aItem );
581
582 if( !zone->GetIsRuleArea() )
583 return nullptr;
584
585 if( !zone->GetPlacementAreaEnabled() )
586 return nullptr;
587
588 return zone;
589 };
590
591 for( EDA_ITEM* item : selection() )
592 {
593 if( ZONE* zone = isSelectedItemAnRA( item ) )
594 {
595 refRAs.push_back( zone );
596 }
597 else if( item->Type() == PCB_GROUP_T )
598 {
599 PCB_GROUP *group = static_cast<PCB_GROUP*>( item );
600
601 for( EDA_ITEM* grpItem : group->GetItems() )
602 {
603 if( ZONE* grpZone = isSelectedItemAnRA( grpItem ) )
604 refRAs.push_back( grpZone );
605 }
606 }
607 }
608
609 if( refRAs.size() != 1 )
610 {
613 this,
614 _( "Select a reference Rule Area to copy from..." ),
615 [&]( EDA_ITEM* aItem )
616 {
617 return isSelectedItemAnRA( aItem ) != nullptr;
618 }
619 } );
620
621 return 0;
622 }
623
625
626 int status = CheckRACompatibility( refRAs.front() );
627
628 if( status < 0 )
629 return status;
630
631 if( m_areas.m_areas.size() <= 1 )
632 {
633 frame()->ShowInfoBarError( _( "No Rule Areas to repeat layout to have been found." ), true );
634 return 0;
635 }
636
638 int ret = dialog.ShowModal();
639
640 if( ret != wxID_OK )
641 return 0;
642
643 return RepeatLayout( aEvent, refRAs.front() );
644}
645
646
648{
649 m_areas.m_refRA = nullptr;
650
651 for( RULE_AREA& ra : m_areas.m_areas )
652 {
653 if( ra.m_zone == aRefZone )
654 {
655 m_areas.m_refRA = &ra;
656 break;
657 }
658 }
659
660 if( !m_areas.m_refRA )
661 return -1;
662
663 m_areas.m_compatMap.clear();
664
665 std::vector<RULE_AREA*> targets;
666
667 for( RULE_AREA& ra : m_areas.m_areas )
668 {
669 if( ra.m_zone == m_areas.m_refRA->m_zone )
670 continue;
671
672 targets.push_back( &ra );
673 m_areas.m_compatMap[&ra] = RULE_AREA_COMPAT_DATA();
674 }
675
676 if( targets.empty() )
677 return 0;
678
679 int total = static_cast<int>( targets.size() );
680 std::atomic<int> completed( 0 );
681 std::atomic<bool> cancelled( false );
682 std::atomic<int> matchedComponents( 0 );
683 std::atomic<int> totalComponents( 0 );
684 RULE_AREA* refRA = m_areas.m_refRA;
685
687 isoParams.m_cancelled = &cancelled;
688 isoParams.m_matchedComponents = &matchedComponents;
689 isoParams.m_totalComponents = &totalComponents;
690
691 // Process RA resolutions sequentially on a single background thread.
692 // Each resolveConnectionTopology call internally parallelizes its MRV scan
693 // across the thread pool, creating many short-lived tasks that fully utilize
694 // all available cores. Running the outer loop sequentially avoids thread
695 // pool starvation from nested parallelism.
697
698 auto future = tp.submit_task(
699 [this, refRA, &targets, &completed, &cancelled, &matchedComponents, &isoParams]()
700 {
701 for( RULE_AREA* target : targets )
702 {
703 if( cancelled.load( std::memory_order_relaxed ) )
704 break;
705
706 matchedComponents.store( 0, std::memory_order_relaxed );
707
708 RULE_AREA_COMPAT_DATA& compatData = m_areas.m_compatMap[target];
709 resolveConnectionTopology( refRA, target, compatData, isoParams );
710 completed.fetch_add( 1, std::memory_order_relaxed );
711 }
712 } );
713
714 if( Pgm().IsGUI() )
715 {
716 std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
717 auto startTime = std::chrono::steady_clock::now();
718 double highWaterMark = 0.0;
719
720 while( future.wait_for( std::chrono::milliseconds( 100 ) ) != std::future_status::ready )
721 {
722 if( !reporter )
723 {
724 auto elapsed = std::chrono::steady_clock::now() - startTime;
725
726 if( elapsed > std::chrono::seconds( 1 ) )
727 {
728 reporter = std::make_unique<WX_PROGRESS_REPORTER>(
729 frame(), _( "Checking Rule Area compatibility..." ), 1, PR_CAN_ABORT );
730 }
731 else
732 {
733 // Flush background-thread log messages so timing traces appear promptly
734 wxLog::FlushActive();
735 }
736 }
737
738 if( reporter )
739 {
740 int done = completed.load( std::memory_order_relaxed );
741 int matched = matchedComponents.load( std::memory_order_relaxed );
742 int compTotal = totalComponents.load( std::memory_order_relaxed );
743
744 double fraction = ( compTotal > 0 )
745 ? static_cast<double>( matched ) / compTotal
746 : 0.0;
747 double progress = static_cast<double>( done + fraction ) / total;
748
749 if( progress > highWaterMark )
750 highWaterMark = progress;
751
752 reporter->SetCurrentProgress( highWaterMark );
753 reporter->Report( wxString::Format(
754 _( "Resolving topology %d of %d (%d/%d components)" ),
755 done + 1, total, matched, compTotal ) );
756
757 if( !reporter->KeepRefreshing() )
758 cancelled.store( true, std::memory_order_relaxed );
759 }
760 }
761 }
762 else
763 {
764 future.wait();
765 }
766
767 if( cancelled.load( std::memory_order_relaxed ) )
768 {
769 m_areas.m_compatMap.clear();
770 return -1;
771 }
772
773 return 0;
774}
775
776
777int MULTICHANNEL_TOOL::RepeatLayout( const TOOL_EVENT& aEvent, RULE_AREA& aRefArea, RULE_AREA& aTargetArea,
778 REPEAT_LAYOUT_OPTIONS& aOptions )
779{
780 wxCHECK_MSG( aRefArea.m_zone, -1, wxT( "Reference Rule Area has no zone." ) );
781 wxCHECK_MSG( aTargetArea.m_zone, -1, wxT( "Target Rule Area has no zone." ) );
782
784
785 if( !resolveConnectionTopology( &aRefArea, &aTargetArea, compat ) )
786 {
787 if( Pgm().IsGUI() )
788 {
789 wxString summary = wxString::Format( _( "Rule Area topologies do not match: %s" ), compat.m_errorMsg );
791 }
792
793 return -1;
794 }
795
796 BOARD_COMMIT commit( GetManager(), true, false );
797
798 // If no anchor is provided, pick the first matched pair to avoid center-alignment shifting
799 // the whole group. This keeps Apply Design Block Layout from moving the group to wherever
800 // the source design block happened to be placed.
801 if( aTargetArea.m_sourceType == PLACEMENT_SOURCE_T::GROUP_PLACEMENT && !aOptions.m_anchorFp )
802 {
803 if( !compat.m_matchingComponents.empty() )
804 aOptions.m_anchorFp = compat.m_matchingComponents.begin()->first;
805 }
806
807 if( !copyRuleAreaContents( &aRefArea, &aTargetArea, &commit, aOptions, compat ) )
808 {
809 auto errMsg = wxString::Format( _( "Copy Rule Area contents failed between rule areas '%s' and '%s'." ),
810 aRefArea.m_zone->GetZoneName(), aTargetArea.m_zone->GetZoneName() );
811
812 commit.Revert();
813
814 if( Pgm().IsGUI() )
815 frame()->ShowInfoBarError( errMsg, true );
816
817 return -1;
818 }
819
821 {
822 if( aTargetArea.m_components.size() == 0 || !( *aTargetArea.m_components.begin() )->GetParentGroup() )
823 {
824 commit.Revert();
825
826 if( Pgm().IsGUI() )
827 frame()->ShowInfoBarError( _( "Target group does not have a group." ), true );
828
829 return -1;
830 }
831
832 EDA_GROUP* group = ( *aTargetArea.m_components.begin() )->GetParentGroup();
833
834 commit.Modify( group->AsEdaItem(), nullptr, RECURSE_MODE::NO_RECURSE );
835
836 for( BOARD_ITEM* item : compat.m_groupableItems )
837 {
838 commit.Modify( item );
839 group->AddItem( item );
840 }
841 }
842
843 commit.Push( _( "Repeat layout" ) );
844
845 return 0;
846}
847
848
849int MULTICHANNEL_TOOL::RepeatLayout( const TOOL_EVENT& aEvent, ZONE* aRefZone )
850{
851 int totalCopied = 0;
852
853 BOARD_COMMIT commit( GetManager(), true, false );
854
855 for( auto& [targetArea, compatData] : m_areas.m_compatMap )
856 {
857 if( !compatData.m_doCopy )
858 {
859 wxLogTrace( traceMultichannelTool, wxT( "skipping copy to RA '%s' (disabled in dialog)\n" ),
860 targetArea->m_ruleName );
861 continue;
862 }
863
864 if( !compatData.m_isOk )
865 continue;
866
867 if( !copyRuleAreaContents( m_areas.m_refRA, targetArea, &commit, m_areas.m_options, compatData ) )
868 {
869 auto errMsg = wxString::Format( _( "Copy Rule Area contents failed between rule areas '%s' and '%s'." ),
870 m_areas.m_refRA->m_zone->GetZoneName(),
871 targetArea->m_zone->GetZoneName() );
872
873 commit.Revert();
874
875 if( Pgm().IsGUI() )
876 frame()->ShowInfoBarError( errMsg, true );
877
878 return -1;
879 }
880
881 totalCopied++;
882 wxSafeYield();
883 }
884
885 if( m_areas.m_options.m_groupItems )
886 {
887 for( const auto& [targetArea, compatData] : m_areas.m_compatMap )
888 {
889 if( compatData.m_groupableItems.size() < 2 )
890 continue;
891
892 pruneExistingGroups( commit, compatData.m_affectedItems );
893
894 PCB_GROUP* group = new PCB_GROUP( board() );
895
896 commit.Add( group );
897
898 for( BOARD_ITEM* item : compatData.m_groupableItems )
899 {
900 commit.Modify( item );
901 group->AddItem( item );
902 }
903 }
904 }
905
906 commit.Push( _( "Repeat layout" ) );
907
908 if( Pgm().IsGUI() )
909 frame()->ShowInfoBarMsg( wxString::Format( _( "Copied to %d Rule Areas." ), totalCopied ), true );
910
911 return 0;
912}
913
914
915wxString MULTICHANNEL_TOOL::stripComponentIndex( const wxString& aRef ) const
916{
917 wxString rv;
918
919 // fixme: i'm pretty sure this can be written in a simpler way, but I really suck at figuring
920 // out which wx's built in functions would do it for me. And I hate regexps :-)
921 for( auto k : aRef )
922 {
923 if( !k.IsAscii() )
924 break;
925
926 char c;
927 k.GetAsChar( &c );
928
929 if( ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) || ( c == '_' ) )
930 rv.Append( k );
931 else
932 break;
933 }
934
935 return rv;
936}
937
938
939int MULTICHANNEL_TOOL::findRoutingInRuleArea( RULE_AREA* aRuleArea, std::set<BOARD_CONNECTED_ITEM*>& aOutput,
940 std::shared_ptr<CONNECTIVITY_DATA> aConnectivity,
941 const SHAPE_POLY_SET& aRAPoly, const REPEAT_LAYOUT_OPTIONS& aOpts ) const
942{
943 if( !aRuleArea || !aRuleArea->m_zone )
944 return 0;
945
946 // The user also will consider tracks and vias that are inside the source area but
947 // not connected to any of the source pads to count as "routing" (e.g. stitching vias)
948
949 int count = 0;
950
951 // When we're copying the layout of a design block, we are provided an exact list of items
952 // rather than querying the board for items that are inside the area.
954 {
955 // Get all board connected items that are from the design block, except pads,
956 // which shouldn't be copied
957 for( EDA_ITEM* item : aRuleArea->m_designBlockItems )
958 {
959 // Include any connected items except pads.
960 if( item->Type() == PCB_PAD_T )
961 continue;
962
963 if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
964 {
965 // Zones are handled by the "copy other items" path, we need this check here
966 // because design blocks explicitly include them as part of the block contents,
967 // but other RA types grab them by querying the board for items enclosed by the RA polygon
968 if( bci->Type() == PCB_ZONE_T )
969 continue;
970
971 if( bci->IsConnected() )
972 aOutput.insert( bci );
973 }
974 }
975
976 return (int) aOutput.size();
977 }
978
980 PCBEXPR_UCODE ucode;
981 PCBEXPR_CONTEXT ctx, preflightCtx;
982
983 auto reportError =
984 [&]( const wxString& aMessage, int aOffset )
985 {
986 wxLogTrace( traceMultichannelTool, wxT( "ERROR: %s" ), aMessage );
987 };
988
989 ctx.SetErrorCallback( reportError );
990 preflightCtx.SetErrorCallback( reportError );
991 compiler.SetErrorCallback( reportError );
992
993 // Use the zone's UUID to identify it uniquely. Using the zone name could match other zones
994 // with the same name (e.g., a copper fill zone with the same name as a rule area).
995 wxString ruleText = wxString::Format( wxT( "A.enclosedByArea('%s')" ),
996 aRuleArea->m_zone->m_Uuid.AsString() );
997
998 auto testAndAdd =
999 [&]( BOARD_CONNECTED_ITEM* aItem )
1000 {
1001 if( aOutput.contains( aItem ) )
1002 return;
1003
1004 ctx.SetItems( aItem, aItem );
1005 LIBEVAL::VALUE* val = ucode.Run( &ctx );
1006
1007 if( val->AsDouble() != 0.0 )
1008 {
1009 aOutput.insert( aItem );
1010 count++;
1011 }
1012 };
1013
1014 if( compiler.Compile( ruleText, &ucode, &preflightCtx ) )
1015 {
1016 for( PCB_TRACK* track : board()->Tracks() )
1017 testAndAdd( track );
1018
1019 for( BOARD_ITEM* drawing : board()->Drawings() )
1020 {
1021 if( drawing->IsConnected() )
1022 testAndAdd( static_cast<BOARD_CONNECTED_ITEM*>( drawing ) );
1023 }
1024
1025 for( PCB_GENERATOR* generator : board()->Generators() )
1026 {
1027 if( generator->GetGeneratorType() != wxT( "tuning_pattern" ) )
1028 continue;
1029
1030 if( !generator->HitTest( aRAPoly.Outline( 0 ), false ) )
1031 continue;
1032
1033 for( EDA_ITEM* member : generator->GetItems() )
1034 {
1035 if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( member ) )
1036 {
1037 if( !aOutput.contains( bci ) )
1038 {
1039 aOutput.insert( bci );
1040 count++;
1041 }
1042 }
1043 }
1044 }
1045 }
1046
1047 return count;
1048}
1049
1050
1052 BOARD_COMMIT* aCommit, REPEAT_LAYOUT_OPTIONS aOpts,
1053 RULE_AREA_COMPAT_DATA& aCompatData )
1054{
1055 // copy RA shapes first
1056 SHAPE_LINE_CHAIN refOutline = aRefArea->m_zone->Outline()->COutline( 0 );
1057 SHAPE_LINE_CHAIN targetOutline = aTargetArea->m_zone->Outline()->COutline( 0 );
1058
1059 FOOTPRINT* targetAnchorFp = nullptr;
1060 VECTOR2I disp = aTargetArea->m_center - aRefArea->m_center;
1061 EDA_ANGLE rot = EDA_ANGLE( 0 );
1062
1063 if( aOpts.m_anchorFp )
1064 {
1065 for( const auto& [refFP, targetFP] : aCompatData.m_matchingComponents )
1066 {
1067 if( refFP->GetReference() == aOpts.m_anchorFp->GetReference() )
1068 targetAnchorFp = targetFP;
1069 }
1070
1071 // If the dialog-selected anchor reference doesn't exist in the target area (e.g. refs don't match),
1072 // fall back to the first matched pair to avoid center-alignment shifting the whole group.
1073 if( !targetAnchorFp && !aCompatData.m_matchingComponents.empty() )
1074 targetAnchorFp = aCompatData.m_matchingComponents.begin()->second;
1075
1076 if( targetAnchorFp )
1077 {
1078 VECTOR2I oldpos = aOpts.m_anchorFp->GetPosition();
1079 rot = EDA_ANGLE( targetAnchorFp->GetOrientationDegrees() - aOpts.m_anchorFp->GetOrientationDegrees() );
1080 aOpts.m_anchorFp->Rotate( VECTOR2( 0, 0 ), EDA_ANGLE( rot ) );
1081 oldpos = aOpts.m_anchorFp->GetPosition();
1082 VECTOR2I newpos = targetAnchorFp->GetPosition();
1083 disp = newpos - oldpos;
1084 aOpts.m_anchorFp->Rotate( VECTOR2( 0, 0 ), EDA_ANGLE( -rot ) );
1085 }
1086 }
1087
1088 SHAPE_POLY_SET refPoly;
1089 refPoly.AddOutline( refOutline );
1090 refPoly.CacheTriangulation();
1091
1092 SHAPE_POLY_SET targetPoly;
1093
1094 SHAPE_LINE_CHAIN newTargetOutline( refOutline );
1095 newTargetOutline.Rotate( rot, VECTOR2( 0, 0 ) );
1096 newTargetOutline.Move( disp );
1097 targetPoly.AddOutline( newTargetOutline );
1098 targetPoly.CacheTriangulation();
1099
1100 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board()->GetConnectivity();
1101 std::map<EDA_GROUP*, EDA_GROUP*> groupMap;
1102
1103 // For Apply Design Block Layout, grouping is handled later by RepeatLayout() using the
1104 // existing target group. Do not clone groups here or we end up with duplicates.
1105 const bool preserveGroups = aTargetArea->m_sourceType != PLACEMENT_SOURCE_T::GROUP_PLACEMENT;
1106
1107 auto fixupParentGroup =
1108 [&]( BOARD_ITEM* sourceItem, BOARD_ITEM* destItem )
1109 {
1110 if( !preserveGroups )
1111 return;
1112
1113 if( EDA_GROUP* parentGroup = sourceItem->GetParentGroup() )
1114 {
1115 if( !groupMap.contains( parentGroup ) )
1116 {
1117 PCB_GROUP* newGroup = static_cast<PCB_GROUP*>(
1118 static_cast<PCB_GROUP*>( parentGroup->AsEdaItem() )->Duplicate( false ) );
1119 newGroup->GetItems().clear();
1120 newGroup->SetParentGroup( nullptr );
1121
1122 if( newGroup->Type() == PCB_GENERATOR_T )
1123 {
1124 newGroup->Rotate( VECTOR2( 0, 0 ), rot );
1125 newGroup->Move( disp );
1126 }
1127
1128 groupMap[parentGroup] = newGroup;
1129 aCommit->Add( newGroup );
1130 }
1131
1132 groupMap[parentGroup]->AddItem( destItem );
1133 }
1134 };
1135
1136 // Only stage changes for a target Rule Area zone if it actually belongs to the board.
1137 // In some workflows (e.g. ApplyDesignBlockLayout), the target area is a temporary zone
1138 // and is not added to the BOARD.
1139 bool targetZoneOnBoard = false;
1140
1141 if( aTargetArea->m_zone )
1142 {
1143 for( ZONE* z : board()->Zones() )
1144 {
1145 if( z == aTargetArea->m_zone )
1146 {
1147 targetZoneOnBoard = true;
1148 break;
1149 }
1150 }
1151 }
1152
1153 if( targetZoneOnBoard )
1154 {
1155 aCommit->Modify( aTargetArea->m_zone );
1156 aCompatData.m_affectedItems.insert( aTargetArea->m_zone );
1157 aCompatData.m_groupableItems.insert( aTargetArea->m_zone );
1158 }
1159
1160 if( aOpts.m_copyRouting )
1161 {
1162 std::set<BOARD_CONNECTED_ITEM*> refRouting;
1163 std::set<BOARD_CONNECTED_ITEM*> targetRouting;
1164
1165 wxLogTrace( traceMultichannelTool, wxT( "copying routing: %d fps\n" ),
1166 (int) aCompatData.m_matchingComponents.size() );
1167
1168 std::set<int> refc;
1169 std::set<int> targc;
1170
1171 for( const auto& [refFP, targetFP] : aCompatData.m_matchingComponents )
1172 {
1173 for( PAD* pad : refFP->Pads() )
1174 refc.insert( pad->GetNetCode() );
1175
1176 for( PAD* pad : targetFP->Pads() )
1177 targc.insert( pad->GetNetCode() );
1178 }
1179
1180 findRoutingInRuleArea( aTargetArea, targetRouting, connectivity, targetPoly, aOpts );
1181 findRoutingInRuleArea( aRefArea, refRouting, connectivity, refPoly, aOpts );
1182
1183 for( BOARD_CONNECTED_ITEM* item : targetRouting )
1184 {
1185 // Never remove pads as part of routing copy.
1186 if( item->Type() == PCB_PAD_T )
1187 continue;
1188
1189 if( item->IsLocked() && !aOpts.m_includeLockedItems )
1190 continue;
1191
1192 if( aOpts.m_connectedRoutingOnly && !targc.contains( item->GetNetCode() ) )
1193 continue;
1194
1195 // item already removed
1196 if( aCommit->GetStatus( item ) != 0 )
1197 continue;
1198
1199 if( !aTargetArea->m_zone->GetLayerSet().Contains( item->GetLayer() ) )
1200 {
1201 continue;
1202 }
1203
1204 aCompatData.m_affectedItems.insert( item );
1205 aCommit->Remove( item );
1206 }
1207
1208 for( BOARD_CONNECTED_ITEM* item : refRouting )
1209 {
1210 // Never copy pads as part of routing copy.
1211 if( item->Type() == PCB_PAD_T )
1212 continue;
1213
1214 if( item->IsLocked() && !aOpts.m_includeLockedItems )
1215 continue;
1216
1217 if( aOpts.m_connectedRoutingOnly && !refc.contains( item->GetNetCode() ) )
1218 continue;
1219
1220 if( !aRefArea->m_zone->GetLayerSet().Contains( item->GetLayer() ) )
1221 continue;
1222
1223 if( !aTargetArea->m_zone->GetLayerSet().Contains( item->GetLayer() ) )
1224 continue;
1225
1226 BOARD_CONNECTED_ITEM* copied = static_cast<BOARD_CONNECTED_ITEM*>( item->Duplicate( false ) );
1227
1228 fixupNet( item, copied, aCompatData.m_matchingComponents );
1229 fixupParentGroup( item, copied );
1230
1231 copied->Rotate( VECTOR2( 0, 0 ), rot );
1232 copied->Move( disp );
1233 aCompatData.m_groupableItems.insert( copied );
1234 aCommit->Add( copied );
1235 }
1236 }
1237
1238 if( aOpts.m_copyOtherItems )
1239 {
1240 std::set<BOARD_ITEM*> sourceItems;
1241 std::set<BOARD_ITEM*> targetItems;
1242
1243 findOtherItemsInRuleArea( aRefArea, sourceItems );
1244 findOtherItemsInRuleArea( aTargetArea, targetItems );
1245
1246 for( BOARD_ITEM* item : targetItems )
1247 {
1248 if( item->Type() == PCB_TEXT_T && item->GetParent() && item->GetParent()->Type() == PCB_FOOTPRINT_T )
1249 continue;
1250
1251 if( item->IsLocked() && !aOpts.m_includeLockedItems )
1252 continue;
1253
1254 // item already removed
1255 if( aCommit->GetStatus( item ) != 0 )
1256 continue;
1257
1258 if( item->Type() == PCB_ZONE_T )
1259 {
1260 ZONE* zone = static_cast<ZONE*>( item );
1261
1262 // Check all zone layers are included in the target rule area.
1263 if( aTargetArea->m_zone->GetLayerSet().ContainsAll( zone->GetLayerSet() ) )
1264 {
1265 aCompatData.m_affectedItems.insert( zone );
1266 aCommit->Remove( zone );
1267 }
1268 }
1269 else
1270 {
1271 if( aTargetArea->m_zone->GetLayerSet().Contains( item->GetLayer() ) )
1272 {
1273 aCompatData.m_affectedItems.insert( item );
1274 aCommit->Remove( item );
1275 }
1276 }
1277 }
1278
1279 for( BOARD_ITEM* item : sourceItems )
1280 {
1281 if( item->Type() == PCB_TEXT_T && item->GetParent() && item->GetParent()->Type() == PCB_FOOTPRINT_T )
1282 continue;
1283
1284 if( item->IsLocked() && !aOpts.m_includeLockedItems )
1285 continue;
1286
1287 BOARD_ITEM* copied = nullptr;
1288
1289 if( item->Type() == PCB_ZONE_T )
1290 {
1291 ZONE* zone = static_cast<ZONE*>( item );
1292 LSET allowedLayers = aRefArea->m_zone->GetLayerSet() & aTargetArea->m_zone->GetLayerSet();
1293
1294 // Check all zone layers are included in both source and target rule areas.
1295 if( !allowedLayers.ContainsAll( zone->GetLayerSet() ) )
1296 continue;
1297
1298 ZONE* targetZone = static_cast<ZONE*>( item->Duplicate( false ) );
1299 fixupNet( zone, targetZone, aCompatData.m_matchingComponents );
1300
1301 copied = targetZone;
1302 }
1303 else
1304 {
1305 if( !aRefArea->m_zone->GetLayerSet().Contains( item->GetLayer() ) )
1306 continue;
1307
1308 if( !aTargetArea->m_zone->GetLayerSet().Contains( item->GetLayer() ) )
1309 continue;
1310
1311 copied = static_cast<BOARD_ITEM*>( item->Clone() );
1312 }
1313
1314 if( copied )
1315 {
1316 fixupParentGroup( item, copied );
1317
1318 copied->ClearFlags();
1319 copied->Rotate( VECTOR2( 0, 0 ), rot );
1320 copied->Move( disp );
1321 aCompatData.m_groupableItems.insert( copied );
1322 aCommit->Add( copied );
1323 }
1324 }
1325 }
1326
1327 if( aOpts.m_copyPlacement )
1328 {
1329 for( const auto& [refFP, targetFP] : aCompatData.m_matchingComponents )
1330 {
1331 if( !aRefArea->m_zone->GetLayerSet().Contains( refFP->GetLayer() ) )
1332 {
1333 wxLogTrace( traceMultichannelTool, wxT( "discard ref:%s (ref layer)\n" ),
1334 refFP->GetReference() );
1335 continue;
1336 }
1337 if( !aTargetArea->m_zone->GetLayerSet().Contains( refFP->GetLayer() ) )
1338 {
1339 wxLogTrace( traceMultichannelTool, wxT( "discard ref:%s (target layer)\n" ),
1340 refFP->GetReference() );
1341 continue;
1342 }
1343
1344 // For regular Rule Area repeat, ignore source footprints outside the reference area.
1345 // For Design Block apply, use the exact source item set collected from the block.
1347 && !refFP->GetEffectiveShape( refFP->GetLayer() )->Collide( &refPoly, 0 ) )
1348 {
1349 continue;
1350 }
1351
1352 if( targetFP->IsLocked() && !aOpts.m_includeLockedItems )
1353 continue;
1354
1355 aCommit->Modify( targetFP );
1356
1357 targetFP->SetLayerAndFlip( refFP->GetLayer() );
1358 targetFP->SetOrientation( refFP->GetOrientation() );
1359 targetFP->SetPosition( refFP->GetPosition() );
1360 targetFP->Rotate( VECTOR2( 0, 0 ), rot );
1361 targetFP->Move( disp );
1362
1363 for( PCB_FIELD* refField : refFP->GetFields() )
1364 {
1365 wxCHECK2( refField, continue );
1366
1367 PCB_FIELD* targetField = targetFP->GetField( refField->GetName() );
1368
1369 if( !targetField )
1370 continue;
1371
1372 targetField->SetLayerSet( refField->GetLayerSet() );
1373 targetField->SetVisible( refField->IsVisible() );
1374 targetField->SetAttributes( refField->GetAttributes() );
1375 targetField->SetPosition( refField->GetPosition() );
1376 targetField->Rotate( VECTOR2( 0, 0 ), rot );
1377 targetField->Move( disp );
1378 targetField->SetIsKnockout( refField->IsKnockout() );
1379 }
1380
1381 // Copy non-field text items (user-added text on the footprint)
1382 for( BOARD_ITEM* refItem : refFP->GraphicalItems() )
1383 {
1384 if( refItem->Type() != PCB_TEXT_T )
1385 continue;
1386
1387 PCB_TEXT* refText = static_cast<PCB_TEXT*>( refItem );
1388
1389 for( BOARD_ITEM* targetItem : targetFP->GraphicalItems() )
1390 {
1391 if( targetItem->Type() != PCB_TEXT_T )
1392 continue;
1393
1394 PCB_TEXT* targetText = static_cast<PCB_TEXT*>( targetItem );
1395
1396 // Match text items by their text content
1397 if( targetText->GetText() == refText->GetText() )
1398 {
1399 targetText->SetLayer( refText->GetLayer() );
1400 targetText->SetVisible( refText->IsVisible() );
1401 targetText->SetAttributes( refText->GetAttributes() );
1402 targetText->SetPosition( refText->GetPosition() );
1403 targetText->Rotate( VECTOR2( 0, 0 ), rot );
1404 targetText->Move( disp );
1405 targetText->SetIsKnockout( refText->IsKnockout() );
1406 break;
1407 }
1408 }
1409 }
1410
1411 // Copy 3D model settings
1412 targetFP->Models() = refFP->Models();
1413
1414 aCompatData.m_affectedItems.insert( targetFP );
1415 aCompatData.m_groupableItems.insert( targetFP );
1416 }
1417 }
1418
1419 aTargetArea->m_zone->RemoveAllContours();
1420 aTargetArea->m_zone->AddPolygon( newTargetOutline );
1421 aTargetArea->m_zone->UnHatchBorder();
1422 aTargetArea->m_zone->HatchBorder();
1423
1424 return true;
1425}
1426
1432 TMATCH::COMPONENT_MATCHES& aComponentMatches )
1433{
1434 auto connectivity = board()->GetConnectivity();
1435 const std::vector<BOARD_CONNECTED_ITEM*> refConnectedPads = connectivity->GetNetItems( aRef->GetNetCode(),
1436 { PCB_PAD_T } );
1437
1438 for( const BOARD_CONNECTED_ITEM* refConItem : refConnectedPads )
1439 {
1440 if( refConItem->Type() != PCB_PAD_T )
1441 continue;
1442
1443 const PAD* refPad = static_cast<const PAD*>( refConItem );
1444 FOOTPRINT* sourceFootprint = refPad->GetParentFootprint();
1445
1446 if( aComponentMatches.contains( sourceFootprint ) )
1447 {
1448 const FOOTPRINT* targetFootprint = aComponentMatches[sourceFootprint];
1449 std::vector<const PAD*> targetFpPads = targetFootprint->GetPads( refPad->GetNumber() );
1450
1451 if( !targetFpPads.empty() )
1452 {
1453 int targetNetCode = targetFpPads[0]->GetNet()->GetNetCode();
1454 aTarget->SetNetCode( targetNetCode );
1455
1456 break;
1457 }
1458 }
1459 }
1460}
1461
1462
1464 RULE_AREA_COMPAT_DATA& aMatches,
1465 const TMATCH::ISOMORPHISM_PARAMS& aParams )
1466{
1467 using namespace TMATCH;
1468
1469 PROF_TIMER timerBuild;
1470 std::unique_ptr<CONNECTION_GRAPH> cgRef( CONNECTION_GRAPH::BuildFromFootprintSet( aRefArea->m_components,
1471 aTargetArea->m_components ) );
1472 std::unique_ptr<CONNECTION_GRAPH> cgTarget( CONNECTION_GRAPH::BuildFromFootprintSet( aTargetArea->m_components,
1473 aRefArea->m_components ) );
1474 timerBuild.Stop();
1475
1476 wxLogTrace( traceMultichannelTool, wxT( "Graph construction: %s (%d + %d components)" ),
1477 timerBuild.to_string(),
1478 (int) aRefArea->m_components.size(),
1479 (int) aTargetArea->m_components.size() );
1480
1481 std::vector<TMATCH::TOPOLOGY_MISMATCH_REASON> mismatchReasons;
1482
1483 PROF_TIMER timerIso;
1484 bool status = cgRef->FindIsomorphism( cgTarget.get(), aMatches.m_matchingComponents,
1485 mismatchReasons, aParams );
1486 timerIso.Stop();
1487
1488 wxLogTrace( traceMultichannelTool, wxT( "FindIsomorphism: %s, result=%d" ),
1489 timerIso.to_string(), status ? 1 : 0 );
1490
1491 aMatches.m_isOk = status;
1492
1493 if( status )
1494 {
1495 aMatches.m_errorMsg = _( "OK" );
1496 aMatches.m_mismatchReasons.clear();
1497 return true;
1498 }
1499
1500 aMatches.m_mismatchReasons.clear();
1501
1502 for( const auto& reason : mismatchReasons )
1503 {
1504 if( reason.m_reason.IsEmpty() )
1505 continue;
1506
1507 if( !reason.m_reference.IsEmpty() && !reason.m_candidate.IsEmpty() )
1508 {
1509 aMatches.m_mismatchReasons.push_back( wxString::Format( wxT( "%s -> %s: %s" ),
1510 reason.m_reference,
1511 reason.m_candidate,
1512 reason.m_reason ) );
1513 }
1514 else if( !reason.m_reference.IsEmpty() )
1515 {
1516 aMatches.m_mismatchReasons.push_back( wxString::Format( wxT( "%s: %s" ),
1517 reason.m_reference,
1518 reason.m_reason ) );
1519 }
1520 else
1521 aMatches.m_mismatchReasons.push_back( reason.m_reason );
1522 }
1523
1524 if( aMatches.m_mismatchReasons.empty() )
1525 aMatches.m_mismatchReasons.push_back( _( "Topology mismatch" ) );
1526
1527 // Component count mismatch
1528 if( aRefArea->m_components.size() != aTargetArea->m_components.size() )
1529 {
1530 aMatches.m_mismatchReasons.push_back(
1531 wxString::Format( _( "Reference area total components: %d" ), (int) aRefArea->m_components.size() ) );
1532 aMatches.m_mismatchReasons.push_back( wxString::Format( _( "Reference area components:\n%s" ),
1533 FormatComponentList( aRefArea->m_components ) ) );
1534 aMatches.m_mismatchReasons.push_back(
1535 wxString::Format( _( "Target area total components: %d" ), (int) aTargetArea->m_components.size() ) );
1536 aMatches.m_mismatchReasons.push_back( wxString::Format( _( "Target area components:\n%s" ),
1537 FormatComponentList( aTargetArea->m_components ) ) );
1538 }
1539
1540 aMatches.m_errorMsg = aMatches.m_mismatchReasons.front();
1541
1542 return status;
1543}
1544
1545
1547 const std::unordered_set<BOARD_ITEM*>& aItemsToRemove )
1548{
1549 // Note: groups are only collections, not "real" hierarchy. A group's members are still parented
1550 // by the board (and therefore nested groups are still in the board's list of groups).
1551 for( PCB_GROUP* group : board()->Groups() )
1552 {
1553 std::vector<EDA_ITEM*> pruneList;
1554
1555 for( EDA_ITEM* refItem : group->GetItems() )
1556 {
1557 for( BOARD_ITEM* testItem : aItemsToRemove )
1558 {
1559 if( refItem->m_Uuid == testItem->m_Uuid )
1560 pruneList.push_back( refItem );
1561 }
1562 }
1563
1564 if( !pruneList.empty() )
1565 {
1566 aCommit.Modify( group );
1567
1568 for( EDA_ITEM* item : pruneList )
1569 group->RemoveItem( item );
1570
1571 if( group->GetItems().size() < 2 )
1572 aCommit.Remove( group );
1573 }
1574 }
1575
1576 return false;
1577}
1578
1579
1581{
1582 if( Pgm().IsGUI() )
1583 {
1585
1586 if( m_areas.m_areas.size() <= 1 )
1587 {
1588 frame()->ShowInfoBarError( _( "Cannot auto-generate any placement areas because the "
1589 "schematic has only one or no hierarchical sheets, "
1590 "groups, or component classes." ),
1591 true );
1592 return 0;
1593 }
1594
1596 int ret = dialog.ShowModal();
1597
1598 if( ret != wxID_OK )
1599 return 0;
1600 }
1601
1602 for( ZONE* zone : board()->Zones() )
1603 {
1604 if( !zone->GetIsRuleArea() )
1605 continue;
1606
1607 if( !zone->GetPlacementAreaEnabled() )
1608 continue;
1609
1610 std::set<FOOTPRINT*> components;
1611 RULE_AREA zoneRA;
1612 zoneRA.m_zone = zone;
1613 zoneRA.m_sourceType = zone->GetPlacementAreaSourceType();
1614 findComponentsInRuleArea( &zoneRA, components );
1615
1616 if( components.empty() )
1617 continue;
1618
1619 for( RULE_AREA& ra : m_areas.m_areas )
1620 {
1621 if( components == ra.m_components )
1622 {
1623 if( zone->GetPlacementAreaSourceType() == PLACEMENT_SOURCE_T::SHEETNAME )
1624 {
1625 wxLogTrace( traceMultichannelTool,
1626 wxT( "Placement rule area for sheet '%s' already exists as '%s'\n" ),
1627 ra.m_sheetPath, zone->GetZoneName() );
1628 }
1629 else if( zone->GetPlacementAreaSourceType() == PLACEMENT_SOURCE_T::COMPONENT_CLASS )
1630 {
1631 wxLogTrace( traceMultichannelTool,
1632 wxT( "Placement rule area for component class '%s' already exists as '%s'\n" ),
1633 ra.m_componentClass, zone->GetZoneName() );
1634 }
1635 else
1636 {
1637 wxLogTrace( traceMultichannelTool,
1638 wxT( "Placement rule area for group '%s' already exists as '%s'\n" ),
1639 ra.m_groupName, zone->GetZoneName() );
1640 }
1641
1642 ra.m_oldZone = zone;
1643 ra.m_existsAlready = true;
1644 }
1645 }
1646 }
1647
1648 wxLogTrace( traceMultichannelTool, wxT( "%d placement areas found\n" ), (int) m_areas.m_areas.size() );
1649
1650 BOARD_COMMIT commit( GetManager(), true, false );
1651
1652 for( RULE_AREA& ra : m_areas.m_areas )
1653 {
1654 if( !ra.m_generateEnabled )
1655 continue;
1656
1657 if( ra.m_existsAlready && !m_areas.m_replaceExisting )
1658 continue;
1659
1660 if( ra.m_components.empty() )
1661 continue;
1662
1663 SHAPE_LINE_CHAIN raOutline;
1664
1665 // Groups are a way for the user to more explicitly provide a list of items to include in
1666 // the multichannel tool, as opposed to inferring them based on sheet structure or component classes.
1667 // So for group-based RAs, we build the RA outline based everything in the group, not just components.
1669 {
1670 std::set<BOARD_ITEM*> groupItems = queryBoardItemsInGroup( ra.m_groupName );
1671
1672 if( groupItems.empty() )
1673 {
1674 wxLogTrace( traceMultichannelTool,
1675 wxT( "Skipping placement rule area generation for source group '%s': group has no board items." ),
1676 ra.m_groupName );
1677 continue;
1678 }
1679
1680 raOutline = buildRAOutline( groupItems, 100000 );
1681 }
1682 else
1683 {
1684 raOutline = buildRAOutline( ra.m_components, 100000 );
1685 }
1686
1687 std::unique_ptr<ZONE> newZone( new ZONE( board() ) );
1688
1690 newZone->SetZoneName( wxString::Format( wxT( "auto-placement-area-%s" ), ra.m_sheetPath ) );
1692 newZone->SetZoneName( wxString::Format( wxT( "auto-placement-area-%s" ), ra.m_componentClass ) );
1693 else
1694 newZone->SetZoneName( wxString::Format( wxT( "auto-placement-area-%s" ), ra.m_groupName ) );
1695
1696 wxLogTrace( traceMultichannelTool, wxT( "Generated rule area '%s' (%d components)\n" ),
1697 newZone->GetZoneName(),
1698 (int) ra.m_components.size() );
1699
1700 newZone->SetIsRuleArea( true );
1701 newZone->SetLayerSet( LSET::AllCuMask() );
1702 newZone->SetPlacementAreaEnabled( true );
1703 newZone->SetDoNotAllowZoneFills( false );
1704 newZone->SetDoNotAllowVias( false );
1705 newZone->SetDoNotAllowTracks( false );
1706 newZone->SetDoNotAllowPads( false );
1707 newZone->SetDoNotAllowFootprints( false );
1708
1710 {
1711 newZone->SetPlacementAreaSourceType( PLACEMENT_SOURCE_T::SHEETNAME );
1712 newZone->SetPlacementAreaSource( ra.m_sheetPath );
1713 }
1715 {
1716 newZone->SetPlacementAreaSourceType( PLACEMENT_SOURCE_T::COMPONENT_CLASS );
1717 newZone->SetPlacementAreaSource( ra.m_componentClass );
1718 }
1719 else
1720 {
1721 newZone->SetPlacementAreaSourceType( PLACEMENT_SOURCE_T::GROUP_PLACEMENT );
1722 newZone->SetPlacementAreaSource( ra.m_groupName );
1723 }
1724
1725 newZone->AddPolygon( raOutline );
1726 newZone->SetHatchStyle( ZONE_BORDER_DISPLAY_STYLE::NO_HATCH );
1727
1728 if( ra.m_existsAlready )
1729 {
1730 commit.Remove( ra.m_oldZone );
1731 }
1732
1733 ra.m_zone = newZone.release();
1734 commit.Add( ra.m_zone );
1735 }
1736
1737 // fixme: handle corner cases where the items belonging to a Rule Area already
1738 // belong to other groups.
1739
1740 if( m_areas.m_options.m_groupItems )
1741 {
1742 for( RULE_AREA& ra : m_areas.m_areas )
1743 {
1744 if( !ra.m_generateEnabled )
1745 continue;
1746
1747 if( ra.m_existsAlready && !m_areas.m_replaceExisting )
1748 continue;
1749
1750 // A group needs at least 2 items (zone + at least 1 component)
1751 if( ra.m_components.empty() )
1752 continue;
1753
1754 std::unordered_set<BOARD_ITEM*> toPrune;
1755
1756 std::copy( ra.m_components.begin(), ra.m_components.end(), std::inserter( toPrune, toPrune.begin() ) );
1757
1758 if( ra.m_existsAlready )
1759 toPrune.insert( ra.m_zone );
1760
1761 pruneExistingGroups( commit, toPrune );
1762
1763 PCB_GROUP* group = new PCB_GROUP( board() );
1764
1765 commit.Add( group );
1766
1767 commit.Modify( ra.m_zone );
1768 group->AddItem( ra.m_zone );
1769
1770 for( FOOTPRINT* fp : ra.m_components )
1771 {
1772 commit.Modify( fp );
1773 group->AddItem( fp );
1774 }
1775 }
1776 }
1777
1778 commit.Push( _( "Auto-generate placement rule areas" ) );
1779
1780 return true;
1781}
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
virtual void Revert() override
Revert the commit by restoring the modified items state.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition board_item.h:268
virtual void SetLayerSet(const LSET &aLayers)
Definition board_item.h:296
virtual bool IsKnockout() const
Definition board_item.h:355
virtual void SetIsKnockout(bool aKnockout)
Definition board_item.h:356
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition board_item.h:316
FOOTPRINT * GetParentFootprint() const
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition board.h:571
constexpr BOX2< Vec > GetInflated(coord_type aDx, coord_type aDy) const
Get a new rectangle that is this one, inflated by aDx and aDy.
Definition box2.h:638
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition commit.h:72
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
Definition commit.h:90
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:106
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
Definition commit.h:78
int GetStatus(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Returns status of an item.
Definition commit.cpp:171
A lightweight representation of a component class.
const std::vector< COMPONENT_CLASS * > & GetConstituentClasses() const
Fetches a vector of the constituent classes for this (effective) class.
const std::vector< BOARD_CONNECTED_ITEM * > GetNetItems(int aNetCode, const std::vector< KICAD_T > &aTypes) const
Function GetNetItems() Returns the list of items that belong to a certain net.
int ShowModal() override
A set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:46
std::unordered_set< EDA_ITEM * > & GetItems()
Definition eda_group.h:54
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:100
const KIID m_Uuid
Definition eda_item.h:528
virtual EDA_GROUP * GetParentGroup() const
Definition eda_item.h:118
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
virtual void SetParentGroup(EDA_GROUP *aGroup)
Definition eda_item.h:117
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:109
virtual bool IsVisible() const
Definition eda_text.h:198
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
Definition eda_text.cpp:417
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:370
const TEXT_ATTRIBUTES & GetAttributes() const
Definition eda_text.h:242
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
double GetOrientationDegrees() const
Definition footprint.h:366
std::vector< const PAD * > GetPads(const wxString &aPadNumber, const PAD *aIgnore=nullptr) const
const wxString & GetReference() const
Definition footprint.h:771
VECTOR2I GetPosition() const override
Definition footprint.h:347
wxString AsString() const
Definition kiid.cpp:244
void SetErrorCallback(std::function< void(const wxString &aMessage, int aOffset)> aCallback)
bool Compile(const wxString &aString, UCODE *aCode, CONTEXT *aPreflightContext)
void SetErrorCallback(std::function< void(const wxString &aMessage, int aOffset)> aCallback)
VALUE * Run(CONTEXT *ctx)
virtual double AsDouble() const
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
bool ContainsAll(const LSET &aLayers) const
See if this layer set contains all layers in another set.
Definition lset.h:85
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition lset.cpp:599
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
Definition lset.h:63
int CheckRACompatibility(ZONE *aRefZone)
std::set< FOOTPRINT * > queryComponentsInSheet(wxString aSheetName) const
bool findOtherItemsInRuleArea(RULE_AREA *aRuleArea, std::set< BOARD_ITEM * > &aItems)
int repeatLayout(const TOOL_EVENT &aEvent)
bool findComponentsInRuleArea(RULE_AREA *aRuleArea, std::set< FOOTPRINT * > &aComponents)
void UpdatePickedItem(const EDA_ITEM *aItem) override
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
const SHAPE_LINE_CHAIN buildRAOutline(std::set< FOOTPRINT * > &aFootprints, int aMargin)
bool resolveConnectionTopology(RULE_AREA *aRefArea, RULE_AREA *aTargetArea, RULE_AREA_COMPAT_DATA &aMatches, const TMATCH::ISOMORPHISM_PARAMS &aParams={})
int findRoutingInRuleArea(RULE_AREA *aRuleArea, std::set< BOARD_CONNECTED_ITEM * > &aOutput, std::shared_ptr< CONNECTIVITY_DATA > aConnectivity, const SHAPE_POLY_SET &aRAPoly, const REPEAT_LAYOUT_OPTIONS &aOpts) const
wxString stripComponentIndex(const wxString &aRef) const
RULE_AREAS_DATA m_areas
bool pruneExistingGroups(COMMIT &aCommit, const std::unordered_set< BOARD_ITEM * > &aItemsToCheck)
void ShowMismatchDetails(wxWindow *aParent, const wxString &aSummary, const std::vector< wxString > &aReasons) const
int RepeatLayout(const TOOL_EVENT &aEvent, ZONE *aRefZone)
int AutogenerateRuleAreas(const TOOL_EVENT &aEvent)
void fixupNet(BOARD_CONNECTED_ITEM *aRef, BOARD_CONNECTED_ITEM *aTarget, TMATCH::COMPONENT_MATCHES &aComponentMatches)
Attempts to make sure copied items are assigned the right net.
bool copyRuleAreaContents(RULE_AREA *aRefArea, RULE_AREA *aTargetArea, BOARD_COMMIT *aCommit, REPEAT_LAYOUT_OPTIONS aOpts, RULE_AREA_COMPAT_DATA &aCompatData)
std::set< FOOTPRINT * > queryComponentsInComponentClass(const wxString &aComponentClassName) const
RULE_AREA * findRAByName(const wxString &aName)
std::set< FOOTPRINT * > queryComponentsInGroup(const wxString &aGroupName) const
std::set< BOARD_ITEM * > queryBoardItemsInGroup(const wxString &aGroupName) const
Definition pad.h:55
const wxString & GetNumber() const
Definition pad.h:137
void SetItems(BOARD_ITEM *a, BOARD_ITEM *b=nullptr)
static TOOL_ACTION repeatLayout
static TOOL_ACTION generatePlacementRuleAreas
static TOOL_ACTION selectItemInteractively
Selection of reference points/items.
A set of BOARD_ITEMs (i.e., without duplicates).
Definition pcb_group.h:53
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
void Move(const VECTOR2I &aMoveVector) override
Move this object.
virtual VECTOR2I GetPosition() const override
Definition pcb_text.h:97
virtual void SetPosition(const VECTOR2I &aPos) override
Definition pcb_text.h:99
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition pcb_text.h:101
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition pcb_text.cpp:440
T * frame() const
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
BOARD * board() const
const PCB_SELECTION & selection() const
A small class to help profiling.
Definition profile.h:49
void Stop()
Save the time when this function was called, and set the counter stane to stop.
Definition profile.h:88
std::string to_string()
Definition profile.h:155
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.
Represent a set of closed polygons.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
virtual void CacheTriangulation(bool aSimplify=false, const TASK_SUBMITTER &aSubmitter={})
Build a polygon triangulation, needed to draw a polygon on OpenGL and in some other calculations.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
static std::unique_ptr< CONNECTION_GRAPH > BuildFromFootprintSet(const std::set< FOOTPRINT * > &aFps, const std::set< FOOTPRINT * > &aOtherChannelFps={})
TOOL_MANAGER * GetManager() const
Return the instance of TOOL_MANAGER that takes care of the tool.
Definition tool_base.h:146
TOOL_MANAGER * m_toolMgr
Definition tool_base.h:220
Generic, UI-independent tool event.
Definition tool_event.h:171
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
Define a general 2D-vector/point.
Definition vector2d.h:71
Handle a list of polygons defining a copper zone.
Definition zone.h:74
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition zone.h:716
void AddPolygon(std::vector< VECTOR2I > &aPolygon)
Add a polygon to the zone outline.
Definition zone.cpp:1173
wxString GetPlacementAreaSource() const
Definition zone.h:721
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
Definition zone.cpp:1300
PLACEMENT_SOURCE_T GetPlacementAreaSourceType() const
Definition zone.h:723
SHAPE_POLY_SET * Outline()
Definition zone.h:336
const wxString & GetZoneName() const
Definition zone.h:164
bool GetPlacementAreaEnabled() const
Definition zone.h:718
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition zone.h:137
void UnHatchBorder()
Clear the zone's hatch.
Definition zone.cpp:1294
void RemoveAllContours(void)
Definition zone.h:555
void BuildConvexHull(std::vector< VECTOR2I > &aResult, const std::vector< VECTOR2I > &aPoly)
Calculate the convex hull of a list of points in counter-clockwise order.
#define _(s)
@ NO_RECURSE
Definition eda_item.h:54
static wxString FormatComponentList(const std::set< FOOTPRINT * > &aComponents)
static const wxString traceMultichannelTool
static void ShowTopologyMismatchReasons(wxWindow *aParent, const wxString &aSummary, const std::vector< wxString > &aReasons)
SHAPE_LINE_CHAIN RectifyPolygon(const SHAPE_LINE_CHAIN &aPoly)
void CollectBoxCorners(const BOX2I &aBox, std::vector< VECTOR2I > &aCorners)
Add the 4 corners of a BOX2I to a vector.
std::map< FOOTPRINT *, FOOTPRINT * > COMPONENT_MATCHES
Definition topo_match.h:184
Class to handle a set of BOARD_ITEMs.
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
Utility functions for working with shapes.
void AccumulateDescription(wxString &aDesc, const wxString &aItem)
Utility to build comma separated lists in messages.
std::vector< wxString > m_mismatchReasons
std::unordered_set< BOARD_ITEM * > m_affectedItems
Filled in by copyRuleAreaContents with items that were affected by the copy operation.
TMATCH::COMPONENT_MATCHES m_matchingComponents
std::unordered_set< BOARD_ITEM * > m_groupableItems
Filled in by copyRuleAreaContents with affected items that can be grouped together.
VECTOR2I m_center
std::unordered_set< EDA_ITEM * > m_designBlockItems
wxString m_sheetName
PLACEMENT_SOURCE_T m_sourceType
wxString m_componentClass
std::set< FOOTPRINT * > m_components
wxString m_ruleName
wxString m_groupName
wxString m_sheetPath
std::atomic< bool > * m_cancelled
Definition topo_match.h:49
std::atomic< int > * m_matchedComponents
Definition topo_match.h:50
std::atomic< int > * m_totalComponents
Definition topo_match.h:51
bool copied
wxString result
Test unit parsing edge cases and error handling.
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
static thread_pool * tp
BS::priority_thread_pool thread_pool
Definition thread_pool.h:31
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition typeinfo.h:88
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition typeinfo.h:108
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition typeinfo.h:105
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition typeinfo.h:89
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:83
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:84
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687
#define PR_CAN_ABORT