39#include <dialogs/dialog_text_properties.h>
48#include <wx/textdlg.h>
53 m_pickerItem( nullptr )
65 wxASSERT_MSG( drawingTools,
"eeschema.SymbolDrawing tool is not available" );
67 auto haveSymbolCondition =
178 commit = &localCommit;
188 for(
unsigned ii = 0; ii < selection.
GetSize(); ii++ )
191 item->
Rotate( rotPoint, ccw );
204 if( !localCommit.
Empty() )
205 localCommit.
Push(
_(
"Rotate" ) );
230 switch( item->
Type() )
260 for(
unsigned ii = 0; ii < selection.
GetSize(); ii++ )
304 if( selection.
Size() < 2 )
314 for(
size_t i = 0; i < sorted.size() - 1; i++ )
320 std::swap( aPos, bPos );
352 for(
EDA_ITEM* selected : selection )
395 std::set<SCH_ITEM*> toDelete;
396 int fieldsHidden = 0;
397 int fieldsAlreadyHidden = 0;
406 toDelete.insert( curr_pin );
412 std::vector<bool> got_unit( symbol->
GetUnitCount() + 1 );
414 got_unit[curr_pin->
GetUnit()] =
true;
418 if( got_unit[
pin->GetUnit()] )
421 if(
pin->GetPosition() != pos )
433 toDelete.insert(
pin );
434 got_unit[
pin->GetUnit()] =
true;
450 fieldsAlreadyHidden++;
455 toDelete.insert( schItem );
462 if( toDelete.size() == 0 )
464 if( fieldsHidden == 1 )
465 commit.
Push(
_(
"Hide Field" ) );
466 else if( fieldsHidden > 1 )
467 commit.
Push(
_(
"Hide Fields" ) );
468 else if( fieldsAlreadyHidden > 0 )
473 commit.
Push(
_(
"Delete" ) );
481#define HITTEST_THRESHOLD_PIXELS 5
497 [
this](
const VECTOR2D& aPosition ) ->
bool
520 for(
int i = collector.GetCount() - 1; i >= 0; --i )
522 if( !selectionTool->
Selectable( collector[ i ] ) )
523 collector.Remove( i );
526 if( collector.GetCount() > 1 )
529 EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] :
nullptr;
544 [
this](
const int& aFinalState )
568 else if( selection.
Size() == 1 )
576 switch( item->
Type() )
580 pinTool->EditPinProperties(
static_cast<SCH_PIN*
>( item ) );
601 wxFAIL_MSG( wxT(
"Unhandled item <" ) + item->
GetClass() + wxT(
">" ) );
617 if( dlg.ShowModal() != wxID_OK )
628 std::vector<MSG_PANEL_ITEM> items;
641 if( dlg.ShowModal() != wxID_OK )
657 if( dlg.ShowModal() != wxID_OK )
668 if( aField ==
nullptr )
676 caption.Printf(
_(
"Edit '%s' Field" ), aField->
GetName() );
693 commit.
Push( caption );
736 int& aSymbolLastPinNumber )
742 aSymbolLastPinNumber++;
743 aNewPin->
SetNumber( wxString::Format( wxT(
"%i" ), aSymbolLastPinNumber ) );
761 if( dlg.ShowModal() == wxID_CANCEL )
764 commit.
Push(
_(
"Edit Pins" ) );
786 if( dlg.ShowModal() == wxID_CANCEL )
808 wxString promptText = wxString::Format(
_(
"Enter display name for unit %s" ),
810 wxString currentvalue;
817 wxTextEntryDialog dlg(
m_frame, promptText,
_(
"Set Unit Display Name" ), currentvalue );
819 if( dlg.ShowModal() == wxID_OK )
869 int retVal =
Copy( aEvent );
883 if( !symbol || !selection.
GetSize() )
893 if( !item.IsSelected() )
919 if( selection.Empty() )
924 if( selection.IsHover() )
936 if( !symbol || symbol->
IsAlias() )
945 if( newParts.empty() || !newParts[0] )
948 newPart = newParts[0];
988 if( !selection.
Empty() )
993 commit.
Push(
_(
"Paste" ) );
1008 if( selection.
GetSize() == 0 )
1013 std::vector<EDA_ITEM*> oldItems;
1014 std::vector<EDA_ITEM*> newItems;
1016 std::copy( selection.
begin(), selection.
end(), std::back_inserter( oldItems ) );
1017 std::sort( oldItems.begin(), oldItems.end(), [](
EDA_ITEM* a,
EDA_ITEM* b )
1021 if( a->Type() != b->Type() )
1022 return a->Type() < b->Type();
1025 if( a->Type() == SCH_PIN_T )
1027 const wxString& aNum = static_cast<SCH_PIN*>( a )->GetNumber();
1028 const wxString& bNum = static_cast<SCH_PIN*>( b )->GetNumber();
1030 cmp = StrNumCmp( aNum, bNum );
1034 if( aNum.IsNumber() && bNum.IsNumber() && cmp != 0 )
1056 newPin->
SetNumber( wxString::Format( wxT(
"%i" ), symbol->GetMaxPinNumber() + 1 ) );
1062 newItems.push_back( newItem );
1064 symbol->AddDrawItem( newItem );
1065 getView()->Add( newItem );
1071 selection.SetReferencePoint( getViewControls()->GetCursorPosition(
true ) );
1074 commit.Push(
_(
"Duplicate" ) );
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 copyAsText
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.
This class is setup in expectation of its children possibly using Kiway player so DIALOG_SHIM::ShowQu...
void UpdateField(SCH_FIELD *aField)
const wxString & GetText() const
bool GetApplyToAllConversions()
bool GetApplyToAllUnits()
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
virtual void SetPosition(const VECTOR2I &aPos)
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)
EDA_ITEM * GetParent() const
virtual bool IsVisible() const
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
GR_TEXT_H_ALIGN_T GetHorizJustify() const
virtual void SetVisible(bool aVisible)
GR_TEXT_V_ALIGN_T GetVertJustify() const
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.
Define a library symbol object.
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.
std::vector< SCH_PIN * > GetAllLibPins() const
Return a list of pin pointers for all units / converts.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
void RemoveDrawItem(SCH_ITEM *aItem)
Remove draw aItem from list.
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.
int GetUnitCount() const override
void SetUnitDisplayName(int aUnit, const wxString &aName)
Set the user-defined display name for aUnit to aName for symbols with units.
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
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
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
wxString GetFullText(int unit=1) const
Return the text of a field.
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
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)
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual void SetBodyStyle(int aBodyStyle)
virtual void MirrorHorizontally(int aCenter)
Mirror item horizontally about aCenter.
virtual void Rotate(const VECTOR2I &aCenter, bool aRotateCCW)
Rotate the item around aCenter 90 degrees in the clockwise direction.
virtual void SetUnit(int aUnit)
wxString GetClass() const override
Return the class name.
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
virtual void MirrorVertically(int aCenter)
Mirror item vertically about aCenter.
void SetNumber(const wxString &aNumber)
void SetOrientation(PIN_ORIENTATION aOrientation)
const wxString & GetName() const
PIN_ORIENTATION GetOrientation() const
VECTOR2I GetPosition() const override
const wxString & GetNumber() const
ELECTRICAL_PINTYPE GetType() const
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
static SELECTION_CONDITION MoreThan(int aNumber)
Create a functor that tests if the number of selected items is greater than the value given as parame...
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.
static SELECTION_CONDITION OnlyTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if the selected items are only of given types.
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.
virtual void Clear() override
Remove all the stored items from the group.
int Size() const
Returns the number of selected parts.
std::vector< EDA_ITEM * > GetItemsSortedBySelectionOrder() const
void SetReferencePoint(const VECTOR2I &aP)
bool Empty() const
Checks if there is anything selected.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
bool IsSymbolAlias() const
Return true if aLibId is an alias for the editor screen symbol.
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()
bool IsSymbolEditable() const
Test if a symbol is loaded and can be edited.
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.
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
std::string GetClipboardUTF8()
Return the information currently stored in the system clipboard.
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
PIN_ORIENTATION
The symbol library pin object orientations.
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:...
constexpr GR_TEXT_H_ALIGN_T GetFlippedAlignment(GR_TEXT_H_ALIGN_T aAlign)
Get the reverse alignment: left-right are swapped, others are unchanged.
constexpr int LexicographicalCompare(const VECTOR2< T > &aA, const VECTOR2< T > &aB)