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>
46#include <tool/tool_manager.h>
49#include <advanced_config.h>
50#include <api/api_handler_sch.h>
51
52#include <pgm_base.h>
55#include <widgets/kistatusbar.h>
56#include <wx/filefn.h>
57#include <wx/log.h>
58#include <trace_helpers.h>
59
60SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString* aPath, const wxString* aReference,
61 bool aSearchHierarchy, SCH_SEARCH_T aSearchType,
62 const wxString& aSearchText )
63{
64 SCH_SHEET_PATH* sheetWithSymbolFound = nullptr;
65 SCH_SYMBOL* symbol = nullptr;
66 SCH_PIN* pin = nullptr;
67 SCH_SHEET_LIST sheetList;
68 SCH_ITEM* foundItem = nullptr;
69
70 if( !aSearchHierarchy )
71 sheetList.push_back( m_frame->GetCurrentSheet() );
72 else
73 sheetList = m_frame->Schematic().Hierarchy();
74
75 for( SCH_SHEET_PATH& sheet : sheetList )
76 {
77 SCH_SCREEN* screen = sheet.LastScreen();
78
79 for( EDA_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
80 {
81 SCH_SYMBOL* candidate = static_cast<SCH_SYMBOL*>( item );
82
83 // Search by path if specified, otherwise search by reference
84 bool found = false;
85
86 if( aPath )
87 {
88 wxString path = sheet.PathAsString() + candidate->m_Uuid.AsString();
89 found = ( *aPath == path );
90 }
91 else
92 {
93 found = ( aReference && aReference->CmpNoCase( candidate->GetRef( &sheet ) ) == 0 );
94 }
95
96 if( found )
97 {
98 symbol = candidate;
99 sheetWithSymbolFound = &sheet;
100
101 if( aSearchType == HIGHLIGHT_PIN )
102 {
103 pin = symbol->GetPin( aSearchText );
104
105 // Fall back to reverse pin-to-pad resolution so a remapped pad highlights its
106 // owning pin (issue #2282); the search text from pcbnew is a pad number.
107 if( !pin )
108 pin = symbol->GetPinByEffectivePadNumber( aSearchText, &sheet,
109 m_frame->Schematic().GetCurrentVariant() );
110
111 // Ensure we have found the right unit in case of multi-units symbol
112 if( pin )
113 {
114 int unit = pin->GetLibPin()->GetUnit();
115
116 if( unit != ALL_UNITS && unit != symbol->GetUnit() )
117 {
118 pin = nullptr;
119 continue;
120 }
121
122 // Get pin position in true schematic coordinate
123 foundItem = pin;
124 break;
125 }
126 }
127 else
128 {
129 foundItem = symbol;
130 break;
131 }
132 }
133 }
134
135 if( foundItem )
136 break;
137 }
138
139 CROSS_PROBING_SETTINGS& crossProbingSettings = m_frame->eeconfig()->m_CrossProbing;
140
141 if( symbol )
142 {
143 if( *sheetWithSymbolFound != m_frame->GetCurrentSheet() )
144 {
145 m_frame->GetToolManager()->RunAction<SCH_SHEET_PATH*>( SCH_ACTIONS::changeSheet,
146 sheetWithSymbolFound );
147 }
148
149 if( crossProbingSettings.center_on_items )
150 {
151 if( crossProbingSettings.zoom_to_fit )
152 {
153 BOX2I bbox = symbol->GetBoundingBox();
154
155 m_toolMgr->GetTool<SCH_SELECTION_TOOL>()->ZoomFitCrossProbeBBox( bbox );
156 }
157
158 if( pin )
159 m_frame->FocusOnItem( pin );
160 else
161 m_frame->FocusOnItem( symbol );
162 }
163 }
164
165 /* Print diag */
166 wxString msg;
167 wxString displayRef;
168
169 if( aReference )
170 displayRef = *aReference;
171 else if( aPath )
172 displayRef = *aPath;
173
174 if( symbol )
175 {
176 if( aSearchType == HIGHLIGHT_PIN )
177 {
178 if( foundItem )
179 msg.Printf( _( "%s pin %s found" ), displayRef, aSearchText );
180 else
181 msg.Printf( _( "%s found but pin %s not found" ), displayRef, aSearchText );
182 }
183 else
184 {
185 msg.Printf( _( "%s found" ), displayRef );
186 }
187 }
188 else
189 {
190 msg.Printf( _( "%s not found" ), displayRef );
191 }
192
193 m_frame->SetStatusText( msg );
194 m_frame->GetCanvas()->Refresh();
195
196 return foundItem;
197}
198
199
200/* Execute a remote command sent via a socket on port KICAD_PCB_PORT_SERVICE_NUMBER
201 *
202 * Commands are:
203 *
204 * $PART: "reference" Put cursor on symbol.
205 * $PART: "reference" $REF: "ref" Put cursor on symbol reference.
206 * $PART: "reference" $VAL: "value" Put cursor on symbol value.
207 * $PART: "reference" $PAD: "pin name" Put cursor on the symbol pin.
208 * $NET: "netname" Highlight a specified net
209 * $CLEAR: "HIGHLIGHTED" Clear symbols highlight
210 *
211 * $CONFIG Show the Manage Symbol Libraries dialog
212 * $ERC Show the ERC dialog
213 */
214void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
215{
216 // A remote command can arrive over the cross-probe socket before tools are registered
217 // or after the tool manager has been torn down while the frame is closing.
218 if( !m_toolManager )
219 return;
220
222
223 if( !editor )
224 return;
225
226 char line[1024];
227
228 strncpy( line, cmdline, sizeof( line ) - 1 );
229 line[ sizeof( line ) - 1 ] = '\0';
230
231 char* idcmd = strtok( line, " \n\r" );
232 char* text = strtok( nullptr, "\"\n\r" );
233
234 if( idcmd == nullptr )
235 return;
236
237 CROSS_PROBING_SETTINGS& crossProbingSettings = eeconfig()->m_CrossProbing;
238
239 if( strcmp( idcmd, "$CONFIG" ) == 0 )
240 {
242 return;
243 }
244 else if( strcmp( idcmd, "$ERC" ) == 0 )
245 {
247 return;
248 }
249 else if( strcmp( idcmd, "$NET:" ) == 0 )
250 {
251 if( !crossProbingSettings.auto_highlight )
252 return;
253
255 return;
256 }
257 else if( strcmp( idcmd, "$CLEAR:" ) == 0 )
258 {
259 // Cross-probing is now done through selection so we no longer need a clear command
260 return;
261 }
262
263 if( !crossProbingSettings.on_selection )
264 return;
265
266 if( text == nullptr )
267 return;
268
269 if( strcmp( idcmd, "$PART:" ) != 0 )
270 return;
271
272 wxString part_ref = From_UTF8( text );
273
274 /* look for a complement */
275 idcmd = strtok( nullptr, " \n\r" );
276
277 if( idcmd == nullptr ) // Highlight symbol only (from CvPcb or Pcbnew)
278 {
279 // Highlight symbol part_ref, or clear Highlight, if part_ref is not existing
280 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString );
281 return;
282 }
283
284 text = strtok( nullptr, "\"\n\r" );
285
286 if( text == nullptr )
287 return;
288
289 wxString msg = From_UTF8( text );
290
291 if( strcmp( idcmd, "$REF:" ) == 0 )
292 {
293 // Highlighting the reference itself isn't actually that useful, and it's harder to
294 // see. Highlight the parent and display the message.
295 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, msg );
296 }
297 else if( strcmp( idcmd, "$VAL:" ) == 0 )
298 {
299 // Highlighting the value itself isn't actually that useful, and it's harder to see.
300 // Highlight the parent and display the message.
301 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, msg );
302 }
303 else if( strcmp( idcmd, "$PAD:" ) == 0 )
304 {
305 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_PIN, msg );
306 }
307 else
308 {
309 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString );
310 }
311}
312
313
314void SCH_EDIT_FRAME::HandleRemoteNetHighlight( const wxString& aNetName )
315{
316 const bool exists = SCH_CONNECTIVITY::NAVIGATION_QUERY( Schematic() ).HasNet( aNetName );
317 SetHighlightedConnection( exists ? aNetName : wxString(), nullptr, true );
318
319 if( SCH_NETCHAIN* chain = Schematic().NetChains().GetNetChainForNet( m_highlightedConn ) )
320 SetHighlightedNetChain( chain->GetName() );
321 else
322 SetHighlightedNetChain( wxEmptyString );
323
326}
327
328
329void SCH_EDIT_FRAME::SendSelectItemsToPcb( const std::vector<EDA_ITEM*>& aItems, bool aForce )
330{
331 kiapi::common::commands::SyncSelection sync;
332
333 for( EDA_ITEM* item : aItems )
334 {
335 switch( item->Type() )
336 {
337 case SCH_SYMBOL_T:
338 {
339 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
340 kiapi::common::commands::SelectionSpec* spec = sync.add_items();
341 spec->mutable_footprint()->set_reference( symbol->GetField( FIELD_T::REFERENCE )->GetText().ToUTF8() );
342 break;
343 }
344
345 case SCH_SHEET_T:
346 {
347 // For cross probing, we need the full path of the sheet, because
348 // we search by the footprint path prefix in the PCB editor.
350 path.push_back( item->m_Uuid );
351
352 kiapi::common::commands::SelectionSpec* spec = sync.add_items();
353 kiapi::common::PackSheetPath( *spec->mutable_sheet_path(), path );
354 break;
355 }
356
357 case SCH_PIN_T:
358 {
359 SCH_PIN* pin = static_cast<SCH_PIN*>( item );
360 SYMBOL* symbol = pin->GetParentSymbol();
361 wxString ref = symbol->GetRef( &GetCurrentSheet(), false );
362
363 // Highlight the resolved pad(s) in pcbnew (issue #2282); a mapped pin may target more
364 // than one pad via stacked notation, so highlight all of them.
365 wxString effective = pin->GetEffectivePadNumber( GetCurrentSheet(), Schematic().GetCurrentVariant() );
366
367 for( const wxString& pad : ExpandStackedPinNotation( effective ) )
368 {
369 kiapi::common::commands::SelectionSpec* spec = sync.add_items();
370 spec->mutable_pad()->set_reference( ref.ToUTF8() );
371 spec->mutable_pad()->set_number( pad.ToUTF8() );
372 }
373
374 break;
375 }
376
377 default:
378 break;
379 }
380 }
381
382 if( sync.items_size() == 0 )
383 return;
384
385 sync.set_context( aForce ? commands::SyncSelectionContext::SSC_EXPLICIT
386 : commands::SyncSelectionContext::SSC_IMPLICIT );
387
388 if( Kiface().IsSingle() )
389 {
391 }
392 else
393 {
394 std::string payload;
395 kiapi::common::PackKiwayApiMessage( sync, payload );
397 }
398}
399
400
401static void sendHighlightNets( SCH_EDIT_FRAME* aFrame, const kiapi::common::commands::HighlightNets& aMessage )
402{
403 if( Kiface().IsSingle() )
404 {
406 }
407 else
408 {
409 std::string payload;
410 kiapi::common::PackKiwayApiMessage( aMessage, payload );
411 aFrame->Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_CROSS_PROBE, payload, aFrame );
412 }
413}
414
415
416void SCH_EDIT_FRAME::SendCrossProbeNetName( const wxString& aNetName )
417{
418 kiapi::common::commands::HighlightNets message;
419
420 message.add_net_name( aNetName.ToUTF8() );
421 sendHighlightNets( this, message );
422}
423
424
425void SCH_EDIT_FRAME::SetCrossProbeConnection( const wxString& aName )
426{
427 const auto names = SCH_CONNECTIVITY::NAVIGATION_QUERY( Schematic() ).SignalNames( aName );
428
429 if( names.empty() )
430 {
432 return;
433 }
434
435 kiapi::common::commands::HighlightNets message;
436
437 for( const wxString& name : names )
438 message.add_net_name( name.ToUTF8() );
439
440 sendHighlightNets( this, message );
441}
442
443
448
449
451{
452 std::string& payload = mail.GetPayload();
453
454 switch( mail.Command() )
455 {
457 {
458 std::stringstream ss( payload );
459 std::string file;
460
463 std::optional<LIBRARY_TABLE*> optTable = manager.Table( LIBRARY_TABLE_TYPE::SYMBOL,
465
466 wxCHECK_RET( optTable.has_value(), "Could not load symbol lib table." );
467 LIBRARY_TABLE* table = optTable.value();
468
469 wxString projectPath = Prj().GetProjectPath();
470
471 // First line of payload is the source project directory.
472 std::string srcProjDir;
473 std::getline( ss, srcProjDir, '\n' );
474
475 std::vector<wxString> toLoad;
476
477 while( std::getline( ss, file, '\n' ) )
478 {
479 if( file.empty() )
480 continue;
481
482 wxFileName fn( file );
484 SCH_IO_MGR::SCH_FILE_T type = SCH_IO_MGR::GuessPluginTypeFromLibPath( fn.GetFullPath() );
485
486 if( type == SCH_IO_MGR::SCH_FILE_UNKNOWN )
487 {
488 wxLogTrace( "KIWAY", "Unknown file type: %s", fn.GetFullPath() );
489 continue;
490 }
491
492 pi.reset( SCH_IO_MGR::FindPlugin( type ) );
493
494 wxString libTableUri;
495 bool isProjectLocal = fn.GetFullPath().StartsWith( wxString( srcProjDir ) );
496
497 if( isProjectLocal )
498 {
499 // Project-local library: copy into the KiCad project directory and use a
500 // project-relative path so the sym-lib-table stays portable.
501 if( !fn.FileExists() )
502 continue;
503
504 wxFileName projectFn( projectPath, fn.GetFullName() );
505
506 if( fn.GetFullPath() != projectFn.GetFullPath() && !projectFn.FileExists() )
507 wxCopyFile( fn.GetFullPath(), projectFn.GetFullPath() );
508
509 libTableUri = wxS( "${KIPRJMOD}/" ) + fn.GetFullName();
510 }
511 else
512 {
513 // External library referenced by absolute path. Preserve the original path.
514 libTableUri = fn.GetFullPath();
515 }
516
517 if( !table->HasRow( fn.GetName() ) )
518 {
519 LIBRARY_TABLE_ROW& row = table->InsertRow();
520 row.SetNickname( fn.GetName() );
521 row.SetURI( libTableUri );
522 row.SetType( SCH_IO_MGR::ShowType( type ) );
523 toLoad.emplace_back( fn.GetName() );
524 }
525 }
526
527 if( !toLoad.empty() )
528 {
529 bool success = true;
530
531 table->Save().map_error(
532 [&]( const LIBRARY_ERROR& aError )
533 {
534 wxLogError( wxT( "Error saving project library table:\n\n" ) + aError.message );
535 success = false;
536 } );
537
538 if( success )
539 {
540 manager.AbortAsyncLoads();
542
543 std::ranges::for_each( toLoad,
544 [adapter]( const wxString& aNick )
545 {
546 adapter->LoadOne( aNick );
547 } );
548 }
549 }
550
554
555 break;
556 }
557
558 // Handled as API commands
559 case MAIL_SELECTION:
560 case MAIL_CROSS_PROBE:
561 if( ApiRequest request; request.ParseFromString( payload.c_str() ) )
562 m_apiHandler->Handle( request );
563
564 break;
565
567 {
568 if( !payload.empty() )
569 {
570 wxString annotationMessage( payload );
571
572 // Ensure schematic is OK for netlist creation (especially that it is fully annotated):
573 bool userCancelled = false;
574
575 if( !ReadyToNetlist( annotationMessage, &userCancelled ) )
576 {
577 // Cancel replies with a sentinel so the caller aborts silently; an unannotated
578 // schematic echoes the annotation message so the caller shows its own error
579 if( userCancelled )
581
582 return;
583 }
584 }
585
587
588 NETLIST_EXPORTER_KICAD exporter( &Schematic(), &Kiway() );
589 STRING_FORMATTER formatter;
590
591 exporter.Format( &formatter, GNL_ALL | GNL_OPT_KICAD );
592
593 RefreshConnectivity( true );
594 payload = formatter.GetString();
595 break;
596 }
597
599 {
600 KIID uuid( payload );
602
603 if( SCH_ITEM* item = m_schematic->ResolveItem( uuid, &path, true ) )
604 {
605 if( item->Type() == SCH_SHEET_T )
606 payload = static_cast<SCH_SHEET*>( item )->GetShownName( INTERNAL );
607 else if( item->Type() == SCH_SYMBOL_T )
608 payload = static_cast<SCH_SYMBOL*>( item )->GetRef( &path, true );
609 else
610 payload = item->GetFriendlyName();
611 }
612
613 break;
614 }
615
617 try
618 {
619 SCH_EDITOR_CONTROL* controlTool = m_toolManager->GetTool<SCH_EDITOR_CONTROL>();
620 controlTool->AssignFootprints( payload );
621 }
622 catch( const IO_ERROR& )
623 {
624 }
625 break;
626
627 case MAIL_SCH_REFRESH:
628 {
630
632 GetCanvas()->Refresh();
633 break;
634 }
635
636 case MAIL_IMPORT_FILE:
637 {
638 // Extract file format type and path (plugin type, path and properties keys, values
639 // separated with \n)
640 std::stringstream ss( payload );
641 char delim = '\n';
642
643 std::string formatStr;
644 wxCHECK( std::getline( ss, formatStr, delim ), /* void */ );
645
646 std::string fnameStr;
647 wxCHECK( std::getline( ss, fnameStr, delim ), /* void */ );
648
649 int importFormat;
650
651 try
652 {
653 importFormat = std::stoi( formatStr );
654 }
655 catch( std::invalid_argument& )
656 {
657 wxFAIL;
658 importFormat = -1;
659 }
660
661 std::map<std::string, UTF8> props;
662
663 do
664 {
665 std::string key, value;
666
667 if( !std::getline( ss, key, delim ) )
668 break;
669
670 std::getline( ss, value, delim ); // We may want an empty string as value
671
672 props.emplace( key, value );
673
674 } while( true );
675
676 payload.clear();
677
678 if( importFormat >= 0 && importFile( fnameStr, importFormat, props.empty() ? nullptr : &props )
679 && importFormat == SCH_IO_MGR::SCH_ORCAD )
680 {
682 std::map<wxString, wxString> names;
683
684 if( map )
686
687 payload = TO_UTF8( IMPORT_PROJ_PROPS::JoinNetNameMap( names ) );
688 }
689
690 break;
691 }
692
693 case MAIL_SCH_SAVE:
694 if( SaveProject() )
695 payload = "success";
696
697 break;
698
699 case MAIL_SCH_UPDATE:
701 break;
702
703 case MAIL_RELOAD_LIB:
704 {
705 if( m_designBlocksPane && m_designBlocksPane->IsShown() )
706 m_designBlocksPane->RefreshLibs();
707
708 // Show any symbol library load errors in the status bar
709 if( KISTATUSBAR* statusBar = dynamic_cast<KISTATUSBAR*>( GetStatusBar() ) )
710 {
712 statusBar->AddWarningMessages( "load", adapter->GetLibraryLoadErrors() );
713 }
714
715 break;
716 }
717
719 {
720 wxString targetFile( payload );
721
722 for( SCH_SHEET_PATH& sheetPath : m_schematic->Hierarchy() )
723 {
724 SCH_SCREEN* screen = sheetPath.LastScreen();
725
726 if( screen && screen->GetFileName() == targetFile )
727 {
728 m_toolManager->RunAction<SCH_SHEET_PATH*>( SCH_ACTIONS::changeSheet, &sheetPath );
729 payload = "success";
730 Raise();
731 return;
732 }
733 }
734
735 payload.clear();
736 break;
737 }
738
739 default:;
740
741 }
742}
const char * name
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
static TOOL_ACTION showSymbolLibTable
Definition actions.h:281
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:599
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:1743
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
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:163
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.
EESCHEMA_SETTINGS * eeconfig() const
One UI operation's hierarchy index.
bool HasNet(const wxString &aName) const
std::vector< wxString > SignalNames(const wxString &aName) const
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the KIGFX::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
friend class SCH_EDITOR_CONTROL
void RefreshConnectivity(bool aForce=false, const SCH_CONNECTIVITY::CHANGE_SET *aChanges=nullptr)
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...
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_MAIL_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:139
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:170
int GetUnit() const
Definition sch_item.h:243
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:122
const wxString & GetFileName() const
Definition sch_screen.h:157
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:73
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:60
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:94
#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::string message
static wxString From_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition idf_helpers.h:44
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition idf_helpers.h:37
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:733
@ 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:57
@ MAIL_SCH_GET_NETLIST
Definition mail_type.h:45
@ MAIL_SELECTION
Definition mail_type.h:36
@ MAIL_RELOAD_LIB
Definition mail_type.h:54
#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:68
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 ...
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
#define ALL_UNITS
Definition symbol.h:150
@ 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