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 )
171 commit.
Push(
_(
"Change Unit" ) );
188 msg.Printf(
_(
"No alternate body style found for symbol '%s' in library '%s'." ),
189 id.GetLibItemName().wx_str(),
190 id.GetLibNickname().wx_str() );
211 commit.
Push(
_(
"Change Body Style" ) );
223 if( aFunction == aPin->
GetName() )
224 aPin->
SetAlt( wxEmptyString );
226 aPin->
SetAlt( aFunction );
228 commit.
Push(
_(
"Set Pin Function" ) );
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
bool Empty() const
Returns status of an item.
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)
Checks the 'do not show again' setting for the dialog.
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
Revert the commit by restoring the modified items state.
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)
void AutoAutoplaceFields(SCH_SCREEN *aScreen)
Autoplace fields only if correct to do so automatically.
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 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.