52 std::vector<PICKED_SYMBOL>& aHistoryList,
53 std::vector<PICKED_SYMBOL>& aAlreadyPlaced,
54 bool aShowFootprints,
const LIB_ID* aHighlight,
60 if( !dialogLock.try_lock() )
64 aAllowFields, aShowFootprints );
88 aHistoryList.insert( aHistoryList.begin(), sel );
104 const int currentUnit = aSymbol->
GetUnit();
106 if( unitCount <= 1 || currentUnit == aUnit )
109 if( aUnit > unitCount )
113 bool swapWithOther =
false;
121 wxString otherSheetName = otherSymbolRef->GetSheetPath().PathHumanReadable(
true,
true );
122 if( otherSheetName.IsEmpty() )
123 otherSheetName =
_(
"Root" );
126 wxString::Format(
_(
"Symbol unit '%s' is already placed (on sheet '%s')" ),
127 targetUnitName, otherSheetName );
129 KIDIALOG dlg(
this, msg,
_(
"Unit Already Placed" ), wxYES_NO | wxCANCEL | wxICON_WARNING );
131 wxString::Format(
_(
"&Swap '%s' and '%s'" ), targetUnitName, currUnitName ),
132 wxString::Format(
_(
"&Duplicate '%s'" ), targetUnitName ) );
137 if( ret == wxID_CANCEL )
140 if( ret == wxID_YES )
141 swapWithOther =
true;
147 wxASSERT( otherSymbolRef );
149 SCH_SYMBOL* otherSymbol = otherSymbolRef->GetSymbol();
152 commit.
Modify( otherSymbol, otherSymbolRef->GetSheetPath().LastScreen() );
155 otherSymbol->
SetUnitSelection( &otherSymbolRef->GetSheetPath(), currentUnit );
156 otherSymbol->
SetUnit( currentUnit );
166 if( !commit.
Empty() )
168 if(
eeconfig()->m_AutoplaceFields.enable )
176 commit.
Push(
_(
"Change Unit" ) );
193 msg.Printf(
_(
"No alternate body style found for symbol '%s' in library '%s'." ),
194 id.GetLibItemName().wx_str(),
195 id.GetLibNickname().wx_str() );
216 commit.
Push(
_(
"Change Body Style" ) );
228 if( aFunction == aPin->
GetName() )
229 aPin->
SetAlt( wxEmptyString );
231 aPin->
SetAlt( aFunction );
233 commit.
Push(
_(
"Set Pin Function" ) );
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Modify a given item in the model.
std::vector< std::pair< int, wxString > > GetFields() const
Get a list of fields edited by the user.
static std::mutex g_Mutex
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
A base class for most all the KiCad significant classes used in schematics and boards.
EDA_ITEM_FLAGS GetEditFlags() const
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
void DoNotShowCheckbox(wxString file, int line)
Shows the 'do not show again' checkbox.
A logical library item identifier and consists of various portions much like a URI.
bool IsValid() const
Check if this LID_ID is valid.
Define a library symbol object.
wxString GetUnitDisplayName(int aUnit) override
Return the user-defined display name for aUnit for symbols with units.
int GetUnitCount() const override
PICKED_SYMBOL PickSymbolFromLibrary(const SYMBOL_LIBRARY_FILTER *aFilter, std::vector< PICKED_SYMBOL > &aHistoryList, std::vector< PICKED_SYMBOL > &aAlreadyPlaced, bool aShowFootprints, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
Call the library viewer to select symbol to import into schematic.
EESCHEMA_SETTINGS * eeconfig() const
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetAltPinFunction(SCH_PIN *aPin, const wxString &aFunction)
SCH_SHEET_PATH & GetCurrentSheet() const
void FlipBodyStyle(SCH_SYMBOL *aSymbol)
void SelectUnit(SCH_SYMBOL *aSymbol, int aUnit)
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
virtual void SetUnit(int aUnit)
AUTOPLACE_ALGO GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
void SetAlt(const wxString &aAlt)
const wxString & GetName() const
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
Automatically orient all the fields in the symbol.
void SetBodyStyle(int aBodyStyle) override
const LIB_ID & GetLibId() const override
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
Helper object to filter a list of libraries.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
This file is part of the common library.
This file is part of the common library.
void delete_if(_Container &__c, _Function &&__f)
Deletes all values from __c for which __f returns true.
std::vector< std::pair< int, wxString > > Fields
Definition for symbol library class.