KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcbnew/cross-probing.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
20
29
30#include <wx/tokenzr.h>
31#include <board.h>
33#include <fmt.h>
34#include <footprint.h>
35#include <pad.h>
36#include <pcb_track.h>
37#include <pcb_group.h>
38#include <zone.h>
39#include <collectors.h>
40#include <eda_dde.h>
41#include <kiface_base.h>
42#include <kiway_mail.h>
43#include <string_utils.h>
46#include <gal/painter.h>
47#include <pcb_painter.h>
48#include <pcb_edit_frame.h>
49#include <pcbnew_settings.h>
50#include <render_settings.h>
51#include <richio.h>
52#include <tool/tool_manager.h>
53#include <tools/pcb_actions.h>
55#include <trace_helpers.h>
58#include <widgets/kistatusbar.h>
59#include <project_pcb.h>
61#include <wx/log.h>
62
63/* Execute a remote command sent via a socket on port KICAD_PCB_PORT_SERVICE_NUMBER
64 *
65 * Commands are:
66 *
67 * $NET: "net name" Highlight the given net
68 * $NETS: "net name 1,net name 2" Highlight all given nets
69 * $CLEAR Clear existing highlight
70 *
71 * $CONFIG Show the Manage Footprint Libraries dialog
72 * $CUSTOM_RULES Show the "Custom Rules" page of the Board Setup dialog
73 * $DRC Show the DRC dialog
74 */
75void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
76{
77 char line[1024];
78 char* idcmd;
79 char* text;
80 int netcode = -1;
81 bool multiHighlight = false;
82 BOARD* pcb = GetBoard();
83
85
86 KIGFX::VIEW* view = m_toolManager->GetView();
87 KIGFX::RENDER_SETTINGS* renderSettings = view->GetPainter()->GetSettings();
88
89 strncpy( line, cmdline, sizeof(line) - 1 );
90 line[sizeof(line) - 1] = 0;
91
92 idcmd = strtok( line, " \n\r" );
93 text = strtok( nullptr, "\"\n\r" );
94
95 if( idcmd == nullptr )
96 return;
97
98 if( strcmp( idcmd, "$CONFIG" ) == 0 )
99 {
101 return;
102 }
103 else if( strcmp( idcmd, "$CUSTOM_RULES" ) == 0 )
104 {
105 ShowBoardSetupDialog( _( "Custom Rules" ) );
106 return;
107 }
108 else if( strcmp( idcmd, "$DRC" ) == 0 )
109 {
111 return;
112 }
113 else if( strcmp( idcmd, "$CLEAR" ) == 0 )
114 {
115 auto* pcbRender = dynamic_cast<KIGFX::PCB_RENDER_SETTINGS*>( renderSettings );
116
117 bool hadHighlight = renderSettings->IsHighlightEnabled();
118 bool hadChain = pcbRender && !pcbRender->GetHighlightedNetChain().IsEmpty();
119
120 if( hadHighlight )
121 renderSettings->SetHighlight( false );
122
123 if( hadChain )
124 pcbRender->SetHighlightedNetChain( wxString() );
125
126 if( hadHighlight || hadChain )
127 view->UpdateAllLayersColor();
128
129 if( pcb->IsHighLightNetON() )
130 {
131 pcb->ResetNetHighLight();
132 SetMsgPanel( pcb );
133 }
134
135 GetCanvas()->Refresh();
136 return;
137 }
138 else if( strcmp( idcmd, "$NET:" ) == 0 )
139 {
140 if( !crossProbingSettings.auto_highlight )
141 return;
142
143 wxString net_name = From_UTF8( text );
144
145 NETINFO_ITEM* netinfo = pcb->FindNet( net_name );
146
147 if( netinfo )
148 {
149 netcode = netinfo->GetNetCode();
150
151 std::vector<MSG_PANEL_ITEM> items;
152 netinfo->GetMsgPanelInfo( this, items );
153 SetMsgPanel( items );
154
155 // If the incoming net belongs to a net chain, promote the single-net
156 // highlight into a multi-net highlight covering every chain member so
157 // the PCB mirrors the chain highlight happening on the schematic side.
158 const wxString& chainName = netinfo->GetNetChain();
159
160 if( !chainName.IsEmpty() )
161 {
162 pcb->SetHighLightNet( netcode );
163 renderSettings->SetHighlight( true, netcode );
164 multiHighlight = true;
165
166 for( NETINFO_ITEM* candidate : pcb->GetNetInfo() )
167 {
168 if( !candidate || candidate == netinfo )
169 continue;
170
171 if( candidate->GetNetChain() == chainName )
172 {
173 pcb->SetHighLightNet( candidate->GetNetCode(), true );
174 renderSettings->SetHighlight( true, candidate->GetNetCode(), true );
175 }
176 }
177
178 if( auto* pcbRender = dynamic_cast<KIGFX::PCB_RENDER_SETTINGS*>( renderSettings ) )
179 pcbRender->SetHighlightedNetChain( chainName );
180
181 netcode = -1;
182 }
183 }
184
185 // fall through to highlighting section
186 }
187 else if( strcmp( idcmd, "$NETS:" ) == 0 )
188 {
189 if( !crossProbingSettings.auto_highlight )
190 return;
191
192 wxStringTokenizer netsTok = wxStringTokenizer( From_UTF8( text ), ",", wxTOKEN_STRTOK );
193 bool first = true;
194
195 while( netsTok.HasMoreTokens() )
196 {
197 NETINFO_ITEM* netinfo = pcb->FindNet( netsTok.GetNextToken().Trim( true ).Trim( false ) );
198
199 if( netinfo )
200 {
201 if( first )
202 {
203 // TODO: Once buses are included in netlist, show bus name
204 std::vector<MSG_PANEL_ITEM> items;
205 netinfo->GetMsgPanelInfo( this, items );
206 SetMsgPanel( items );
207 first = false;
208
209 pcb->SetHighLightNet( netinfo->GetNetCode() );
210 renderSettings->SetHighlight( true, netinfo->GetNetCode() );
211 multiHighlight = true;
212 }
213 else
214 {
215 pcb->SetHighLightNet( netinfo->GetNetCode(), true );
216 renderSettings->SetHighlight( true, netinfo->GetNetCode(), true );
217 }
218 }
219 }
220
221 netcode = -1;
222
223 // fall through to highlighting section
224 }
225
226 BOX2I bbox;
227
228 if( netcode > 0 || multiHighlight )
229 {
230 if( !multiHighlight )
231 {
232 renderSettings->SetHighlight( ( netcode >= 0 ), netcode );
233 pcb->SetHighLightNet( netcode );
234 }
235 else
236 {
237 // Just pick the first one for area calculation
238 netcode = *pcb->GetHighLightNetCodes().begin();
239 }
240
241 pcb->HighLightON();
242
243 auto merge_area =
244 [netcode, &bbox]( BOARD_CONNECTED_ITEM* aItem )
245 {
246 if( aItem->GetNetCode() == netcode )
247 bbox.Merge( aItem->GetBoundingBox() );
248 };
249
250 if( crossProbingSettings.center_on_items )
251 {
252 for( ZONE* zone : pcb->Zones() )
253 merge_area( zone );
254
255 for( PCB_TRACK* track : pcb->Tracks() )
256 merge_area( track );
257
258 for( FOOTPRINT* fp : pcb->Footprints() )
259 {
260 for( PAD* p : fp->Pads() )
261 merge_area( p );
262 }
263 }
264 }
265 else
266 {
267 renderSettings->SetHighlight( false );
268 }
269
270 if( crossProbingSettings.center_on_items && bbox.GetWidth() != 0 && bbox.GetHeight() != 0 )
271 {
272 if( crossProbingSettings.zoom_to_fit )
273 GetToolManager()->GetTool<PCB_SELECTION_TOOL>()->ZoomFitCrossProbeBBox( bbox );
274
275 FocusOnLocation( bbox.Centre() );
276 }
277
278 view->UpdateAllLayersColor();
279
280 // Ensure the display is refreshed, because in some installs the refresh is done only
281 // when the gal canvas has the focus, and that is not the case when crossprobing from
282 // Eeschema:
283 GetCanvas()->Refresh();
284}
285
286
287std::string FormatProbeItem( BOARD_ITEM* aItem )
288{
289 if( !aItem )
290 return "$CLEAR: \"HIGHLIGHTED\""; // message to clear highlight state
291
292 switch( aItem->Type() )
293 {
294 case PCB_FOOTPRINT_T:
295 {
296 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( aItem );
297 return fmt::format( "$PART: \"{}\"", TO_UTF8( footprint->GetReference() ) );
298 }
299
300 case PCB_PAD_T:
301 {
302 PAD* pad = static_cast<PAD*>( aItem );
303 FOOTPRINT* footprint = pad->GetParentFootprint();
304
305 return fmt::format( "$PART: \"{}\" $PAD: \"{}\"",
306 TO_UTF8( footprint->GetReference() ),
307 TO_UTF8( pad->GetNumber() ) );
308 }
309
310 case PCB_FIELD_T:
311 {
312 PCB_FIELD* field = static_cast<PCB_FIELD*>( aItem );
313 FOOTPRINT* footprint = field->GetParentFootprint();
314 const char* text_key;
315
316 /* This can't be a switch since the break need to pull out
317 * from the outer switch! */
318 if( field->IsReference() )
319 text_key = "$REF:";
320 else if( field->IsValue() )
321 text_key = "$VAL:";
322 else
323 break;
324
325 return fmt::format( "$PART: \"{}\" {} \"{}\"",
326 TO_UTF8( footprint->GetReference() ),
327 text_key,
328 TO_UTF8( field->GetText() ) );
329 }
330
331 default:
332 break;
333 }
334
335 return "";
336}
337
338
339template <typename ItemContainer>
340void collectItemsForSyncParts( ItemContainer& aItems, std::set<wxString>& parts )
341{
342 for( EDA_ITEM* item : aItems )
343 {
344 switch( item->Type() )
345 {
346 case PCB_GROUP_T:
347 {
348 PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
349
350 collectItemsForSyncParts( group->GetItems(), parts );
351 break;
352 }
353 case PCB_FOOTPRINT_T:
354 {
355 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
356 wxString ref = footprint->GetReference();
357
358 parts.emplace( wxT( "F" ) + EscapeString( ref, CTX_IPC ) );
359 break;
360 }
361
362 case PCB_PAD_T:
363 {
364 PAD* pad = static_cast<PAD*>( item );
365 wxString ref = pad->GetParentFootprint()->GetReference();
366
367 parts.emplace( wxT( "P" ) + EscapeString( ref, CTX_IPC ) + wxT( "/" )
368 + EscapeString( pad->GetNumber(), CTX_IPC ) );
369 break;
370 }
371
372 default: break;
373 }
374 }
375}
376
377
378void PCB_EDIT_FRAME::SendSelectItemsToSch( const std::deque<EDA_ITEM*>& aItems,
379 EDA_ITEM* aFocusItem, bool aForce )
380{
381 std::string command = "$SELECT: ";
382
383 if( aFocusItem )
384 {
385 std::deque<EDA_ITEM*> focusItems = { aFocusItem };
386 std::set<wxString> focusParts;
387 collectItemsForSyncParts( focusItems, focusParts );
388
389 if( focusParts.size() > 0 )
390 {
391 command += "1,";
392 command += *focusParts.begin();
393 command += ",";
394 }
395 else
396 {
397 command += "0,";
398 }
399 }
400 else
401 {
402 command += "0,";
403 }
404
405 std::set<wxString> parts;
406 collectItemsForSyncParts( aItems, parts );
407
408 if( parts.empty() )
409 return;
410
411 for( wxString part : parts )
412 {
413 command += part;
414 command += ",";
415 }
416
417 command.pop_back();
418
419 if( Kiface().IsSingle() )
420 {
421 SendCommand( MSG_TO_SCH, command );
422 }
423 else
424 {
425 // Typically ExpressMail is going to be s-expression packets, but since
426 // we have existing interpreter of the selection packet on the other
427 // side in place, we use that here.
429 this );
430 }
431}
432
433
434void PCB_EDIT_FRAME::SendCrossProbeNetName( const wxString& aNetName )
435{
436 std::string packet = fmt::format( "$NET: \"{}\"", TO_UTF8( aNetName ) );
437
438 if( !packet.empty() )
439 {
440 if( Kiface().IsSingle() )
441 {
442 SendCommand( MSG_TO_SCH, packet );
443 }
444 else
445 {
446 // Typically ExpressMail is going to be s-expression packets, but since
447 // we have existing interpreter of the cross probe packet on the other
448 // side in place, we use that here.
449 Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
450 }
451 }
452}
453
454
456{
457 std::string packet = FormatProbeItem( aSyncItem );
458
459 if( !packet.empty() )
460 {
461 if( Kiface().IsSingle() )
462 {
463 SendCommand( MSG_TO_SCH, packet );
464 }
465 else
466 {
467 // Typically ExpressMail is going to be s-expression packets, but since
468 // we have existing interpreter of the cross probe packet on the other
469 // side in place, we use that here.
470 Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
471 }
472 }
473}
474
475
476std::vector<BOARD_ITEM*> PCB_EDIT_FRAME::FindItemsFromSyncSelection( std::string syncStr )
477{
478 wxArrayString syncArray = wxStringTokenize( syncStr, "," );
479
480 std::vector<std::pair<int, BOARD_ITEM*>> orderPairs;
481
482 for( FOOTPRINT* footprint : GetBoard()->Footprints() )
483 {
484 if( footprint == nullptr )
485 continue;
486
487 wxString fpSheetPath = footprint->GetPath().AsString().BeforeLast( '/' );
488 wxString fpUUID = footprint->m_Uuid.AsString();
489
490 if( fpSheetPath.IsEmpty() )
491 fpSheetPath += '/';
492
493 if( fpUUID.empty() )
494 continue;
495
496 wxString fpRefEscaped = EscapeString( footprint->GetReference(), CTX_IPC );
497
498 for( unsigned index = 0; index < syncArray.size(); ++index )
499 {
500 wxString syncEntry = syncArray[index];
501
502 if( syncEntry.empty() )
503 continue;
504
505 wxString syncData = syncEntry.substr( 1 );
506
507 switch( syncEntry.GetChar( 0 ).GetValue() )
508 {
509 case 'S': // Select sheet with subsheets: S<Sheet path>
510 if( fpSheetPath.StartsWith( syncData ) )
511 {
512 orderPairs.emplace_back( index, footprint );
513 }
514 break;
515 case 'F': // Select footprint: F<Reference>
516 if( syncData == fpRefEscaped )
517 {
518 orderPairs.emplace_back( index, footprint );
519 }
520 break;
521 case 'P': // Select pad: P<Footprint reference>/<Pad number>
522 {
523 if( syncData.StartsWith( fpRefEscaped ) )
524 {
525 wxString selectPadNumberEscaped =
526 syncData.substr( fpRefEscaped.size() + 1 ); // Skips the slash
527
528 wxString selectPadNumber = UnescapeString( selectPadNumberEscaped );
529
530 for( PAD* pad : footprint->Pads() )
531 {
532 if( selectPadNumber == pad->GetNumber() )
533 {
534 orderPairs.emplace_back( index, pad );
535 }
536 }
537 }
538 break;
539 }
540 default: break;
541 }
542 }
543 }
544
545 std::sort(
546 orderPairs.begin(), orderPairs.end(),
547 []( const std::pair<int, BOARD_ITEM*>& a, const std::pair<int, BOARD_ITEM*>& b ) -> bool
548 {
549 return a.first < b.first;
550 } );
551
552 std::vector<BOARD_ITEM*> items;
553 items.reserve( orderPairs.size() );
554
555 for( const std::pair<int, BOARD_ITEM*>& pair : orderPairs )
556 items.push_back( pair.second );
557
558 return items;
559}
560
561
563{
564 std::string& payload = mail.GetPayload();
565
566 switch( mail.Command() )
567 {
569 {
572
573 for( FOOTPRINT* footprint : GetBoard()->Footprints() )
574 {
575 if( footprint->GetAttributes() & FP_BOARD_ONLY )
576 continue; // Don't add board-only footprints to the netlist
577
578 COMPONENT* component = new COMPONENT( footprint->GetFPID(), footprint->GetReference(),
579 footprint->GetValue(), footprint->GetPath(), {} );
580
581 for( PAD* pad : footprint->Pads() )
582 {
583 const wxString& netname = pad->GetShortNetname();
584
585 if( !netname.IsEmpty() )
586 {
587 component->AddNet( pad->GetNumber(), netname, pad->GetPinFunction(),
588 pad->GetPinType() );
589 }
590 }
591
592 nlohmann::ordered_map<wxString, wxString> fields;
593
594 for( PCB_FIELD* field : footprint->GetFields() )
595 {
596 wxCHECK2( field, continue );
597
598 fields[field->GetCanonicalName()] = field->GetText();
599 }
600
601 component->SetFields( fields );
602
603 // Add DNP, Exclude from BOM, and Exclude from Position Files properties
604 std::map<wxString, wxString> properties;
605
606 if( footprint->GetAttributes() & FP_DNP )
607 properties.emplace( "dnp", "" );
608
609 if( footprint->GetAttributes() & FP_EXCLUDE_FROM_BOM )
610 properties.emplace( "exclude_from_bom", "" );
611
612 if( footprint->GetAttributes() & FP_EXCLUDE_FROM_POS_FILES )
613 properties.emplace( "exclude_from_pos_files", "" );
614
615 component->SetProperties( properties );
616
617 netlist.AddComponent( component );
618 }
619
620 netlist.Format( "pcb_netlist", &sf, 0, CTL_OMIT_FILTERS );
621 payload = sf.GetString();
622 break;
623 }
624
626 try
627 {
629 FetchNetlistFromSchematic( netlist, wxEmptyString );
630
631 BOARD_NETLIST_UPDATER updater( this, GetBoard() );
632 updater.SetLookupByTimestamp( false );
633 updater.SetDeleteUnusedFootprints( false );
634 updater.SetReplaceFootprints( false );
635 updater.SetTransferGroups( false );
636 updater.UpdateNetlist( netlist );
637
638 bool dummy;
639 OnNetlistChanged( updater, &dummy );
640 }
641 catch( const IO_ERROR& )
642 {
643 assert( false ); // should never happen
644 return;
645 }
646
647 break;
648
649 case MAIL_CROSS_PROBE:
650 ExecuteRemoteCommand( payload.c_str() );
651 break;
652
653
654 case MAIL_SELECTION:
655 if( !GetPcbNewSettings()->m_CrossProbing.on_selection )
656 break;
657
659
661 {
662 // $SELECT: <mode 0 - only footprints, 1 - with connections>,<spec1>,<spec2>,<spec3>
663 std::string prefix = "$SELECT: ";
664
665 if( !payload.compare( 0, prefix.size(), prefix ) )
666 {
667 std::string del = ",";
668 std::string paramStr = payload.substr( prefix.size() );
669 size_t modeEnd = paramStr.find( del );
670 bool selectConnections = false;
671
672 try
673 {
674 if( std::stoi( paramStr.substr( 0, modeEnd ) ) == 1 )
675 selectConnections = true;
676 }
677 catch( std::invalid_argument& )
678 {
679 wxFAIL;
680 }
681
682 std::vector<BOARD_ITEM*> items =
683 FindItemsFromSyncSelection( paramStr.substr( modeEnd + 1 ) );
684
685 m_ProbingSchToPcb = true; // recursion guard
686
687 if( selectConnections )
689 else
691
692 // Update 3D viewer highlighting
693 Update3DView( false, GetPcbNewSettings()->m_Display.m_Live3DRefresh );
694
695 m_ProbingSchToPcb = false;
696
697 if( GetPcbNewSettings()->m_CrossProbing.flash_selection )
698 {
699 wxLogTrace( traceCrossProbeFlash, "MAIL_SELECTION(_FORCE) PCB: flash enabled, items=%zu", items.size() );
700 if( items.empty() )
701 {
702 wxLogTrace( traceCrossProbeFlash, "MAIL_SELECTION(_FORCE) PCB: nothing to flash" );
703 }
704 else
705 {
706 std::vector<BOARD_ITEM*> boardItems;
707 std::copy( items.begin(), items.end(), std::back_inserter( boardItems ) );
708 StartCrossProbeFlash( boardItems );
709 }
710 }
711 else
712 {
713 wxLogTrace( traceCrossProbeFlash, "MAIL_SELECTION(_FORCE) PCB: flash disabled" );
714 }
715 }
716
717 break;
718 }
719
720 case MAIL_PCB_UPDATE:
722 break;
723
724 case MAIL_IMPORT_FILE:
725 {
726 // Extract file format type and path (plugin type, path and properties keys, values separated with \n)
727 std::stringstream ss( payload );
728 char delim = '\n';
729
730 std::string formatStr;
731 wxCHECK( std::getline( ss, formatStr, delim ), /* void */ );
732
733 std::string fnameStr;
734 wxCHECK( std::getline( ss, fnameStr, delim ), /* void */ );
735 wxASSERT( !fnameStr.empty() );
736
737 int importFormat;
738
739 try
740 {
741 importFormat = std::stoi( formatStr );
742 }
743 catch( std::invalid_argument& )
744 {
745 wxFAIL;
746 importFormat = -1;
747 }
748
749 std::map<std::string, UTF8> props;
750
751 std::string key, value;
752 do
753 {
754 if( !std::getline( ss, key, delim ) )
755 break;
756
757 if( !std::getline( ss, value, delim ) )
758 break;
759
760 props.emplace( key, value );
761
762 } while( true );
763
764 if( importFormat >= 0 )
765 importFile( fnameStr, importFormat, props.empty() ? nullptr : &props );
766
767 break;
768 }
769
772 break;
773
774 case MAIL_PCB_SAVE:
775 if( SavePcbFile( Prj().AbsolutePath( GetBoard()->GetFileName() ) ) )
776 payload = "success";
777
778 break;
779
780 case MAIL_RELOAD_LIB:
781 {
782 m_designBlocksPane->RefreshLibs();
783
784 // Show any footprint library load errors in the status bar
785 if( KISTATUSBAR* statusBar = dynamic_cast<KISTATUSBAR*>( GetStatusBar() ) )
786 {
788 wxString errors = adapter->GetLibraryLoadErrors();
789
790 if( !errors.IsEmpty() )
791 statusBar->AddWarningMessages( "load", errors );
792 }
793
794 break;
795 }
796
797 // many many others.
798 default:
799 ;
800 }
801}
802
int index
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
static TOOL_ACTION updatePcbFromSchematic
Definition actions.h:260
static TOOL_ACTION pluginsReload
Definition actions.h:290
static TOOL_ACTION showFootprintLibTable
Definition actions.h:279
CROSS_PROBING_SETTINGS m_CrossProbing
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:81
FOOTPRINT * GetParentFootprint() const
Update the BOARD with a new netlist.
bool UpdateNetlist(NETLIST &aNetlist)
Update the board's components according to the new netlist.
void SetDeleteUnusedFootprints(bool aEnabled)
void SetReplaceFootprints(bool aEnabled)
void SetLookupByTimestamp(bool aEnabled)
void SetTransferGroups(bool aEnabled)
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
const NETINFO_LIST & GetNetInfo() const
Definition board.h:1086
const std::set< int > & GetHighLightNetCodes() const
Definition board.h:710
void SetHighLightNet(int aNetCode, bool aMulti=false)
Select the netcode to be highlighted.
Definition board.cpp:3612
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition board.cpp:2657
const ZONES & Zones() const
Definition board.h:424
void ResetNetHighLight()
Reset all high light data to the init state.
Definition board.cpp:3603
const FOOTPRINTS & Footprints() const
Definition board.h:420
const TRACKS & Tracks() const
Definition board.h:418
bool IsHighLightNetON() const
Definition board.h:726
void HighLightON(bool aValue=true)
Enable or disable net highlighting.
Definition board.cpp:3627
constexpr size_type GetWidth() const
Definition box2.h:210
constexpr Vec Centre() const
Definition box2.h:93
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition box2.h:654
constexpr size_type GetHeight() const
Definition box2.h:211
Store all of the related component information found in a netlist.
void SetProperties(std::map< wxString, wxString > aProps)
void AddNet(const wxString &aPinName, const wxString &aNetName, const wxString &aPinFunction, const wxString &aPinType)
void SetFields(nlohmann::ordered_map< wxString, wxString > aFields)
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void FocusOnLocation(const VECTOR2I &aPos, bool aAllowScroll=true)
Useful to focus on a particular location, in find functions.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:96
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:110
An interface to the global shared library manager that is schematic-specific and linked to one projec...
const wxString & GetReference() const
Definition footprint.h:841
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
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:78
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
bool IsHighlightEnabled() const
Return current highlight setting.
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition view.cpp:844
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition view.h:225
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition kiway_mail.h:34
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
Definition kiway_mail.h:52
MAIL_T Command()
Returns the MAIL_T associated with this mail.
Definition kiway_mail.h:44
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr, bool aFromOtherThread=false)
Send aPayload to aDestination from aSource.
Definition kiway.cpp:496
wxString GetLibraryLoadErrors() const
Returns all library load errors as newline-separated strings for display.
Handle the data for a net.
Definition netinfo.h:46
const wxString & GetNetChain() const
Definition netinfo.h:112
int GetNetCode() const
Definition netinfo.h:94
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.
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition pad.h:61
static TOOL_ACTION runDRC
static TOOL_ACTION syncSelection
Sets selection to specified items, zooms to fit, if enabled.
Definition pcb_actions.h:59
static TOOL_ACTION syncSelectionWithNets
Sets selection to specified items with connected nets, zooms to fit, if enabled.
Definition pcb_actions.h:62
PCBNEW_SETTINGS * GetPcbNewSettings() const
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
BOARD * GetBoard() const
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
void StartCrossProbeFlash(const std::vector< BOARD_ITEM * > &aItems)
void KiwayMailIn(KIWAY_MAIL_EVENT &aEvent) override
Receive #KIWAY_ROUTED_EVENT messages from other players.
void ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString, wxWindow *aParent=nullptr)
void OnNetlistChanged(BOARD_NETLIST_UPDATER &aUpdater, bool *aRunDragCommand)
Called after netlist is updated.
void ExecuteRemoteCommand(const char *cmdline) override
Execute a remote command send by Eeschema via a socket, port KICAD_PCB_PORT_SERVICE_NUMBER (currently...
void SendCrossProbeItem(BOARD_ITEM *aSyncItem)
Send a message to the schematic editor so that it may move its cursor to an item with the same refere...
bool FetchNetlistFromSchematic(NETLIST &aNetlist, const wxString &aAnnotateMessage)
void SendSelectItemsToSch(const std::deque< EDA_ITEM * > &aItems, EDA_ITEM *aFocusItem, bool aForce)
Send a message to the schematic editor to try to find schematic counterparts of specified PCB items a...
std::vector< BOARD_ITEM * > FindItemsFromSyncSelection(std::string syncStr)
Used to find items by selection synchronization spec string.
PCB_DESIGN_BLOCK_PANE * m_designBlocksPane
bool SavePcbFile(const wxString &aFileName, bool addToHistory=true, bool aChangeProject=true)
Write the board data structures to a aFileName.
bool importFile(const wxString &aFileName, int aFileType, const std::map< std::string, UTF8 > *aProperties=nullptr)
Load the given filename but sets the path to the current project path.
void SendCrossProbeNetName(const wxString &aNetName)
Send a net name to Eeschema for highlighting.
bool IsReference() const
Definition pcb_field.h:66
bool IsValue() const
Definition pcb_field.h:67
A set of BOARD_ITEMs (i.e., without duplicates).
Definition pcb_group.h:49
The selection tool: currently supports:
static FOOTPRINT_LIBRARY_ADAPTER * FootprintLibAdapter(PROJECT *aProject)
Implement an OUTPUTFORMATTER to a memory buffer.
Definition richio.h:418
const std::string & GetString()
Definition richio.h:441
TOOL_MANAGER * m_toolManager
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Handle a list of polygons defining a copper zone.
Definition zone.h:70
#define CTL_OMIT_FILTERS
Omit the ki_fp_filters attribute in .kicad_xxx files.
Definition ctl_flags.h:41
#define _(s)
bool SendCommand(int aService, const std::string &aMessage)
Used by a client to sent (by a socket connection) a data to a server.
Definition eda_dde.cpp:226
DDE server & client.
#define MSG_TO_SCH
Definition eda_dde.h:46
@ FP_DNP
Definition footprint.h:89
@ FP_EXCLUDE_FROM_POS_FILES
Definition footprint.h:85
@ FP_BOARD_ONLY
Definition footprint.h:87
@ FP_EXCLUDE_FROM_BOM
Definition footprint.h:86
@ FRAME_SCH
Definition frame_type.h:30
const wxChar *const traceCrossProbeFlash
Flag to enable debug output for cross-probe flash operations.
PROJECT & Prj()
Definition kicad.cpp:730
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition macros.h:79
@ MAIL_PCB_UPDATE_LINKS
Definition mail_type.h:49
@ MAIL_IMPORT_FILE
Definition mail_type.h:45
@ MAIL_CROSS_PROBE
Definition mail_type.h:35
@ MAIL_PCB_UPDATE
Definition mail_type.h:43
@ MAIL_SELECTION_FORCE
Definition mail_type.h:37
@ MAIL_RELOAD_PLUGINS
Definition mail_type.h:55
@ MAIL_PCB_SAVE
Definition mail_type.h:40
@ MAIL_SELECTION
Definition mail_type.h:36
@ MAIL_RELOAD_LIB
Definition mail_type.h:54
@ MAIL_PCB_GET_NETLIST
Definition mail_type.h:48
Class to handle a set of BOARD_ITEMs.
void collectItemsForSyncParts(ItemContainer &aItems, std::set< wxString > &parts)
std::string FormatProbeItem(BOARD_ITEM *aItem)
KIWAY Kiway(KFCTL_STANDALONE)
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
wxString From_UTF8(const char *cstring)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
@ CTX_IPC
Cross-probing behavior.
bool zoom_to_fit
Zoom to fit items (ignored if center_on_items is off).
bool center_on_items
Automatically pan to cross-probed items.
bool auto_highlight
Automatically turn on highlight mode in the target frame.
std::string netlist
wxLogTrace helper definitions.
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition typeinfo.h:104
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition typeinfo.h:83
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:79
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:80