52 std::vector<PICKED_SYMBOL>& aHistoryList,
53 std::vector<PICKED_SYMBOL>& aAlreadyPlaced,
54 bool aShowFootprints,
const LIB_ID* aHighlight,
60 if( !dialogLock.try_lock() )
63 bool aCancelled =
false;
66 aAllowFields, aShowFootprints, aCancelled );
68 if( aCancelled || dlg.
ShowModal() == wxID_CANCEL )
90 aHistoryList.insert( aHistoryList.begin(), sel );
108 const int currentUnit = aSymbol->
GetUnit();
110 if( unitCount <= 1 || currentUnit == aUnit )
113 if( aUnit > unitCount )
117 bool swapWithOther =
false;
119 aSymbol->
GetRef( &sheetPath,
false ),
126 wxString otherSheetName = otherSymbolRef->GetSheetPath().PathHumanReadable(
true,
true );
128 if( otherSheetName.IsEmpty() )
129 otherSheetName =
_(
"Root" );
131 const wxString msg = wxString::Format(
_(
"Symbol unit '%s' is already placed (on sheet '%s')" ),
132 targetUnitName, otherSheetName );
134 KIDIALOG dlg(
this, msg,
_(
"Unit Already Placed" ), wxYES_NO | wxCANCEL | wxICON_WARNING );
135 dlg.SetYesNoLabels( wxString::Format(
_(
"&Swap '%s' and '%s'" ), targetUnitName, currUnitName ),
136 wxString::Format(
_(
"&Duplicate '%s'" ), targetUnitName ) );
141 if( ret == wxID_CANCEL )
144 if( ret == wxID_YES )
145 swapWithOther =
true;
151 wxASSERT( otherSymbolRef );
153 SCH_SYMBOL* otherSymbol = otherSymbolRef->GetSymbol();
156 commit.
Modify( otherSymbol, otherSymbolRef->GetSheetPath().LastScreen() );
159 otherSymbol->
SetUnitSelection( &otherSymbolRef->GetSheetPath(), currentUnit );
160 otherSymbol->
SetUnit( currentUnit );
170 if( !commit.
Empty() )
172 if(
eeconfig()->m_AutoplaceFields.enable )
181 commit.
Push(
_(
"Swap Units" ) );
183 commit.
Push(
_(
"Change Unit" ) );
200 msg.Printf(
_(
"No alternate body style found for symbol '%s' in library '%s'." ),
201 id.GetLibItemName().wx_str(),
202 id.GetLibNickname().wx_str() );
223 commit.
Push(
_(
"Change Body Style" ) );
235 if( aFunction == aPin->
GetName() )
236 aPin->
SetAlt( wxEmptyString );
238 aPin->
SetAlt( aFunction );
240 commit.
Push(
_(
"Set Pin Function" ) );
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
std::vector< std::pair< FIELD_T, 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
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.
int GetUnitCount() const override
wxString GetUnitDisplayName(int aUnit, bool aLabel) const override
Return the user-defined display name for aUnit for symbols with units.
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
Search 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)
Set the name of the alternate pin.
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)
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.
std::vector< std::pair< FIELD_T, wxString > > Fields
Definition for symbol library class.