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->GetField( FIELD_T::REFERENCE )->GetText().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 kiapi::common::PackKiwayApiMessage( sync, payload );
400 }
401}
402
403
404static void sendHighlightNets( SCH_EDIT_FRAME* aFrame, const kiapi::common::commands::HighlightNets& aMessage )
405{
406 if( Kiface().IsSingle() )
407 {
409 }
410 else
411 {
412 std::string payload;
413 kiapi::common::PackKiwayApiMessage( aMessage, payload );
414 aFrame->Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_CROSS_PROBE, payload, aFrame );
415 }
416}
417
418
419void SCH_EDIT_FRAME::SendCrossProbeNetName( const wxString& aNetName )
420{
421 kiapi::common::commands::HighlightNets message;
422
423 message.add_net_name( aNetName.ToUTF8() );
424 sendHighlightNets( this, message );
425}
426
427
428void SCH_EDIT_FRAME::SetCrossProbeConnection( const wxString& aName )
429{
430 const auto names = SCH_CONNECTIVITY::NAVIGATION_QUERY( Schematic() ).SignalNames( aName );
431
432 if( names.empty() )
433 {
435 return;
436 }
437
438 kiapi::common::commands::HighlightNets message;
439
440 for( const wxString& name : names )
441 message.add_net_name( name.ToUTF8() );
442
443 sendHighlightNets( this, message );
444}
445
446
451
452
454{
455 std::string& payload = mail.GetPayload();
456
457 switch( mail.Command() )
458 {
460 {
461 std::stringstream ss( payload );
462 std::string file;
463
464 // First line of payload is the source project directory.
465 std::string srcProjDir;
466 std::getline( ss, srcProjDir, '\n' );
467
468 std::vector<wxString> libraries;
469
470 while( std::getline( ss, file, '\n' ) )
471 libraries.push_back( wxString::FromUTF8( file ) );
472
473 RegisterLocalSymbolLibraries( Prj(), wxString::FromUTF8( srcProjDir ), libraries,
475
479
480 break;
481 }
482
483 // Handled as API commands
484 case MAIL_SELECTION:
485 case MAIL_CROSS_PROBE:
486 if( ApiRequest request; request.ParseFromString( payload.c_str() ) )
487 m_apiHandler->Handle( request );
488
489 break;
490
492 {
493 if( !payload.empty() )
494 {
495 wxString annotationMessage( payload );
496
497 // Ensure schematic is OK for netlist creation (especially that it is fully annotated):
498 bool userCancelled = false;
499
500 if( !ReadyToNetlist( annotationMessage, &userCancelled ) )
501 {
502 // Cancel replies with a sentinel so the caller aborts silently; an unannotated
503 // schematic echoes the annotation message so the caller shows its own error
504 if( userCancelled )
506
507 return;
508 }
509 }
510
512
513 NETLIST_EXPORTER_KICAD exporter( &Schematic(), &Kiway() );
514 STRING_FORMATTER formatter;
515
516 exporter.Format( &formatter, GNL_ALL | GNL_OPT_KICAD );
517
518 RefreshConnectivity( true );
519 payload = formatter.GetString();
520 break;
521 }
522
524 {
525 KIID uuid( payload );
527
528 if( SCH_ITEM* item = m_schematic->ResolveItem( uuid, &path, true ) )
529 {
530 if( item->Type() == SCH_SHEET_T )
531 payload = static_cast<SCH_SHEET*>( item )->GetShownName( INTERNAL );
532 else if( item->Type() == SCH_SYMBOL_T )
533 payload = static_cast<SCH_SYMBOL*>( item )->GetRef( &path, true );
534 else
535 payload = item->GetFriendlyName();
536 }
537
538 break;
539 }
540
542 try
543 {
544 SCH_EDITOR_CONTROL* controlTool = m_toolManager->GetTool<SCH_EDITOR_CONTROL>();
545 controlTool->AssignFootprints( payload );
546 }
547 catch( const IO_ERROR& )
548 {
549 }
550 break;
551
552 case MAIL_SCH_REFRESH:
553 {
555
557 GetCanvas()->Refresh();
558 break;
559 }
560
562 {
563 std::optional<std::map<wxString, wxString>> footprints =
565 wxString::FromUTF8( payload ) );
566
567 if( footprints && LinkImportedFootprints( Schematic(), *footprints, WXLOG_REPORTER::GetInstance() ) > 0 )
568 OnModify();
569
570 break;
571 }
572
573 case MAIL_IMPORT_FILE:
574 {
575 // Extract file format type and path (plugin type, path and properties keys, values
576 // separated with \n)
577 std::stringstream ss( payload );
578 char delim = '\n';
579
580 std::string formatStr;
581 wxCHECK( std::getline( ss, formatStr, delim ), /* void */ );
582
583 std::string fnameStr;
584 wxCHECK( std::getline( ss, fnameStr, delim ), /* void */ );
585
586 int importFormat;
587
588 try
589 {
590 importFormat = std::stoi( formatStr );
591 }
592 catch( std::invalid_argument& )
593 {
594 wxFAIL;
595 importFormat = -1;
596 }
597
598 std::map<std::string, UTF8> props;
599
600 do
601 {
602 std::string key, value;
603
604 if( !std::getline( ss, key, delim ) )
605 break;
606
607 std::getline( ss, value, delim ); // We may want an empty string as value
608
609 props.emplace( key, value );
610
611 } while( true );
612
613 payload.clear();
614
615 if( importFormat < 0 || !importFile( fnameStr, importFormat, props.empty() ? nullptr : &props ) )
616 break;
617
618 if( importFormat == SCH_IO_MGR::SCH_ORCAD )
619 {
621 std::map<wxString, wxString> names;
622
623 if( map )
625
626 payload = TO_UTF8( IMPORT_PROJ_PROPS::JoinNetNameMap( names ) );
627 }
628 else
629 {
630 payload = "success";
631 }
632
633 break;
634 }
635
636 case MAIL_SCH_SAVE:
637 if( SaveProject() )
638 payload = "success";
639
640 break;
641
642 case MAIL_SCH_RELOAD:
643 {
644 // A git operation rewrote files on disk. Reload the schematic so the editor matches.
645 if( Schematic().GetFileName().IsEmpty() )
646 break;
647
648 SCH_SCREENS screens( Schematic().Root() );
649
650 // A payload lists the changed files. When none is a sheet of this schematic, the change
651 // belongs to another project and reloading would only cost this one its undo history.
652 if( !payload.empty() )
653 {
654 wxArrayString changed = wxSplit( wxString::FromUTF8( payload.c_str() ), '\n' );
655 bool mine = false;
656
657 for( SCH_SCREEN* screen = screens.GetFirst(); screen && !mine; screen = screens.GetNext() )
658 {
659 wxString screenFile = wxFileName( screen->GetFileName() ).GetFullPath();
660
661 for( const wxString& changedFile : changed )
662 {
663 if( !changedFile.IsEmpty() && screenFile == wxFileName( changedFile ).GetFullPath() )
664 {
665 mine = true;
666 break;
667 }
668 }
669 }
670
671 if( !mine )
672 break;
673 }
674
675 // Neither choice is safe without asking: reloading discards the unsaved edits, keeping
676 // them means the next save overwrites what arrived.
677 if( IsContentModified() )
678 {
679 wxMessageDialog dlg( this,
680 _( "The schematic changed on disk while you were editing it.\n\n"
681 "Reloading loses your unsaved edits. Keeping them means your "
682 "next save overwrites the changes that just arrived. To get those "
683 "back later, use Discard Changes on the file in the Version Control "
684 "panel, which drops your edits to it." ),
685 _( "Schematic Changed on Disk" ),
686 wxYES_NO | wxNO_DEFAULT | wxICON_WARNING | wxCENTER );
687 dlg.SetYesNoLabels( _( "&Reload" ), _( "&Keep My Edits" ) );
688
689 if( dlg.ShowModal() != wxID_YES )
690 break;
691 }
692
694 break;
695 }
696
697 case MAIL_SCH_UPDATE:
699 break;
700
702 // Net colors and widths resolve through per-net caches, and text variables at draw time,
703 // so both need a flush and a repaint.
707
709 GetCanvas()->Refresh();
710 break;
711
712 case MAIL_RELOAD_LIB:
713 {
714 if( m_designBlocksPane && m_designBlocksPane->IsShown() )
715 m_designBlocksPane->RefreshLibs();
716
717 // Show any symbol library load errors in the status bar
718 if( KISTATUSBAR* statusBar = dynamic_cast<KISTATUSBAR*>( GetStatusBar() ) )
719 {
721 statusBar->AddWarningMessages( "load", adapter->GetLibraryLoadErrors() );
722 }
723
724 break;
725 }
726
728 {
729 wxString targetFile( payload );
730
731 for( SCH_SHEET_PATH& sheetPath : m_schematic->Hierarchy() )
732 {
733 SCH_SCREEN* screen = sheetPath.LastScreen();
734
735 if( screen && screen->GetFileName() == targetFile )
736 {
737 m_toolManager->RunAction<SCH_SHEET_PATH*>( SCH_ACTIONS::changeSheet, &sheetPath );
738 payload = "success";
739 Raise();
740 return;
741 }
742 }
743
744 payload.clear();
745 break;
746 }
747
748 default:;
749
750 }
751}
const char * name
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
static TOOL_ACTION showSymbolLibTable
Definition actions.h:282
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:2475
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:499
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.
void ClearAllCaches()
Clears the effective netclass cache for all nets.
std::shared_ptr< NET_SETTINGS > & NetSettings()
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
void IncrementNetclassesTicker()
Definition project.h:115
virtual PROJECT_FILE & GetProjectFile() const
Definition project.h:201
void IncrementTextVarsTicker()
Definition project.h:112
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.
bool IsContentModified() const override
Get if the current schematic has been modified but not saved.
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
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.
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
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: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...
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:165
#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::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:737
@ 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_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:76
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 ...
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
@ 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