45 const wxString& aSearchText )
54 if( !aSearchHierarchy )
65 SCH_SYMBOL* candidate = static_cast<SCH_SYMBOL*>( item );
73 found = ( *aPath ==
path );
77 found = ( aReference && aReference->CmpNoCase( candidate->
GetRef( &sheet ) ) == 0 );
83 sheetWithSymbolFound = &sheet;
94 int unit =
pin->GetLibPin()->GetUnit();
96 if( unit != 0 && unit != symbol->
GetUnit() )
103 pos =
pin->GetPosition();
153 double compRatio = bbSize.y / currTextHeight;
154 double compRatioBent = 1.0;
162 std::vector<std::pair<double, double>> lut
174 std::vector<std::pair<double, double>>::iterator it;
177 compRatioBent = lut.back().second;
182 if( compRatio >= lut.front().first )
184 for( it = lut.begin(); it < lut.end() - 1; it++ )
186 if( it->first <= compRatio &&
next( it )->first >= compRatio )
189 double diffx = compRatio - it->first;
190 double diffn =
next( it )->first - it->first;
192 compRatioBent = it->second
193 + (
next( it )->second - it->second ) * diffx / diffn;
200 compRatioBent = lut.front().second;
210 screenSize.
x = std::max( 10.0, screenSize.
x );
211 screenSize.
y = std::max( 10.0, screenSize.
y );
212 double ratio = std::max( -1.0, fabs( bbSize.y / screenSize.
y ) );
215 double kicadRatio = std::max( fabs( bbSize.x / screenSize.
x ),
216 fabs( bbSize.y / screenSize.
y ) );
221 if( bbSize.x > screenSize.
x * ratio * compRatioBent )
226 wxLogTrace(
"CROSS_PROBE_SCALE",
227 wxT(
"Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f" ),
233 ratio *= compRatioBent;
235 bool alwaysZoom =
false;
238 if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom )
251 displayRef = *aReference;
260 msg.Printf(
_(
"%s pin %s found" ), displayRef, aSearchText );
262 msg.Printf(
_(
"%s found but pin %s not found" ), displayRef, aSearchText );
266 msg.Printf(
_(
"%s found" ), displayRef );
271 msg.Printf(
_(
"%s not found" ), displayRef );
299 strncpy( line, cmdline,
sizeof( line ) - 1 );
300 line[
sizeof( line ) - 1 ] =
'\0';
302 char* idcmd = strtok( line,
" \n\r" );
303 char*
text = strtok(
nullptr,
"\"\n\r" );
305 if( idcmd ==
nullptr )
310 if( strcmp( idcmd,
"$NET:" ) == 0 )
317 if(
auto sg =
Schematic().ConnectionGraph()->FindFirstSubgraphByName( netName ) )
324 SetStatusText(
_(
"Selected net:" ) + wxS(
" " ) +
UnescapeString( netName ) );
328 if( strcmp( idcmd,
"$CLEAR:" ) == 0 )
334 if(
text ==
nullptr )
337 if( strcmp( idcmd,
"$PART:" ) != 0 )
343 idcmd = strtok(
nullptr,
" \n\r" );
345 if( idcmd ==
nullptr )
352 text = strtok(
nullptr,
"\"\n\r" );
354 if(
text ==
nullptr )
359 if( strcmp( idcmd,
"$REF:" ) == 0 )
365 else if( strcmp( idcmd,
"$VAL:" ) == 0 )
371 else if( strcmp( idcmd,
"$PAD:" ) == 0 )
388 switch( aItem->
Type() )
416 aSymbol =
pin->GetParentSymbol();
418 if( !
pin->GetShownNumber().IsEmpty() )
420 return StrPrintf(
"$PIN: \"%s\" $PART: \"%s\"",
441 wxASSERT( aObjectToSync );
448 if( !packet.empty() )
471 if( !packet.empty() )
496 if( aConnection->
IsNet() )
502 if( aConnection->
Members().empty() )
507 wxString nets = all_members[0]->Name();
509 if( all_members.size() == 1 )
519 for(
size_t i = 1; i < all_members.size(); i++ )
520 nets <<
"," << all_members[i]->Name();
524 if( !packet.empty() )
541 std::string packet =
"$CLEAR\n";
569 if( !payload.empty() )
571 wxString annotationMessage( payload );
619 for(
const wxString&
name :
Schematic().GetNetClassAssignmentCandidates() )
625 for(
const wxString& member : *ii.second )
637 if( ii.second ==
"Default" )
643 netclass->Add( ii.first );
651 size_t split = payload.find(
'\n' );
652 wxCHECK(
split != std::string::npos, );
657 importFormat = std::stoi( payload.substr( 0,
split ) );
659 catch( std::invalid_argument& )
665 std::string
path = payload.substr(
split + 1 );
666 wxASSERT( !
path.empty() );
668 if( importFormat >= 0 )
Field Reference of part, i.e. "IC21".
bool ReadyToNetlist(const wxString &aAnnotateMessage)
Check if we are ready to write a netlist file for the current schematic.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
EE_TYPE OfType(KICAD_T aType) const
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
std::map< wxString, wxString > m_NetClassAssignments
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
NETCLASSPTR Find(const wxString &aName) const
Search this container for a NETCLASS given by aName.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
void SendCrossProbeNetName(const wxString &aNetName)
Sends a net name to Pcbnew for highlighting.
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
virtual PROJECT_FILE & GetProjectFile() const
void SendCrossProbeClearHighlight()
Tell Pcbnew to clear the existing highlighted net, if one exists.
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
bool SendCommand(int aService, const std::string &aMessage)
Used by a client to sent (by a socket connection) a data to a server.
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.
wxString AsString() const
NET_SETTINGS & NetSettings()
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
wxString PathAsString() const
Return the path of time stamps which do not changes even when editing sheet parameters.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
void DisplayCurrentSheet()
Draw the current sheet on the display.
void Format(OUTPUTFORMATTER *aOutputFormatter, int aCtl)
Output this s-expression netlist into aOutputFormatter.
static TOOL_ACTION updateNetHighlighting
bool importFile(const wxString &aFileName, int aFileType)
Load the given filename but sets the path to the current project path.
bool SaveProject(bool aSaveAs=false)
Save the currently-open schematic (including its hierarchy) and associated project.
EESCHEMA_SETTINGS * eeconfig() const
int StrPrintf(std::string *result, const char *format,...)
This is like sprintf() but the output is appended to a std::string instead of to a character array.
Handle actions specific to the schematic editor.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
static TOOL_ACTION updateSchematicFromPcb
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
wxString Name(bool aIgnoreSheet=false) const
const std::vector< std::shared_ptr< SCH_CONNECTION > > AllMembers() const
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Generate the KiCad netlist format supported by Pcbnew.
SCHEMATIC & Schematic() const
void KiwayMailIn(KIWAY_EXPRESS &aEvent) override
Receive KIWAY_EXPRESS messages from other players.
NET_SETTINGS stores various net-related settings in a project context.
static TOOL_ACTION clearSelection
Clears the current selection.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
std::string FormatProbeItem(const SCH_SHEET_PATH &aCurrentSheet, EDA_ITEM *aItem, SCH_SYMBOL *aSymbol)
wxString UnescapeString(const wxString &aSource)
bool zoom_to_fit
Zoom to fit items (ignored if center_on_items is off)
const SCH_CONNECTION * m_highlightedConn
The highlighted net or bus, or nullptr.
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
static bool m_allowRealTime
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
bool auto_highlight
Automatically turn on highlight mode in the target frame.
SCH_SEARCH_T
Schematic search type used by the socket link with Pcbnew.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
Handle the component boundary box.
void SetCrossProbeConnection(const SCH_CONNECTION *aConnection)
Send a connection (net or bus) to Pcbnew for highlighting.
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
wxPoint GetPosition() const override
A base class for most all the KiCad significant classes used in schematics and boards.
void ExecuteRemoteCommand(const char *cmdline) override
Execute a remote command sent by Pcbnew via a socket connection.
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()
void AssignFootprints(const std::string &aChangedSetOfReferences)
SCH_SHEET_PATH & GetCurrentSheet() const
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void FocusOnItem(SCH_ITEM *aItem)
void SendMessageToPCBNEW(EDA_ITEM *aObjectToSync, SCH_SYMBOL *aPart)
Send a message to Pcbnew via a socket connection.
const Vec & GetSize() const
CROSS_PROBING_SETTINGS m_CrossProbing
MAIL_T Command()
Returns the MAIL_T associated with this mail.
bool center_on_items
Automatically pan to cross-probed items.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Base class for any item which can be embedded within the SCHEMATIC container class,...
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
virtual const wxString & GetText() const
Return the string associated with the text object.
bool IsSingle() const
Is this KIFACE running under single_top?
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
KICAD_T Type() const
Returns the type of object.
static std::vector< std::string > split(const std::string &aStr, const std::string &aDelim)
Split the input string into a vector of output strings.