139 auto netlistCallback = [
this]()
153 return std::string(
"" );
158 return std::string(
"" );
160 wxString symbolNetlist;
164 pins.push_back(
pin->GetNumber() +
' ' +
pin->GetShownName() );
166 if( !pins.IsEmpty() )
169 symbolNetlist << wxS(
"\r" );
173 if( !fpFilters.IsEmpty() )
176 symbolNetlist << wxS(
"\r" );
178 return symbolNetlist.ToStdString();
234 aFallbackSelection.
Clear();
236 return aFallbackSelection;
249 return selection.
Empty() ? nullptr : selection.
Front();
299 else if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } ) )
370 colorProp->SetBackgroundColor( bg );
391 wxCHECK_MSG( firstItem,
nullptr, wxT(
"getPropertyFromEvent for a property with nothing selected!") );
394 wxCHECK_MSG( property,
nullptr, wxT(
"getPropertyFromEvent for a property not found on the selected item!" ) );
412 wxVariant newValue = aEvent.GetPropertyValue();
414 if(
VALIDATOR_RESULT validationFailure = property->Validate( newValue.GetAny(), frontItem ) )
416 wxString errorMsg = wxString::Format( wxS(
"%s: %s" ), wxGetTranslation( property->Name() ),
417 validationFailure->get()->Format(
m_frame ) );
418 m_frame->ShowInfoBarError( errorMsg );
438 wxVariant newValue = aEvent.GetPropertyValue();
444 for(
EDA_ITEM* edaItem : selection )
446 if( !edaItem->IsSCH_ITEM() )
451 wxCHECK2( property,
continue );
457 && property->Name() == wxT(
"Text" ) )
460 wxCHECK2( symbol,
continue );
472 && property->Name() == wxT(
"Text" ) )
481 if( !variantName.IsEmpty() )
494 && property->Name() == wxT(
"Text" ) )
518 item->
Set( property, newValue );
522 symbol->SyncOtherUnits( symbol->Schematic()->CurrentSheet(), changes, property,
523 symbol->Schematic()->GetCurrentVariant() );
527 changes.
Push(
_(
"Edit Properties" ) );
531 for(
EDA_ITEM* edaItem : selection )
532 m_frame->UpdateItem( edaItem );
543 const wxString& aNewFilename )
549 DisplayError( aFrame,
_(
"A sheet must have a valid file name." ) );
554 newFilename.Replace( wxT(
"\\" ), wxT(
"/" ) );
557 oldFilename.Replace( wxT(
"\\" ), wxT(
"/" ) );
559 if( newFilename == oldFilename )
585 if( prop->
Group() ==
_HKI(
"Custom Properties" ) )
610 return m_propMgr.GetProperty( item, aName ) !=
nullptr;
623 for(
EDA_ITEM* edaItem : selection )
625 if( !edaItem->IsSCH_ITEM() )
629 bool renamed =
false;
667 changes.
Push(
_(
"Rename Property" ) );
675 if( aPGProp->IsCategory() )
677 if( aPGProp->GetLabel() == wxGetTranslation(
_HKI(
"Fields" ) ) )
679 else if( aPGProp->GetLabel() == wxGetTranslation(
_HKI(
"Custom Properties" ) ) )
696 else if( prop->
Group() ==
_HKI(
"Custom Properties" ) )
703 return aMenu.GetMenuItemCount() > 0;
709 switch( aEvent.GetId() )
727 if( selection.
Empty() )
732 for(
int n = 0; ; ++n )
753 for(
EDA_ITEM* edaItem : selection )
755 if( !edaItem->IsSCH_ITEM() )
780 changes.
Push(
_(
"Add Field" ) );
796 if( selection.
Empty() )
801 for(
int n = 0; ; ++n )
803 name = wxString::Format( wxS(
"Property%d" ), n );
823 for(
EDA_ITEM* edaItem : selection )
825 if( !edaItem->IsSCH_ITEM() )
834 changes.
Push(
_(
"Add Custom Property" ) );
852 for(
EDA_ITEM* edaItem : selection )
854 if( !edaItem->IsSCH_ITEM() )
875 for(
auto it = fields.begin(); it != fields.end(); ++it )
877 if( !it->IsMandatory() && it->GetName() == aName )
887 changes.
Push(
_(
"Remove Field" ) );
901 for(
EDA_ITEM* edaItem : selection )
903 if( !edaItem->IsSCH_ITEM() )
912 changes.
Push(
_(
"Remove Custom Property" ) );
946 && aProperty->
Name() == wxT(
"Text" ) )
955 if( !variantName.IsEmpty() )
958 aValue = wxVariant(
text );
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Dialog used to edit SCH_SYMBOL objects in a schematic.
void SelectPinMapPage()
Select the Pin Map page so the dialog opens directly on the pin-to-pad mapping editor (issue #2282).
A base class for most all the KiCad significant classes used in schematics and boards.
bool GetCustomProperty(const wxString &aKey, wxString &aValue) const
void RemoveCustomProperty(const wxString &aKey)
KICAD_T Type() const
Returns the type of object.
EDA_ITEM * GetParent() const
void SetCustomProperty(const wxString &aKey, const wxString &aValue)
virtual void SetVisible(bool aVisible)
Class that other classes need to inherit from, in order to be inspectable.
bool Set(PROPERTY_BASE *aProperty, wxAny &aValue, bool aNotify=true)
A color representation with 4 components: red, green, blue, alpha.
Define a library symbol object.
std::vector< const SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
wxArrayString GetFPFilters() const
static const wxString EDITOR_NAME
static const wxString EDITOR_NAME
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
wxString m_contextMenuPropertyName
PROPERTIES_PANEL(wxWindow *aParent, EDA_BASE_FRAME *aFrame)
void beginLabelEdit(const wxString &aKey, bool aStartBlank=false)
void settlePendingLabelEdit()
Synchronously ends any in-progress label edit; potentially canceling a newly added row.
int m_SuppressGridChangeEvents
virtual void OnLanguageChanged(wxCommandEvent &aEvent)
virtual bool getItemValue(EDA_ITEM *aItem, PROPERTY_BASE *aProperty, wxVariant &aValue)
Utility to fetch a property value and convert to wxVariant Precondition: aItem is known to have prope...
virtual void rebuildProperties(const SELECTION &aSelection)
Generates the property grid for a given selection of items.
void addCategoryButton(const wxString &aGroupKey, const wxString &aTooltip, BITMAPS aBitmap, std::function< void()> aAction, std::function< bool()> aEnableFunc=nullptr, bool aForceCategory=false)
Registers an overlay button on a category caption row.
wxString m_pendingNewKey
Key of a freshly-added blank field/custom property awaiting a name from the user.
const wxString & Name() const
Provide class metadata.Helper macro to map type hashes to names.
wxString GetCurrentVariant() const
Return the current variant being edited.
SCH_SHEET_PATH & CurrentSheet() const
static TOOL_ACTION clearVariantSymbol
static TOOL_ACTION setVariantSymbol
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Schematic editor (Eeschema) main window.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
SCH_SHEET_PATH & GetCurrentSheet() const
bool ChangeSheetFile(SCH_SHEET *aSheet, const wxString &aNewFilename, bool *aClearAnnotationNewItems=nullptr, bool *aIsUndoable=nullptr, const wxString *aSourceSheetFilename=nullptr)
Change the file backing a schematic sheet.
virtual const wxString & GetText() const override
Return the string associated with the text object.
void SetName(const wxString &aName)
void SetText(const wxString &aText) override
Base class for any item which can be embedded within the SCHEMATIC container class,...
const SYMBOL * GetParentSymbol() const
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
bool getItemValue(EDA_ITEM *aItem, PROPERTY_BASE *aProperty, wxVariant &aValue) override
Utility to fetch a property value and convert to wxVariant Precondition: aItem is known to have prope...
void onContextMenu(wxCommandEvent &aEvent)
bool buildContextMenu(wxMenu &aMenu, wxPGProperty *aPGProp) override
bool isKeyEditable(const wxPGProperty *aPGProp) const override
wxPGProperty * createPGProperty(const PROPERTY_BASE *aProperty) const override
PROPERTY_MANAGER & m_propMgr
void removeCustomProperty(const wxString &aName)
PG_CHECKBOX_EDITOR * m_checkboxEditorInstance
PG_FPID_EDITOR * m_fpEditorInstance
static bool m_selContainsJunctions
const SELECTION & getSelection(SELECTION &aFallbackSelection)
Get the current selection from the selection tool.
void UpdateData() override
void onEditPinMap()
Open the symbol properties dialog on its Pin Map page for the single selected symbol (issue #2282).
void valueChanging(wxPropertyGridEvent &aEvent) override
PG_UNIT_EDITOR * m_unitEditorInstance
bool isKeyNameInUse(const wxString &aName) const override
void AfterCommit() override
void removeField(const wxString &aName)
void valueChanged(wxPropertyGridEvent &aEvent) override
void onKeyRenamed(const wxString &aOldName, const wxString &aNewName) override
SCH_PROPERTIES_PANEL(wxWindow *aParent, SCH_BASE_FRAME *aFrame)
void onNewItemLeftBlank(const wxString &aKey) override
PG_COLOR_EDITOR * m_colorEditorInstance
EDA_ITEM * getFrontItem()
Get the front item of the current selection.
void addBlankCustomProperty()
PROPERTY_BASE * getPropertyFromEvent(const wxPropertyGridEvent &aEvent) const
void OnLanguageChanged(wxCommandEvent &aEvent) override
virtual ~SCH_PROPERTIES_PANEL()
bool handleSheetFilenameChange(SCH_EDIT_FRAME *aFrame, SCH_SHEET *aSheet, SCH_COMMIT &aChanges, const wxString &aNewFilename)
static bool m_selContainsWiresOrBuses
void rebuildProperties(const SELECTION &aSelection) override
Generates the property grid for a given selection of items.
PG_URL_EDITOR * m_urlEditorInstance
SCH_SYMBOL * getSinglePinMappedSymbol()
SCH_SCREEN * LastScreen()
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void SetFileName(const wxString &aFilename)
wxString GetFileName() const
Return the filename corresponding to this sheet.
std::vector< SCH_FIELD > & GetFields()
Return a reference to the vector holding the sheet's fields.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a @aField to the list of fields.
void SetRefProp(const wxString &aRef)
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
void SyncOtherUnits(const SCH_SHEET_PATH &aSourceSheet, SCH_COMMIT &aCommit, PROPERTY_BASE *aProperty, const wxString &aVariantName=wxEmptyString)
Keep fields other than the reference, include/exclude flags, and alternate pin assignments in sync in...
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
bool HasEffectiveAssociatedFootprint() const
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
virtual void Add(EDA_ITEM *aItem)
A null aItem is ignored; the selection never holds null members.
virtual void Clear() override
Remove all the stored items from the group.
int Size() const
Returns the number of selected parts.
bool Empty() const
Checks if there is anything selected.
The symbol library editor main window.
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
@ SYMBOL_PROPS_WANT_SET_VARIANT_SYMBOL
@ SYMBOL_PROPS_WANT_CLEAR_VARIANT_SYMBOL
@ FRAME_SCH_SYMBOL_EDITOR
static const std::string KiCadSchematicFileExtension
@ LAYER_SCHEMATIC_BACKGROUND
wxPGProperty * PGPropertyFactory(const PROPERTY_BASE *aProperty, EDA_DRAW_FRAME *aFrame)
Customized abstract wxPGProperty class to handle coordinate/size units.
APIIMPORT wxPGGlobalVarsClass * wxPGGlobalVars
@ ID_CTX_REMOVE_CUSTOM_PROPERTY
@ ID_CTX_ADD_CUSTOM_PROPERTY
std::optional< std::unique_ptr< VALIDATION_ERROR > > VALIDATOR_RESULT
Null optional means validation succeeded.
std::vector< FAB_LAYER_COLOR > dummy
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
bool IsFullFileNameValid(const wxString &aFullFilename)
Checks if a full filename is valid, i.e.
wxString GetUserFieldName(int aFieldNdx, TRANSLATION aTranslation)
wxString GetDefaultFieldName(FIELD_T aFieldId, TRANSLATION aTranslation)
Return a default symbol field name for a mandatory field type.
@ USER
The field ID hasn't been set yet; field is invalid.
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
Definition of file extensions used in Kicad.