140 auto netlistCallback = [
this]()
154 return std::string(
"" );
159 return std::string(
"" );
161 wxString symbolNetlist;
165 pins.push_back(
pin->GetNumber() +
' ' +
pin->GetShownName() );
167 if( !pins.IsEmpty() )
170 symbolNetlist << wxS(
"\r" );
174 if( !fpFilters.IsEmpty() )
177 symbolNetlist << wxS(
"\r" );
179 return symbolNetlist.ToStdString();
235 aFallbackSelection.
Clear();
237 return aFallbackSelection;
250 return selection.
Empty() ? nullptr : selection.
Front();
300 else if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } ) )
371 colorProp->SetBackgroundColor( bg );
392 wxCHECK_MSG( firstItem,
nullptr, wxT(
"getPropertyFromEvent for a property with nothing selected!") );
395 wxCHECK_MSG( property,
nullptr, wxT(
"getPropertyFromEvent for a property not found on the selected item!" ) );
411 wxVariant newValue = aEvent.GetPropertyValue();
423 if(
VALIDATOR_RESULT validationFailure = property->Validate( newValue.GetAny(), item ) )
425 errorMsg = wxString::Format( wxS(
"%s: %s" ), wxGetTranslation( property->Name() ),
426 validationFailure->get()->Format(
m_frame ) );
434 else if(
SCH_SYMBOL* symbol = field ?
dynamic_cast<SCH_SYMBOL*
>( field->GetParentSymbol() ) :
nullptr;
436 && property->Name() == wxS(
"Text" ) )
439 errorMsg = symbol->BaseRefFromUser( symbol->Schematic()->CurrentSheet(), newValue.GetString(), base );
442 if( !errorMsg.IsEmpty() )
444 m_frame->ShowInfoBarError( errorMsg );
465 wxVariant newValue = aEvent.GetPropertyValue();
471 for(
EDA_ITEM* edaItem : selection )
473 if( !edaItem->IsSCH_ITEM() )
478 wxCHECK2( property,
continue );
484 && property->Name() == wxT(
"Text" ) )
487 wxCHECK2( symbol,
continue );
499 && property->Name() == wxT(
"Text" ) )
508 if( !variantName.IsEmpty() )
521 && property->Name() == wxT(
"Text" ) )
545 item->
Set( property, newValue );
549 symbol->SyncOtherUnits( symbol->Schematic()->CurrentSheet(), changes, property,
550 symbol->Schematic()->GetCurrentVariant() );
554 changes.
Push(
_(
"Edit Properties" ) );
558 for(
EDA_ITEM* edaItem : selection )
559 m_frame->UpdateItem( edaItem );
570 const wxString& aNewFilename )
576 DisplayError( aFrame,
_(
"A sheet must have a valid file name." ) );
581 newFilename.Replace( wxT(
"\\" ), wxT(
"/" ) );
584 oldFilename.Replace( wxT(
"\\" ), wxT(
"/" ) );
586 if( newFilename == oldFilename )
612 if( prop->
Group() ==
_HKI(
"Custom Properties" ) )
637 return m_propMgr.GetProperty( item, aName ) !=
nullptr;
649 for(
EDA_ITEM* edaItem : selection )
654 const SCH_FIELD* field = std::as_const( *
static_cast<SCH_SHEET*
>( edaItem ) ).GetField( aOldName );
663 m_frame->ShowInfoBarError( msg );
674 for(
EDA_ITEM* edaItem : selection )
676 if( !edaItem->IsSCH_ITEM() )
680 bool renamed =
false;
718 changes.
Push(
_(
"Rename Property" ) );
726 if( aPGProp->IsCategory() )
728 if( aPGProp->GetLabel() == wxGetTranslation(
_HKI(
"Fields" ) ) )
730 else if( aPGProp->GetLabel() == wxGetTranslation(
_HKI(
"Custom Properties" ) ) )
747 else if( prop->
Group() ==
_HKI(
"Custom Properties" ) )
754 return aMenu.GetMenuItemCount() > 0;
760 switch( aEvent.GetId() )
778 if( selection.
Empty() )
783 for(
int n = 0; ; ++n )
804 for(
EDA_ITEM* edaItem : selection )
806 if( !edaItem->IsSCH_ITEM() )
827 changes.
Push(
_(
"Add Field" ) );
843 if( selection.
Empty() )
848 for(
int n = 0; ; ++n )
850 name = wxString::Format( wxS(
"Property%d" ), n );
870 for(
EDA_ITEM* edaItem : selection )
872 if( !edaItem->IsSCH_ITEM() )
881 changes.
Push(
_(
"Add Custom Property" ) );
899 for(
EDA_ITEM* edaItem : selection )
901 if( !edaItem->IsSCH_ITEM() )
922 for(
auto it = fields.begin(); it != fields.end(); ++it )
924 if( !it->IsMandatory() && it->GetName() == aName )
934 changes.
Push(
_(
"Remove Field" ) );
948 for(
EDA_ITEM* edaItem : selection )
950 if( !edaItem->IsSCH_ITEM() )
959 changes.
Push(
_(
"Remove Custom Property" ) );
993 && aProperty->
Name() == wxT(
"Text" ) )
1002 if( !variantName.IsEmpty() )
1005 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.
wxArrayString GetFPFilters() const
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const override
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
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
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,...
Commit for the schematic and symbol editors.
void Push(const wxString &aMessage=wxEmptyString, 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 aFieldName 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)
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".
@ SHEET_REF_SUFFIX
Optional sheet field appended to the references of the sheet's symbols.
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
wxString GetFieldValidationErrorMessage(FIELD_T aFieldId, const wxString &aValue)
Return the error message if aValue is invalid for aFieldId.
Custom text control validator definitions.
Definition of file extensions used in Kicad.