KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eeschema/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 (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2011 Wayne Stambaugh <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#include <wx/tokenzr.h>
23#include <api/api_utils.h>
24#include <api/common/commands/cross_probe_commands.pb.h>
26#include <fmt.h>
27#include <kiface_base.h>
28#include <kiway.h>
29#include <kiway_mail.h>
30#include <import_net_map.h>
32#include <reporter.h>
35#include <sch_netchain.h>
36#include <sch_sheet.h>
37#include <sch_symbol.h>
38#include <sch_reference_list.h>
39#include <string_utils.h>
43#include <project_sch.h>
44#include <richio.h>
45#include <tools/sch_actions.h>
47#include <advanced_config.h>
48#include <api/api_handler_sch.h>
49
50#include <pgm_base.h>
53#include <widgets/kistatusbar.h>
54#include <wx/filefn.h>
55#include <wx/log.h>
56#include <trace_helpers.h>
57
58SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString* aPath, const wxString* aReference,
59 bool aSearchHierarchy, SCH_SEARCH_T aSearchType,
60 const wxString& aSearchText )
61{
62 SCH_SHEET_PATH* sheetWithSymbolFound = nullptr;
63 SCH_SYMBOL* symbol = nullptr;
64 SCH_PIN* pin = nullptr;
65 SCH_SHEET_LIST sheetList;
66 SCH_ITEM* foundItem = nullptr;
67
68 if( !aSearchHierarchy )
69 sheetList.push_back( m_frame->GetCurrentSheet() );
70 else
71 sheetList = m_frame->Schematic().Hierarchy();
72
73 for( SCH_SHEET_PATH& sheet : sheetList )
74 {
75 SCH_SCREEN* screen = sheet.LastScreen();
76
77 for( EDA_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
78 {
79 SCH_SYMBOL* candidate = static_cast<SCH_SYMBOL*>( item );
80
81 // Search by path if specified, otherwise search by reference
82 bool found = false;
83
84 if( aPath )
85 {
86 wxString path = sheet.PathAsString() + candidate->m_Uuid.AsString();
87 found = ( *aPath == path );
88 }
89 else
90 {
91 found = ( aReference && aReference->CmpNoCase( candidate->GetRef( &sheet ) ) == 0 );
92 }
93
94 if( found )
95 {
96 symbol = candidate;
97 sheetWithSymbolFound = &sheet;
98
99 if( aSearchType == HIGHLIGHT_PIN )
100 {
101 pin = symbol->GetPin( aSearchText );
102
103 // Fall back to reverse pin-to-pad resolution so a remapped pad highlights its
104 // owning pin (issue #2282); the search text from pcbnew is a pad number.
105 if( !pin )
106 pin = symbol->GetPinByEffectivePadNumber( aSearchText, &sheet,
107 m_frame->Schematic().GetCurrentVariant() );
108
109 // Ensure we have found the right unit in case of multi-units symbol
110 if( pin )
111 {
112 int unit = pin->GetLibPin()->GetUnit();
113
114 if( unit != 0 && unit != symbol->GetUnit() )
115 {
116 pin = nullptr;
117 continue;
118 }
119
120 // Get pin position in true schematic coordinate
121 foundItem = pin;
122 break;
123 }
124 }
125 else
126 {
127 foundItem = symbol;
128 break;
129 }
130 }
131 }
132
133 if( foundItem )
134 break;
135 }
136
137 CROSS_PROBING_SETTINGS& crossProbingSettings = m_frame->eeconfig()->m_CrossProbing;
138
139 if( symbol )
140 {
141 if( *sheetWithSymbolFound != m_frame->GetCurrentSheet() )
142 {
143 m_frame->GetToolManager()->RunAction<SCH_SHEET_PATH*>( SCH_ACTIONS::changeSheet,
144 sheetWithSymbolFound );
145 }
146
147 if( crossProbingSettings.center_on_items )
148 {
149 if( crossProbingSettings.zoom_to_fit )
150 {
151 BOX2I bbox = symbol->GetBoundingBox();
152
153 m_toolMgr->GetTool<SCH_SELECTION_TOOL>()->ZoomFitCrossProbeBBox( bbox );
154 }
155
156 if( pin )
157 m_frame->FocusOnItem( pin );
158 else
159 m_frame->FocusOnItem( symbol );
160 }
161 }
162
163 /* Print diag */
164 wxString msg;
165 wxString displayRef;
166
167 if( aReference )
168 displayRef = *aReference;
169 else if( aPath )
170 displayRef = *aPath;
171
172 if( symbol )
173 {
174 if( aSearchType == HIGHLIGHT_PIN )
175 {
176 if( foundItem )
177 msg.Printf( _( "%s pin %s found" ), displayRef, aSearchText );
178 else
179 msg.Printf( _( "%s found but pin %s not found" ), displayRef, aSearchText );
180 }
181 else
182 {
183 msg.Printf( _( "%s found" ), displayRef );
184 }
185 }
186 else
187 {
188 msg.Printf( _( "%s not found" ), displayRef );
189 }
190
191 m_frame->SetStatusText( msg );
192 m_frame->GetCanvas()->Refresh();
193
194 return foundItem;
195}
196
197
198/* Execute a remote command sent via a socket on port KICAD_PCB_PORT_SERVICE_NUMBER
199 *
200 * Commands are:
201 *
202 * $PART: "reference" Put cursor on symbol.
203 * $PART: "reference" $REF: "ref" Put cursor on symbol reference.
204 * $PART: "reference" $VAL: "value" Put cursor on symbol value.
205 * $PART: "reference" $PAD: "pin name" Put cursor on the symbol pin.
206 * $NET: "netname" Highlight a specified net
207 * $CLEAR: "HIGHLIGHTED" Clear symbols highlight
208 *
209 * $CONFIG Show the Manage Symbol Libraries dialog
210 * $ERC Show the ERC dialog
211 */
212void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
213{
214 // A remote command can arrive over the cross-probe socket before tools are registered
215 // or after the tool manager has been torn down while the frame is closing.
216 if( !m_toolManager )
217 return;
218
220
221 if( !editor )
222 return;
223
224 char line[1024];
225
226 strncpy( line, cmdline, sizeof( line ) - 1 );
227 line[ sizeof( line ) - 1 ] = '\0';
228
229 char* idcmd = strtok( line, " \n\r" );
230 char* text = strtok( nullptr, "\"\n\r" );
231
232 if( idcmd == nullptr )
233 return;
234
235 CROSS_PROBING_SETTINGS& crossProbingSettings = eeconfig()->m_CrossProbing;
236
237 if( strcmp( idcmd, "$CONFIG" ) == 0 )
238 {
240 return;
241 }
242 else if( strcmp( idcmd, "$ERC" ) == 0 )
243 {
245 return;
246 }
247 else if( strcmp( idcmd, "$NET:" ) == 0 )
248 {
249 if( !crossProbingSettings.auto_highlight )
250 return;
251
253 return;
254 }
255 else if( strcmp( idcmd, "$CLEAR:" ) == 0 )
256 {
257 // Cross-probing is now done through selection so we no longer need a clear command
258 return;
259 }
260
261 if( !crossProbingSettings.on_selection )
262 return;
263
264 if( text == nullptr )
265 return;
266
267 if( strcmp( idcmd, "$PART:" ) != 0 )
268 return;
269
270 wxString part_ref = From_UTF8( text );
271
272 /* look for a complement */
273 idcmd = strtok( nullptr, " \n\r" );
274
275 if( idcmd == nullptr ) // Highlight symbol only (from CvPcb or Pcbnew)
276 {
277 // Highlight symbol part_ref, or clear Highlight, if part_ref is not existing
278 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString );
279 return;
280 }
281
282 text = strtok( nullptr, "\"\n\r" );
283
284 if( text == nullptr )
285 return;
286
287 wxString msg = From_UTF8( text );
288
289 if( strcmp( idcmd, "$REF:" ) == 0 )
290 {
291 // Highlighting the reference itself isn't actually that useful, and it's harder to
292 // see. Highlight the parent and display the message.
293 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, msg );
294 }
295 else if( strcmp( idcmd, "$VAL:" ) == 0 )
296 {
297 // Highlighting the value itself isn't actually that useful, and it's harder to see.
298 // Highlight the parent and display the message.
299 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, msg );
300 }
301 else if( strcmp( idcmd, "$PAD:" ) == 0 )
302 {
303 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_PIN, msg );
304 }
305 else
306 {
307 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString );
308 }
309}
310
311
312void SCH_EDIT_FRAME::HandleRemoteNetHighlight( const wxString& aNetName )
313{
314 const bool exists = SCH_CONNECTIVITY::NAVIGATION_QUERY( Schematic() ).HasNet( aNetName );
315 SetHighlightedConnection( exists ? aNetName : wxString(), nullptr, true );
316
317 if( SCH_NETCHAIN* chain = Schematic().NetChains().GetNetChainForNet( m_highlightedConn ) )
318 SetHighlightedNetChain( chain->GetName() );
319 else
320 SetHighlightedNetChain( wxEmptyString );
321
324}
325
326
327void SCH_EDIT_FRAME::SendSelectItemsToPcb( const std::vector<EDA_ITEM*>& aItems, bool aForce )
328{
329 kiapi::common::commands::SyncSelection sync;
330
331 for( EDA_ITEM* item : aItems )
332 {
333 switch( item->Type() )
334 {
335 case SCH_SYMBOL_T:
336 {
337 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
338 kiapi::common::commands::SelectionSpec* spec = sync.add_items();
339 spec->mutable_footprint()->set_reference( symbol->GetField( FIELD_T::REFERENCE )->GetText().ToUTF8() );
340 break;
341 }
342
343 case SCH_SHEET_T:
344 {
345 // For cross probing, we need the full path of the sheet, because
346 // we search by the footprint path prefix in the PCB editor.
348 path.push_back( item->m_Uuid );
349
350 kiapi::common::commands::SelectionSpec* spec = sync.add_items();
351 kiapi::common::PackSheetPath( *spec->mutable_sheet_path(), path );
352 break;
353 }
354
355 case SCH_PIN_T:
356 {
357 SCH_PIN* pin = static_cast<SCH_PIN*>( item );
358 SYMBOL* symbol = pin->GetParentSymbol();
359 wxString ref = symbol->GetRef( &GetCurrentSheet(), false );
360
361 // Highlight the resolved pad(s) in pcbnew (issue #2282); a mapped pin may target more
362 // than one pad via stacked notation, so highlight all of them.
363 wxString effective = pin->GetEffectivePadNumber( GetCurrentSheet(), Schematic().GetCurrentVariant() );
364
365 for( const wxString& pad : ExpandStackedPinNotation( effective ) )
366 {
367 kiapi::common::commands::SelectionSpec* spec = sync.add_items();
368 spec->mutable_pad()->set_reference( ref.ToUTF8() );
369 spec->mutable_pad()->set_number( pad.ToUTF8() );
370 }
371
372 break;
373 }
374
375 default:
376 break;
377 }
378 }
379
380 if( sync.items_size() == 0 )
381 return;
382
383 sync.set_context( aForce ? commands::SyncSelectionContext::SSC_EXPLICIT
384 : commands::SyncSelectionContext::SSC_IMPLICIT );
385
386 if( Kiface().IsSingle() )
387 {
389 }
390 else
391 {
392 std::string payload;
393 kiapi::common::PackKiwayApiMessage( sync, payload );
395 }
396}
397
398
399static void sendHighlightNets( SCH_EDIT_FRAME* aFrame, const kiapi::common::commands::HighlightNets& aMessage )
400{
401 if( Kiface().IsSingle() )
402 {
404 }
405 else
406 {
407 std::string payload;
408 kiapi::common::PackKiwayApiMessage( aMessage, payload );
409 aFrame->Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_CROSS_PROBE, payload, aFrame );
410 }
411}
412
413
414void SCH_EDIT_FRAME::SendCrossProbeNetName( const wxString& aNetName )
415{
416 kiapi::common::commands::HighlightNets message;
417
418 message.add_net_name( aNetName.ToUTF8() );
419 sendHighlightNets( this, message );
420}
421
422
423void SCH_EDIT_FRAME::SetCrossProbeConnection( const wxString& aName )
424{
425 const auto names = SCH_CONNECTIVITY::NAVIGATION_QUERY( Schematic() ).SignalNames( aName );
426
427 if( names.empty() )
428 {
430 return;
431 }
432
433 kiapi::common::commands::HighlightNets message;
434
435 for( const wxString& name : names )
436 message.add_net_name( name.ToUTF8() );
437
438 sendHighlightNets( this, message );
439}
440
441
446
447
449{
450 std::string& payload = mail.GetPayload();
451
452 switch( mail.Command() )
453 {
455 {
456 std::stringstream ss( payload );
457 std::string file;
458
461 std::optional<LIBRARY_TABLE*> optTable = manager.Table( LIBRARY_TABLE_TYPE::SYMBOL,
463
464 wxCHECK_RET( optTable.has_value(), "Could not load symbol lib table." );
465 LIBRARY_TABLE* table = optTable.value();
466
467 wxString projectPath = Prj().GetProjectPath();
468
469 // First line of payload is the source project directory.
470 std::string srcProjDir;
471 std::getline( ss, srcProjDir, '\n' );
472
473 std::vector<wxString> toLoad;
474
475 while( std::getline( ss, file, '\n' ) )
476 {
477 if( file.empty() )
478 continue;
479
480 wxFileName fn( file );
482 SCH_IO_MGR::SCH_FILE_T type = SCH_IO_MGR::GuessPluginTypeFromLibPath( fn.GetFullPath() );
483
484 if( type == SCH_IO_MGR::SCH_FILE_UNKNOWN )
485 {
486 wxLogTrace( "KIWAY", "Unknown file type: %s", fn.GetFullPath() );
487 continue;
488 }
489
490 pi.reset( SCH_IO_MGR::FindPlugin( type ) );
491
492 wxString libTableUri;
493 bool isProjectLocal = fn.GetFullPath().StartsWith( wxString( srcProjDir ) );
494
495 if( isProjectLocal )
496 {
497 // Project-local library: copy into the KiCad project directory and use a
498 // project-relative path so the sym-lib-table stays portable.
499 if( !fn.FileExists() )
500 continue;
501
502 wxFileName projectFn( projectPath, fn.GetFullName() );
503
504 if( fn.GetFullPath() != projectFn.GetFullPath() && !projectFn.FileExists() )
505 wxCopyFile( fn.GetFullPath(), projectFn.GetFullPath() );
506
507 libTableUri = wxS( "${KIPRJMOD}/" ) + fn.GetFullName();
508 }
509 else
510 {
511 // External library referenced by absolute path. Preserve the original path.
512 libTableUri = fn.GetFullPath();
513 }
514
515 if( !table->HasRow( fn.GetName() ) )
516 {
517 LIBRARY_TABLE_ROW& row = table->InsertRow();
518 row.SetNickname( fn.GetName() );
519 row.SetURI( libTableUri );
520 row.SetType( SCH_IO_MGR::ShowType( type ) );
521 toLoad.emplace_back( fn.GetName() );
522 }
523 }
524
525 if( !toLoad.empty() )
526 {
527 bool success = true;
528
529 table->Save().map_error(
530 [&]( const LIBRARY_ERROR& aError )
531 {
532 wxLogError( wxT( "Error saving project library table:\n\n" ) + aError.message );
533 success = false;
534 } );
535
536 if( success )
537 {
538 manager.AbortAsyncLoads();
540
541 std::ranges::for_each( toLoad,
542 [adapter]( const wxString& aNick )
543 {
544 adapter->LoadOne( aNick );
545 } );
546 }
547 }
548
552
553 break;
554 }
555
556 // Handled as API commands
557 case MAIL_SELECTION:
558 case MAIL_CROSS_PROBE:
559 if( ApiRequest request; request.ParseFromString( payload.c_str() ) )
560 m_apiHandler->Handle( request );
561
562 break;
563
565 {
566 if( !payload.empty() )
567 {
568 wxString annotationMessage( payload );
569
570 // Ensure schematic is OK for netlist creation (especially that it is fully annotated):
571 bool userCancelled = false;
572
573 if( !ReadyToNetlist( annotationMessage, &userCancelled ) )
574 {
575 // Cancel replies with a sentinel so the caller aborts silently; an unannotated
576 // schematic echoes the annotation message so the caller shows its own error
577 if( userCancelled )
579
580 return;
581 }
582 }
583
585
586 NETLIST_EXPORTER_KICAD exporter( &Schematic() );
587 STRING_FORMATTER formatter;
588
589 exporter.SetKiway( &Kiway() );
590 exporter.Format( &formatter, GNL_ALL | GNL_OPT_KICAD );
591
592 RefreshConnectivity( true );
593 payload = formatter.GetString();
594 break;
595 }
596
598 {
599 KIID uuid( payload );
601
602 if( SCH_ITEM* item = m_schematic->ResolveItem( uuid, &path, true ) )
603 {
604 if( item->Type() == SCH_SHEET_T )
605 payload = static_cast<SCH_SHEET*>( item )->GetShownName( INTERNAL );
606 else if( item->Type() == SCH_SYMBOL_T )
607 payload = static_cast<SCH_SYMBOL*>( item )->GetRef( &path, true );
608 else
609 payload = item->GetFriendlyName();
610 }
611
612 break;
613 }
614
616 try
617 {
618 SCH_EDITOR_CONTROL* controlTool = m_toolManager->GetTool<SCH_EDITOR_CONTROL>();
619 controlTool->AssignFootprints( payload );
620 }
621 catch( const IO_ERROR& )
622 {
623 }
624 break;
625
626 case MAIL_SCH_REFRESH:
627 {
629
631 GetCanvas()->Refresh();
632 break;
633 }
634
635 case MAIL_IMPORT_FILE:
636 {
637 // Extract file format type and path (plugin type, path and properties keys, values
638 // separated with \n)
639 std::stringstream ss( payload );
640 char delim = '\n';
641
642 std::string formatStr;
643 wxCHECK( std::getline( ss, formatStr, delim ), /* void */ );
644
645 std::string fnameStr;
646 wxCHECK( std::getline( ss, fnameStr, delim ), /* void */ );
647
648 int importFormat;
649
650 try
651 {
652 importFormat = std::stoi( formatStr );
653 }
654 catch( std::invalid_argument& )
655 {
656 wxFAIL;
657 importFormat = -1;
658 }
659
660 std::map<std::string, UTF8> props;
661
662 do
663 {
664 std::string key, value;
665
666 if( !std::getline( ss, key, delim ) )
667 break;
668
669 std::getline( ss, value, delim ); // We may want an empty string as value
670
671 props.emplace( key, value );
672
673 } while( true );
674
675 payload.clear();
676
677 if( importFormat >= 0 && importFile( fnameStr, importFormat, props.empty() ? nullptr : &props )
678 && importFormat == SCH_IO_MGR::SCH_ORCAD )
679 {
681 std::map<wxString, wxString> names;
682
683 if( map )
685
686 payload = TO_UTF8( IMPORT_PROJ_PROPS::JoinNetNameMap( names ) );
687 }
688
689 break;
690 }
691
692 case MAIL_SCH_SAVE:
693 if( SaveProject() )
694 payload = "success";
695
696 break;
697
698 case MAIL_SCH_UPDATE:
700 break;
701
702 case MAIL_RELOAD_LIB:
703 {
704 if( m_designBlocksPane && m_designBlocksPane->IsShown() )
705 {
706 m_designBlocksPane->RefreshLibs();
707 SyncView();
708 }
709
710 // Show any symbol library load errors in the status bar
711 if( KISTATUSBAR* statusBar = dynamic_cast<KISTATUSBAR*>( GetStatusBar() ) )
712 {
714 statusBar->AddWarningMessages( "load", adapter->GetLibraryLoadErrors() );
715 }
716
717 break;
718 }
719
721 {
722 wxString targetFile( payload );
723
724 for( SCH_SHEET_PATH& sheetPath : m_schematic->Hierarchy() )
725 {
726 SCH_SCREEN* screen = sheetPath.LastScreen();
727
728 if( screen && screen->GetFileName() == targetFile )
729 {
730 m_toolManager->RunAction<SCH_SHEET_PATH*>( SCH_ACTIONS::changeSheet, &sheetPath );
731 payload = "success";
732 Raise();
733 return;
734 }
735 }
736
737 payload.clear();
738 break;
739 }
740
741 default:;
742
743 }
744}
const char * name
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
BOX2< VECTOR2I > BOX2I
Definition box2.h:927
static TOOL_ACTION showSymbolLibTable
Definition actions.h:280
static TOOL_ACTION updateSchematicFromPcb
Definition actions.h:261
CROSS_PROBING_SETTINGS m_CrossProbing
static bool SendToFrame(FRAME_T aTarget, const google::protobuf::Message &aRequest)
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:98
const KIID m_Uuid
Definition eda_item.h:597
EE_TYPE OfType(KICAD_T aType) const
Definition sch_rtree.h:248
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition view.cpp:1703
Definition kiid.h:46
wxString AsString() const
Definition kiid.cpp:264
KISTATUSBAR is a wxStatusBar suitable for Kicad manager.
Definition kistatusbar.h:50
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
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:486
std::vector< KI_ERROR > GetLibraryLoadErrors() const
Returns all library load errors as newline-separated strings for display.
std::optional< LIBRARY_TABLE * > Table(LIBRARY_TABLE_TYPE aType, LIBRARY_TABLE_SCOPE aScope)
Retrieves a given table; creating a new empty project table if a valid project is loaded and the give...
void AbortAsyncLoads()
Abort any async library loading operations in progress.
void LoadProjectTables(std::initializer_list< LIBRARY_TABLE_TYPE > aTablesToLoad={})
(Re)loads the project library tables in the given list, or all tables if no list is given
void SetNickname(const wxString &aNickname)
void SetType(const wxString &aType)
void SetURI(const wxString &aUri)
static LOAD_INFO_REPORTER & GetInstance()
Definition reporter.cpp:351
void SetKiway(KIWAY *aKiway)
Generate the KiCad netlist format supported by Pcbnew.
void Format(OUTPUTFORMATTER *aOutputFormatter, int aCtl)
Output this s-expression netlist into aOutputFormatter.
virtual LIBRARY_MANAGER & GetLibraryManager() const
Definition pgm_base.h:125
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition project.cpp:183
const IMPORT_NET_MAP * GetImportNetMap() const
Definition schematic.h:162
static TOOL_ACTION runERC
Inspection and Editing.
static TOOL_ACTION changeSheet
static TOOL_ACTION updateNetHighlighting
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SyncView()
Mark all items for refresh.
EESCHEMA_SETTINGS * eeconfig() const
Net membership for one UI operation.
bool HasNet(const wxString &aName) const
std::vector< wxString > SignalNames(const wxString &aName) const
Signal itself or leaf signals of a bus, suitable for PCB cross-probing.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void AssignFootprints(const std::string &aChangedSetOfReferences)
SCH_ITEM * FindSymbolAndItem(const wxString *aPath, const wxString *aReference, bool aSearchHierarchy, SCH_SEARCH_T aSearchType, const wxString &aSearchText)
Find a symbol in the schematic and an item in this symbol and select it.
Schematic editor (Eeschema) main window.
std::unique_ptr< API_HANDLER_SCH > m_apiHandler
void RefreshConnectivity(bool aForce=false)
Refresh connectivity-dependent display state after a model rebuild.
friend class SCH_EDITOR_CONTROL
void SendSelectItemsToPcb(const std::vector< EDA_ITEM * > &aItems, bool aForce)
Send items to board editor for selection.
bool ReadyToNetlist(const wxString &aAnnotateMessage, bool *aUserCancelled=nullptr)
Check if we are ready to write a netlist file for the current schematic.
void SendCrossProbeClearHighlight()
Tell Pcbnew to clear the existing highlighted net, if one exists.
SCHEMATIC * m_schematic
The currently loaded schematic.
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
void ExecuteRemoteCommand(const char *cmdline) override
Execute a remote command sent via a socket on port KICAD_SCH_PORT_SERVICE_NUMBER (which defaults to 4...
void PrepareForNetlist()
Commit source cleanup before the exporter's full connectivity rebuild.
SCH_DESIGN_BLOCK_PANE * m_designBlocksPane
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 Pcbnew for highlighting.
void KiwayMailIn(KIWAY_MAIL_EVENT &aEvent) override
Receive #KIWAY_ROUTED_EVENT messages from other players.
void SetHighlightedConnection(const wxString &aConnection, const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr, bool aForceNetNavigatorRefresh=false)
void SetHighlightedNetChain(const wxString &aNetChain)
void SetCrossProbeConnection(const wxString &aName)
Send a connection (net or bus) to Pcbnew for highlighting.
void UpdateNetHighlightStatus()
void HandleRemoteNetHighlight(const wxString &aNetName)
wxString m_highlightedConn
The highlighted net or bus or empty string.
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
bool SaveProject(bool aSaveAs=false)
Save the currently-open schematic (including its hierarchy) and associated project.
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:138
static const wxString ShowType(SCH_FILE_T aFileType)
Return a brief name for a plugin, given aFileType enum.
static SCH_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath, int aCtl=0)
Return a plugin type given a symbol library using the file extension of aLibPath.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:165
int GetUnit() const
Definition sch_item.h:237
A net chain is a collection of nets that are connected together through passive components.
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Definition sch_screen.h:118
const wxString & GetFileName() const
Definition sch_screen.h:153
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
Schematic symbol object.
Definition sch_symbol.h:75
SCH_PIN * GetPinByEffectivePadNumber(const wxString &aPadNumber, const SCH_SHEET_PATH *aSheet, const wxString &aVariantName=wxEmptyString) const
Find the pin whose effective footprint pad number (issue #2282) is aPadNumber on aSheet,...
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
Implement an OUTPUTFORMATTER to a memory buffer.
Definition richio.h:430
const std::string & GetString()
Definition richio.h:453
An interface to the global shared library manager that is schematic-specific and linked to one projec...
std::optional< LIB_STATUS > LoadOne(LIB_DATA *aLib) override
Loads or reloads the given library, if it exists.
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition symbol.h:59
virtual const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const =0
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.
@ INTERNAL
Definition common.h:92
#define _(s)
static void sendHighlightNets(SCH_EDIT_FRAME *aFrame, const kiapi::common::commands::HighlightNets &aMessage)
@ FRAME_PCB_EDITOR
Definition frame_type.h:38
@ FRAME_SCH_SYMBOL_EDITOR
Definition frame_type.h:31
@ FRAME_SCH_VIEWER
Definition frame_type.h:32
@ FRAME_CVPCB
Definition frame_type.h:48
std::map< wxString, wxString > GetBoardNetNameMap(const IMPORT_NET_MAP &aMap, REPORTER &aReporter)
Reduce the map to the board net renames it justifies.
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
Definition io_mgr.h:33
PROJECT & Prj()
Definition kicad.cpp:727
@ MAIL_IMPORT_FILE
Definition mail_type.h:44
@ MAIL_SCH_REFRESH
Definition mail_type.h:49
@ MAIL_CROSS_PROBE
Definition mail_type.h:35
@ MAIL_SCH_SAVE
Definition mail_type.h:38
@ MAIL_ASSIGN_FOOTPRINTS
Definition mail_type.h:37
@ MAIL_SCH_GET_ITEM
Definition mail_type.h:46
@ MAIL_SCH_UPDATE
Definition mail_type.h:43
@ MAIL_ADD_LOCAL_LIB
Definition mail_type.h:50
@ MAIL_SCH_NAVIGATE_TO_SHEET
Definition mail_type.h:56
@ MAIL_SCH_GET_NETLIST
Definition mail_type.h:45
@ MAIL_SELECTION
Definition mail_type.h:36
@ MAIL_RELOAD_LIB
Definition mail_type.h:53
#define MAIL_SCH_GET_NETLIST_CANCELLED
Reply payload for MAIL_SCH_GET_NETLIST when the user deliberately aborts netlist generation (for exam...
Definition mail_type.h:67
wxString JoinNetNameMap(const std::map< wxString, wxString > &aNames)
Encode source-to-imported net names as a single property value.
@ ALL
All except INITIAL_ADD.
Definition view_item.h:55
KICOMMON_API void PackSheetPath(types::SheetPath &aOutput, const KIID_PATH &aInput)
KICOMMON_API bool PackKiwayApiMessage(const google::protobuf::Message &aMessage, std::string &aBytes)
#define GNL_ALL
@ GNL_OPT_KICAD
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
SCH_SEARCH_T
Schematic search type used by the socket link with Pcbnew.
@ HIGHLIGHT_SYMBOL
@ HIGHLIGHT_PIN
KIWAY Kiway(KFCTL_STANDALONE)
std::vector< wxString > ExpandStackedPinNotation(const wxString &aPinName, bool *aValid)
Expand stacked pin notation like [1,2,3], [1-4], [A1-A4], or [AA1-AA3,AB4,CD12-CD14] into individual ...
wxString From_UTF8(const char *cstring)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Cross-probing behavior.
bool on_selection
Synchronize the selection for multiple items too.
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.
Import provenance, held only for the lifetime of the importing SCHEMATIC.
wxString message
@ REFERENCE
Field Reference of part, i.e. "IC21".
std::string path
KIBIS_PIN * pin
const SHAPE_LINE_CHAIN chain
wxLogTrace helper definitions.
@ SCH_SYMBOL_T
Definition typeinfo.h:168
@ SCH_SHEET_T
Definition typeinfo.h:171
@ SCH_PIN_T
Definition typeinfo.h:149