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() )
169 for(
unsigned ii = 0; ii < selection.
GetSize(); ii++ )
172 item->
Rotate( rotPoint, ccw );
213 for(
unsigned ii = 0; ii < selection.
GetSize(); ii++ )
266 std::set<LIB_ITEM *> toDelete;
275 toDelete.insert( curr_pin );
281 std::vector<bool> got_unit( symbol->
GetUnitCount() + 1 );
283 got_unit[curr_pin->
GetUnit()] =
true;
292 if( got_unit[
pin->GetUnit()] )
295 if(
pin->GetPosition() != pos )
298 if(
pin->GetConvert() != curr_convert )
301 if(
pin->GetType() != etype )
307 toDelete.insert(
pin );
308 got_unit[
pin->GetUnit()] =
true;
314 toDelete.insert( (
LIB_ITEM*) item );
328#define HITTEST_THRESHOLD_PIXELS 5
344 [
this](
const VECTOR2D& aPosition ) ->
bool
367 for(
int i = collector.GetCount() - 1; i >= 0; --i )
369 if( !selectionTool->
Selectable( collector[ i ] ) )
370 collector.Remove( i );
373 if( collector.GetCount() > 1 )
376 EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] :
nullptr;
391 [
this](
const int& aFinalState )
415 else if( selection.
Size() == 1 )
423 switch( item->
Type() )
451 wxFAIL_MSG( wxT(
"Unhandled item <" ) + item->
GetClass() + wxT(
">" ) );
469 if( dlg.ShowModal() != wxID_OK )
480 std::vector<MSG_PANEL_ITEM> items;
493 if( dlg.ShowModal() != wxID_OK )
509 if( dlg.ShowModal() != wxID_OK )
520 if( aField ==
nullptr )
530 caption.Printf(
_(
"Edit '%s' Field" ), aField->
GetName() );
589 int& aSymbolLastPinNumber )
595 aSymbolLastPinNumber++;
596 aNewPin->
SetNumber( wxString::Format( wxT(
"%i" ), aSymbolLastPinNumber ) );
613 if( dlg.ShowModal() == wxID_CANCEL )
638 if( dlg.ShowModal() == wxID_CANCEL )
660 wxString promptText = wxString::Format(
_(
"Enter display name for unit %s" ),
662 wxString currentvalue;
669 wxTextEntryDialog dlg(
m_frame, promptText,
_(
"Set Unit Display Name" ), currentvalue );
671 if( dlg.ShowModal() == wxID_OK )
711 int retVal =
Copy( aEvent );
725 if( !symbol || !selection.
GetSize() )
735 if( !item.IsSelected() )
760 if( !symbol || symbol->
IsAlias() )
776 newText->
SetText( wxString::FromUTF8( text_utf8.c_str() ) );
811 if( !selection.
Empty() )
838 int symbolLastPinNumber = -1;
840 for(
unsigned ii = 0; ii < selection.
GetSize(); ++ii )
847 if( symbolLastPinNumber == -1 )
853 static_cast<LIB_PIN*
>( newItem ), symbolLastPinNumber );
859 newItems.push_back( newItem );
VECTOR2D mapCoords(const VECTOR2D &aSource)
static TOOL_ACTION cancelInteractive
static TOOL_ACTION pickerTool
static TOOL_ACTION duplicate
static TOOL_ACTION doDelete
static TOOL_ACTION deleteTool
static TOOL_ACTION refreshPreview
static TOOL_ACTION selectAll
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)
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
virtual void SetText(const wxString &aText)
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
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
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.
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_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static void FormatLibSymbol(LIB_SYMBOL *aPart, OUTPUTFORMATTER &aFormatter)
static LIB_SYMBOL * ParseLibSymbol(LINE_READER &aReader, int aVersion=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.
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
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.
void SaveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO aUndoType=UNDO_REDO::LIBEDIT, bool aAppend=false)
Create a copy of the current symbol, and save it in the undo list.
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 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.