22#include <wx/tokenzr.h>
24#include <api/common/commands/cross_probe_commands.pb.h>
65 const wxString& aSearchText )
73 if( !aSearchHierarchy )
74 sheetList.push_back(
m_frame->GetCurrentSheet() );
76 sheetList =
m_frame->Schematic().Hierarchy();
92 found = ( *aPath ==
path );
96 found = ( aReference && aReference->CmpNoCase( candidate->
GetRef( &sheet ) ) == 0 );
102 sheetWithSymbolFound = &sheet;
112 m_frame->Schematic().GetCurrentVariant() );
117 int unit =
pin->GetLibPin()->GetUnit();
146 if( *sheetWithSymbolFound !=
m_frame->GetCurrentSheet() )
149 sheetWithSymbolFound );
164 m_frame->FocusOnItem( symbol );
173 displayRef = *aReference;
182 msg.Printf(
_(
"%s pin %s found" ), displayRef, aSearchText );
184 msg.Printf(
_(
"%s found but pin %s not found" ), displayRef, aSearchText );
188 msg.Printf(
_(
"%s found" ), displayRef );
193 msg.Printf(
_(
"%s not found" ), displayRef );
197 m_frame->GetCanvas()->Refresh();
231 strncpy( line, cmdline,
sizeof( line ) - 1 );
232 line[
sizeof( line ) - 1 ] =
'\0';
234 char* idcmd = strtok( line,
" \n\r" );
235 char*
text = strtok(
nullptr,
"\"\n\r" );
237 if( idcmd ==
nullptr )
242 if( strcmp( idcmd,
"$CONFIG" ) == 0 )
247 else if( strcmp( idcmd,
"$ERC" ) == 0 )
252 else if( strcmp( idcmd,
"$NET:" ) == 0 )
260 else if( strcmp( idcmd,
"$CLEAR:" ) == 0 )
269 if(
text ==
nullptr )
272 if( strcmp( idcmd,
"$PART:" ) != 0 )
278 idcmd = strtok(
nullptr,
" \n\r" );
280 if( idcmd ==
nullptr )
287 text = strtok(
nullptr,
"\"\n\r" );
289 if(
text ==
nullptr )
294 if( strcmp( idcmd,
"$REF:" ) == 0 )
300 else if( strcmp( idcmd,
"$VAL:" ) == 0 )
306 else if( strcmp( idcmd,
"$PAD:" ) == 0 )
334 kiapi::common::commands::SyncSelection sync;
338 switch( item->Type() )
343 kiapi::common::commands::SelectionSpec* spec = sync.add_items();
353 path.push_back( item->m_Uuid );
355 kiapi::common::commands::SelectionSpec* spec = sync.add_items();
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() );
385 if( sync.items_size() == 0 )
388 sync.set_context( aForce ? commands::SyncSelectionContext::SSC_EXPLICIT
389 : commands::SyncSelectionContext::SSC_IMPLICIT );
421 kiapi::common::commands::HighlightNets
message;
423 message.add_net_name( aNetName.ToUTF8() );
438 kiapi::common::commands::HighlightNets
message;
440 for(
const wxString&
name : names )
461 std::stringstream ss( payload );
465 std::string srcProjDir;
466 std::getline( ss, srcProjDir,
'\n' );
468 std::vector<wxString> libraries;
470 while( std::getline( ss, file,
'\n' ) )
471 libraries.push_back( wxString::FromUTF8( file ) );
486 if( ApiRequest request; request.ParseFromString( payload.c_str() ) )
493 if( !payload.empty() )
495 wxString annotationMessage( payload );
498 bool userCancelled =
false;
525 KIID uuid( payload );
533 payload =
static_cast<SCH_SYMBOL*
>( item )->GetRef( &
path,
true );
535 payload = item->GetFriendlyName();
563 std::optional<std::map<wxString, wxString>> footprints =
565 wxString::FromUTF8( payload ) );
577 std::stringstream ss( payload );
580 std::string formatStr;
581 wxCHECK( std::getline( ss, formatStr, delim ), );
583 std::string fnameStr;
584 wxCHECK( std::getline( ss, fnameStr, delim ), );
590 importFormat = std::stoi( formatStr );
592 catch( std::invalid_argument& )
598 std::map<std::string, UTF8> props;
602 std::string key, value;
604 if( !std::getline( ss, key, delim ) )
607 std::getline( ss, value, delim );
609 props.emplace( key, value );
615 if( importFormat < 0 || !
importFile( fnameStr, importFormat, props.empty() ?
nullptr : &props ) )
618 if( importFormat == SCH_IO_MGR::SCH_ORCAD )
621 std::map<wxString, wxString> names;
645 if(
Schematic().GetFileName().IsEmpty() )
652 if( !payload.empty() )
654 wxArrayString changed = wxSplit( wxString::FromUTF8( payload.c_str() ),
'\n' );
659 wxString screenFile = wxFileName( screen->GetFileName() ).GetFullPath();
661 for(
const wxString& changedFile : changed )
663 if( !changedFile.IsEmpty() && screenFile == wxFileName( changedFile ).GetFullPath() )
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" ) );
689 if( dlg.ShowModal() != wxID_YES )
729 wxString targetFile( payload );
735 if( screen && screen->
GetFileName() == targetFile )
static TOOL_ACTION showSymbolLibTable
static TOOL_ACTION updateSchematicFromPcb
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.
EE_TYPE OfType(KICAD_T aType) const
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.
wxString AsString() const
KISTATUSBAR is a wxStatusBar suitable for Kicad manager.
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.
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
MAIL_T Command()
Returns the MAIL_T associated with this mail.
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr, bool aFromOtherThread=false)
Send aPayload to aDestination from aSource.
std::vector< KI_ERROR > GetLibraryLoadErrors() const
Returns all library load errors as newline-separated strings for display.
static LOAD_INFO_REPORTER & GetInstance()
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()
virtual PROJECT_FILE & GetProjectFile() const
void IncrementTextVarsTicker()
const IMPORT_NET_MAP * GetImportNetMap() const
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.
Base class for any item which can be embedded within the SCHEMATIC container class,...
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.
EE_RTREE & Items()
Get the full RTree, usually for iterating.
const wxString & GetFileName() const
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.
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.
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.
virtual const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const =0
static REPORTER & GetInstance()
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static void sendHighlightNets(SCH_EDIT_FRAME *aFrame, const kiapi::common::commands::HighlightNets &aMessage)
@ FRAME_SCH_SYMBOL_EDITOR
static wxString From_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
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.
@ MAIL_SCH_LINK_FOOTPRINTS
@ MAIL_SCH_PROJECT_SETTINGS_CHANGED
@ MAIL_SCH_NAVIGATE_TO_SHEET
#define MAIL_SCH_GET_NETLIST_CANCELLED
Reply payload for MAIL_SCH_GET_NETLIST when the user deliberately aborts netlist generation (for exam...
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.
KICOMMON_API void PackSheetPath(types::SheetPath &aOutput, const KIID_PATH &aInput)
KICOMMON_API bool PackKiwayApiMessage(const google::protobuf::Message &aMessage, std::string &aBytes)
SCH_SEARCH_T
Schematic search type used by the socket link with Pcbnew.
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 ...
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.
@ REFERENCE
Field Reference of part, i.e. "IC21".
const SHAPE_LINE_CHAIN chain
wxLogTrace helper definitions.