41#include <dialogs/dialog_text_properties.h>
50#include <wx/textdlg.h>
55 m_pickerItem( nullptr )
67 wxASSERT_MSG( drawingTools,
"eeschema.SymbolDrawing tool is not available" );
69 auto haveSymbolCondition =
180 commit = &localCommit;
190 for(
unsigned ii = 0; ii < selection.
GetSize(); ii++ )
193 item->
Rotate( rotPoint, ccw );
206 if( !localCommit.
Empty() )
207 localCommit.
Push(
_(
"Rotate" ) );
232 switch( item->
Type() )
262 for(
unsigned ii = 0; ii < selection.
GetSize(); ii++ )
306 if( selection.
Size() < 2 )
316 for(
size_t i = 0; i < sorted.size() - 1; i++ )
322 std::swap( aPos, bPos );
354 for(
EDA_ITEM* selected : selection )
397 std::set<SCH_ITEM*> toDelete;
398 int fieldsHidden = 0;
399 int fieldsAlreadyHidden = 0;
408 toDelete.insert( curr_pin );
414 std::vector<bool> got_unit( symbol->
GetUnitCount() + 1 );
416 got_unit[curr_pin->
GetUnit()] =
true;
420 if( got_unit[
pin->GetUnit()] )
423 if(
pin->GetPosition() != pos )
435 toDelete.insert(
pin );
436 got_unit[
pin->GetUnit()] =
true;
452 fieldsAlreadyHidden++;
457 toDelete.insert( schItem );
464 if( toDelete.size() == 0 )
466 if( fieldsHidden == 1 )
467 commit.
Push(
_(
"Hide Field" ) );
468 else if( fieldsHidden > 1 )
469 commit.
Push(
_(
"Hide Fields" ) );
470 else if( fieldsAlreadyHidden > 0 )
475 commit.
Push(
_(
"Delete" ) );
483#define HITTEST_THRESHOLD_PIXELS 5
499 [
this](
const VECTOR2D& aPosition ) ->
bool
522 for(
int i = collector.GetCount() - 1; i >= 0; --i )
524 if( !selectionTool->
Selectable( collector[ i ] ) )
525 collector.Remove( i );
528 if( collector.GetCount() > 1 )
531 EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] :
nullptr;
546 [
this](
const int& aFinalState )
570 else if( selection.
Size() == 1 )
578 switch( item->
Type() )
588 bool mouseOverNumber =
false;
591 mouseOverNumber = numberBox->Contains( mousePos );
595 pinTool->EditPinProperties( &
pin, mouseOverNumber );
616 wxFAIL_MSG( wxT(
"Unhandled item <" ) + item->
GetClass() + wxT(
">" ) );
643 std::vector<MSG_PANEL_ITEM> items;
683 if( aField ==
nullptr )
691 caption.Printf(
_(
"Edit '%s' Field" ), aField->
GetName() );
708 commit.
Push( caption );
751 int& aSymbolLastPinNumber )
757 aSymbolLastPinNumber++;
758 aNewPin->
SetNumber( wxString::Format( wxT(
"%i" ), aSymbolLastPinNumber ) );
779 commit.
Push(
_(
"Edit Pins" ) );
823 wxString promptText = wxString::Format(
_(
"Enter display name for unit %s" ),
825 wxString currentvalue;
832 wxTextEntryDialog dlg(
m_frame, promptText,
_(
"Set Unit Display Name" ), currentvalue );
834 if( dlg.ShowModal() == wxID_OK )
884 int retVal =
Copy( aEvent );
898 if( !symbol || !selection.
GetSize() )
908 if( !item.IsSelected() )
934 if( selection.Empty() )
939 if( selection.IsHover() )
951 if( !symbol || symbol->
IsAlias() )
960 if( newParts.empty() || !newParts[0] )
963 newPart = newParts[0];
1003 if( !selection.
Empty() )
1008 commit.
Push(
_(
"Paste" ) );
1023 if( selection.
GetSize() == 0 )
1028 std::vector<EDA_ITEM*> oldItems;
1029 std::vector<EDA_ITEM*> newItems;
1031 std::copy( selection.
begin(), selection.
end(), std::back_inserter( oldItems ) );
1032 std::sort( oldItems.begin(), oldItems.end(), [](
EDA_ITEM* a,
EDA_ITEM* b )
1036 if( a->Type() != b->Type() )
1037 return a->Type() < b->Type();
1040 if( a->Type() == SCH_PIN_T )
1042 const wxString& aNum = static_cast<SCH_PIN*>( a )->GetNumber();
1043 const wxString& bNum = static_cast<SCH_PIN*>( b )->GetNumber();
1045 cmp = StrNumCmp( aNum, bNum );
1049 if( aNum.IsNumber() && bNum.IsNumber() && cmp != 0 )
1071 newPin->
SetNumber( wxString::Format( wxT(
"%i" ), symbol->GetMaxPinNumber() + 1 ) );
1077 newItems.push_back( newItem );
1079 symbol->AddDrawItem( newItem );
1080 getView()->Add( newItem );
1086 selection.SetReferencePoint( getViewControls()->GetCursorPosition(
true ) );
1089 commit.Push(
_(
"Duplicate" ) );
1102 if( selection.Empty() )
1106 bool allSameType =
true;
1109 if( item->Type() != type )
1111 allSameType =
false;
1130 switch( item->Type() )
1140 if( bbox && bbox->Contains( mousePosition ) )
1142 std::optional<wxString> nextNumber =
1147 pin.SetNumber( *nextNumber );
1156 if( bbox && bbox->Contains( mousePosition ) )
1158 std::optional<wxString> nextName =
1163 pin.SetName( *nextName );
1174 std::optional<wxString> newLabel =
1189 commit.
Push(
_(
"Increment" ) );
std::optional< BOX2I > OPT_BOX2I
static TOOL_ACTION decrementPrimary
static TOOL_ACTION cancelInteractive
static TOOL_ACTION unselectAll
static TOOL_ACTION decrementSecondary
static TOOL_ACTION pickerTool
static TOOL_ACTION incrementSecondary
static TOOL_ACTION duplicate
static TOOL_ACTION incrementPrimary
static TOOL_ACTION doDelete
static TOOL_ACTION deleteTool
static TOOL_ACTION increment
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 const wxString & GetText() const
Return the string associated with the text object.
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
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 VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
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.
A pin layout helper is a class that manages the layout of the parts of a pin on a schematic symbol:
OPT_BOX2I GetPinNumberBBox()
Get the bounding box of the pin number, if there is one.
OPT_BOX2I GetPinNameBBox()
Get the bounding box of the pin name, if there is one.
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.
Heuristically increment a string's n'th part from the right.
void SetSkipIOSQXZ(bool aSkip)
If a alphabetic part is found, skip the letters I, O, S, Q, X, Z.
std::optional< wxString > Increment(const wxString &aStr, int aDelta, size_t aRightIndex) const
Increment the n-th part from the right of the given string.
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.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
constexpr int LexicographicalCompare(const VECTOR2< T > &aA, const VECTOR2< T > &aB)