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>
34#include <reporter.h>
37#include <sch_netchain.h>
38#include <sch_sheet.h>
39#include <sch_symbol.h>
40#include <sch_reference_list.h>
41#include <string_utils.h>
45#include <project_sch.h>
46#include <richio.h>
47#include <tools/sch_actions.h>
48#include <tool/tool_manager.h>
51#include <advanced_config.h>
52#include <api/api_handler_sch.h>
53
54#include <pgm_base.h>
57#include <widgets/kistatusbar.h>
58#include <wx/filefn.h>
59#include <wx/log.h>
60#include <wx/msgdlg.h>
61#include <trace_helpers.h>
62
63SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString* aPath, const wxString* aReference,
64 bool aSearchHierarchy, SCH_SEARCH_T aSearchType,
65 const wxString& aSearchText )
66{
67 SCH_SHEET_PATH* sheetWithSymbolFound = nullptr;
68 SCH_SYMBOL* symbol = nullptr;
69 SCH_PIN* pin = nullptr;
70 SCH_SHEET_LIST sheetList;
71 SCH_ITEM* foundItem = nullptr;
72
73 if( !aSearchHierarchy )
74 sheetList.push_back( m_frame->GetCurrentSheet() );
75 else
76 sheetList = m_frame->Schematic().Hierarchy();
77
78 for( SCH_SHEET_PATH& sheet : sheetList )
79 {
80 SCH_SCREEN* screen = sheet.LastScreen();
81
82 for( EDA_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
83 {
84 SCH_SYMBOL* candidate = static_cast<SCH_SYMBOL*>( item );
85
86 // Search by path if specified, otherwise search by reference
87 bool found = false;
88
89 if( aPath )
90 {
91 wxString path = sheet.PathAsString() + candidate->m_Uuid.AsString();
92 found = ( *aPath == path );
93 }
94 else
95 {
96 found = ( aReference && aReference->CmpNoCase( candidate->GetRef( &sheet ) ) == 0 );
97 }
98
99 if( found )
100 {
101 symbol = candidate;
102 sheetWithSymbolFound = &sheet;
103
104 if( aSearchType == HIGHLIGHT_PIN )
105 {
106 pin = symbol->GetPin( aSearchText );
107
108 // Fall back to reverse pin-to-pad resolution so a remapped pad highlights its
109 // owning pin (issue #2282); the search text from pcbnew is a pad number.
110 if( !pin )
111 pin = symbol->GetPinByEffectivePadNumber( aSearchText, &sheet,
112 m_frame->Schematic().GetCurrentVariant() );
113
114 // Ensure we have found the right unit in case of multi-units symbol
115 if( pin )
116 {
117 int unit = pin->GetLibPin()->GetUnit();
118
119 if( unit != ALL_UNITS && unit != symbol->GetUnit() )
120 {
121 pin = nullptr;
122 continue;
123 }
124
125 // Get pin position in true schematic coordinate
126 foundItem = pin;
127 break;
128 }
129 }
130 else
131 {
132 foundItem = symbol;
133 break;
134 }
135 }
136 }
137
138 if( foundItem )
139 break;
140 }
141
142 CROSS_PROBING_SETTINGS& crossProbingSettings = m_frame->eeconfig()->m_CrossProbing;
143
144 if( symbol )
145 {
146 if( *sheetWithSymbolFound != m_frame->GetCurrentSheet() )
147 {
148 m_frame->GetToolManager()->RunAction<SCH_SHEET_PATH*>( SCH_ACTIONS::changeSheet,
149 sheetWithSymbolFound );
150 }
151
152 if( crossProbingSettings.center_on_items )
153 {
154 if( crossProbingSettings.zoom_to_fit )
155 {
156 BOX2I bbox = symbol->GetBoundingBox();
157
158 m_toolMgr->GetTool<SCH_SELECTION_TOOL>()->ZoomFitCrossProbeBBox( bbox );
159 }
160
161 if( pin )
162 m_frame->FocusOnItem( pin );
163 else
164 m_frame->FocusOnItem( symbol );
165 }
166 }
167
168 /* Print diag */
169 wxString msg;
170 wxString displayRef;
171
172 if( aReference )
173 displayRef = *aReference;
174 else if( aPath )
175 displayRef = *aPath;
176
177 if( symbol )
178 {
179 if( aSearchType == HIGHLIGHT_PIN )
180 {
181 if( foundItem )
182 msg.Printf( _( "%s pin %s found" ), displayRef, aSearchText );
183 else
184 msg.Printf( _( "%s found but pin %s not found" ), displayRef, aSearchText );
185 }
186 else
187 {
188 msg.Printf( _( "%s found" ), displayRef );
189 }
190 }
191 else
192 {
193 msg.Printf( _( "%s not found" ), displayRef );
194 }
195
196 m_frame->SetStatusText( msg );
197 m_frame->GetCanvas()->Refresh();
198
199 return foundItem;
200}
201
202
203/* Execute a remote command sent via a socket on port KICAD_PCB_PORT_SERVICE_NUMBER
204 *
205 * Commands are:
206 *
207 * $PART: "reference" Put cursor on symbol.
208 * $PART: "reference" $REF: "ref" Put cursor on symbol reference.
209 * $PART: "reference" $VAL: "value" Put cursor on symbol value.
210 * $PART: "reference" $PAD: "pin name" Put cursor on the symbol pin.
211 * $NET: "netname" Highlight a specified net
212 * $CLEAR: "HIGHLIGHTED" Clear symbols highlight
213 *
214 * $CONFIG Show the Manage Symbol Libraries dialog
215 * $ERC Show the ERC dialog
216 */
217void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
218{
219 // A remote command can arrive over the cross-probe socket before tools are registered
220 // or after the tool manager has been torn down while the frame is closing.
221 if( !m_toolManager )
222 return;
223
225
226 if( !editor )
227 return;
228
229 char line[1024];
230
231 strncpy( line, cmdline, sizeof( line ) - 1 );
232 line[ sizeof( line ) - 1 ] = '\0';
233
234 char* idcmd = strtok( line, " \n\r" );
235 char* text = strtok( nullptr, "\"\n\r" );
236
237 if( idcmd == nullptr )
238 return;
239
240 CROSS_PROBING_SETTINGS& crossProbingSettings = eeconfig()->m_CrossProbing;
241
242 if( strcmp( idcmd, "$CONFIG" ) == 0 )
243 {
245 return;
246 }
247 else if( strcmp( idcmd, "$ERC" ) == 0 )
248 {
250 return;
251 }
252 else if( strcmp( idcmd, "$NET:" ) == 0 )
253 {
254 if( !crossProbingSettings.auto_highlight )
255 return;
256
258 return;
259 }
260 else if( strcmp( idcmd, "$CLEAR:" ) == 0 )
261 {
262 // Cross-probing is now done through selection so we no longer need a clear command
263 return;
264 }
265
266 if( !crossProbingSettings.on_selection )
267 return;
268
269 if( text == nullptr )
270 return;
271
272 if( strcmp( idcmd, "$PART:" ) != 0 )
273 return;
274
275 wxString part_ref = From_UTF8( text );
276
277 /* look for a complement */
278 idcmd = strtok( nullptr, " \n\r" );
279
280 if( idcmd == nullptr ) // Highlight symbol only (from CvPcb or Pcbnew)
281 {
282 // Highlight symbol part_ref, or clear Highlight, if part_ref is not existing
283 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString );
284 return;
285 }
286
287 text = strtok( nullptr, "\"\n\r" );
288
289 if( text == nullptr )
290 return;
291
292 wxString msg = From_UTF8( text );
293
294 if( strcmp( idcmd, "$REF:" ) == 0 )
295 {
296 // Highlighting the reference itself isn't actually that useful, and it's harder to
297 // see. Highlight the parent and display the message.
298 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, msg );
299 }
300 else if( strcmp( idcmd, "$VAL:" ) == 0 )
301 {
302 // Highlighting the value itself isn't actually that useful, and it's harder to see.
303 // Highlight the parent and display the message.
304 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, msg );
305 }
306 else if( strcmp( idcmd, "$PAD:" ) == 0 )
307 {
308 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_PIN, msg );
309 }
310 else
311 {
312 editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString );
313 }
314}
315
316
317void SCH_EDIT_FRAME::HandleRemoteNetHighlight( const wxString& aNetName )
318{
319 const bool exists = SCH_CONNECTIVITY::NAVIGATION_QUERY( Schematic() ).HasNet( aNetName );
320 SetHighlightedConnection( exists ? aNetName : wxString(), nullptr, true );
321
322 if( SCH_NETCHAIN* chain = Schematic().NetChains().GetNetChainForNet( m_highlightedConn ) )
323 SetHighlightedNetChain( chain->GetName() );
324 else
325 SetHighlightedNetChain( wxEmptyString );
326
329}
330
331
332void SCH_EDIT_FRAME::SendSelectItemsToPcb( const std::vector<EDA_ITEM*>& aItems, bool aForce )
333{
334 kiapi::common::commands::SyncSelection sync;
335
336 for( EDA_ITEM* item : aItems )
337 {
338 switch( item->Type() )
339 {
340 case SCH_SYMBOL_T:
341 {
342 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
343 kiapi::common::commands::SelectionSpec* spec = sync.add_items();
344 spec->mutable_footprint()->set_reference( symbol->GetCurrentSheetRef().ToUTF8() );
345 break;
346 }
347
348 case SCH_SHEET_T:
349 {
350 // For cross probing, we need the full path of the sheet, because
351 // we search by the footprint path prefix in the PCB editor.
353 path.push_back( item->m_Uuid );
354
355 kiapi::common::commands::SelectionSpec* spec = sync.add_items();
356 kiapi::common::PackSheetPath( *spec->mutable_sheet_path(), path );
357 break;
358 }
359
360 case SCH_PIN_T:
361 {
362 SCH_PIN* pin = static_cast<SCH_PIN*>( item );
363 SYMBOL* symbol = pin->GetParentSymbol();
364 wxString ref = symbol->GetRef( &GetCurrentSheet(), false );
365
366 // Highlight the resolved pad(s) in pcbnew (issue #2282); a mapped pin may target more
367 // than one pad via stacked notation, so highlight all of them.
368 wxString effective = pin->GetEffectivePadNumber( GetCurrentSheet(), Schematic().GetCurrentVariant() );
369
370 for( const wxString& pad : ExpandStackedPinNotation( effective ) )
371 {
372 kiapi::common::commands::SelectionSpec* spec = sync.add_items();
373 spec->mutable_pad()->set_reference( ref.ToUTF8() );
374 spec->mutable_pad()->set_number( pad.ToUTF8() );
375 }
376
377 break;
378 }
379
380 default:
381 break;
382 }
383 }
384
385 if( sync.items_size() == 0 )
386 return;
387
388 sync.set_context( aForce ? commands::SyncSelectionContext::SSC_EXPLICIT
389 : commands::SyncSelectionContext::SSC_IMPLICIT );
390
391 if( Kiface().IsSingle() )
392 {
394 }
395 else
396 {
397 std::string payload;
398
399 if( kiapi::common::PackKiwayApiMessage( sync, payload ) )
401 }
402}
403
404
405static void sendHighlightNets( SCH_EDIT_FRAME* aFrame, const kiapi::common::commands::HighlightNets& aMessage )
406{
407 if( Kiface().IsSingle() )
408 {
410 }
411 else
412 {
413 std::string payload;
414
415 if( kiapi::common::PackKiwayApiMessage( aMessage, payload ) )
416 aFrame->Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_CROSS_PROBE, payload, aFrame );
417 }
418}
419
420
421void SCH_EDIT_FRAME::SendCrossProbeNetName( const wxString& aNetName )
422{
423 kiapi::common::commands::HighlightNets message;
424
425 message.add_net_name( aNetName.ToUTF8() );
426 sendHighlightNets( this, message );
427}
428
429
430void SCH_EDIT_FRAME::SetCrossProbeConnection( const wxString& aName )
431{
432 const auto names = SCH_CONNECTIVITY::NAVIGATION_QUERY( Schematic() ).SignalNames( aName );
433
434 if( names.empty() )
435 {
437 return;
438 }
439
440 kiapi::common::commands::HighlightNets message;
441
442 for( const wxString& name : names )
443 message.add_net_name( name.ToUTF8() );
444
445 sendHighlightNets( this, message );
446}
447
448
453
454
456{
457 std::string& payload = mail.GetPayload();
458
459 switch( mail.Command() )
460 {
462 {
463 std::stringstream ss( payload );
464 std::string file;
465
466 // First line of payload is the source project directory.
467 std::string srcProjDir;
468 std::getline( ss, srcProjDir, '\n' );
469
470 std::vector<wxString> libraries;
471
472 while( std::getline( ss, file, '\n' ) )
473 libraries.push_back( wxString::FromUTF8( file ) );
474
475 RegisterLocalSymbolLibraries( Prj(), wxString::FromUTF8( srcProjDir ), libraries,
477
481
482 break;
483 }
484
485 // Handled as API commands
486 case MAIL_SELECTION:
487 case MAIL_CROSS_PROBE:
488 if( ApiRequest request; request.ParseFromString( payload.c_str() ) )
489 m_apiHandler->Handle( request );
490
491 break;
492
494 {
495 if( !payload.empty() )
496 {
497 wxString annotationMessage( payload );
498
499 // Ensure schematic is OK for netlist creation (especially that it is fully annotated):
500 bool userCancelled = false;
501
502 if( !ReadyToNetlist( annotationMessage, &userCancelled ) )
503 {
504 // Cancel replies with a sentinel so the caller aborts silently; an unannotated
505 // schematic echoes the annotation message so the caller shows its own error
506 if( userCancelled )
508
509 return;
510 }
511 }
512
514
515 NETLIST_EXPORTER_KICAD exporter( &Schematic(), &Kiway() );
516 STRING_FORMATTER formatter;
517
518 exporter.Format( &formatter, GNL_ALL | GNL_OPT_KICAD );
519
520 RefreshConnectivity( true );
521 payload = formatter.GetString();
522 break;
523 }
524
526 {
527 payload = Schematic().FormatRefSuffixes();
528 break;
529 }
530
532 {
533 KIID uuid( payload );
535
536 if( SCH_ITEM* item = m_schematic->ResolveItem( uuid, &path, true ) )
537 {
538 if( item->Type() == SCH_SHEET_T )
539 payload = static_cast<SCH_SHEET*>( item )->GetShownName( INTERNAL );
540 else if( item->Type() == SCH_SYMBOL_T )
541 payload = static_cast<SCH_SYMBOL*>( item )->GetRef( &path, true );
542 else
543 payload = item->GetFriendlyName();
544 }
545
546 break;
547 }
548
550 try
551 {
552 SCH_EDITOR_CONTROL* controlTool = m_toolManager->GetTool<SCH_EDITOR_CONTROL>();
553 controlTool->AssignFootprints( payload );
554 }
555 catch( const IO_ERROR& )
556 {
557 }
558 break;
559
560 case MAIL_SCH_REFRESH:
561 {
563
565 GetCanvas()->Refresh();
566 break;
567 }
568
570 {
571 std::optional<std::map<wxString, wxString>> footprints =
573 wxString::FromUTF8( payload ) );
574
575 if( footprints && LinkImportedFootprints( Schematic(), *footprints, WXLOG_REPORTER::GetInstance() ) > 0 )
576 OnModify();
577
578 break;
579 }
580
581 case MAIL_IMPORT_FILE:
582 {
583 // Extract file format type and path (plugin type, path and properties keys, values
584 // separated with \n)
585 std::stringstream ss( payload );
586 char delim = '\n';
587
588 std::string formatStr;
589 wxCHECK( std::getline( ss, formatStr, delim ), /* void */ );
590
591 std::string fnameStr;
592 wxCHECK( std::getline( ss, fnameStr, delim ), /* void */ );
593
594 int importFormat;
595
596 try
597 {
598 importFormat = std::stoi( formatStr );
599 }
600 catch( std::invalid_argument& )
601 {
602 wxFAIL;
603 importFormat = -1;
604 }
605
606 std::map<std::string, UTF8> props;
607
608 do
609 {
610 std::string key, value;
611
612 if( !std::getline( ss, key, delim ) )
613 break;
614
615 std::getline( ss, value, delim ); // We may want an empty string as value
616
617 props.emplace( key, value );
618
619 } while( true );
620
621 payload.clear();
622
623 if( importFormat < 0 || !importFile( fnameStr, importFormat, props.empty() ? nullptr : &props ) )
624 break;
625
626 if( importFormat == SCH_IO_MGR::SCH_ORCAD )
627 {
629 std::map<wxString, wxString> names;
630
631 if( map )
633
634 payload = TO_UTF8( IMPORT_PROJ_PROPS::JoinNetNameMap( names ) );
635 }
636 else
637 {
638 payload = "success";
639 }
640
641 break;
642 }
643
644 case MAIL_SCH_SAVE:
645 if( SaveProject() )
646 payload = "success";
647
648 break;
649
650 case MAIL_SCH_RELOAD:
651 {
652 // A git operation rewrote files on disk. Reload the schematic so the editor matches.
653 if( Schematic().GetFileName().IsEmpty() )
654 break;
655
656 SCH_SCREENS screens( Schematic().Root() );
657
658 // A payload lists the changed files. When none is a sheet of this schematic, the change
659 // belongs to another project and reloading would only cost this one its undo history.
660 if( !payload.empty() )
661 {
662 wxArrayString changed = wxSplit( wxString::FromUTF8( payload.c_str() ), '\n' );
663 bool mine = false;
664
665 for( SCH_SCREEN* screen = screens.GetFirst(); screen && !mine; screen = screens.GetNext() )
666 {
667 wxString screenFile = wxFileName( screen->GetFileName() ).GetFullPath();
668
669 for( const wxString& changedFile : changed )
670 {
671 if( !changedFile.IsEmpty() && screenFile == wxFileName( changedFile ).GetFullPath() )
672 {
673 mine = true;
674 break;
675 }
676 }
677 }
678
679 // A new top-level sheet is not one of this schematic's files yet
680 if( !TopLevelSheetsChangedOnDisk() && !mine )
681 break;
682 }
683
684 // Neither choice is safe without asking: reloading discards the unsaved edits, keeping
685 // them means the next save overwrites what arrived.
686 if( !ConfirmReloadFromDisk( _( "The schematic changed on disk while you were editing it.\n\n"
687 "Reloading loses your unsaved edits. Keeping them means your "
688 "next save overwrites the changes that just arrived. To get those "
689 "back later, use Discard Changes on the file in the Version Control "
690 "panel, which drops your edits to it." ),
691 _( "Schematic Changed on Disk" ) ) )
692 {
693 break;
694 }
695
697 break;
698 }
699
700 case MAIL_SCH_UPDATE:
702 break;
703
706 break;
707
708 case MAIL_RELOAD_LIB:
709 {
710 if( m_designBlocksPane && m_designBlocksPane->IsShown() )
711 m_designBlocksPane->RefreshLibs();
712
713 // Show any symbol library load errors in the status bar
714 if( KISTATUSBAR* statusBar = dynamic_cast<KISTATUSBAR*>( GetStatusBar() ) )
715 {
717 statusBar->AddWarningMessages( "load", adapter->GetLibraryLoadErrors() );
718 }
719
720 break;
721 }
722
724 {
725 wxString targetFile( payload );
726
727 for( SCH_SHEET_PATH& sheetPath : m_schematic->Hierarchy() )
728 {
729 SCH_SCREEN* screen = sheetPath.LastScreen();
730
731 if( screen && screen->GetFileName() == targetFile )
732 {
733 m_toolManager->RunAction<SCH_SHEET_PATH*>( SCH_ACTIONS::changeSheet, &sheetPath );
734 payload = "success";
735 Raise();
736 return;
737 }
738 }
739
740 payload.clear();
741 break;
742 }
743
744 default:;
745
746 }
747}
const char * name
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
static TOOL_ACTION showSymbolLibTable
Definition actions.h:283
static TOOL_ACTION updateSchematicFromPcb
Definition actions.h:262
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:2474
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:511
std::vector< KI_ERROR > GetLibraryLoadErrors() const
Returns all library load errors as newline-separated strings for display.
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.
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
std::string FormatRefSuffixes() const
const IMPORT_NET_MAP * GetImportNetMap() const
Definition schematic.h:169
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.
void ReloadProjectFileSettings()
Bring the frame in line with a project file that was reread from disk.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
std::unique_ptr< API_HANDLER_SCH > m_apiHandler
bool TopLevelSheetsChangedOnDisk()
Check whether the last read of the project file brought a top-level sheet list that the open schemati...
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.
bool ReloadFromDisk()
Reload the schematic and all its sheets from disk.
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.
bool ConfirmReloadFromDisk(const wxString &aMessage, const wxString &aTitle)
Ask whether to reload when that would discard unsaved edits.
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.
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.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition sch_screen.h:826
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
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:50
Schematic symbol object.
Definition sch_symbol.h:76
wxString GetCurrentSheetRef() const
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
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...
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.
static REPORTER & GetInstance()
Definition reporter.cpp:324
@ INTERNAL
Definition common.h:96
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Definition cvpcb.cpp:178
#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
std::vector< wxString > RegisterLocalSymbolLibraries(PROJECT &aProject, const wxString &aSourceProjectDir, const std::vector< wxString > &aLibraries, REPORTER &aReporter)
Register the symbol libraries a source project names in the project symbol library table.
std::map< wxString, wxString > GetBoardNetNameMap(const IMPORT_NET_MAP &aMap, REPORTER &aReporter)
Reduce the map to the board net renames it justifies.
PROJECT & Prj()
Definition kicad.cpp:730
@ 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_SCH_LINK_FOOTPRINTS
Definition mail_type.h:67
@ 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_SCH_PROJECT_SETTINGS_CHANGED
Definition mail_type.h:63
@ MAIL_ADD_LOCAL_LIB
Definition mail_type.h:50
@ MAIL_SCH_GET_REF_SUFFIXES
Definition mail_type.h:68
@ MAIL_SCH_NAVIGATE_TO_SHEET
Definition mail_type.h:58
@ MAIL_SCH_GET_NETLIST
Definition mail_type.h:45
@ MAIL_SELECTION
Definition mail_type.h:36
@ MAIL_SCH_RELOAD
Definition mail_type.h:61
@ MAIL_RELOAD_LIB
Definition mail_type.h:55
#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:79
std::optional< std::map< wxString, wxString > > SplitTaggedMap(const char *aTag, const wxString &aValue)
Decode a tagged string map property value, or nothing when the value is not one.
wxString JoinNetNameMap(const std::map< wxString, wxString > &aNames)
Encode source-to-imported net names as a single property value.
constexpr char FOOTPRINT_ID_MAP_TAG[]
Leading field marking a value as an encoded map from reference to footprint LIB_ID.
@ 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
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.
#define ALL_UNITS
Definition symbol.h:150
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