KiCad PCB EDA Suite
Loading...
Searching...
No Matches
board_inspection_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, see <https://www.gnu.org/licenses/>.
18 */
19
21
22#include <bitmaps.h>
23#include <board_loader.h>
24#include <collectors.h>
29#include <footprint.h>
30#include <pcb_io/pcb_io_mgr.h>
32#include <kiway.h>
33#include <local_history.h>
35#include <wx/filedlg.h>
36#include <wx/filename.h>
37#include <pcb_group.h>
38#include <tool/tool_manager.h>
41#include <tools/edit_tool.h>
42#include <tools/drc_tool.h>
43#include <pcb_painter.h>
45#include <drc/drc_engine.h>
50#include <dialogs/dialog_drc.h>
51#include <kiplatform/ui.h>
52#include <status_popup.h>
53#include <string_utils.h>
56#include <pcb_marker.h>
57#include <pcb_painter.h>
58#include <pcb_shape.h>
62#include <wx/choice.h>
63#include <wx/sizer.h>
64#include <wx/stattext.h>
65#include <drc/drc_item.h>
66#include <pad.h>
67#include <pcb_track.h>
68#include <project_pcb.h>
69#include <view/view_controls.h>
70
71
73 PCB_TOOL_BASE( "pcbnew.InspectionTool" ),
74 m_frame( nullptr )
75{
76 m_dynamicData = nullptr;
77}
78
79
81{
82public:
95
96private:
97 ACTION_MENU* create() const override
98 {
99 return new NET_CONTEXT_MENU();
100 }
101};
102
103
105{
106 PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
107
108 std::shared_ptr<NET_CONTEXT_MENU> netSubMenu = std::make_shared<NET_CONTEXT_MENU>();
109 netSubMenu->SetTool( this );
110
111 // Only show the net menu if all items in the selection are connectable
112 auto showNetMenuFunc =
113 []( const SELECTION& aSelection )
114 {
115 if( aSelection.Empty() )
116 return false;
117
118 for( const EDA_ITEM* item : aSelection )
119 {
120 switch( item->Type() )
121 {
122 case PCB_TRACE_T:
123 case PCB_ARC_T:
124 case PCB_VIA_T:
125 case PCB_PAD_T:
126 case PCB_ZONE_T:
127 continue;
128
129 case PCB_SHAPE_T:
130 {
131 if( !static_cast<const PCB_SHAPE*>( item )->IsOnCopperLayer() )
132 return false;
133 else
134 continue;
135 }
136
137 default:
138 return false;
139 }
140 }
141
142 return true;
143 };
144
145 CONDITIONAL_MENU& menu = selectionTool->GetToolMenu().GetMenu();
146
147 selectionTool->GetToolMenu().RegisterSubMenu( netSubMenu );
148
149 menu.AddMenu( netSubMenu.get(), showNetMenuFunc, 100 );
150
151 return true;
152}
153
154
159
160
162{
164 dialog.ShowModal();
165 return 0;
166}
167
168
169std::unique_ptr<DRC_ENGINE> BOARD_INSPECTION_TOOL::makeDRCEngine( bool* aCompileError,
170 bool* aCourtyardError )
171{
172 auto engine = std::make_unique<DRC_ENGINE>( m_frame->GetBoard(),
173 &m_frame->GetBoard()->GetDesignSettings() );
174
175 try
176 {
177 engine->InitEngine( m_frame->GetBoard()->GetDesignRulesPath() );
178 }
179 catch( PARSE_ERROR& )
180 {
181 if( aCompileError )
182 *aCompileError = true;
183 }
184
185 for( ZONE* zone : m_frame->GetBoard()->Zones() )
186 zone->CacheBoundingBox();
187
188 for( FOOTPRINT* footprint : m_frame->GetBoard()->Footprints() )
189 {
190 for( ZONE* zone : footprint->Zones() )
191 zone->CacheBoundingBox();
192
193 footprint->BuildCourtyardCaches();
194
195 if( aCourtyardError && ( footprint->GetFlags() & MALFORMED_COURTYARDS ) != 0 )
196 *aCourtyardError = true;
197 }
198
199 return engine;
200}
201
202
203bool isNPTHPad( const BOARD_ITEM& aItem )
204{
205 if( aItem.Type() != PCB_PAD_T )
206 return false;
207
208 const PAD& pad = static_cast<const PAD&>( aItem );
209 return pad.GetAttribute() == PAD_ATTRIB::NPTH;
210}
211
212
214{
215 // Null items have no description
216 if( !aItem )
217 return wxString();
218
219 wxString msg = aItem->GetItemDescription( m_frame, true );
220
221 if( aItem->IsConnected() && !isNPTHPad( *aItem ) )
222 {
223 const BOARD_CONNECTED_ITEM* cItem = static_cast<const BOARD_CONNECTED_ITEM*>( aItem );
224
225 msg += wxS( " " )
226 + wxString::Format( _( "[netclass %s]" ),
228 }
229
230 return msg;
231};
232
233
235 const VECTOR2I& aPos )
236{
237 std::vector<BOARD_ITEM*> toAdd;
238
239 for( int i = 0; i < aCollector.GetCount(); ++i )
240 {
241 if( aCollector[i]->Type() == PCB_GROUP_T )
242 {
243 PCB_GROUP* group = static_cast<PCB_GROUP*>( aCollector[i] );
244
245 group->RunOnChildren(
246 [&]( BOARD_ITEM* child )
247 {
248 if( child->Type() == PCB_GROUP_T )
249 return;
250
251 if( !child->HitTest( aPos ) )
252 return;
253
254 toAdd.push_back( child );
255
256 if( child->Type() == PCB_FOOTPRINT_T )
257 {
258 for( PAD* pad : static_cast<FOOTPRINT*>( child )->Pads() )
259 {
260 if( pad->HitTest( aPos ) )
261 toAdd.push_back( pad );
262 }
263 }
264 },
266 }
267 }
268
269 for( BOARD_ITEM* item : toAdd )
270 aCollector.Append( item );
271
272 bool hasPadOrTrack = false;
273
274 for( int i = 0; i < aCollector.GetCount(); ++i )
275 {
276 KICAD_T type = aCollector[i]->Type();
277
278 if( type == PCB_PAD_T || type == PCB_VIA_T || type == PCB_TRACE_T
279 || type == PCB_ARC_T || type == PCB_ZONE_T )
280 {
281 hasPadOrTrack = true;
282 break;
283 }
284 }
285
286 for( int i = aCollector.GetCount() - 1; i >= 0; --i )
287 {
288 BOARD_ITEM* item = aCollector[i];
289
290 if( hasPadOrTrack && item->Type() == PCB_FOOTPRINT_T )
291 {
292 aCollector.Remove( i );
293 continue;
294 }
295
296 if( item->Type() == PCB_GROUP_T )
297 aCollector.Remove( i );
298 }
299}
300
301
303 const wxString& aPrompt,
304 const std::vector<KICAD_T>& aTypes,
305 BOARD_ITEM* aLockedHighlight )
306{
307 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
308 PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
309 STATUS_TEXT_POPUP statusPopup( m_frame );
310 BOARD_ITEM* pickedItem = nullptr;
311 BOARD_ITEM* highlightedItem = nullptr;
312 bool done = false;
313
314 statusPopup.SetText( aPrompt );
315
316 picker->SetCursor( KICURSOR::BULLSEYE );
317 picker->SetSnapping( false );
318 picker->ClearHandlers();
319
320 picker->SetClickHandler(
321 [&]( const VECTOR2D& aPoint ) -> bool
322 {
324
325 GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
326 GENERAL_COLLECTOR collector;
327
328 collector.Collect( m_frame->GetBoard(), aTypes, aPoint, guide );
329
330 for( int i = collector.GetCount() - 1; i >= 0; --i )
331 {
332 if( !selTool->Selectable( collector[i] ) )
333 collector.Remove( i );
334 }
335
336 filterCollectorForInspection( collector, aPoint );
337
338 if( collector.GetCount() > 1 )
339 selTool->GuessSelectionCandidates( collector, aPoint );
340
341 if( collector.GetCount() == 0 )
342 return true;
343
344 pickedItem = collector[0];
345 statusPopup.Hide();
346
347 return false;
348 } );
349
350 picker->SetMotionHandler(
351 [&]( const VECTOR2D& aPos )
352 {
353 statusPopup.Move( KIPLATFORM::UI::GetMousePosition() + wxPoint( 20, -50 ) );
354
355 GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
356 GENERAL_COLLECTOR collector;
357
358 collector.Collect( m_frame->GetBoard(), aTypes, aPos, guide );
359
360 for( int i = collector.GetCount() - 1; i >= 0; --i )
361 {
362 if( !selTool->Selectable( collector[i] ) )
363 collector.Remove( i );
364 }
365
366 filterCollectorForInspection( collector, aPos );
367
368 if( collector.GetCount() > 1 )
369 selTool->GuessSelectionCandidates( collector, aPos );
370
371 BOARD_ITEM* item = collector.GetCount() >= 1 ? collector[0] : nullptr;
372
373 if( highlightedItem != item )
374 {
375 if( highlightedItem && highlightedItem != aLockedHighlight )
376 selTool->UnbrightenItem( highlightedItem );
377
378 highlightedItem = item;
379
380 if( highlightedItem && highlightedItem != aLockedHighlight )
381 selTool->BrightenItem( highlightedItem );
382 }
383 } );
384
385 picker->SetCancelHandler(
386 [&]()
387 {
388 if( highlightedItem && highlightedItem != aLockedHighlight )
389 selTool->UnbrightenItem( highlightedItem );
390
391 highlightedItem = nullptr;
392 statusPopup.Hide();
393 done = true;
394 } );
395
396 picker->SetFinalizeHandler(
397 [&]( const int& aFinalState )
398 {
399 if( highlightedItem && highlightedItem != aLockedHighlight )
400 selTool->UnbrightenItem( highlightedItem );
401
402 highlightedItem = nullptr;
403
404 if( !pickedItem )
405 done = true;
406 } );
407
408 statusPopup.Move( KIPLATFORM::UI::GetMousePosition() + wxPoint( 20, -50 ) );
409 statusPopup.Popup();
410 m_frame->GetCanvas()->SetStatusPopup( statusPopup.GetPanel() );
411
412 m_toolMgr->RunAction( ACTIONS::pickerTool, &aEvent );
413
414 while( !done && !pickedItem )
415 {
416 if( TOOL_EVENT* evt = Wait() )
417 evt->SetPassEvent();
418 else
419 break;
420 }
421
422 picker->ClearHandlers();
423 m_frame->GetCanvas()->SetStatusPopup( nullptr );
424
425 return pickedItem;
426}
427
428
430{
431 r->Report( "" );
432 r->Report( _( "Report incomplete: could not compile custom design rules." )
433 + wxS( "&nbsp;&nbsp;" )
434 + wxS( "<a href='$CUSTOM_RULES'>" ) + _( "Show design rules." ) + wxS( "</a>" ) );
435}
436
437
438void BOARD_INSPECTION_TOOL::reportHeader( const wxString& aTitle, const BOARD_ITEM* a, REPORTER* r )
439{
440 r->Report( wxT( "<h7>" ) + EscapeHTML( aTitle ) + wxT( "</h7>" ) );
441 r->Report( wxT( "<ul><li>" ) + EscapeHTML( getItemDescription( a ) ) + wxT( "</li></ul>" ) );
442}
443
444
445void BOARD_INSPECTION_TOOL::reportHeader( const wxString& aTitle, const BOARD_ITEM* a, const BOARD_ITEM* b,
446 REPORTER* r )
447{
448 r->Report( wxT( "<h7>" ) + EscapeHTML( aTitle ) + wxT( "</h7>" ) );
449 r->Report( wxT( "<ul><li>" ) + EscapeHTML( getItemDescription( a ) ) + wxT( "</li>" )
450 + wxT( "<li>" ) + EscapeHTML( getItemDescription( b ) ) + wxT( "</li></ul>" ) );
451}
452
453
454void BOARD_INSPECTION_TOOL::reportHeader( const wxString& aTitle, const BOARD_ITEM* a, const BOARD_ITEM* b,
455 PCB_LAYER_ID aLayer, REPORTER* r )
456{
457 wxString layerStr = _( "Layer" ) + wxS( " " ) + m_frame->GetBoard()->GetLayerName( aLayer );
458
459 r->Report( wxT( "<h7>" ) + EscapeHTML( aTitle ) + wxT( "</h7>" ) );
460 r->Report( wxT( "<ul><li>" ) + EscapeHTML( layerStr ) + wxT( "</li>" )
461 + wxT( "<li>" ) + EscapeHTML( getItemDescription( a ) ) + wxT( "</li>" )
462 + wxT( "<li>" ) + EscapeHTML( getItemDescription( b ) ) + wxT( "</li></ul>" ) );
463}
464
465
466namespace
467{
468class VECTOR_REPORTER : public REPORTER
469{
470public:
471 REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override
472 {
473 m_messages.push_back( aText );
474 return *this;
475 }
476
477 bool HasMessage() const override { return !m_messages.empty(); }
478 EDA_UNITS GetUnits() const override { return EDA_UNITS::UNSCALED; }
479
480 std::vector<wxString> m_messages;
481};
482} // namespace
483
484
485wxString reportMin( PCB_BASE_FRAME* aFrame, DRC_CONSTRAINT& aConstraint )
486{
487 if( aConstraint.m_Value.HasMin() )
488 return aFrame->StringFromValue( aConstraint.m_Value.Min(), true );
489 else
490 return wxT( "<i>" ) + _( "undefined" ) + wxT( "</i>" );
491}
492
493
494wxString reportOpt( PCB_BASE_FRAME* aFrame, DRC_CONSTRAINT& aConstraint )
495{
496 if( aConstraint.m_Value.HasOpt() )
497 return aFrame->StringFromValue( aConstraint.m_Value.Opt(), true );
498 else
499 return wxT( "<i>" ) + _( "undefined" ) + wxT( "</i>" );
500}
501
502
503wxString reportMax( PCB_BASE_FRAME* aFrame, DRC_CONSTRAINT& aConstraint )
504{
505 if( aConstraint.m_Value.HasMax() )
506 return aFrame->StringFromValue( aConstraint.m_Value.Max(), true );
507 else
508 return wxT( "<i>" ) + _( "undefined" ) + wxT( "</i>" );
509}
510
511
512wxString BOARD_INSPECTION_TOOL::InspectDRCErrorMenuText( const std::shared_ptr<RC_ITEM>& aDRCItem )
513{
514 if( aDRCItem->GetErrorCode() == DRCE_CLEARANCE
515 || aDRCItem->GetErrorCode() == DRCE_EDGE_CLEARANCE
516 || aDRCItem->GetErrorCode() == DRCE_HOLE_CLEARANCE
517 || aDRCItem->GetErrorCode() == DRCE_DRILLED_HOLES_TOO_CLOSE
518 || aDRCItem->GetErrorCode() == DRCE_STARVED_THERMAL )
519 {
520 return m_frame->GetRunMenuCommandDescription( PCB_ACTIONS::inspectClearance );
521 }
522 else if( aDRCItem->GetErrorCode() == DRCE_TEXT_HEIGHT
523 || aDRCItem->GetErrorCode() == DRCE_LINE_WIDTH
524 || aDRCItem->GetErrorCode() == DRCE_DP_UNCOUPLED_LENGTH_TOO_LONG
525 || aDRCItem->GetErrorCode() == DRCE_TRACK_WIDTH
526 || aDRCItem->GetErrorCode() == DRCE_TRACK_ANGLE
527 || aDRCItem->GetErrorCode() == DRCE_TRACK_SEGMENT_LENGTH
528 || aDRCItem->GetErrorCode() == DRCE_VIA_DIAMETER
529 || aDRCItem->GetErrorCode() == DRCE_ANNULAR_WIDTH
530 || aDRCItem->GetErrorCode() == DRCE_DRILL_OUT_OF_RANGE
531 || aDRCItem->GetErrorCode() == DRCE_MICROVIA_DRILL_OUT_OF_RANGE
532 || aDRCItem->GetErrorCode() == DRCE_CONNECTION_WIDTH
533 || aDRCItem->GetErrorCode() == DRCE_ASSERTION_FAILURE )
534 {
535 return m_frame->GetRunMenuCommandDescription( PCB_ACTIONS::inspectConstraints );
536 }
537 else if( aDRCItem->GetErrorCode() == DRCE_LIB_FOOTPRINT_MISMATCH )
538 {
539 return m_frame->GetRunMenuCommandDescription( PCB_ACTIONS::diffFootprint );
540 }
541
542 return wxEmptyString;
543}
544
545
546void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr<RC_ITEM>& aDRCItem )
547{
548 DRC_TOOL* drcTool = m_toolMgr->GetTool<DRC_TOOL>();
549
550 wxCHECK( drcTool && m_frame, /* void */ );
551
552 BOARD_ITEM* a = m_frame->GetBoard()->ResolveItem( aDRCItem->GetMainItemID() );
553 BOARD_ITEM* b = m_frame->GetBoard()->ResolveItem( aDRCItem->GetAuxItemID() );
554 const BOARD_CONNECTED_ITEM* ac = dynamic_cast<const BOARD_CONNECTED_ITEM*>( a );
555 const BOARD_CONNECTED_ITEM* bc = dynamic_cast<const BOARD_CONNECTED_ITEM*>( b );
556 PCB_LAYER_ID layer = m_frame->GetActiveLayer();
557
558 if( aDRCItem->GetErrorCode() == DRCE_LIB_FOOTPRINT_MISMATCH )
559 {
560 if( FOOTPRINT* footprint = dynamic_cast<FOOTPRINT*>( a ) )
561 DiffFootprint( footprint, drcTool->GetDRCDialog() );
562
563 return;
564 }
565
566 DIALOG_BOOK_REPORTER* dialog = m_frame->GetInspectDrcErrorDialog();
567 wxCHECK( dialog, /* void */ );
568
569 dialog->DeleteAllPages();
570
571 bool compileError = false;
572 bool courtyardError = false;
573 std::unique_ptr<DRC_ENGINE> drcEngine = makeDRCEngine( &compileError, &courtyardError );
574
575 // Use the same principal-layer policy as the DRC dialog's cross-probe.
576 PCB_MARKER* marker = nullptr;
577
578 for( PCB_MARKER* candidate : m_frame->GetBoard()->Markers() )
579 {
580 if( candidate->GetRCItem() == aDRCItem )
581 {
582 marker = candidate;
583 break;
584 }
585 }
586
587 // Pull out the principal layer for this DRC item if there is one.
588 //
589 // Note: some tests evaluate the constraint with UNDEFINED_LAYER, so a
590 // rule's (layer ...) restriction is not checked against the item's layer
591 // (DRC_TEST_PROVIDER_EDGE_CLEARANCE, for example). When we evaluate
592 // the constraint later, match the provider's layer choice in those cases so
593 // the resolution agrees with the DRC run.
594
595 {
596 PCB_LAYER_ID principalLayer = UNDEFINED_LAYER;
597 LSET violationLayers;
598
599 DRC_ITEM::GetViolationLayers( m_frame->GetBoard(), aDRCItem, marker, principalLayer, violationLayers );
600
601 if( principalLayer > UNDEFINED_LAYER )
602 layer = principalLayer;
603 }
604
605 WX_HTML_REPORT_BOX* r = nullptr;
606 DRC_CONSTRAINT constraint;
607 int clearance = 0;
608 wxString clearanceStr;
609
610 switch( aDRCItem->GetErrorCode() )
611 {
613 {
614 for( KIID id : aDRCItem->GetIDs() )
615 {
616 bc = dynamic_cast<BOARD_CONNECTED_ITEM*>( m_frame->GetBoard()->ResolveItem( id, true ) );
617
618 if( ac && bc && ac->GetNetCode() != bc->GetNetCode() )
619 break;
620 }
621
622 r = dialog->AddHTMLPage( _( "Uncoupled Length" ) );
623 reportHeader( _( "Diff pair uncoupled length resolution for:" ), ac, bc, r );
624
625 if( compileError )
627
628 constraint = drcEngine->EvalRules( MAX_UNCOUPLED_CONSTRAINT, a, b, layer, r );
629
630 r->Report( "" );
631 r->Report( wxString::Format( _( "Resolved max uncoupled length: %s." ),
632 reportMax( m_frame, constraint ) ) );
633 break;
634 }
635
636 case DRCE_TEXT_HEIGHT:
637 r = dialog->AddHTMLPage( _( "Text Height" ) );
638 reportHeader( _( "Text height resolution for:" ), a, r );
639
640 if( compileError )
642
643 constraint = drcEngine->EvalRules( TEXT_HEIGHT_CONSTRAINT, a, b, layer, r );
644
645 r->Report( "" );
646 r->Report( wxString::Format( _( "Resolved height constraints: min %s; max %s." ),
647 reportMin( m_frame, constraint ),
648 reportMax( m_frame, constraint ) ) );
649 break;
650
651 case DRCE_LINE_WIDTH:
652 r = dialog->AddHTMLPage( _( "Line width" ) );
653 reportHeader( _( "Line width resolution for:" ), a, r );
654
655 if( compileError )
657
658 constraint = drcEngine->EvalRules( LINE_WIDTH_CONSTRAINT, a, b, layer, r );
659
660 r->Report( "" );
661 r->Report( wxString::Format( _( "Resolved line width constraints: min %s; max %s." ),
662 reportMin( m_frame, constraint ), reportMax( m_frame, constraint ) ) );
663 break;
664
665 case DRCE_TRACK_WIDTH:
666 r = dialog->AddHTMLPage( _( "Track Width" ) );
667 reportHeader( _( "Track width resolution for:" ), a, r );
668
669 if( compileError )
671
672 constraint = drcEngine->EvalRules( TRACK_WIDTH_CONSTRAINT, a, b, layer, r );
673
674 r->Report( "" );
675 r->Report( wxString::Format( _( "Resolved width constraints: min %s; max %s." ),
676 reportMin( m_frame, constraint ),
677 reportMax( m_frame, constraint ) ) );
678 break;
679
680 case DRCE_TRACK_ANGLE:
681 r = dialog->AddHTMLPage( _( "Track Angle" ) );
682 reportHeader( _( "Track Angle resolution for:" ), a, r );
683
684 if( compileError )
686
687 constraint = drcEngine->EvalRules( TRACK_ANGLE_CONSTRAINT, a, b, layer, r );
688
689 r->Report( "" );
690 r->Report( wxString::Format( _( "Resolved angle constraints: min %s; max %s." ),
691 reportMin( m_frame, constraint ),
692 reportMax( m_frame, constraint ) ) );
693 break;
694
696 r = dialog->AddHTMLPage( _( "Track Segment Length" ) );
697 reportHeader( _( "Track segment length resolution for:" ), a, r );
698
699 if( compileError )
701
702 constraint = drcEngine->EvalRules( TRACK_SEGMENT_LENGTH_CONSTRAINT, a, b, layer, r );
703
704 r->Report( "" );
705 r->Report( wxString::Format( _( "Resolved segment length constraints: min %s; max %s." ),
706 reportMin( m_frame, constraint ),
707 reportMax( m_frame, constraint ) ) );
708 break;
709
711 r = dialog->AddHTMLPage( _( "Connection Width" ) );
712 reportHeader( _( "Connection width resolution for:" ), a, b, r );
713
714 if( compileError )
716
717 constraint = drcEngine->EvalRules( CONNECTION_WIDTH_CONSTRAINT, a, b, layer, r );
718
719 r->Report( "" );
720 r->Report( wxString::Format( _( "Resolved min connection width: %s." ),
721 reportMin( m_frame, constraint ) ) );
722 break;
723
725 r = dialog->AddHTMLPage( _( "Via Diameter" ) );
726 reportHeader( _( "Via diameter resolution for:" ), a, r );
727
728 if( compileError )
730
731 constraint = drcEngine->EvalRules( VIA_DIAMETER_CONSTRAINT, a, b, layer, r );
732
733 r->Report( "" );
734 r->Report( wxString::Format( _( "Resolved diameter constraints: min %s; max %s." ),
735 reportMin( m_frame, constraint ),
736 reportMax( m_frame, constraint ) ) );
737 break;
738
740 r = dialog->AddHTMLPage( _( "Via Annulus" ) );
741 reportHeader( _( "Via annular width resolution for:" ), a, r );
742
743 if( compileError )
745
746 constraint = drcEngine->EvalRules( ANNULAR_WIDTH_CONSTRAINT, a, b, layer, r );
747
748 r->Report( "" );
749 r->Report( wxString::Format( _( "Resolved annular width constraints: min %s; max %s." ),
750 reportMin( m_frame, constraint ),
751 reportMax( m_frame, constraint ) ) );
752 break;
753
756 r = dialog->AddHTMLPage( _( "Hole Size" ) );
757 reportHeader( _( "Hole size resolution for:" ), a, r );
758
759 if( compileError )
761
762 // Hole tests were done with UNDEFINED_LAYER
763 constraint = drcEngine->EvalRules( HOLE_SIZE_CONSTRAINT, a, b, UNDEFINED_LAYER, r );
764
765 r->Report( "" );
766 r->Report( wxString::Format( _( "Resolved hole size constraints: min %s; max %s." ),
767 reportMin( m_frame, constraint ),
768 reportMax( m_frame, constraint ) ) );
769 break;
770
772 r = dialog->AddHTMLPage( _( "Hole Clearance" ) );
773 reportHeader( _( "Hole clearance resolution for:" ), a, b, r );
774
775 if( compileError )
777
778 if( ac && bc && ac->GetNetCode() == bc->GetNetCode() )
779 {
780 r->Report( "" );
781 r->Report( _( "Items belong to the same net. Clearance is 0." ) );
782 }
783 else
784 {
785 constraint = drcEngine->EvalRules( HOLE_CLEARANCE_CONSTRAINT, a, b, layer, r );
786 clearance = constraint.m_Value.Min();
787 clearanceStr = m_frame->StringFromValue( clearance, true );
788
789 r->Report( "" );
790 r->Report( wxString::Format( _( "Resolved min clearance: %s." ), clearanceStr ) );
791 }
792
793 r->Report( "" );
794 r->Report( "" );
795 r->Report( "" );
796 reportHeader( _( "Physical hole clearance resolution for:" ), a, b, layer, r );
797
798 constraint = drcEngine->EvalRules( PHYSICAL_HOLE_CLEARANCE_CONSTRAINT, a, b, layer, r );
799 clearance = constraint.m_Value.Min();
800 clearanceStr = m_frame->StringFromValue( clearance, true );
801
802 if( !drcEngine->HasRulesForConstraintType( PHYSICAL_HOLE_CLEARANCE_CONSTRAINT ) )
803 {
804 r->Report( "" );
805 r->Report( _( "No 'physical_hole_clearance' constraints defined." ) );
806 }
807 else
808 {
809 r->Report( "" );
810 r->Report( wxString::Format( _( "Resolved min clearance: %s." ), clearanceStr ) );
811 }
812
813 break;
814
816 r = dialog->AddHTMLPage( _( "Hole to Hole" ) );
817 reportHeader( _( "Hole-to-hole clearance resolution for:" ), a, b, r );
818
819 if( compileError )
821
822 constraint = drcEngine->EvalRules( HOLE_TO_HOLE_CONSTRAINT, a, b, UNDEFINED_LAYER, r );
823 clearance = constraint.m_Value.Min();
824 clearanceStr = m_frame->StringFromValue( clearance, true );
825
826 r->Report( "" );
827 r->Report( wxString::Format( _( "Resolved min clearance: %s." ), clearanceStr ) );
828 break;
829
831 r = dialog->AddHTMLPage( _( "Edge Clearance" ) );
832 reportHeader( _( "Edge clearance resolution for:" ), a, b, r );
833
834 if( compileError )
836
837 // Edge clearance test is done with UNDEFINED_LAYER
838 constraint = drcEngine->EvalRules( EDGE_CLEARANCE_CONSTRAINT, a, b, UNDEFINED_LAYER, r );
839 clearance = constraint.m_Value.Min();
840 clearanceStr = m_frame->StringFromValue( clearance, true );
841
842 r->Report( "" );
843 r->Report( wxString::Format( _( "Resolved min clearance: %s." ), clearanceStr ) );
844 break;
845
846 case DRCE_CLEARANCE:
847 {
848 r = dialog->AddHTMLPage( _( "Clearance" ) );
849 reportHeader( _( "Clearance resolution for:" ), a, b, layer, r );
850
851 if( compileError )
853
854 if( ac && bc && ac->GetNetCode() == bc->GetNetCode() )
855 {
856 r->Report( "" );
857 r->Report( _( "Items belong to the same net. Clearance is 0." ) );
858 }
859 else
860 {
861 constraint = drcEngine->EvalRules( CLEARANCE_CONSTRAINT, a, b, layer, r );
862 clearance = constraint.m_Value.Min();
863 clearanceStr = m_frame->StringFromValue( clearance, true );
864
865 r->Report( "" );
866 r->Report( wxString::Format( _( "Resolved min clearance: %s." ), clearanceStr ) );
867 }
868
869 r->Report( "" );
870 r->Report( "" );
871 r->Report( "" );
872 reportHeader( _( "Physical clearance resolution for:" ), a, b, layer, r );
873
874 constraint = drcEngine->EvalRules( PHYSICAL_CLEARANCE_CONSTRAINT, a, b, layer, r );
875 clearance = constraint.m_Value.Min();
876 clearanceStr = m_frame->StringFromValue( clearance, true );
877
878 if( !drcEngine->HasRulesForConstraintType( PHYSICAL_CLEARANCE_CONSTRAINT ) )
879 {
880 r->Report( "" );
881 r->Report( _( "No 'physical_clearance' constraints defined." ) );
882 }
883 else
884 {
885 r->Report( "" );
886 r->Report( wxString::Format( _( "Resolved min clearance: %s." ), clearanceStr ) );
887 }
888
889 break;
890 }
892 r = dialog->AddHTMLPage( _( "Assertions" ) );
893 reportHeader( _( "Assertions for:" ), a, r );
894
895 if( compileError )
897
898 drcEngine->ProcessAssertions( a, []( const DRC_CONSTRAINT* c ){}, r );
899 break;
900
901 default:
902 return;
903 }
904
905 r->Flush();
906
907 KIPLATFORM::UI::ReparentWindow( dialog, drcTool->GetDRCDialog() );
908 dialog->Show( true );
909}
910
911
913{
914 wxCHECK( m_frame, 0 );
915
916 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
917
918 wxCHECK( selTool, 0 );
919
920 const PCB_SELECTION& selection = selTool->GetSelection();
921 BOARD_ITEM* firstItem = nullptr;
922 BOARD_ITEM* secondItem = nullptr;
923
924 if( selection.Size() == 2 )
925 {
926 if( !selection.GetItem( 0 )->IsBOARD_ITEM() || !selection.GetItem( 1 )->IsBOARD_ITEM() )
927 return 0;
928
929 firstItem = static_cast<BOARD_ITEM*>( selection.GetItem( 0 ) );
930 secondItem = static_cast<BOARD_ITEM*>( selection.GetItem( 1 ) );
931
932 reportClearance( firstItem, secondItem );
933 return 0;
934 }
935
936 // Selection size is not 2, so we need to use picker mode.
937 // If there is one item selected, use it as the first item.
938 if( selection.Size() == 1 && selection.GetItem( 0 )->IsBOARD_ITEM() )
939 firstItem = static_cast<BOARD_ITEM*>( selection.GetItem( 0 ) );
940
941 static const std::vector<KICAD_T> clearanceTypes = {
942 PCB_PAD_T,
943 PCB_VIA_T,
945 PCB_ARC_T,
950 };
951
952 Activate();
953
954 if( !firstItem )
955 {
956 firstItem = pickItemForInspection( aEvent,
957 _( "Select first item for clearance resolution..." ),
958 clearanceTypes, nullptr );
959
960 if( !firstItem )
961 return 0;
962 }
963
964 // Keep the first item highlighted while selecting the second
965 selTool->BrightenItem( firstItem );
966
967 secondItem = pickItemForInspection( aEvent,
968 _( "Select second item for clearance resolution..." ),
969 clearanceTypes, firstItem );
970
971 selTool->UnbrightenItem( firstItem );
972
973 if( !secondItem )
974 return 0;
975
976 if( firstItem == secondItem )
977 {
978 m_frame->ShowInfoBarError( _( "Select two different items for clearance resolution." ) );
979 return 0;
980 }
981
982 reportClearance( firstItem, secondItem );
983
984 return 0;
985}
986
987
989{
990 wxCHECK( m_frame && aItemA && aItemB, /* void */ );
991
992 const BOARD_ITEM* a = aItemA;
993 const BOARD_ITEM* b = aItemB;
994
995 if( a->Type() == PCB_GROUP_T )
996 {
997 const PCB_GROUP* ag = static_cast<const PCB_GROUP*>( a );
998
999 if( ag->GetItems().empty() )
1000 {
1001 m_frame->ShowInfoBarError( _( "Cannot generate clearance report on empty group." ) );
1002 return;
1003 }
1004
1005 a = static_cast<const BOARD_ITEM*>( *ag->GetItems().begin() );
1006 }
1007
1008 if( b->Type() == PCB_GROUP_T )
1009 {
1010 const PCB_GROUP* bg = static_cast<const PCB_GROUP*>( b );
1011
1012 if( bg->GetItems().empty() )
1013 {
1014 m_frame->ShowInfoBarError( _( "Cannot generate clearance report on empty group." ) );
1015 return;
1016 }
1017
1018 b = static_cast<const BOARD_ITEM*>( *bg->GetItems().begin() );
1019 }
1020
1021 if( !a || !b )
1022 return;
1023
1024 const auto checkFootprint =
1025 [&]( const FOOTPRINT* footprint ) -> const BOARD_ITEM*
1026 {
1027 const PAD* foundPad = nullptr;
1028
1029 for( const PAD* pad : footprint->Pads() )
1030 {
1031 if( !foundPad || pad->SameLogicalPadAs( foundPad ) )
1032 foundPad = pad;
1033 else
1034 return footprint;
1035 }
1036
1037 if( !foundPad )
1038 return footprint;
1039
1040 return foundPad;
1041 };
1042
1043 if( a->Type() == PCB_FOOTPRINT_T )
1044 a = checkFootprint( static_cast<const FOOTPRINT*>( a ) );
1045
1046 if( b->Type() == PCB_FOOTPRINT_T )
1047 b = checkFootprint( static_cast<const FOOTPRINT*>( b ) );
1048
1049 if( !a || !b )
1050 return;
1051
1052 DIALOG_BOOK_REPORTER* dialog = m_frame->GetInspectClearanceDialog();
1053
1054 wxCHECK( dialog, /* void */ );
1055
1056 dialog->DeleteAllPages();
1057
1058 if( a->Type() != PCB_ZONE_T && b->Type() == PCB_ZONE_T )
1059 std::swap( a, b );
1060 else if( !a->IsConnected() && b->IsConnected() )
1061 std::swap( a, b );
1062
1063 WX_HTML_REPORT_BOX* r = nullptr;
1064 PCB_LAYER_ID active = m_frame->GetActiveLayer();
1065 LSET layerIntersection = a->GetLayerSet() & b->GetLayerSet();
1066 LSET copperIntersection = layerIntersection & LSET::AllCuMask();
1067 DRC_CONSTRAINT constraint;
1068 int clearance = 0;
1069
1070 const BOARD_CONNECTED_ITEM* ac = dynamic_cast<const BOARD_CONNECTED_ITEM*>( a );
1071 const BOARD_CONNECTED_ITEM* bc = dynamic_cast<const BOARD_CONNECTED_ITEM*>( b );
1072 const ZONE* zone = dynamic_cast<const ZONE*>( a );
1073 const PAD* pad = dynamic_cast<const PAD*>( b );
1074 const FOOTPRINT* aFP = dynamic_cast<const FOOTPRINT*>( a );
1075 const FOOTPRINT* bFP = dynamic_cast<const FOOTPRINT*>( b );
1076
1077 bool compileError = false;
1078 bool courtyardError = false;
1079 std::unique_ptr<DRC_ENGINE> drcEngine = makeDRCEngine( &compileError, &courtyardError );
1080
1081 if( copperIntersection.any() && zone && pad && zone->GetNetCode() == pad->GetNetCode() )
1082 {
1084
1085 if( zone->IsOnLayer( active ) )
1086 layer = active;
1087 else if( zone->GetLayerSet().count() > 0 )
1088 layer = zone->GetLayerSet().Seq().front();
1089
1090 r = dialog->AddHTMLPage( _( "Zone" ) );
1091 reportHeader( _( "Zone connection resolution for:" ), a, b, layer, r );
1092
1093 constraint = drcEngine->EvalZoneConnection( pad, zone, layer, r );
1094
1095 if( constraint.m_ZoneConnection == ZONE_CONNECTION::THERMAL )
1096 {
1097 r->Report( "" );
1098 r->Report( "" );
1099 reportHeader( _( "Thermal-relief gap resolution for:" ), a, b, layer, r );
1100
1101 constraint = drcEngine->EvalRules( THERMAL_RELIEF_GAP_CONSTRAINT, pad, zone, layer, r );
1102 int gap = constraint.m_Value.Min();
1103
1104 if( compileError )
1105 reportCompileError( r );
1106
1107 r->Report( "" );
1108 r->Report( wxString::Format( _( "Resolved thermal relief gap: %s." ),
1109 m_frame->StringFromValue( gap, true ) ) );
1110
1111 r->Report( "" );
1112 r->Report( "" );
1113 reportHeader( _( "Thermal-relief spoke width resolution for:" ), a, b, layer, r );
1114
1115 constraint = drcEngine->EvalRules( THERMAL_SPOKE_WIDTH_CONSTRAINT, pad, zone, layer, r );
1116 int width = constraint.m_Value.Opt();
1117
1118 if( compileError )
1119 reportCompileError( r );
1120
1121 r->Report( "" );
1122 r->Report( wxString::Format( _( "Resolved spoke width: %s." ),
1123 m_frame->StringFromValue( width, true ) ) );
1124
1125 r->Report( "" );
1126 r->Report( "" );
1127 reportHeader( _( "Thermal-relief min spoke count resolution for:" ), a, b, layer, r );
1128
1129 constraint = drcEngine->EvalRules( MIN_RESOLVED_SPOKES_CONSTRAINT, pad, zone, layer, r );
1130 int minSpokes = constraint.m_Value.Min();
1131
1132 if( compileError )
1133 reportCompileError( r );
1134
1135 r->Report( "" );
1136 r->Report( wxString::Format( _( "Resolved min spoke count: %d." ),
1137 minSpokes ) );
1138
1139 std::shared_ptr<CONNECTIVITY_DATA> connectivity = pad->GetBoard()->GetConnectivity();
1140 }
1141 else if( constraint.m_ZoneConnection == ZONE_CONNECTION::NONE )
1142 {
1143 r->Report( "" );
1144 r->Report( "" );
1145 reportHeader( _( "Zone clearance resolution for:" ), a, b, layer, r );
1146
1147 clearance = zone->GetLocalClearance().value();
1148 r->Report( "" );
1149 r->Report( wxString::Format( _( "Zone clearance: %s." ),
1150 m_frame->StringFromValue( clearance, true ) ) );
1151
1152 constraint = drcEngine->EvalRules( PHYSICAL_CLEARANCE_CONSTRAINT, pad, zone, layer, r );
1153
1154 if( constraint.m_Value.Min() > clearance )
1155 {
1156 clearance = constraint.m_Value.Min();
1157
1158 r->Report( "" );
1159 r->Report( wxString::Format( _( "Overridden by larger physical clearance from %s;"
1160 "clearance: %s." ),
1161 EscapeHTML( constraint.GetName() ),
1162 m_frame->StringFromValue( clearance, true ) ) );
1163 }
1164
1165 if( !pad->FlashLayer( layer ) )
1166 {
1167 constraint = drcEngine->EvalRules( PHYSICAL_HOLE_CLEARANCE_CONSTRAINT, pad, zone,
1168 layer, r );
1169
1170 if( constraint.m_Value.Min() > clearance )
1171 {
1172 clearance = constraint.m_Value.Min();
1173
1174 r->Report( "" );
1175 r->Report( wxString::Format( _( "Overridden by larger physical hole clearance "
1176 "from %s; clearance: %s." ),
1177 EscapeHTML( constraint.GetName() ),
1178 m_frame->StringFromValue( clearance, true ) ) );
1179 }
1180 }
1181
1182 if( compileError )
1183 reportCompileError( r );
1184
1185 r->Report( "" );
1186 r->Report( wxString::Format( _( "Resolved min clearance: %s." ),
1187 m_frame->StringFromValue( clearance, true ) ) );
1188 }
1189 else
1190 {
1191 r->Report( "" );
1192 r->Report( "" );
1193 reportHeader( _( "Zone clearance resolution for:" ), a, b, layer, r );
1194
1195 if( compileError )
1196 reportCompileError( r );
1197
1198 r->Report( "" );
1199 r->Report( wxString::Format( _( "Resolved min clearance: %s." ),
1200 m_frame->StringFromValue( 0, true ) ) );
1201 }
1202
1203 r->Flush();
1204 }
1205 else if( copperIntersection.any() && !aFP && !bFP )
1206 {
1207 bool sameNet = ac && bc && ac->GetNetCode() > 0 && ac->GetNetCode() == bc->GetNetCode();
1208
1209 std::vector<PCB_LAYER_ID> layers;
1210
1211 if( copperIntersection.test( active ) )
1212 layers.push_back( active );
1213
1214 for( PCB_LAYER_ID layer : copperIntersection.Seq() )
1215 {
1216 if( layer != active )
1217 layers.push_back( layer );
1218 }
1219
1220 auto fillReport =
1221 [&]( PCB_LAYER_ID layer, REPORTER* rep )
1222 {
1223 reportHeader( _( "Clearance resolution for:" ), a, b, layer, rep );
1224
1225 if( sameNet )
1226 {
1227 rep->Report( _( "Items belong to the same net. Min clearance is 0." ) );
1228 return;
1229 }
1230
1231 constraint = drcEngine->EvalRules( CLEARANCE_CONSTRAINT, a, b, layer, rep );
1232 clearance = constraint.m_Value.Min();
1233
1234 if( compileError )
1235 reportCompileError( rep );
1236
1237 rep->Report( "" );
1238
1239 if( constraint.IsNull() )
1240 {
1241 rep->Report( _( "Min clearance is 0." ) );
1242 }
1243 else if( clearance < 0 )
1244 {
1245 rep->Report( wxString::Format( _( "Resolved clearance: %s; clearance will "
1246 "not be tested." ),
1247 m_frame->StringFromValue( clearance, true ) ) );
1248 }
1249 else
1250 {
1251 rep->Report( wxString::Format( _( "Resolved min clearance: %s." ),
1252 m_frame->StringFromValue( clearance, true ) ) );
1253 }
1254 };
1255
1256 if( layers.size() == 1 )
1257 {
1258 PCB_LAYER_ID layer = layers.front();
1259
1260 r = dialog->AddHTMLPage( m_frame->GetBoard()->GetLayerName( layer ) );
1261 fillReport( layer, r );
1262 r->Flush();
1263 }
1264 else
1265 {
1266 auto perLayerMessages = std::make_shared<std::vector<std::vector<wxString>>>();
1267 perLayerMessages->reserve( layers.size() );
1268
1269 for( PCB_LAYER_ID layer : layers )
1270 {
1271 VECTOR_REPORTER tmp;
1272 fillReport( layer, &tmp );
1273 perLayerMessages->push_back( std::move( tmp.m_messages ) );
1274 }
1275
1276 wxPanel* panel = dialog->AddBlankPage( _( "Clearance" ) );
1277 wxBoxSizer* vbox = new wxBoxSizer( wxVERTICAL );
1278
1279 wxChoice* choice = new wxChoice( panel, wxID_ANY );
1280
1281 for( PCB_LAYER_ID layer : layers )
1282 choice->Append( m_frame->GetBoard()->GetLayerName( layer ) );
1283
1284 choice->SetSelection( 0 );
1285
1286 WX_HTML_REPORT_BOX* reportBox = new WX_HTML_REPORT_BOX( panel, wxID_ANY, wxDefaultPosition,
1287 wxDefaultSize,
1288 wxHW_SCROLLBAR_AUTO | wxBORDER_SIMPLE );
1289 reportBox->SetUnits( m_frame->GetUserUnits() );
1290
1291 wxStaticText* layerLabel = new wxStaticText( panel, wxID_ANY, _( "Layer:" ) );
1292
1293 vbox->Add( layerLabel, 0, wxLEFT | wxRIGHT | wxTOP, 5 );
1294 vbox->Add( choice, 0, wxEXPAND | wxALL, 5 );
1295 vbox->Add( reportBox, 1, wxEXPAND | wxALL, 5 );
1296 panel->SetSizer( vbox );
1297 panel->Layout();
1298
1299 auto refresh =
1300 [reportBox, perLayerMessages]( int sel )
1301 {
1302 reportBox->Clear();
1303
1304 if( sel >= 0 && sel < (int) perLayerMessages->size() )
1305 {
1306 for( const wxString& line : ( *perLayerMessages )[sel] )
1307 reportBox->Report( line );
1308 }
1309
1310 reportBox->Flush();
1311 };
1312
1313 choice->Bind( wxEVT_CHOICE,
1314 [refresh]( wxCommandEvent& evt )
1315 {
1316 refresh( evt.GetSelection() );
1317 } );
1318
1319 refresh( 0 );
1320 }
1321 }
1322
1323 if( ac && bc )
1324 {
1325 NETINFO_ITEM* refNet = ac->GetNet();
1326 wxString coupledNet;
1327 wxString dummy;
1328
1329 if( DRC_ENGINE::MatchDpSuffix( refNet->GetNetname(), coupledNet, dummy )
1330 && bc->GetNetname() == coupledNet )
1331 {
1332 LSET dpIntersection = ac->GetLayerSet() & bc->GetLayerSet() & LSET::AllCuMask();
1333 PCB_LAYER_ID dpLayer = active;
1334
1335 if( !dpIntersection.test( dpLayer ) && dpIntersection.any() )
1336 dpLayer = dpIntersection.Seq().front();
1337
1338 r = dialog->AddHTMLPage( _( "Diff Pair" ) );
1339 reportHeader( _( "Diff-pair gap resolution for:" ), ac, bc, dpLayer, r );
1340
1341 constraint = drcEngine->EvalRules( DIFF_PAIR_GAP_CONSTRAINT, ac, bc, dpLayer, r );
1342
1343 r->Report( "" );
1344 r->Report( wxString::Format( _( "Resolved gap constraints: min %s; opt %s; max %s." ),
1345 reportMin( m_frame, constraint ),
1346 reportOpt( m_frame, constraint ),
1347 reportMax( m_frame, constraint ) ) );
1348
1349 r->Report( "" );
1350 r->Report( "" );
1351 r->Report( "" );
1352 reportHeader( _( "Diff-pair max uncoupled length resolution for:" ), ac, bc, dpLayer, r );
1353
1354 if( !drcEngine->HasRulesForConstraintType( MAX_UNCOUPLED_CONSTRAINT ) )
1355 {
1356 r->Report( "" );
1357 r->Report( _( "No 'diff_pair_uncoupled' constraints defined." ) );
1358 }
1359 else
1360 {
1361 constraint = drcEngine->EvalRules( MAX_UNCOUPLED_CONSTRAINT, ac, bc, dpLayer, r );
1362
1363 r->Report( "" );
1364 r->Report( wxString::Format( _( "Resolved max uncoupled length: %s." ),
1365 reportMax( m_frame, constraint ) ) );
1366 }
1367
1368 r->Flush();
1369 }
1370 }
1371
1372 const auto isOnCorrespondingLayer=
1373 [&]( const BOARD_ITEM& aItem, PCB_LAYER_ID aLayer, wxString* aWarning )
1374 {
1375 if( aItem.IsOnLayer( aLayer ) )
1376 return true;
1377
1378 PCB_LAYER_ID correspondingMask = IsFrontLayer( aLayer ) ? F_Mask : B_Mask;
1379 PCB_LAYER_ID correspondingCopper = IsFrontLayer( aLayer ) ? F_Cu : B_Cu;
1380
1381 if( aItem.IsOnLayer( aLayer ) )
1382 return true;
1383
1384 if( aItem.IsOnLayer( correspondingMask ) )
1385 return true;
1386
1387 if( aItem.IsTented( correspondingMask ) && aItem.IsOnLayer( correspondingCopper ) )
1388 {
1389 *aWarning = wxString::Format( _( "Note: %s is tented; clearance will only be "
1390 "applied to holes." ),
1391 getItemDescription( &aItem ) );
1392 return true;
1393 }
1394
1395 return false;
1396 };
1397
1398 for( PCB_LAYER_ID layer : { F_SilkS, B_SilkS } )
1399 {
1400 wxString warning;
1401
1402 if( ( a->IsOnLayer( layer ) && isOnCorrespondingLayer( *b, layer, &warning ) )
1403 || ( b->IsOnLayer( layer ) && isOnCorrespondingLayer( *a, layer, &warning ) ) )
1404 {
1405 r = dialog->AddHTMLPage( m_frame->GetBoard()->GetLayerName( layer ) );
1406 reportHeader( _( "Silkscreen clearance resolution for:" ), a, b, layer, r );
1407
1408 constraint = drcEngine->EvalRules( SILK_CLEARANCE_CONSTRAINT, a, b, layer, r );
1409 clearance = constraint.m_Value.Min();
1410
1411 if( compileError )
1412 reportCompileError( r );
1413
1414 r->Report( "" );
1415
1416 if( !warning.IsEmpty() )
1417 r->Report( warning );
1418
1419 r->Report( wxString::Format( _( "Resolved min clearance: %s." ),
1420 m_frame->StringFromValue( clearance, true ) ) );
1421
1422 r->Flush();
1423 }
1424 }
1425
1426 for( PCB_LAYER_ID layer : { F_CrtYd, B_CrtYd } )
1427 {
1428 bool aCourtyard = aFP && !aFP->GetCourtyard( layer ).IsEmpty();
1429 bool bCourtyard = bFP && !bFP->GetCourtyard( layer ).IsEmpty();
1430
1431 if( aCourtyard && bCourtyard )
1432 {
1433 r = dialog->AddHTMLPage( m_frame->GetBoard()->GetLayerName( layer ) );
1434 reportHeader( _( "Courtyard clearance resolution for:" ), a, b, layer, r );
1435
1436 constraint = drcEngine->EvalRules( COURTYARD_CLEARANCE_CONSTRAINT, a, b, layer, r );
1437 clearance = constraint.m_Value.Min();
1438
1439 if( compileError )
1440 reportCompileError( r );
1441
1442 r->Report( "" );
1443 r->Report( wxString::Format( _( "Resolved min clearance: %s." ),
1444 m_frame->StringFromValue( clearance, true ) ) );
1445
1446 r->Flush();
1447 }
1448 }
1449
1450 if( a->HasHole() || b->HasHole() )
1451 {
1453 bool pageAdded = false;
1454
1455 if( a->HasHole() && b->IsOnLayer( active ) && IsCopperLayer( active ) )
1456 layer = active;
1457 else if( b->HasHole() && a->IsOnLayer( active ) && IsCopperLayer( active ) )
1458 layer = active;
1459 else if( a->HasHole() && b->IsOnCopperLayer() )
1460 layer = b->GetLayer();
1461 else if( b->HasHole() && a->IsOnCopperLayer() )
1462 layer = a->GetLayer();
1463
1464 if( layer >= 0 )
1465 {
1466 r = dialog->AddHTMLPage( _( "Hole" ) );
1467 pageAdded = true;
1468
1469 reportHeader( _( "Hole clearance resolution for:" ), a, b, layer, r );
1470
1471 constraint = drcEngine->EvalRules( HOLE_CLEARANCE_CONSTRAINT, a, b, layer, r );
1472 clearance = constraint.m_Value.Min();
1473
1474 if( compileError )
1475 reportCompileError( r );
1476
1477 r->Report( "" );
1478 r->Report( wxString::Format( _( "Resolved min clearance: %s." ),
1479 m_frame->StringFromValue( clearance, true ) ) );
1480
1481 r->Flush();
1482 }
1483
1484 if( a->HasDrilledHole() || b->HasDrilledHole() )
1485 {
1486 if( !pageAdded )
1487 {
1488 r = dialog->AddHTMLPage( _( "Hole" ) );
1489 pageAdded = true;
1490 }
1491 else
1492 {
1493 r->Report( "" );
1494 r->Report( "" );
1495 r->Report( "" );
1496 }
1497
1498 reportHeader( _( "Hole-to-hole clearance resolution for:" ), a, b, r );
1499
1500 constraint = drcEngine->EvalRules( HOLE_TO_HOLE_CONSTRAINT, a, b, UNDEFINED_LAYER, r );
1501 clearance = constraint.m_Value.Min();
1502
1503 if( compileError )
1504 reportCompileError( r );
1505
1506 r->Report( "" );
1507 r->Report( wxString::Format( _( "Resolved min clearance: %s." ),
1508 m_frame->StringFromValue( clearance, true ) ) );
1509
1510 r->Flush();
1511 }
1512 }
1513
1514 for( PCB_LAYER_ID edgeLayer : { Edge_Cuts, Margin } )
1515 {
1517
1518 if( a->IsOnLayer( edgeLayer ) && b->Type() != PCB_FOOTPRINT_T )
1519 {
1520 if( b->IsOnLayer( active ) && IsCopperLayer( active ) )
1521 layer = active;
1522 else if( IsCopperLayer( b->GetLayer() ) )
1523 layer = b->GetLayer();
1524 }
1525 else if( b->IsOnLayer( edgeLayer ) && a->Type() != PCB_FOOTPRINT_T )
1526 {
1527 if( a->IsOnLayer( active ) && IsCopperLayer( active ) )
1528 layer = active;
1529 else if( IsCopperLayer( a->GetLayer() ) )
1530 layer = a->GetLayer();
1531 }
1532
1533 if( layer >= 0 )
1534 {
1535 wxString layerName = m_frame->GetBoard()->GetLayerName( edgeLayer );
1536 r = dialog->AddHTMLPage( layerName + wxS( " " ) + _( "Clearance" ) );
1537 reportHeader( _( "Edge clearance resolution for:" ), a, b, layer, r );
1538
1539 constraint = drcEngine->EvalRules( EDGE_CLEARANCE_CONSTRAINT, a, b, layer, r );
1540 clearance = constraint.m_Value.Min();
1541
1542 if( compileError )
1543 reportCompileError( r );
1544
1545 r->Report( "" );
1546 r->Report( wxString::Format( _( "Resolved min clearance: %s." ),
1547 m_frame->StringFromValue( clearance, true ) ) );
1548
1549 r->Flush();
1550 }
1551 }
1552
1553 r = dialog->AddHTMLPage( _( "Physical Clearances" ) );
1554
1555 if( compileError )
1556 {
1557 reportCompileError( r );
1558 }
1559 else if( !drcEngine->HasRulesForConstraintType( PHYSICAL_CLEARANCE_CONSTRAINT ) )
1560 {
1561 r->Report( "" );
1562 r->Report( _( "No 'physical_clearance' constraints defined." ) );
1563 }
1564 else
1565 {
1566 LSET reportLayers = layerIntersection;
1567 bool reported = false;
1568
1569 if( a->IsOnLayer( Edge_Cuts ) )
1570 {
1571 LSET edgeInteractingLayers = bFP ? LSET( { F_CrtYd, B_CrtYd } )
1573 reportLayers |= edgeInteractingLayers;
1574 }
1575
1576 if( b->IsOnLayer( Edge_Cuts ) )
1577 {
1578 LSET edgeInteractingLayers = aFP ? LSET( { F_CrtYd, B_CrtYd } )
1580 reportLayers |= edgeInteractingLayers;
1581 }
1582
1583 for( PCB_LAYER_ID layer : reportLayers )
1584 {
1585 reported = true;
1586 reportHeader( _( "Physical clearance resolution for:" ), a, b, layer, r );
1587
1588 constraint = drcEngine->EvalRules( PHYSICAL_CLEARANCE_CONSTRAINT, a, b, layer, r );
1589 clearance = constraint.m_Value.Min();
1590
1591 if( constraint.IsNull() )
1592 {
1593 r->Report( "" );
1594 r->Report( wxString::Format( _( "No 'physical_clearance' constraints in effect on %s." ),
1595 m_frame->GetBoard()->GetLayerName( layer ) ) );
1596 }
1597 else
1598 {
1599 r->Report( "" );
1600 r->Report( wxString::Format( _( "Resolved min clearance: %s." ),
1601 m_frame->StringFromValue( clearance, true ) ) );
1602 }
1603
1604 r->Report( "" );
1605 r->Report( "" );
1606 r->Report( "" );
1607 }
1608
1609 if( !reported )
1610 {
1611 reportHeader( _( "Physical clearance resolution for:" ), a, b, r );
1612 r->Report( "" );
1613 r->Report( _( "Items share no relevant layers. No 'physical_clearance' constraints will "
1614 "be applied." ) );
1615 }
1616 }
1617
1618 if( a->HasHole() || b->HasHole() )
1619 {
1620 PCB_LAYER_ID layer;
1621
1622 if( a->HasHole() && b->IsOnLayer( active ) )
1623 layer = active;
1624 else if( b->HasHole() && a->IsOnLayer( active ) )
1625 layer = active;
1626 else if( a->HasHole() )
1627 layer = b->GetLayer();
1628 else
1629 layer = a->GetLayer();
1630
1631 reportHeader( _( "Physical hole clearance resolution for:" ), a, b, layer, r );
1632
1633 constraint = drcEngine->EvalRules( PHYSICAL_HOLE_CLEARANCE_CONSTRAINT, a, b, layer, r );
1634 clearance = constraint.m_Value.Min();
1635
1636 if( compileError )
1637 {
1638 reportCompileError( r );
1639 }
1640 else if( !drcEngine->HasRulesForConstraintType( PHYSICAL_HOLE_CLEARANCE_CONSTRAINT ) )
1641 {
1642 r->Report( "" );
1643 r->Report( _( "No 'physical_hole_clearance' constraints defined." ) );
1644 }
1645 else
1646 {
1647 r->Report( "" );
1648 r->Report( wxString::Format( _( "Resolved min clearance: %s." ),
1649 m_frame->StringFromValue( clearance, true ) ) );
1650 }
1651 }
1652
1653 r->Flush();
1654
1655 dialog->Raise();
1656 dialog->Show( true );
1657}
1658
1659
1661{
1662#define EVAL_RULES( constraint, a, b, layer, r ) drcEngine->EvalRules( constraint, a, b, layer, r )
1663
1664 wxCHECK( m_frame, 0 );
1665
1666 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
1667
1668 wxCHECK( selTool, 0 );
1669
1670 const PCB_SELECTION& selection = selTool->GetSelection();
1671 BOARD_ITEM* item = nullptr;
1672
1673 if( selection.Size() == 1 && selection.GetItem( 0 )->IsBOARD_ITEM() )
1674 {
1675 item = static_cast<BOARD_ITEM*>( selection.GetItem( 0 ) );
1676 }
1677 else if( selection.Size() == 0 )
1678 {
1679 static const std::vector<KICAD_T> constraintTypes = {
1680 PCB_PAD_T,
1681 PCB_VIA_T,
1683 PCB_ARC_T,
1684 PCB_ZONE_T,
1688 PCB_TEXT_T,
1691 };
1692
1693 Activate();
1694
1695 item = pickItemForInspection( aEvent, _( "Select item for constraints resolution..." ),
1696 constraintTypes, nullptr );
1697
1698 if( !item )
1699 return 0;
1700 }
1701 else
1702 {
1703 m_frame->ShowInfoBarError( _( "Select a single item for a constraints resolution report." ) );
1704 return 0;
1705 }
1706
1707 DIALOG_BOOK_REPORTER* dialog = m_frame->GetInspectConstraintsDialog();
1708
1709 wxCHECK( dialog, 0 );
1710
1711 dialog->DeleteAllPages();
1712 DRC_CONSTRAINT constraint;
1713
1714 bool compileError = false;
1715 bool courtyardError = false;
1716 std::unique_ptr<DRC_ENGINE> drcEngine = makeDRCEngine( &compileError, &courtyardError );
1717
1718 WX_HTML_REPORT_BOX* r = nullptr;
1719
1720 if( item->Type() == PCB_TRACE_T )
1721 {
1722 r = dialog->AddHTMLPage( _( "Track Width" ) );
1723 reportHeader( _( "Track width resolution for:" ), item, r );
1724
1725 constraint = EVAL_RULES( TRACK_WIDTH_CONSTRAINT, item, nullptr, item->GetLayer(), r );
1726
1727 if( compileError )
1728 reportCompileError( r );
1729
1730 r->Report( "" );
1731 r->Report( wxString::Format( _( "Resolved width constraints: min %s; opt %s; max %s." ),
1732 reportMin( m_frame, constraint ),
1733 reportOpt( m_frame, constraint ),
1734 reportMax( m_frame, constraint ) ) );
1735
1736 r->Flush();
1737 }
1738
1739 if( item->Type() == PCB_VIA_T )
1740 {
1741 r = dialog->AddHTMLPage( _( "Via Diameter" ) );
1742 reportHeader( _( "Via diameter resolution for:" ), item, r );
1743
1744 // PADSTACKS TODO: once we have padstacks we'll need to run this per-layer....
1745 constraint = EVAL_RULES( VIA_DIAMETER_CONSTRAINT, item, nullptr, UNDEFINED_LAYER, r );
1746
1747 if( compileError )
1748 reportCompileError( r );
1749
1750 r->Report( "" );
1751 r->Report( wxString::Format( _( "Resolved diameter constraints: min %s; opt %s; max %s." ),
1752 reportMin( m_frame, constraint ),
1753 reportOpt( m_frame, constraint ),
1754 reportMax( m_frame, constraint ) ) );
1755
1756 r->Flush();
1757
1758 r = dialog->AddHTMLPage( _( "Via Annular Width" ) );
1759 reportHeader( _( "Via annular width resolution for:" ), item, r );
1760
1761 // PADSTACKS TODO: once we have padstacks we'll need to run this per-layer....
1762 constraint = EVAL_RULES( ANNULAR_WIDTH_CONSTRAINT, item, nullptr, UNDEFINED_LAYER, r );
1763
1764 if( compileError )
1765 reportCompileError( r );
1766
1767 r->Report( "" );
1768 r->Report( wxString::Format( _( "Resolved annular width constraints: min %s; opt %s; max %s." ),
1769 reportMin( m_frame, constraint ),
1770 reportOpt( m_frame, constraint ),
1771 reportMax( m_frame, constraint ) ) );
1772
1773 r->Flush();
1774 }
1775
1776 if( ( item->Type() == PCB_PAD_T && static_cast<PAD*>( item )->GetDrillSize().x > 0 )
1777 || item->Type() == PCB_VIA_T )
1778 {
1779 r = dialog->AddHTMLPage( _( "Hole Size" ) );
1780 reportHeader( _( "Hole size resolution for:" ), item, r );
1781
1782 constraint = EVAL_RULES( HOLE_SIZE_CONSTRAINT, item, nullptr, UNDEFINED_LAYER, r );
1783
1784 if( compileError )
1785 reportCompileError( r );
1786
1787 r->Report( "" );
1788 r->Report( wxString::Format( _( "Resolved hole size constraints: min %s; opt %s; max %s." ),
1789 reportMin( m_frame, constraint ),
1790 reportOpt( m_frame, constraint ),
1791 reportMax( m_frame, constraint ) ) );
1792
1793 r->Flush();
1794 }
1795
1796 if( item->Type() == PCB_PAD_T || item->Type() == PCB_SHAPE_T || dynamic_cast<PCB_TRACK*>( item ) )
1797 {
1798 r = dialog->AddHTMLPage( _( "Solder Mask" ) );
1799 reportHeader( _( "Solder mask expansion resolution for:" ), item, r );
1800
1801 constraint = EVAL_RULES( SOLDER_MASK_EXPANSION_CONSTRAINT, item, nullptr, UNDEFINED_LAYER, r );
1802
1803 if( compileError )
1804 reportCompileError( r );
1805
1806 r->Report( "" );
1807 r->Report( wxString::Format( _( "Resolved solder mask expansion: %s." ),
1808 reportOpt( m_frame, constraint ) ) );
1809
1810 r->Flush();
1811 }
1812
1813 if( item->Type() == PCB_PAD_T )
1814 {
1815 r = dialog->AddHTMLPage( _( "Solder Paste" ) );
1816 reportHeader( _( "Solder paste absolute clearance resolution for:" ), item, r );
1817
1818 constraint = EVAL_RULES( SOLDER_PASTE_ABS_MARGIN_CONSTRAINT, item, nullptr, UNDEFINED_LAYER, r );
1819
1820 if( compileError )
1821 reportCompileError( r );
1822
1823 r->Report( "" );
1824 r->Report( wxString::Format( _( "Resolved solder paste absolute clearance: %s." ),
1825 reportOpt( m_frame, constraint ) ) );
1826
1827 reportHeader( _( "Solder paste relative clearance resolution for:" ), item, r );
1828
1829 constraint = EVAL_RULES( SOLDER_PASTE_REL_MARGIN_CONSTRAINT, item, nullptr, UNDEFINED_LAYER, r );
1830
1831 if( compileError )
1832 reportCompileError( r );
1833
1834 r->Report( "" );
1835 r->Report( "" );
1836 r->Report( "" );
1837 r->Report( wxString::Format( _( "Resolved solder paste relative clearance: %s." ),
1838 reportOpt( m_frame, constraint ) ) );
1839
1840 r->Flush();
1841 }
1842
1843 if( item->Type() == PCB_FIELD_T || item->Type() == PCB_TEXT_T || item->Type() == PCB_TEXTBOX_T )
1844 {
1845 r = dialog->AddHTMLPage( _( "Text Size" ) );
1846 reportHeader( _( "Text height resolution for:" ), item, r );
1847
1848 constraint = EVAL_RULES( TEXT_HEIGHT_CONSTRAINT, item, nullptr, UNDEFINED_LAYER, r );
1849
1850 if( compileError )
1851 reportCompileError( r );
1852
1853 r->Report( "" );
1854 r->Report( wxString::Format( _( "Resolved height constraints: min %s; opt %s; max %s." ),
1855 reportMin( m_frame, constraint ),
1856 reportOpt( m_frame, constraint ),
1857 reportMax( m_frame, constraint ) ) );
1858
1859 r->Report( "" );
1860 r->Report( "" );
1861 r->Report( "" );
1862 reportHeader( _( "Text thickness resolution for:" ), item, r );
1863
1864 constraint = EVAL_RULES( LINE_WIDTH_CONSTRAINT, item, nullptr, UNDEFINED_LAYER, r );
1865
1866 if( compileError )
1867 reportCompileError( r );
1868
1869 r->Report( "" );
1870 r->Report( wxString::Format( _( "Resolved thickness constraints: min %s; opt %s; max %s." ),
1871 reportMin( m_frame, constraint ),
1872 reportOpt( m_frame, constraint ),
1873 reportMax( m_frame, constraint ) ) );
1874
1875 r->Flush();
1876 }
1877
1878 r = dialog->AddHTMLPage( _( "Keepouts" ) );
1879 reportHeader( _( "Keepout resolution for:" ), item, r );
1880
1881 constraint = EVAL_RULES( DISALLOW_CONSTRAINT, item, nullptr, item->GetLayer(), r );
1882
1883 if( compileError )
1884 reportCompileError( r );
1885
1886 if( courtyardError )
1887 {
1888 r->Report( "" );
1889 r->Report( _( "Report may be incomplete: some footprint courtyards are malformed." )
1890 + wxS( "&nbsp;&nbsp;" )
1891 + wxS( "<a href='$DRC'>" ) + _( "Run DRC for a full analysis." )
1892 + wxS( "</a>" ) );
1893 }
1894
1895 r->Report( "" );
1896
1897 if( constraint.m_DisallowFlags )
1898 r->Report( _( "Item <b>disallowed</b> at current location." ) );
1899 else
1900 r->Report( _( "Item allowed at current location." ) );
1901
1902 r->Flush();
1903
1904 r = dialog->AddHTMLPage( _( "Assertions" ) );
1905 reportHeader( _( "Assertions for:" ), item, r );
1906
1907 if( compileError )
1908 reportCompileError( r );
1909
1910 if( courtyardError )
1911 {
1912 r->Report( "" );
1913 r->Report( _( "Report may be incomplete: some footprint courtyards are malformed." )
1914 + wxS( "&nbsp;&nbsp;" )
1915 + wxS( "<a href='$DRC'>" ) + _( "Run DRC for a full analysis." )
1916 + wxS( "</a>" ) );
1917 }
1918
1919 drcEngine->ProcessAssertions( item, []( const DRC_CONSTRAINT* c ){}, r );
1920 r->Flush();
1921
1922 dialog->Raise();
1923 dialog->Show( true );
1924 return 0;
1925}
1926
1927
1929{
1930 wxCHECK( m_frame, 0 );
1931
1932 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
1933
1934 wxCHECK( selTool, 0 );
1935
1936 const PCB_SELECTION& selection = selTool->RequestSelection(
1937 []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
1938 {
1939 // Iterate from the back so we don't have to worry about removals.
1940 for( int i = aCollector.GetCount() - 1; i >= 0; --i )
1941 {
1942 BOARD_ITEM* item = aCollector[ i ];
1943
1944 if( !dynamic_cast<FOOTPRINT*>( item ) )
1945 aCollector.Remove( item );
1946 }
1947 } );
1948
1949 if( selection.Size() == 1 )
1950 DiffFootprint( static_cast<FOOTPRINT*>( selection.GetItem( 0 ) ) );
1951 else
1952 m_frame->ShowInfoBarError( _( "Select a footprint to diff with its library equivalent." ) );
1953
1954 return 0;
1955}
1956
1957
1959{
1960 wxCHECK( m_frame, 0 );
1961
1962 wxFileDialog dlg( m_frame, _( "Choose Board to Compare With" ), wxEmptyString,
1963 wxEmptyString, FILEEXT::PcbFileWildcard(),
1964 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1965
1966 if( dlg.ShowModal() != wxID_OK )
1967 return 0;
1968
1969 wxFileName otherFn( dlg.GetPath() );
1970 otherFn.MakeAbsolute();
1971
1972 const wxString otherPath = otherFn.GetFullPath();
1973
1974 wxFileName projectFn = otherFn;
1975 projectFn.SetExt( FILEEXT::ProjectFileExtension );
1976 const wxString projectPath = projectFn.GetFullPath();
1977
1978 wxFileName activeProjectFn( m_frame->Prj().GetProjectFullName() );
1979 activeProjectFn.MakeAbsolute();
1980
1981 // Refuse the self-compare before touching SETTINGS_MANAGER — attaching the
1982 // active PROJECT to a second BOARD would clobber its m_BoardSettings. Use
1983 // wxFileName::SameAs (path normalization + case folding) rather than a raw
1984 // string compare, matching SCH_INSPECTION_TOOL::CompareSchematic.
1985 if( projectFn.SameAs( activeProjectFn ) )
1986 {
1987 m_frame->ShowInfoBarError(
1988 _( "Select a board file from another project to compare." ) );
1989 return 0;
1990 }
1991
1992 return showBoardComparison( otherPath, projectPath, otherPath );
1993}
1994
1995
1996namespace
1997{
1998// Everything needed to show one board-vs-board comparison: the diff, the clones
1999// of removed live-board items (kept alive because the canvas references them),
2000// and the canvas-context switcher. Moveable so it can be swapped on reload.
2001struct PCB_DIFF_VIEW
2002{
2004 KICAD_DIFF::DOCUMENT_GEOMETRY referenceGeometry;
2005 KICAD_DIFF::DOCUMENT_GEOMETRY comparisonGeometry;
2006 std::vector<std::unique_ptr<BOARD_ITEM>> clones;
2008};
2009
2010
2012struct HISTORY_REVISION
2013{
2014 explicit HISTORY_REVISION( SETTINGS_MANAGER* aMgr ) :
2015 mgr( aMgr )
2016 {
2017 }
2018
2019 ~HISTORY_REVISION()
2020 {
2021 // The view's clones and switcher may reference the board
2022 view = PCB_DIFF_VIEW();
2023
2024 if( board )
2025 {
2026 board->ClearProject();
2027 board.reset();
2028 }
2029
2030 // Skip a project the manager already evicted
2031 if( prj && mgr->IsProjectLoaded( prj ) )
2032 mgr->UnloadProject( prj, false );
2033
2034 if( !tempDir.IsEmpty() )
2035 wxFileName::Rmdir( tempDir, wxPATH_RMDIR_RECURSIVE );
2036 }
2037
2038 SETTINGS_MANAGER* mgr;
2039 std::unique_ptr<BOARD> board;
2040 PROJECT* prj = nullptr;
2041 wxString tempDir;
2042 PCB_DIFF_VIEW view;
2043};
2044
2045
2046PCB_DIFF_VIEW buildPcbDiffView( BOARD* aLive, BOARD* aOther, const wxString& aOtherPath )
2047{
2048 PCB_DIFF_VIEW view;
2049
2050 KICAD_DIFF::PCB_DIFFER differ( aLive, aOther, aOtherPath );
2051 view.result = differ.Diff();
2052
2053 const KICAD_DIFF::DIFF_COLOR_THEME theme;
2054
2055 // The layer checkboxes come from the geometry
2056 view.referenceGeometry = KICAD_DIFF::ExtractBoardGeometry( *aLive, theme.reference );
2057 view.comparisonGeometry = KICAD_DIFF::ExtractBoardGeometry( *aOther, theme.comparison );
2058
2059 std::map<KIID, KIGFX::COLOR4D> refOverrides;
2060 std::map<KIID, KIGFX::COLOR4D> compOverrides;
2061 std::map<KIID, KICAD_DIFF::CATEGORY> kiidCategories;
2062
2063 std::function<void( const KICAD_DIFF::ITEM_CHANGE& )> collect =
2064 [&]( const KICAD_DIFF::ITEM_CHANGE& aChange )
2065 {
2066 if( !aChange.id.empty() )
2067 {
2068 const KIID& kiid = aChange.id.back();
2069 kiidCategories[kiid] = KICAD_DIFF::CategoryFor( aChange.kind );
2070
2071 switch( aChange.kind )
2072 {
2073 case KICAD_DIFF::CHANGE_KIND::ADDED: compOverrides[kiid] = theme.added; break;
2075 refOverrides[kiid] = theme.removed;
2076 compOverrides[kiid] = theme.removed;
2077 break;
2079 refOverrides[kiid] = theme.modified;
2080 compOverrides[kiid] = theme.modified;
2081 break;
2082 default:
2083 refOverrides[kiid] = theme.conflict;
2084 compOverrides[kiid] = theme.conflict;
2085 break;
2086 }
2087 }
2088
2089 for( const KICAD_DIFF::ITEM_CHANGE& child : aChange.children )
2090 collect( child );
2091 };
2092
2093 for( const KICAD_DIFF::ITEM_CHANGE& change : view.result.changes )
2094 collect( change );
2095
2096 // Clone removed items from the live board because their originals are
2097 // pinned to the editor's VIEW.
2098 for( const auto& [kiid, color] : refOverrides )
2099 {
2100 if( color != theme.removed )
2101 continue;
2102
2103 if( BOARD_ITEM* found = KICAD_DIFF::FindPcbDiffItem( aLive, kiid ) )
2104 {
2105 if( BOARD_ITEM* clone = dynamic_cast<BOARD_ITEM*>( found->Clone() ) )
2106 view.clones.emplace_back( clone );
2107 }
2108 }
2109
2110 std::vector<KIGFX::VIEW_ITEM*> extraItems;
2111
2112 for( const std::unique_ptr<BOARD_ITEM>& clone : view.clones )
2113 {
2114 // A footprint draws nothing itself. Its pads, graphics and fields are
2115 // independent view items, so add them too or the clone is invisible.
2116 if( FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( clone.get() ) )
2117 {
2118 std::vector<KIGFX::VIEW_ITEM*> fpItems = KICAD_DIFF::CollectFootprintDiffContextItems( *fp );
2119 extraItems.insert( extraItems.end(), fpItems.begin(), fpItems.end() );
2120 }
2121 else
2122 {
2123 extraItems.push_back( clone.get() );
2124 }
2125 }
2126
2127 view.switcher =
2128 [other = aOther, color = theme.modified, overrides = compOverrides, extras = std::move( extraItems ),
2129 categories = kiidCategories] ( WIDGET_DIFF_CANVAS& aCanvas, const KIID_PATH& )
2130 {
2131 KICAD_DIFF::ConfigurePcbDiffCanvasContext( aCanvas, nullptr, other, color, overrides, extras,
2132 categories );
2133 };
2134
2135 return view;
2136}
2137} // namespace
2138
2139
2140int BOARD_INSPECTION_TOOL::showBoardComparison( const wxString& aOtherPath, const wxString& aProjectPath,
2141 const wxString& aComparisonLabel )
2142{
2143 // Load the comparison board into its own non-active PROJECT so the live
2144 // project settings are never overwritten. A missing .kicad_pro is fine
2145 // (LoadProject returns false but still inserts a defaults-only slot); a
2146 // present-but-malformed .kicad_pro is treated as failure.
2147 SETTINGS_MANAGER* mgr = m_frame->GetSettingsManager();
2148 bool projectLoadOk = mgr && mgr->LoadProject( aProjectPath, false );
2149 PROJECT* otherPrj = mgr ? mgr->GetProject( aProjectPath ) : nullptr;
2150
2151 if( !otherPrj )
2152 {
2153 m_frame->ShowInfoBarError( wxString::Format( _( "Failed to load project for %s" ), aOtherPath ) );
2154 return 0;
2155 }
2156
2157 if( !projectLoadOk && wxFileName( aProjectPath ).FileExists() )
2158 {
2159 mgr->UnloadProject( otherPrj, false );
2160 m_frame->ShowInfoBarError( wxString::Format( _( "Failed to load project for %s" ), aOtherPath ) );
2161 return 0;
2162 }
2163
2165
2166 // Skip editor-frame initialization (drawing sheet singleton, BASE_SCREEN
2167 // globals, DRC engine, connectivity) so the read-only compare cannot leak
2168 // state into the live frame.
2169 BOARD_LOADER::OPTIONS loadOptions;
2170 loadOptions.initialize_after_load = false;
2171
2172 std::unique_ptr<BOARD> otherBoard;
2173
2174 try
2175 {
2176 otherBoard = BOARD_LOADER::Load( aOtherPath, pluginType, otherPrj, loadOptions );
2177 }
2178 catch( const IO_ERROR& ioe )
2179 {
2180 m_frame->ShowInfoBarError( wxString::Format( _( "Failed to load %s: %s" ), aOtherPath, ioe.What() ) );
2181 mgr->UnloadProject( otherPrj, false );
2182 return 0;
2183 }
2184 catch( ... )
2185 {
2186 m_frame->ShowInfoBarError( wxString::Format( _( "Failed to load %s" ), aOtherPath ) );
2187 mgr->UnloadProject( otherPrj, false );
2188 return 0;
2189 }
2190
2191 if( !otherBoard )
2192 {
2193 m_frame->ShowInfoBarError( wxString::Format( _( "Failed to load %s" ), aOtherPath ) );
2194 mgr->UnloadProject( otherPrj, false );
2195 return 0;
2196 }
2197
2198 BOARD* board = m_frame->GetBoard();
2199 PCB_DIFF_VIEW view = buildPcbDiffView( board, otherBoard.get(), aOtherPath );
2200
2201 auto dlgDiff = std::make_unique<DIALOG_KICAD_DIFF>( m_frame, board->GetFileName(), aComparisonLabel, view.result,
2202 view.referenceGeometry, view.comparisonGeometry,
2203 view.switcher );
2204 dlgDiff->ShowModal();
2205
2206 // Destroy the dialog (its canvas drops its references to the board's items)
2207 // before the board is freed, or teardown dereferences freed items.
2208 dlgDiff.reset();
2209
2210 otherBoard->ClearProject();
2211 otherBoard.reset();
2212
2213 mgr->UnloadProject( otherPrj, false );
2214
2215 return 0;
2216}
2217
2218
2220{
2221 wxCHECK( m_frame, 0 );
2222
2223 BOARD* liveBoard = m_frame->GetBoard();
2224
2225 if( !liveBoard || liveBoard->GetFileName().IsEmpty() )
2226 {
2227 m_frame->ShowInfoBarError( _( "Save the board before comparing against local history." ) );
2228 return 0;
2229 }
2230
2231 const wxString projectPath = m_frame->Prj().GetProjectPath();
2232 LOCAL_HISTORY& history = m_frame->Kiway().LocalHistory();
2233
2234 std::vector<LOCAL_HISTORY_SNAPSHOT_INFO> snapshots = history.GetSnapshots( projectPath );
2235
2236 if( snapshots.empty() )
2237 {
2238 m_frame->ShowInfoBarError( _( "No local history snapshots for this project." ) );
2239 return 0;
2240 }
2241
2242 // The history repo stores files by project-relative path with forward slashes.
2243 wxFileName boardFn( liveBoard->GetFileName() );
2244 boardFn.MakeRelativeTo( projectPath );
2245 const wxString relPath = boardFn.GetFullPath( wxPATH_UNIX );
2246
2247 wxFileName projFn( m_frame->Prj().GetProjectFullName() );
2248 projFn.MakeRelativeTo( projectPath );
2249 const wxString projRel = projFn.GetFullPath( wxPATH_UNIX );
2250
2251 // One entry per distinct board version: newest-first, skipping commits with
2252 // no board or whose board content matches the previously kept one. This
2253 // drops schematic-only saves and collapses runs that left the board untouched.
2254 std::vector<LOCAL_HISTORY_SNAPSHOT_INFO> boardSnapshots;
2255 wxString prevFingerprint;
2256
2257 for( const LOCAL_HISTORY_SNAPSHOT_INFO& s : snapshots )
2258 {
2259 wxString fingerprint = history.TreeFingerprint( projectPath, s.hash, wxS( ".kicad_pcb" ) );
2260
2261 if( fingerprint.IsEmpty() || fingerprint == prevFingerprint )
2262 continue;
2263
2264 prevFingerprint = fingerprint;
2265 boardSnapshots.push_back( s );
2266 }
2267
2268 if( boardSnapshots.empty() )
2269 {
2270 m_frame->ShowInfoBarError( _( "No local history snapshots change this board." ) );
2271 return 0;
2272 }
2273
2274 snapshots = std::move( boardSnapshots );
2275
2276 SETTINGS_MANAGER* mgr = m_frame->GetSettingsManager();
2277
2278 std::vector<wxString> labels;
2279
2280 for( const LOCAL_HISTORY_SNAPSHOT_INFO& s : snapshots )
2281 {
2282 wxString summary = s.summary.IsEmpty() ? s.message.BeforeFirst( '\n' ) : s.summary;
2283 labels.push_back( wxString::Format( wxS( "%s (%s)" ), summary, s.hash.Left( 8 ) ) );
2284 }
2285
2286 // Extract + load snapshot aIndex into the out-params. Cleans up its own temp
2287 // on any failure.
2288 auto loadRevision =
2289 [&]( int aIndex, std::unique_ptr<BOARD>& aBoard, PROJECT*& aPrj, wxString& aTempDir ) -> bool
2290 {
2291 const wxString hash = snapshots[aIndex].hash;
2292 wxFileName dirFn;
2293 dirFn.AssignDir( wxFileName::GetTempDir() );
2294 // Unique per load, another process or a kept revision may hold the same snapshot
2295 dirFn.AppendDir( wxS( "kicad-history-" ) + KIID().AsString() );
2296 const wxString tempDir = dirFn.GetPath();
2297
2298 // Extract just the board, the project file (its real net classes and
2299 // design settings) and the rules and library tables the board differ
2300 // compares, skipping the schematic, 3D models, gerbers, etc.
2301 if( !history.ExtractAllFilesAtCommit( projectPath, hash, tempDir,
2302 { wxS( ".kicad_pcb" ), wxS( ".kicad_pro" ),
2303 wxS( ".kicad_dru" ), wxS( "fp-lib-table" ),
2304 wxS( "sym-lib-table" ) } ) )
2305 {
2306 wxFileName::Rmdir( tempDir, wxPATH_RMDIR_RECURSIVE );
2307 return false;
2308 }
2309
2310 const wxString boardPath = tempDir + wxS( "/" ) + relPath;
2311 const wxString proPath = tempDir + wxS( "/" ) + projRel;
2312
2313 mgr->LoadProject( proPath, false );
2314 PROJECT* prj = mgr->GetProject( proPath );
2315
2316 if( !prj )
2317 {
2318 wxFileName::Rmdir( tempDir, wxPATH_RMDIR_RECURSIVE );
2319 return false;
2320 }
2321
2322 BOARD_LOADER::OPTIONS loadOptions;
2323 loadOptions.initialize_after_load = false;
2324
2325 std::unique_ptr<BOARD> loaded;
2326
2327 try
2328 {
2329 loaded = BOARD_LOADER::Load( boardPath,
2331 prj, loadOptions );
2332 }
2333 catch( ... )
2334 {
2335 // A historical board may be malformed or in a format this build cannot parse. Skip it
2336 // rather than letting the throw escape.
2337 mgr->UnloadProject( prj, false );
2338 wxFileName::Rmdir( tempDir, wxPATH_RMDIR_RECURSIVE );
2339 return false;
2340 }
2341
2342 if( !loaded )
2343 {
2344 mgr->UnloadProject( prj, false );
2345 wxFileName::Rmdir( tempDir, wxPATH_RMDIR_RECURSIVE );
2346 return false;
2347 }
2348
2349 aBoard = std::move( loaded );
2350 aPrj = prj;
2351 aTempDir = tempDir;
2352 return true;
2353 };
2354
2355 // Load a revision and build its diff view, guarding both the parse and the
2356 // diff so a bad snapshot is skipped instead of crashing.
2357 auto loadView =
2358 [&]( int aIndex ) -> std::unique_ptr<HISTORY_REVISION>
2359 {
2360 auto revision = std::make_unique<HISTORY_REVISION>( mgr );
2361
2362 if( !loadRevision( aIndex, revision->board, revision->prj, revision->tempDir ) )
2363 return nullptr;
2364
2365 try
2366 {
2367 // A load that skips initialisation leaves the board without its net classes and settings
2368 revision->board->SetProject( revision->prj );
2369 revision->view = buildPcbDiffView( liveBoard, revision->board.get(),
2370 revision->tempDir + wxS( "/" ) + relPath );
2371 }
2372 catch( ... )
2373 {
2374 return nullptr;
2375 }
2376
2377 return revision;
2378 };
2379
2380 std::unique_ptr<HISTORY_REVISION> shown = loadView( 0 );
2381 int startIndex = 0;
2382
2383 if( !shown )
2384 {
2385 m_frame->ShowInfoBarError( _( "Could not compare against the selected snapshot." ) );
2386 return 0;
2387 }
2388
2389 // Default to the first commit back from HEAD that actually differs from the
2390 // current board, so opening lands on real changes rather than an in-sync HEAD.
2391 while( shown->view.result.Empty() && startIndex + 1 < static_cast<int>( snapshots.size() ) )
2392 {
2393 std::unique_ptr<HISTORY_REVISION> next = loadView( startIndex + 1 );
2394
2395 if( !next )
2396 break;
2397
2398 shown = std::move( next );
2399 startIndex++;
2400 }
2401
2402 // Every revision the canvas may reference, declared first so it outlives the dialog
2403 std::vector<std::unique_ptr<HISTORY_REVISION>> revisions;
2404 revisions.push_back( std::move( shown ) );
2405
2406 int shownIndex = startIndex;
2407 const PCB_DIFF_VIEW& view = revisions.back()->view;
2408
2409 auto dlgDiff = std::make_unique<DIALOG_KICAD_DIFF>( m_frame, liveBoard->GetFileName(), labels[startIndex],
2410 view.result, view.referenceGeometry,
2411 view.comparisonGeometry, view.switcher );
2412
2413 dlgDiff->SetRevisionChooser(
2414 labels, startIndex,
2415 [&]( int aIndex )
2416 {
2417 if( aIndex == shownIndex )
2418 return;
2419
2420 std::unique_ptr<HISTORY_REVISION> next = loadView( aIndex );
2421
2422 if( !next )
2423 {
2424 m_frame->ShowInfoBarError( _( "Could not compare against the selected snapshot." ) );
2425 return;
2426 }
2427
2428 // A reload that throws can leave the canvas on either revision, so keep both
2429 revisions.push_back( std::move( next ) );
2430 const PCB_DIFF_VIEW& nextView = revisions.back()->view;
2431
2432 try
2433 {
2434 dlgDiff->Reload( liveBoard->GetFileName(), labels[aIndex], nextView.result,
2435 nextView.referenceGeometry, nextView.comparisonGeometry, nextView.switcher,
2436 {} );
2437 }
2438 catch( ... )
2439 {
2440 m_frame->ShowInfoBarError( _( "Could not compare against the selected snapshot." ) );
2441 dlgDiff->EndModal( wxID_CANCEL );
2442 return;
2443 }
2444
2445 // The canvas now references only the new revision
2446 revisions.erase( revisions.begin(), revisions.end() - 1 );
2447 shownIndex = aIndex;
2448 } );
2449
2450 dlgDiff->ShowModal();
2451
2452 // Destroy the dialog before the boards it references are freed.
2453 dlgDiff.reset();
2454 return 0;
2455}
2456
2457
2459{
2460 wxCHECK( m_frame, 0 );
2461
2462 PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
2463
2464 wxCHECK( selTool, 0 );
2465
2466 const PCB_SELECTION& selection = selTool->GetSelection();
2467
2468 if( selection.Size() != 1 || selection.Front()->Type() != PCB_FOOTPRINT_T )
2469 {
2470 m_frame->ShowInfoBarError( _( "Select a footprint for a footprint associations report." ) );
2471 return 0;
2472 }
2473
2474 DIALOG_FOOTPRINT_ASSOCIATIONS dlg( m_frame, static_cast<FOOTPRINT*>( selection.Front() ) );
2475
2476 dlg.ShowModal();
2477
2478 return 0;
2479}
2480
2481
2482void BOARD_INSPECTION_TOOL::DiffFootprint( FOOTPRINT* aFootprint, wxTopLevelWindow* aReparentTo )
2483{
2484 DIALOG_BOOK_REPORTER* dialog = m_frame->GetFootprintDiffDialog();
2485
2486 wxCHECK( dialog, /* void */ );
2487
2488 dialog->DeleteAllPages();
2489 dialog->SetUserItemID( aFootprint->m_Uuid );
2490
2491 LIB_ID fpID = aFootprint->GetFPID();
2492 wxString libName = fpID.GetLibNickname();
2493 wxString fpName = fpID.GetLibItemName();
2494 WX_HTML_REPORT_BOX* r = nullptr;
2495
2496 r = dialog->AddHTMLPage( _( "Summary" ) );
2497
2498 r->Report( wxS( "<h7>" ) + _( "Board vs library diff for:" ) + wxS( "</h7>" ) );
2499 r->Report( wxS( "<ul><li>" ) + EscapeHTML( getItemDescription( aFootprint ) ) + wxS( "</li>" )
2500 + wxS( "<li>" ) + _( "Library: " ) + EscapeHTML( libName ) + wxS( "</li>" )
2501 + wxS( "<li>" ) + _( "Library item: " ) + EscapeHTML( fpName ) + wxS( "</li></ul>" ) );
2502
2503 r->Report( "" );
2504
2505 PROJECT* project = aFootprint->GetBoard()->GetProject();
2507
2508 if( !adapter->HasLibrary( libName, false ) )
2509 {
2510 r->Report( _( "The library is not included in the current configuration." )
2511 + wxS( "&nbsp;&nbsp;&nbsp" )
2512 + wxS( "<a href='$CONFIG'>" ) + _( "Manage Footprint Libraries" )
2513 + wxS( "</a>" ) );
2514
2515 }
2516 else if( !adapter->HasLibrary( libName, true ) )
2517 {
2518 r->Report( _( "The library is not enabled in the current configuration." )
2519 + wxS( "&nbsp;&nbsp;&nbsp" )
2520 + wxS( "<a href='$CONFIG'>" ) + _( "Manage Footprint Libraries" )
2521 + wxS( "</a>" ) );
2522
2523 }
2524 else
2525 {
2526 std::shared_ptr<FOOTPRINT> libFootprint;
2527
2528 try
2529 {
2530 libFootprint.reset( adapter->LoadFootprint( libName, fpName, true ) );
2531 }
2532 catch( const IO_ERROR& )
2533 {
2534 }
2535
2536 if( !libFootprint )
2537 {
2538 r->Report( wxString::Format( _( "The library no longer contains the item %s." ),
2539 fpName) );
2540 }
2541 else
2542 {
2543 if( !aFootprint->FootprintNeedsUpdate( libFootprint.get(), 0, r ) )
2544 r->Report( _( "No relevant differences detected." ) );
2545
2546 wxPanel* panel = dialog->AddBlankPage( _( "Visual" ) );
2548
2549 diff->DisplayDiff( aFootprint, libFootprint );
2550 }
2551 }
2552
2553 r->Flush();
2554
2555 if( aReparentTo )
2556 KIPLATFORM::UI::ReparentWindow( dialog, aReparentTo );
2557 else
2558 dialog->Raise();
2559
2560 dialog->Show( true );
2561}
2562
2563
2565{
2566 wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
2567
2568 FOOTPRINT_DIFF_WIDGET* diffWidget = new FOOTPRINT_DIFF_WIDGET( aParentPanel, m_frame->Kiway() );
2569
2570 sizer->Add( diffWidget, 1, wxEXPAND | wxALL, 5 );
2571 aParentPanel->SetSizer( sizer );
2572 aParentPanel->Layout();
2573
2574 return diffWidget;
2575}
2576
2577
2579{
2580 BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
2581
2582 m_frame->m_ProbingSchToPcb = true; // recursion guard
2583 {
2584 m_toolMgr->RunAction( ACTIONS::selectionClear );
2585
2586 if( item )
2587 m_toolMgr->RunAction<EDA_ITEM*>( ACTIONS::selectItem, item );
2588 }
2589 m_frame->m_ProbingSchToPcb = false;
2590
2591 bool request3DviewRedraw = frame()->GetPcbNewSettings()->m_Display.m_Live3DRefresh;
2592
2593 if( item && item->Type() != PCB_FOOTPRINT_T )
2594 request3DviewRedraw = false;
2595
2596 // Update 3D viewer highlighting
2597 if( request3DviewRedraw )
2598 m_frame->Update3DView( false, true );
2599
2600 return 0;
2601}
2602
2603
2604 bool BOARD_INSPECTION_TOOL::highlightNet( const VECTOR2D& aPosition, bool aUseSelection )
2605{
2606 BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
2608 PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
2609
2610 int net = -1;
2611 bool enableHighlight = false;
2612
2613 if( aUseSelection )
2614 {
2615 const PCB_SELECTION& selection = selectionTool->GetSelection();
2616 std::set<int> netcodes;
2617
2618 for( EDA_ITEM* item : selection )
2619 {
2620 if( BOARD_CONNECTED_ITEM* ci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
2621 netcodes.insert( ci->GetNetCode() );
2622 }
2623
2624 enableHighlight = !netcodes.empty();
2625
2626 if( enableHighlight && netcodes.size() > 1 )
2627 {
2628 // If we are doing a multi-highlight, cross-probing back and other stuff is not
2629 // yet supported
2630 settings->SetHighlight( netcodes );
2631 board->ResetNetHighLight();
2632
2633 for( int multiNet : netcodes )
2634 board->SetHighLightNet( multiNet, true );
2635
2636 board->HighLightON();
2637 m_toolMgr->GetView()->UpdateAllLayersColor();
2638 m_currentlyHighlighted = netcodes;
2639 return true;
2640 }
2641 else if( enableHighlight )
2642 {
2643 net = *netcodes.begin();
2644 }
2645 }
2646
2647 // If we didn't get a net to highlight from the selection, use the cursor
2648 if( net < 0 )
2649 {
2650 GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
2651 guide.SetIgnoreZoneFills( false );
2652 guide.SetIgnoreNoNets( true );
2653
2654 PCB_LAYER_ID activeLayer = static_cast<PCB_LAYER_ID>( view()->GetTopLayer() );
2655 guide.SetPreferredLayer( activeLayer );
2656
2657 GENERAL_COLLECTOR collector;
2658 collector.Collect( board, { PCB_PAD_T, PCB_VIA_T, PCB_TRACE_T, PCB_ARC_T, PCB_SHAPE_T }, aPosition,
2659 guide );
2660
2661 if( collector.GetCount() == 0 )
2662 collector.Collect( board, { PCB_ZONE_T }, aPosition, guide );
2663
2664 // Apply the active selection filter, except we want to allow picking locked items for
2665 // highlighting even if the user has disabled them for selection
2666 PCB_SELECTION_FILTER_OPTIONS& filter = selectionTool->GetFilter();
2667
2668 bool saved = filter.lockedItems;
2669 filter.lockedItems = true;
2670
2671 selectionTool->FilterCollectedItems( collector, true, nullptr );
2672
2673 filter.lockedItems = saved;
2674
2675 // Clear the previous highlight
2676 //m_frame->SendMessageToEESCHEMA( nullptr );
2677
2678 bool highContrast = settings->GetHighContrast();
2679 PCB_LAYER_ID contrastLayer = settings->GetPrimaryHighContrastLayer();
2680
2681 for( int i = collector.GetCount() - 1; i >= 0; i-- )
2682 {
2683 LSET itemLayers = collector[i]->GetLayerSet();
2684
2685 if( ( itemLayers & LSET::AllCuMask() ).none() ||
2686 ( highContrast && !itemLayers.Contains( contrastLayer ) ) )
2687 {
2688 collector.Remove( i );
2689 continue;
2690 }
2691 }
2692
2693 enableHighlight = ( collector.GetCount() > 0 );
2694
2695 // Obtain net code for the clicked item
2696 if( enableHighlight )
2697 {
2698 BOARD_CONNECTED_ITEM* targetItem = static_cast<BOARD_CONNECTED_ITEM*>( collector[0] );
2699
2700 if( targetItem->Type() == PCB_PAD_T )
2701 m_frame->SendCrossProbeItem( targetItem );
2702
2703 net = targetItem->GetNetCode();
2704 }
2705 }
2706
2707 const std::set<int>& netcodes = settings->GetHighlightNetCodes();
2708
2709 if( !aUseSelection && net >= 0 && netcodes.size() == 1 && netcodes.contains( net ) && settings->IsHighlightEnabled() )
2710 {
2711 if( BOARD* board2 = m_frame->GetBoard() )
2712 {
2713 if( NETINFO_ITEM* netinfo = board2->FindNet( net ) )
2714 {
2715 wxString sig = netinfo->GetNetChain();
2716 if( !sig.IsEmpty() )
2717 {
2718 int count = 0;
2719
2720 for( NETINFO_ITEM* n : board2->GetNetInfo() )
2721 {
2722 if( n->GetNetChain() == sig )
2723 count++;
2724 }
2725
2726 if( count > 1 )
2727 {
2728 std::set<int> sigCodes;
2729
2730
2731 for( NETINFO_ITEM* n : board2->GetNetInfo() )
2732 {
2733 if( n->GetNetChain() == sig )
2734 sigCodes.insert( n->GetNetCode() );
2735 }
2736
2737 settings->SetHighlight( sigCodes, true );
2738 m_toolMgr->GetView()->UpdateAllLayersColor();
2739 m_currentlyHighlighted = sigCodes;
2741
2742 if( auto pcbSettings = dynamic_cast<KIGFX::PCB_RENDER_SETTINGS*>( settings ) )
2743 pcbSettings->SetHighlightedNetChain( sig );
2744
2745 board2->ResetNetHighLight();
2746
2747 for( int c : sigCodes )
2748 board2->SetHighLightNet( c, true );
2749
2750 board2->HighLightON();
2751
2752 return true;
2753 }
2754 }
2755 }
2756 }
2757
2758 enableHighlight = !settings->IsHighlightEnabled();
2759 }
2760 else if( !aUseSelection && netcodes.size() == 1 && netcodes.contains( net ) )
2761 {
2762 enableHighlight = !settings->IsHighlightEnabled();
2763 }
2764
2765 if( enableHighlight != settings->IsHighlightEnabled() || !netcodes.count( net ) )
2766 {
2767 if( !netcodes.empty() )
2768 m_lastHighlighted = netcodes;
2769
2770 KIGFX::VIEW* view = m_toolMgr->GetView();
2771 const bool wasEnabled = settings->IsHighlightEnabled();
2772 const std::set<int> before = settings->GetHighlightNetCodes();
2773
2774 settings->SetHighlight( enableHighlight, net );
2775
2776 auto* pcbSettings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( settings );
2777 const bool retained = view->GetGAL()->HasRetainedScene();
2778
2779 auto onChangedNet =
2780 [&]( KIGFX::VIEW_ITEM* aItem ) -> bool
2781 {
2782 BOARD_CONNECTED_ITEM* connected = dynamic_cast<BOARD_CONNECTED_ITEM*>( aItem );
2783
2784 return connected
2785 && ( connected->GetNetCode() == net || before.contains( connected->GetNetCode() ) );
2786 };
2787
2788 // Switching between highlighted nets recolours only those two nets. Toggling highlight
2789 // dims or restores everything else, which a canvas that fades layers does itself.
2790 const bool switchedNet = wasEnabled && enableHighlight;
2791
2792 if( retained && ( switchedNet || pcbSettings->HasCanvasFadedLayers() ) )
2793 {
2794 if( !switchedNet )
2795 {
2796 view->UpdateLayersColor( false,
2797 [pcbSettings]( int aLayer )
2798 {
2799 return !pcbSettings->IsCanvasFadedLayer( aLayer );
2800 } );
2801 }
2802
2803 view->UpdateAllItemsConditionally( KIGFX::COLOR, onChangedNet );
2804 }
2805 else
2806 {
2807 view->UpdateAllLayersColor();
2808 }
2809 }
2810
2811 m_highlightedNetChain.clear();
2812
2813 if( auto pcbSettings = dynamic_cast<KIGFX::PCB_RENDER_SETTINGS*>( settings ) )
2814 pcbSettings->SetHighlightedNetChain( wxEmptyString );
2815
2816 // Store the highlighted netcode in the current board (for dialogs for instance)
2817 if( enableHighlight && net >= 0 )
2818 {
2819 m_currentlyHighlighted = netcodes;
2820 board->SetHighLightNet( net );
2821 board->HighLightON();
2822
2823 NETINFO_ITEM* netinfo = board->FindNet( net );
2824
2825 if( netinfo )
2826 {
2827 std::vector<MSG_PANEL_ITEM> items;
2828 netinfo->GetMsgPanelInfo( m_frame, items );
2829 m_frame->SetMsgPanel( items );
2830 m_frame->SendCrossProbeNetName( netinfo->GetNetname() );
2831 }
2832 }
2833 else
2834 {
2835 m_currentlyHighlighted.clear();
2836 board->ResetNetHighLight();
2837 m_frame->SetMsgPanel( board );
2838 m_frame->SendCrossProbeNetName( "" );
2839 }
2840
2841 return true;
2842}
2843
2844
2846{
2847 int netcode = aEvent.Parameter<int>();
2848 KIGFX::RENDER_SETTINGS* settings = m_toolMgr->GetView()->GetPainter()->GetSettings();
2849 const std::set<int>& highlighted = settings->GetHighlightNetCodes();
2850
2851 if( netcode > 0 )
2852 {
2853 m_lastHighlighted = highlighted;
2854 settings->SetHighlight( true, netcode );
2855 m_toolMgr->GetView()->UpdateAllLayersColor();
2856 m_currentlyHighlighted.clear();
2857 m_currentlyHighlighted.insert( netcode );
2858
2859 // If this net belongs to a multi-net chain and was already highlighted, escalate to chain highlight
2860 if( BOARD* board = m_frame->GetBoard() )
2861 {
2862 if( NETINFO_ITEM* net = board->FindNet( netcode ) )
2863 {
2864 wxString sig = net->GetNetChain();
2865 if( !sig.IsEmpty() )
2866 {
2867 int count = 0;
2868 for( NETINFO_ITEM* n : board->GetNetInfo() )
2869 if( n->GetNetChain() == sig )
2870 count++;
2871 bool alreadyHighlighted = highlighted.count( netcode );
2872 if( count > 1 && alreadyHighlighted )
2873 {
2874 if( m_highlightedNetChain != sig )
2875 {
2876 TOOL_EVENT sigEvt = PCB_ACTIONS::highlightNetChain.MakeEvent();
2877 HighlightNetChain( sigEvt );
2878 }
2879 }
2880 }
2881 }
2882 }
2883 }
2884 else if( aEvent.IsAction( &PCB_ACTIONS::highlightNetSelection ) )
2885 {
2886 // Highlight selection (cursor position will be ignored)
2887 highlightNet( getViewControls()->GetMousePosition(), true );
2888 }
2889 else if( aEvent.IsAction( &PCB_ACTIONS::toggleLastNetHighlight ) )
2890 {
2891 std::set<int> temp = highlighted;
2892 settings->SetHighlight( m_lastHighlighted );
2893 m_toolMgr->GetView()->UpdateAllLayersColor();
2895 m_lastHighlighted = std::move( temp );
2896 }
2897 else if( aEvent.IsAction( &PCB_ACTIONS::toggleNetHighlight ) )
2898 {
2899 bool turnOn = highlighted.empty() && !m_currentlyHighlighted.empty();
2900 settings->SetHighlight( m_currentlyHighlighted, turnOn );
2901 m_toolMgr->GetView()->UpdateAllLayersColor();
2902 }
2903 else // Highlight the net belonging to the item under the cursor
2904 {
2905 highlightNet( getViewControls()->GetMousePosition(), false );
2906 }
2907
2908 return 0;
2909}
2910
2911
2913{
2915 VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
2916 BOARD_ITEM* item = nullptr;
2917
2918 {
2919 // Collect nearest connectable item at cursor position
2920 BOARD* board = m_frame->GetBoard();
2921 GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
2922 GENERAL_COLLECTOR collector;
2923 collector.Collect( board, { PCB_PAD_T, PCB_VIA_T, PCB_TRACE_T, PCB_ARC_T, PCB_SHAPE_T }, cursorPos, guide );
2924
2925 if( collector.GetCount() > 0 )
2926 item = collector[0];
2927 }
2928
2929 wxString sig;
2930
2931 if( item )
2932 {
2933 NETINFO_ITEM* net = nullptr;
2934
2935 if( PAD* pad = dynamic_cast<PAD*>( item ) )
2936 net = pad->GetNet();
2937 else if( BOARD_CONNECTED_ITEM* ci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
2938 net = ci->GetNet();
2939
2940 if( net )
2941 sig = net->GetNetChain();
2942 }
2943
2944 KIGFX::RENDER_SETTINGS* settings = m_toolMgr->GetView()->GetPainter()->GetSettings();
2945
2946 // If no chain under cursor and a chain is currently highlighted, toggle off
2947 if( sig.IsEmpty() && !m_highlightedNetChain.IsEmpty() )
2948 {
2949 m_highlightedNetChain.clear();
2950
2951 if( auto pcbSettings = dynamic_cast<KIGFX::PCB_RENDER_SETTINGS*>( settings ) )
2952 pcbSettings->SetHighlightedNetChain( wxEmptyString );
2953
2954 settings->SetHighlight( false );
2955 m_currentlyHighlighted.clear();
2956 m_toolMgr->GetView()->UpdateAllLayersColor();
2957
2958 if( KIGFX::PCB_RENDER_SETTINGS* pcbSettings = dynamic_cast<KIGFX::PCB_RENDER_SETTINGS*>( settings ) )
2959 pcbSettings->SetHighlightedNetChain( wxString() );
2960
2961 return 0;
2962 }
2963
2964
2965 // If same chain already highlighted, clear highlight
2966 if( !sig.IsEmpty() && sig == m_highlightedNetChain )
2967 {
2968 m_highlightedNetChain.clear();
2969
2970 if( auto pcbSettings = dynamic_cast<KIGFX::PCB_RENDER_SETTINGS*>( settings ) )
2971 pcbSettings->SetHighlightedNetChain( wxEmptyString );
2972
2973 settings->SetHighlight( false );
2974 m_currentlyHighlighted.clear();
2975 m_toolMgr->GetView()->UpdateAllLayersColor();
2976
2977 if( KIGFX::PCB_RENDER_SETTINGS* pcbSettings = dynamic_cast<KIGFX::PCB_RENDER_SETTINGS*>( settings ) )
2978 pcbSettings->SetHighlightedNetChain( wxString() );
2979
2980 return 0;
2981 }
2982
2983 // If we have a net highlight active but no chain highlight, convert to chain highlight
2984 if( !sig.IsEmpty() && m_highlightedNetChain.IsEmpty() && !m_currentlyHighlighted.empty() )
2985 {
2986 // Determine chain from first highlighted net if cursor item had no chain
2987 if( sig.IsEmpty() )
2988 {
2989 int firstCode = *m_currentlyHighlighted.begin();
2990
2991 if( NETINFO_ITEM* net = m_frame->GetBoard()->FindNet( firstCode ) )
2992 sig = net->GetNetChain();
2993 }
2994 }
2995
2997
2998 if( KIGFX::PCB_RENDER_SETTINGS* pcbSettings = dynamic_cast<KIGFX::PCB_RENDER_SETTINGS*>( settings ) )
2999 pcbSettings->SetHighlightedNetChain( sig );
3000
3001 std::set<int> codes;
3002
3003 if( !sig.IsEmpty() )
3004 {
3005 for( NETINFO_ITEM* net : m_frame->GetBoard()->GetNetInfo() )
3006 {
3007 if( net->GetNetChain() == sig )
3008 codes.insert( net->GetNetCode() );
3009 }
3010 }
3011
3012 settings->SetHighlight( codes, true );
3013 m_toolMgr->GetView()->UpdateAllLayersColor();
3014 m_currentlyHighlighted = codes;
3015
3016 return 0;
3017}
3018
3019
3021{
3022 if( m_highlightedNetChain.IsEmpty() )
3023 return 0;
3024
3025 // Parameters are passed as a single pair<old,new>
3026 std::pair<wxString, wxString> ids = aEvent.Parameter<std::pair<wxString, wxString>>();
3027 KIID oldId( ids.first );
3028 KIID newId( ids.second );
3029 m_frame->GetBoard()->ReplaceNetChainTerminalPad( m_highlightedNetChain, oldId, newId );
3030 return 0;
3031}
3032
3033
3035{
3036 BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
3037 KIGFX::RENDER_SETTINGS* settings = m_toolMgr->GetView()->GetPainter()->GetSettings();
3038
3039 m_currentlyHighlighted.clear();
3040 m_lastHighlighted.clear();
3041
3042 board->ResetNetHighLight();
3043 settings->SetHighlight( false );
3044
3045 // Also clear any chain-specific state
3046 if( KIGFX::PCB_RENDER_SETTINGS* pcbSettings = dynamic_cast<KIGFX::PCB_RENDER_SETTINGS*>( settings ) )
3047 pcbSettings->SetHighlightedNetChain( wxString() );
3048
3049 m_toolMgr->GetView()->UpdateAllLayersColor();
3050 m_frame->SetMsgPanel( board );
3051 m_frame->SendCrossProbeNetName( "" );
3052 return 0;
3053}
3054
3055
3057{
3058 PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
3059
3060 // Deactivate other tools; particularly important if another PICKER is currently running
3061 Activate();
3062
3063 picker->SetCursor( KICURSOR::BULLSEYE );
3064 picker->SetSnapping( false );
3065 picker->ClearHandlers();
3066
3067 picker->SetClickHandler(
3068 [this]( const VECTOR2D& pt ) -> bool
3069 {
3070 PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
3071
3072 m_toolMgr->RunAction( ACTIONS::selectionClear );
3074 EDIT_TOOL::PadFilter );
3075
3076 PCB_SELECTION& selection = selectionTool->GetSelection();
3077
3078 if( selection.Empty() )
3079 {
3081 EDIT_TOOL::FootprintFilter );
3082 selection = selectionTool->GetSelection();
3083 }
3084
3085 if( selection.Empty() )
3086 {
3087 // Clear the previous local ratsnest if we click off all items
3088 for( FOOTPRINT* fp : getModel<BOARD>()->Footprints() )
3089 {
3090 for( PAD* pad : fp->Pads() )
3091 pad->SetLocalRatsnestVisible( displayOptions().m_ShowGlobalRatsnest );
3092 }
3093 }
3094 else
3095 {
3096 for( EDA_ITEM* item : selection )
3097 {
3098 if( PAD* pad = dyn_cast<PAD*>( item) )
3099 {
3100 pad->SetLocalRatsnestVisible( !pad->GetLocalRatsnestVisible() );
3101 }
3102 else if( FOOTPRINT* fp = dyn_cast<FOOTPRINT*>( item) )
3103 {
3104 if( !fp->Pads().empty() )
3105 {
3106 bool enable = !fp->Pads()[0]->GetLocalRatsnestVisible();
3107
3108 for( PAD* childPad : fp->Pads() )
3109 childPad->SetLocalRatsnestVisible( enable );
3110 }
3111 }
3112 }
3113 }
3114
3115 m_toolMgr->GetView()->MarkTargetDirty( KIGFX::TARGET_OVERLAY );
3116
3117 return true;
3118 } );
3119
3120 picker->SetFinalizeHandler(
3121 [this]( int aCondition )
3122 {
3123 if( aCondition != PCB_PICKER_TOOL::END_ACTIVATE )
3124 {
3125 for( FOOTPRINT* fp : getModel<BOARD>()->Footprints() )
3126 {
3127 for( PAD* pad : fp->Pads() )
3128 pad->SetLocalRatsnestVisible( displayOptions().m_ShowGlobalRatsnest );
3129 }
3130 }
3131 } );
3132
3133 m_toolMgr->RunAction( ACTIONS::pickerTool, &aEvent );
3134
3135 return 0;
3136}
3137
3138
3140{
3141 VECTOR2I delta = aEvent.Parameter<VECTOR2I>();
3142
3143 if( delta == VECTOR2I() )
3144 {
3145 // We can delete the existing map to force a recalculation
3146 delete m_dynamicData;
3147 m_dynamicData = nullptr;
3148 }
3149
3150 PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
3151 PCB_SELECTION& selection = selectionTool->GetSelection();
3152 std::shared_ptr<CONNECTIVITY_DATA> connectivity = getModel<BOARD>()->GetConnectivity();
3153
3154 if( selection.Empty() )
3155 {
3156 connectivity->ClearLocalRatsnest();
3157 delete m_dynamicData;
3158 m_dynamicData = nullptr;
3159 }
3160 else
3161 {
3163 }
3164
3165 return 0;
3166}
3167
3168
3170{
3171 getModel<BOARD>()->GetConnectivity()->ClearLocalRatsnest();
3172 delete m_dynamicData;
3173 m_dynamicData = nullptr;
3174
3175 return 0;
3176}
3177
3178
3180{
3181 PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
3182 SELECTION& selection = selectionTool->GetSelection();
3183 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board()->GetConnectivity();
3184 std::vector<BOARD_ITEM*> items;
3185 std::deque<EDA_ITEM*> queued_items( selection.begin(), selection.end() );
3186
3187 for( std::size_t i = 0; i < queued_items.size(); ++i )
3188 {
3189 if( !queued_items[i]->IsBOARD_ITEM() )
3190 continue;
3191
3192 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( queued_items[i] );
3193
3194 wxCHECK2( item, continue );
3195
3196 if( item->Type() == PCB_FOOTPRINT_T )
3197 {
3198 for( PAD* pad : static_cast<FOOTPRINT*>( item )->Pads() )
3199 {
3200 if( pad->GetLocalRatsnestVisible() || displayOptions().m_ShowModuleRatsnest )
3201 items.push_back( pad );
3202 }
3203 }
3204 else if( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T )
3205 {
3206 item->RunOnChildren( [ &queued_items ]( BOARD_ITEM *aItem )
3207 {
3208 queued_items.push_back( aItem );
3209 },
3211 }
3212 else if( BOARD_CONNECTED_ITEM* boardItem = dyn_cast<BOARD_CONNECTED_ITEM*>( item ) )
3213 {
3214 if( boardItem->GetLocalRatsnestVisible() || displayOptions().m_ShowModuleRatsnest )
3215 items.push_back( boardItem );
3216 }
3217 }
3218
3219 if( items.empty() || std::none_of( items.begin(), items.end(),
3220 []( const BOARD_ITEM* aItem )
3221 {
3222 return( aItem->Type() == PCB_TRACE_T
3223 || aItem->Type() == PCB_PAD_T
3224 || aItem->Type() == PCB_ARC_T
3225 || aItem->Type() == PCB_ZONE_T
3226 || aItem->Type() == PCB_FOOTPRINT_T
3227 || aItem->Type() == PCB_VIA_T
3228 || aItem->Type() == PCB_SHAPE_T );
3229 } ) )
3230 {
3231 return;
3232 }
3233
3234 if( !m_dynamicData )
3235 {
3236 m_dynamicData = new CONNECTIVITY_DATA( board()->GetConnectivity(), items, true );
3237 connectivity->BlockRatsnestItems( items );
3238 }
3239 else
3240 {
3241 m_dynamicData->Move( aDelta );
3242 }
3243
3244 connectivity->ComputeLocalRatsnest( items, m_dynamicData );
3245}
3246
3247
3249{
3250 doHideRatsnestNet( aEvent.Parameter<int>(), true );
3251 return 0;
3252}
3253
3254
3256{
3257 doHideRatsnestNet( aEvent.Parameter<int>(), false );
3258 return 0;
3259}
3260
3261
3262void BOARD_INSPECTION_TOOL::doHideRatsnestNet( int aNetCode, bool aHide )
3263{
3265 m_toolMgr->GetView()->GetPainter()->GetSettings() );
3266
3267 PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
3268 SELECTION& selection = selectionTool->GetSelection();
3269
3270 if( aNetCode <= 0 && !selection.Empty() )
3271 {
3272 for( EDA_ITEM* item : selection )
3273 {
3274 if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
3275 {
3276 if( bci->GetNetCode() > 0 )
3277 doHideRatsnestNet( bci->GetNetCode(), aHide );
3278 }
3279 }
3280
3281 return;
3282 }
3283
3284 if( aHide )
3285 rs->GetHiddenNets().insert( aNetCode );
3286 else
3287 rs->GetHiddenNets().erase( aNetCode );
3288
3289 if( !m_frame->GetAppearancePanel()->IsTogglingNetclassRatsnestVisibility() )
3290 {
3291 m_frame->GetCanvas()->RedrawRatsnest();
3292 m_frame->GetCanvas()->Refresh();
3293
3294 m_frame->GetAppearancePanel()->OnNetVisibilityChanged( aNetCode, !aHide );
3295 }
3296}
3297
3298
3300{
3304
3313
3322
3325}
std::function< void(const VECTOR2I &, GENERAL_COLLECTOR &, PCB_SELECTION_TOOL *)> CLIENT_SELECTION_FILTER
Definition actions.h:33
#define EVAL_RULES(constraint, a, b, layer, r)
wxString reportMax(PCB_BASE_FRAME *aFrame, DRC_CONSTRAINT &aConstraint)
wxString reportMin(PCB_BASE_FRAME *aFrame, DRC_CONSTRAINT &aConstraint)
bool isNPTHPad(const BOARD_ITEM &aItem)
wxString reportOpt(PCB_BASE_FRAME *aFrame, DRC_CONSTRAINT &aConstraint)
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition actions.h:224
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition actions.h:214
static TOOL_ACTION pickerTool
Definition actions.h:250
static TOOL_ACTION selectionClear
Clear the current selection.
Definition actions.h:221
ACTION_MENU(bool isContextMenu, TOOL_INTERACTIVE *aTool=nullptr)
Default constructor.
void SetTitle(const wxString &aTitle) override
Set title for the menu.
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual NETCLASS * GetEffectiveNetClass() const
Return the NETCLASS for this item.
NETINFO_ITEM * GetNet() const
Return NETINFO_ITEM object for a given item.
void InspectDRCError(const std::shared_ptr< RC_ITEM > &aDRCItem)
int HighlightNet(const TOOL_EVENT &aEvent)
Highlight net belonging to the item under the cursor.
void calculateSelectionRatsnest(const VECTOR2I &aDelta)
Recalculate dynamic ratsnest for the current selection.
void setTransitions() override
Bind handlers to corresponding TOOL_ACTIONs.
int ShowBoardStatistics(const TOOL_EVENT &aEvent)
Show dialog with board statistics.
wxString InspectDRCErrorMenuText(const std::shared_ptr< RC_ITEM > &aDRCItem)
bool highlightNet(const VECTOR2D &aPosition, bool aUseSelection)
Look for a BOARD_CONNECTED_ITEM in a given spot and if one is found - it enables highlight for its ne...
int HighlightNetChain(const TOOL_EVENT &aEvent)
int DiffFootprint(const TOOL_EVENT &aEvent)
wxString getItemDescription(const BOARD_ITEM *aItem)
int LocalRatsnestTool(const TOOL_EVENT &aEvent)
Show local ratsnest of a component.
bool Init() override
Init() is called once upon a registration of the tool.
int ShowNetInRatsnest(const TOOL_EVENT &aEvent)
Show the ratsnest for a given net.
void reportCompileError(REPORTER *r)
int ClearHighlight(const TOOL_EVENT &aEvent)
Clear all board highlights.
void reportClearance(const BOARD_ITEM *aItemA, const BOARD_ITEM *aItemB)
std::unique_ptr< DRC_ENGINE > makeDRCEngine(bool *aCompileError, bool *aCourtyardError)
int HideNetInRatsnest(const TOOL_EVENT &aEvent)
Hide the ratsnest for a given net.
int InspectConstraints(const TOOL_EVENT &aEvent)
void doHideRatsnestNet(int aNetCode, bool aHide)
BOARD_ITEM * pickItemForInspection(const TOOL_EVENT &aEvent, const wxString &aPrompt, const std::vector< KICAD_T > &aTypes, BOARD_ITEM *aLockedHighlight)
CONNECTIVITY_DATA * m_dynamicData
int showBoardComparison(const wxString &aOtherPath, const wxString &aProjectPath, const wxString &aComparisonLabel)
Diff the board at aOtherPath against the live one and show the dialog.
int ReplaceTerminalPad(const TOOL_EVENT &aEvent)
int ShowFootprintLinks(const TOOL_EVENT &aEvent)
void filterCollectorForInspection(GENERAL_COLLECTOR &aCollector, const VECTOR2I &aPos)
int CompareBoardWithFile(const TOOL_EVENT &aEvent)
Diff the current board against a user-selected .kicad_pcb file.
FOOTPRINT_DIFF_WIDGET * constructDiffPanel(wxPanel *aParentPanel)
int InspectClearance(const TOOL_EVENT &aEvent)
Show the clearance resolution for two selected items.
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
std::set< int > m_currentlyHighlighted
int UpdateLocalRatsnest(const TOOL_EVENT &aEvent)
Update ratsnest for selected items.
void reportHeader(const wxString &aTitle, const BOARD_ITEM *a, REPORTER *r)
int CompareBoardWithHistory(const TOOL_EVENT &aEvent)
Diff the current board against the most recent local-history commit.
int HideLocalRatsnest(const TOOL_EVENT &aEvent)
Hide ratsnest for selected items. Called when there are no items selected.
int HighlightItem(const TOOL_EVENT &aEvent)
Perform the appropriate action in response to an Eeschema cross-probe.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:99
virtual bool IsConnected() const
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
Definition board_item.h:187
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual void Move(const VECTOR2I &aMoveVector)
Move this object.
Definition board_item.h:459
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition board_item.h:432
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition board_item.h:369
virtual bool IsTented(PCB_LAYER_ID aLayer) const
Checks if the given object is tented (its copper shape is covered by solder mask) on a given side of ...
Definition board_item.h:239
virtual void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const
Invoke a function on all children.
Definition board_item.h:279
virtual bool HasDrilledHole() const
Definition board_item.h:227
virtual bool IsOnCopperLayer() const
Definition board_item.h:204
virtual bool HasHole() const
Definition board_item.h:222
static std::unique_ptr< BOARD > Load(const wxString &aFileName, PCB_IO_MGR::PCB_FILE_T aFormat, PROJECT *aProject, const OPTIONS &aOptions)
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
const wxString & GetFileName() const
Definition board.h:454
PROJECT * GetProject() const
Definition board.h:774
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition board.h:758
int GetCount() const
Return the number of objects in the list.
Definition collector.h:79
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition collector.h:107
void Append(EDA_ITEM *item)
Add an item to the end of the list.
Definition collector.h:97
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Add a submenu to the menu.
Dialog to show common board info.
wxPanel * AddBlankPage(const wxString &aTitle)
WX_HTML_REPORT_BOX * AddHTMLPage(const wxString &aTitle)
void SetUserItemID(const KIID &aID)
Dialog to show footprint library and symbol links.
std::function< void(WIDGET_DIFF_CANVAS &, const KIID_PATH &)> SHEET_SWITCHER
bool Show(bool show) override
int ShowModal() override
wxString GetName() const
Definition drc_rule.h:162
int m_DisallowFlags
Definition drc_rule.h:207
ZONE_CONNECTION m_ZoneConnection
Definition drc_rule.h:208
MINOPTMAX< int > m_Value
Definition drc_rule.h:206
bool IsNull() const
Definition drc_rule.h:122
static int MatchDpSuffix(const wxString &aNetName, wxString &aComplementNet, wxString &aBaseDpName)
Check if the given net is a diff pair, returning its polarity and complement if so.
static void GetViolationLayers(BOARD *aBoard, const std::shared_ptr< RC_ITEM > &aItem, PCB_MARKER *aMarker, PCB_LAYER_ID &aPrincipalLayer, LSET &aViolationLayers)
Work out which layer to focus on and which layers a violation involves.
Definition drc_item.cpp:642
DIALOG_DRC * GetDRCDialog()
Definition drc_tool.h:62
std::unordered_set< EDA_ITEM * > & GetItems()
Definition eda_group.h:78
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const
Return a user-visible description string of this item.
Definition eda_item.cpp:314
const KIID m_Uuid
Definition eda_item.h:599
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
Test if aPosition is inside or on the boundary of this item.
Definition eda_item.h:309
void DisplayDiff(FOOTPRINT *aBoardFootprint, std::shared_ptr< FOOTPRINT > &aLibFootprint)
Set the currently displayed symbol.
An interface to the global shared library manager that is schematic-specific and linked to one projec...
FOOTPRINT * LoadFootprint(const wxString &aNickname, const wxString &aName, bool aKeepUUID)
Load a FOOTPRINT having aName from the library given by aNickname.
bool FootprintNeedsUpdate(const FOOTPRINT *aLibFP, int aCompareFlags=0, REPORTER *aReporter=nullptr)
Return true if a board footprint differs from the library version.
const LIB_ID & GetFPID() const
Definition footprint.h:417
const SHAPE_POLY_SET & GetCourtyard(PCB_LAYER_ID aLayer) const
Used in DRC to test the courtyard area (a complex polygon).
A general implementation of a COLLECTORS_GUIDE.
Definition collectors.h:320
void SetIgnoreZoneFills(bool ignore)
Definition collectors.h:470
void SetPreferredLayer(PCB_LAYER_ID aLayer)
Definition collectors.h:387
void SetIgnoreNoNets(bool ignore)
Definition collectors.h:473
Used when the right click button is pressed, or when the select tool is in effect.
Definition collectors.h:203
void Collect(BOARD_ITEM *aItem, const std::vector< KICAD_T > &aScanList, const VECTOR2I &aRefPos, const COLLECTORS_GUIDE &aGuide)
Scan a BOARD_ITEM using this class's Inspector method, which does the collection.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
Diff two already-parsed BOARDs and produce a DOCUMENT_DIFF.
Definition pcb_differ.h:62
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
PCB specific render settings.
Definition pcb_painter.h:94
std::set< int > & GetHiddenNets()
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const std::set< int > & GetHighlightNetCodes() const
Return the netcode of currently highlighted net.
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
bool IsHighlightEnabled() const
Return current highlight setting.
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
An interface for classes handling user events controlling the view behavior such as zooming,...
An abstract base class for deriving all objects that can be added to a VIEW.
Definition view_item.h:82
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:68
virtual int GetTopLayer() const
Definition view.cpp:1238
PAINTER * GetPainter() const
Return the painter object used by the view for drawing VIEW_ITEM objects.
Definition view.h:242
Definition kiid.h:46
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library tables.
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
const UTF8 & GetLibItemName() const
Definition lib_id.h:98
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition lib_id.h:83
Simple local history manager built on libgit2.
std::vector< LOCAL_HISTORY_SNAPSHOT_INFO > GetSnapshots(const wxString &aProjectPath)
Snapshots (commits) for the project, newest first.
wxString TreeFingerprint(const wxString &aProjectPath, const wxString &aHash, const wxString &aExtension)
Fingerprint of all files ending in aExtension recorded by commit aHash (sorted path:blob pairs).
bool ExtractAllFilesAtCommit(const wxString &aProjectPath, const wxString &aHash, const wxString &aDestDir, const std::vector< wxString > &aExtensions={})
Write files recorded at aHash into aDestDir, recreating the project's relative folder structure.
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
Definition lset.cpp:604
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition lset.cpp:309
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition lset.cpp:595
static const LSET & PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition lset.cpp:693
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
Definition lset.h:63
T Min() const
Definition minoptmax.h:29
bool HasMax() const
Definition minoptmax.h:38
bool HasMin() const
Definition minoptmax.h:37
T Max() const
Definition minoptmax.h:30
T Opt() const
Definition minoptmax.h:31
bool HasOpt() const
Definition minoptmax.h:39
const wxString GetHumanReadableName() const
Gets the consolidated name of this netclass (which may be an aggregate).
Definition netclass.cpp:348
Handle the data for a net.
Definition netinfo.h:50
const wxString & GetNetChain() const
Definition netinfo.h:122
const wxString & GetNetname() const
Definition netinfo.h:110
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Return the information about the NETINFO_ITEM in aList to display in the message panel.
ACTION_MENU * create() const override
Return an instance of this class. It has to be overridden in inheriting classes.
Definition pad.h:61
VECTOR2I GetDrillSize() const
Definition pad.h:320
static TOOL_ACTION highlightItem
static TOOL_ACTION toggleNetHighlight
static TOOL_ACTION setTerminalPad
static TOOL_ACTION highlightNet
static TOOL_ACTION hideNetInRatsnest
static TOOL_ACTION hideLocalRatsnest
static TOOL_ACTION showNetInRatsnest
static TOOL_ACTION highlightNetChain
static TOOL_ACTION toggleLastNetHighlight
static TOOL_ACTION compareBoardWithHistory
static TOOL_ACTION inspectConstraints
static TOOL_ACTION clearHighlight
static TOOL_ACTION inspectClearance
static TOOL_ACTION updateLocalRatsnest
static TOOL_ACTION compareBoardWithFile
static TOOL_ACTION diffFootprint
static TOOL_ACTION showFootprintAssociations
static TOOL_ACTION highlightNetSelection
static TOOL_ACTION boardStatistics
static TOOL_ACTION localRatsnestTool
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
A set of BOARD_ITEMs (i.e., without duplicates).
Definition pcb_group.h:51
PCB_FILE_T
The set of file types that the PCB_IO_MGR knows about, and for which there has been a plugin written,...
Definition pcb_io_mgr.h:52
static PCB_FILE_T FindPluginTypeFromBoardPath(const wxString &aFileName, int aCtl=0)
Return a plugin type given a path for a board file.
Generic tool for picking an item.
void ClearHandlers()
Handlers only.
The selection tool: currently supports:
void GuessSelectionCandidates(GENERAL_COLLECTOR &aCollector, const VECTOR2I &aWhere) const
Try to guess best selection candidates in case multiple items are clicked, by doing some brain-dead h...
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter)
Return the current selection, filtered according to aClientFilter.
bool Selectable(const BOARD_ITEM *aItem, bool checkVisibilityOnly=false) const
PCB_SELECTION_FILTER_OPTIONS & GetFilter()
PCB_SELECTION & GetSelection()
void FilterCollectedItems(GENERAL_COLLECTOR &aCollector, bool aMultiSelect, PCB_SELECTION_FILTER_OPTIONS *aRejected=nullptr)
Apply the SELECTION_FITLER_OPTIONS to the collector.
T * frame() const
KIGFX::PCB_VIEW * view() const
KIGFX::VIEW_CONTROLS * controls() const
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
BOARD * board() const
PCBNEW_SETTINGS::DISPLAY_OPTIONS & displayOptions() const
const PCB_SELECTION & selection() const
FOOTPRINT * footprint() const
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition picker_tool.h:81
void SetSnapping(bool aSnap)
Definition picker_tool.h:65
void SetCursor(KICURSOR aCursor)
Definition picker_tool.h:63
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Set a handler for the finalize event.
static FOOTPRINT_LIBRARY_ADAPTER * FootprintLibAdapter(PROJECT *aProject)
Container for project specific data.
Definition project.h:63
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Definition reporter.h:102
void BrightenItem(EDA_ITEM *aItem)
void UnbrightenItem(EDA_ITEM *aItem)
PROJECT * GetProject(const wxString &aFullPath) const
Retrieve a loaded project by name.
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Save, unload and unregister the given PROJECT.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true, bool aOverrideLock=false)
Load a project or sets up a new project with a specified path.
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
Extension of STATUS_POPUP for displaying a single line text.
T * getEditFrame() const
Return the application window object, casted to requested user type.
Definition tool_base.h:182
T * getModel() const
Return the model object if it matches the requested type.
Definition tool_base.h:195
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition tool_base.cpp:40
TOOL_MANAGER * m_toolMgr
Definition tool_base.h:220
KIGFX::VIEW * getView() const
Return the instance of KIGFX::VIEW object used in the application.
Definition tool_base.cpp:34
RESET_REASON
Determine the reason of reset for a tool.
Definition tool_base.h:74
Generic, UI-independent tool event.
Definition tool_event.h:167
bool DisableGridSnapping() const
Definition tool_event.h:367
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
T Parameter() const
Return a parameter assigned to the event.
Definition tool_event.h:484
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).
TOOL_MENU & GetToolMenu()
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
void Activate()
Run the tool.
CONDITIONAL_MENU & GetMenu()
Definition tool_menu.cpp:40
void RegisterSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition tool_menu.cpp:46
wxString StringFromValue(double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
Converts aValue in internal units into a united string.
GAL-backed canvas for visualizing a KICAD_DIFF::DIFF_SCENE.
A slimmed down version of WX_HTML_REPORT_PANEL.
void Clear() override
Delete the stored messages.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
void SetUnits(EDA_UNITS aUnits)
void Flush()
Build the HTML messages page.
Handle a list of polygons defining a copper zone.
Definition zone.h:70
std::optional< int > GetLocalClearance() const override
Definition zone.cpp:1099
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
Definition zone.cpp:808
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition zone.h:133
@ BULLSEYE
Definition cursors.h:55
@ ANNULAR_WIDTH_CONSTRAINT
@ COURTYARD_CLEARANCE_CONSTRAINT
@ VIA_DIAMETER_CONSTRAINT
@ DIFF_PAIR_GAP_CONSTRAINT
@ DISALLOW_CONSTRAINT
@ TRACK_WIDTH_CONSTRAINT
@ SILK_CLEARANCE_CONSTRAINT
@ EDGE_CLEARANCE_CONSTRAINT
@ MIN_RESOLVED_SPOKES_CONSTRAINT
@ TRACK_SEGMENT_LENGTH_CONSTRAINT
@ PHYSICAL_HOLE_CLEARANCE_CONSTRAINT
@ CLEARANCE_CONSTRAINT
@ THERMAL_SPOKE_WIDTH_CONSTRAINT
@ CONNECTION_WIDTH_CONSTRAINT
@ THERMAL_RELIEF_GAP_CONSTRAINT
@ MAX_UNCOUPLED_CONSTRAINT
@ LINE_WIDTH_CONSTRAINT
@ HOLE_CLEARANCE_CONSTRAINT
@ SOLDER_PASTE_ABS_MARGIN_CONSTRAINT
@ SOLDER_MASK_EXPANSION_CONSTRAINT
@ TRACK_ANGLE_CONSTRAINT
@ HOLE_SIZE_CONSTRAINT
@ TEXT_HEIGHT_CONSTRAINT
@ PHYSICAL_CLEARANCE_CONSTRAINT
@ SOLDER_PASTE_REL_MARGIN_CONSTRAINT
@ HOLE_TO_HOLE_CONSTRAINT
@ DRCE_DP_UNCOUPLED_LENGTH_TOO_LONG
Definition drc_item.h:126
@ DRCE_HOLE_CLEARANCE
Definition drc_item.h:63
@ DRCE_VIA_DIAMETER
Definition drc_item.h:70
@ DRCE_TRACK_WIDTH
Definition drc_item.h:64
@ DRCE_DRILL_OUT_OF_RANGE
Definition drc_item.h:69
@ DRCE_EDGE_CLEARANCE
Definition drc_item.h:55
@ DRCE_STARVED_THERMAL
Definition drc_item.h:58
@ DRCE_TRACK_SEGMENT_LENGTH
Definition drc_item.h:66
@ DRCE_TRACK_ANGLE
Definition drc_item.h:65
@ DRCE_CLEARANCE
Definition drc_item.h:52
@ DRCE_DRILLED_HOLES_TOO_CLOSE
Definition drc_item.h:61
@ DRCE_MICROVIA_DRILL_OUT_OF_RANGE
Definition drc_item.h:73
@ DRCE_TEXT_HEIGHT
Definition drc_item.h:116
@ DRCE_ASSERTION_FAILURE
Definition drc_item.h:104
@ DRCE_LIB_FOOTPRINT_MISMATCH
Definition drc_item.h:98
@ DRCE_LINE_WIDTH
Definition drc_item.h:117
@ DRCE_CONNECTION_WIDTH
Definition drc_item.h:68
@ DRCE_ANNULAR_WIDTH
Definition drc_item.h:67
#define _(s)
@ RECURSE
Definition eda_item.h:51
#define MALFORMED_COURTYARDS
EDA_UNITS
Definition eda_units.h:45
static const std::string ProjectFileExtension
static wxString PcbFileWildcard()
#define KICTL_KICAD_ONLY
chosen file is from KiCad according to user
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
Definition layer_ids.h:847
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:744
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ F_CrtYd
Definition layer_ids.h:112
@ Edge_Cuts
Definition layer_ids.h:108
@ B_Mask
Definition layer_ids.h:94
@ B_Cu
Definition layer_ids.h:61
@ F_Mask
Definition layer_ids.h:93
@ Margin
Definition layer_ids.h:109
@ F_SilkS
Definition layer_ids.h:96
@ B_CrtYd
Definition layer_ids.h:111
@ UNDEFINED_LAYER
Definition layer_ids.h:57
@ B_SilkS
Definition layer_ids.h:97
@ F_Cu
Definition layer_ids.h:60
void ConfigurePcbDiffCanvasContext(WIDGET_DIFF_CANVAS &aCanvas, BOARD *aReference, BOARD *aComparison, const KIGFX::COLOR4D &aColor, const std::map< KIID, KIGFX::COLOR4D > &aOverrides, const std::vector< KIGFX::VIEW_ITEM * > &aExtraItems, const std::map< KIID, KICAD_DIFF::CATEGORY > &aCategories)
BOARD_ITEM * FindPcbDiffItem(const BOARD *aBoard, const KIID &aId)
Resolve an actual UUID or a footprint field's diff ID on a board.
DOCUMENT_GEOMETRY ExtractBoardGeometry(const BOARD &aBoard, const KIGFX::COLOR4D &aColor)
Extract a coarse outline of a BOARD into a DOCUMENT_GEOMETRY for use as background context in DIFF_SC...
std::vector< KIGFX::VIEW_ITEM * > CollectFootprintDiffContextItems(FOOTPRINT &aFootprint)
CATEGORY CategoryFor(CHANGE_KIND aKind)
Map a CHANGE_KIND to the visual category it belongs to.
@ COLOR
Color has changed.
Definition view_item.h:50
@ TARGET_OVERLAY
Items that may change while the view stays the same (noncached)
Definition definitions.h:35
void ReparentWindow(wxNonOwnedWindow *aWindow, wxTopLevelWindow *aParent)
Definition wxgtk/ui.cpp:370
wxPoint GetMousePosition()
Returns the mouse position in screen coordinates.
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition padstack.h:104
Class to handle a set of BOARD_ITEMs.
CITER next(CITER it)
Definition ptree.cpp:120
SEVERITY
@ RPT_SEVERITY_UNDEFINED
std::vector< FAB_LAYER_COLOR > dummy
wxString EscapeHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
Diff colors with defaults for light backgrounds.
Definition diff_scene.h:278
KIGFX::COLOR4D reference
Default color for source-document context geometry.
Definition diff_scene.h:292
The full set of changes between two parsed documents of one type.
std::vector< ITEM_CHANGE > changes
Aggregate of background geometry extracted from one source document.
Definition diff_scene.h:163
One change record on a single item.
std::vector< ITEM_CHANGE > children
A filename or source description, a problem input line, a line number, a byte offset,...
This file contains data structures that are saved in the project file or project local settings file ...
int clearance
wxString result
Test unit parsing edge cases and error handling.
int delta
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:80
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition typeinfo.h:83
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:89
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition typeinfo.h:103
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition typeinfo.h:85
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition typeinfo.h:100
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition typeinfo.h:84
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition typeinfo.h:82
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:78
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:79
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:90
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:88
Casted dyn_cast(From aObject)
A lightweight dynamic downcast.
Definition typeinfo.h:55
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707
Definition of file extensions used in Kicad.
@ THERMAL
Use thermal relief for pads.
Definition zones.h:46
@ NONE
Pads are not covered.
Definition zones.h:45