45#include <wx/textdlg.h>
50 m_pickerItem( nullptr )
62 wxASSERT_MSG( drawingTools,
"eeschema.SymbolDrawing tool is not available" );
64 auto haveSymbolCondition =
77 if( !
editor->IsSymbolEditable() )
80 if(
editor->IsSymbolAlias() )
166 commit = &localCommit;
176 for(
unsigned ii = 0; ii < selection.
GetSize(); ii++ )
179 item->
Rotate( rotPoint, ccw );
193 if( !localCommit.
Empty() )
194 localCommit.
Push(
_(
"Rotate" ) );
219 switch( item->
Type() )
249 for(
unsigned ii = 0; ii < selection.
GetSize(); ii++ )
302 std::set<LIB_ITEM*> toDelete;
311 toDelete.insert( curr_pin );
317 std::vector<bool> got_unit( symbol->
GetUnitCount() + 1 );
319 got_unit[curr_pin->
GetUnit()] =
true;
328 if( got_unit[
pin->GetUnit()] )
331 if(
pin->GetPosition() != pos )
334 if(
pin->GetConvert() != curr_convert )
337 if(
pin->GetType() != etype )
343 toDelete.insert(
pin );
344 got_unit[
pin->GetUnit()] =
true;
350 toDelete.insert( (
LIB_ITEM*) item );
357 commit.
Push(
_(
"Delete" ) );
363#define HITTEST_THRESHOLD_PIXELS 5
379 [
this](
const VECTOR2D& aPosition ) ->
bool
402 for(
int i = collector.GetCount() - 1; i >= 0; --i )
404 if( !selectionTool->
Selectable( collector[ i ] ) )
405 collector.Remove( i );
408 if( collector.GetCount() > 1 )
411 EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] :
nullptr;
426 [
this](
const int& aFinalState )
450 else if( selection.
Size() == 1 )
458 switch( item->
Type() )
486 wxFAIL_MSG( wxT(
"Unhandled item <" ) + item->
GetClass() + wxT(
">" ) );
502 if( dlg.ShowModal() != wxID_OK )
513 std::vector<MSG_PANEL_ITEM> items;
526 if( dlg.ShowModal() != wxID_OK )
542 if( dlg.ShowModal() != wxID_OK )
553 if( aField ==
nullptr )
563 caption.Printf(
_(
"Edit '%s' Field" ), aField->
GetName() );
622 int& aSymbolLastPinNumber )
628 aSymbolLastPinNumber++;
629 aNewPin->
SetNumber( wxString::Format( wxT(
"%i" ), aSymbolLastPinNumber ) );
646 if( dlg.ShowModal() == wxID_CANCEL )
671 if( dlg.ShowModal() == wxID_CANCEL )
693 wxString promptText = wxString::Format(
_(
"Enter display name for unit %s" ),
695 wxString currentvalue;
702 wxTextEntryDialog dlg(
m_frame, promptText,
_(
"Set Unit Display Name" ), currentvalue );
704 if( dlg.ShowModal() == wxID_OK )
744 int retVal =
Copy( aEvent );
758 if( !symbol || !selection.
GetSize() )
768 if( !item.IsSelected() )
794 if( !symbol || symbol->
IsAlias() )
803 if( newParts.empty() || !newParts[0] )
806 newPart = newParts[0];
813 newText->
SetText( clipboardData );
847 if( !selection.
Empty() )
852 commit.
Push(
_(
"Paste" ) );
874 for(
unsigned ii = 0; ii < selection.
GetSize(); ++ii )
890 newItems.push_back( newItem );
902 commit.
Push(
_(
"Duplicate" ) );
VECTOR2D mapCoords(const VECTOR2D &aSource)
static TOOL_ACTION cancelInteractive
static TOOL_ACTION unselectAll
static TOOL_ACTION pickerTool
static TOOL_ACTION duplicate
static TOOL_ACTION doDelete
static TOOL_ACTION deleteTool
static TOOL_ACTION refreshPreview
static TOOL_ACTION selectAll
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.
const wxString & GetText() const
Handle editing a single symbol field in the symbol editor.
void UpdateField(LIB_FIELD *aField)
Dialog to edit library component graphic items.
bool GetApplyToAllUnits()
bool GetApplyToAllConversions()
Dialog to update or change schematic library symbols.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
VECTOR2I GetNearestHalfGridPosition(const VECTOR2I &aPosition) const
Return the nearest aGridSize / 2 location to aPosition.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
A base class for most all the KiCad significant classes used in schematics and boards.
virtual VECTOR2I GetPosition() const
EDA_ITEM_FLAGS GetEditFlags() const
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
virtual void SetParent(EDA_ITEM *aParent)
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
GR_TEXT_H_ALIGN_T GetHorizJustify() const
GR_TEXT_V_ALIGN_T GetVertJustify() const
virtual void SetText(const wxString &aText)
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
static TOOL_ACTION mirrorV
static TOOL_ACTION selectionActivate
Activation of the selection tool.
static TOOL_ACTION properties
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
static TOOL_ACTION pinTable
static TOOL_ACTION clearSelection
Clears the current selection.
static TOOL_ACTION rotateCCW
static TOOL_ACTION mirrorH
static TOOL_ACTION rotateCW
static TOOL_ACTION symbolProperties
static TOOL_ACTION setUnitDisplayName
static TOOL_ACTION updateSymbolFields
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Field object used in symbol libraries.
wxString GetClass() const override
Return the class name.
wxString GetFullText(int unit=1) const
Return the text of a field.
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
The base class for drawable items used by schematic library symbols.
virtual void MirrorHorizontal(const VECTOR2I &aCenter)=0
Mirror the draw object along the horizontal (X) axis about aCenter point.
virtual void Rotate(const VECTOR2I &aCenter, bool aRotateCCW=true)=0
Rotate the object about aCenter point.
LIB_ITEM * Duplicate() const
Create a copy of this LIB_ITEM (with a new Uuid).
virtual void MirrorVertical(const VECTOR2I &aCenter)=0
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
LIB_SYMBOL * GetParent() const
void SetConvert(int aConvert)
ELECTRICAL_PINTYPE GetType() const
VECTOR2I GetPosition() const override
const wxString & GetNumber() const
void SetNumber(const wxString &aNumber)
const wxString & GetName() const
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
Define a library symbol object.
void RemoveDrawItem(LIB_ITEM *aItem)
Remove draw aItem from list.
bool UnitsLocked() const
Check whether symbol units are interchangeable.
wxString GetUnitDisplayName(int aUnit) override
Return the user-defined display name for aUnit for symbols with units.
int GetMaxPinNumber() const
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
void AddDrawItem(LIB_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
bool HasUnitDisplayName(int aUnit) override
Return true if the given unit aUnit has a display name defined.
wxString GetUnitReference(int aUnit) override
Return an identifier for aUnit for symbols with units.
std::vector< LIB_PIN * > GetAllLibPins() const
Return a list of pin pointers for all units / converts.
int GetUnitCount() const override
For items with units, return the number of units.
void SetUnitDisplayName(int aUnit, const wxString &aName)
Set the user-defined display name for aUnit to aName for symbols with units.
Define a symbol library graphical text item.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
virtual void Revert() override
static void FormatLibSymbol(LIB_SYMBOL *aPart, OUTPUTFORMATTER &aFormatter)
static std::vector< LIB_SYMBOL * > ParseLibSymbols(std::string &aSymbolText, std::string aSource, int aFileVersion=SEXPR_SCHEMATIC_FILE_VERSION)
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
static bool IdleSelection(const SELECTION &aSelection)
Test if all selected items are not being edited.
static SELECTION_CONDITION Count(int aNumber)
Create a functor that tests if the number of selected items is equal to the value given as parameter.
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
const std::deque< EDA_ITEM * > GetItems() const
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
virtual unsigned int GetSize() const override
Return the number of stored items.
int Size() const
Returns the number of selected parts.
void SetReferencePoint(const VECTOR2I &aP)
bool Empty() const
Checks if there is anything selected.
The symbol library editor main window.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
bool m_SyncPinEdit
Set to true to synchronize pins at the same position when editing symbols with multiple units or mult...
void RebuildSymbolUnitsList()
void GetSymbolFromRedoList()
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
void UpdateSymbolMsgPanelInfo()
Display the documentation of the selected symbol.
void GetSymbolFromUndoList()
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
#define IS_NEW
New item, just created.
#define SELECTED
Item was manually selected by the user.
#define STRUCT_DELETED
flag indication structures to be erased
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
wxString TitleCaps(const wxString &aString)
Capitalize the first letter in each word.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ MANDATORY_FIELDS
The first 5 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.