41#include <dialogs/dialog_text_properties.h>
50#include <wx/textdlg.h>
56 m_pickerItem( nullptr )
68 wxASSERT_MSG( drawingTools,
"eeschema.SymbolDrawing tool is not available" );
70 auto haveSymbolCondition =
181 commit = &localCommit;
191 for(
unsigned ii = 0; ii < selection.
GetSize(); ii++ )
194 item->
Rotate( rotPoint, ccw );
207 if( !localCommit.
Empty() )
208 localCommit.
Push(
_(
"Rotate" ) );
233 switch( item->
Type() )
263 for(
unsigned ii = 0; ii < selection.
GetSize(); ii++ )
307 if( selection.
Size() < 2 )
317 for(
size_t i = 0; i < sorted.size() - 1; i++ )
323 std::swap( aPos, bPos );
355 for(
EDA_ITEM* selected : selection )
398 std::set<SCH_ITEM*> toDelete;
399 int fieldsHidden = 0;
400 int fieldsAlreadyHidden = 0;
409 toDelete.insert( curr_pin );
415 std::vector<bool> got_unit( symbol->
GetUnitCount() + 1 );
417 got_unit[curr_pin->
GetUnit()] =
true;
421 if( got_unit[
pin->GetUnit()] )
424 if(
pin->GetPosition() != pos )
436 toDelete.insert(
pin );
437 got_unit[
pin->GetUnit()] =
true;
453 fieldsAlreadyHidden++;
458 toDelete.insert( schItem );
465 if( toDelete.size() == 0 )
467 if( fieldsHidden == 1 )
468 commit.
Push(
_(
"Hide Field" ) );
469 else if( fieldsHidden > 1 )
470 commit.
Push(
_(
"Hide Fields" ) );
471 else if( fieldsAlreadyHidden > 0 )
476 commit.
Push(
_(
"Delete" ) );
484#define HITTEST_THRESHOLD_PIXELS 5
500 [
this](
const VECTOR2D& aPosition ) ->
bool
523 for(
int i = collector.GetCount() - 1; i >= 0; --i )
525 if( !selectionTool->
Selectable( collector[ i ] ) )
526 collector.Remove( i );
529 if( collector.GetCount() > 1 )
532 EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] :
nullptr;
547 [
this](
const int& aFinalState )
571 else if( selection.
Size() == 1 )
579 switch( item->
Type() )
589 bool mouseOverNumber =
false;
592 mouseOverNumber = numberBox->Contains( mousePos );
596 pinTool->EditPinProperties( &
pin, mouseOverNumber );
617 wxFAIL_MSG( wxT(
"Unhandled item <" ) + item->
GetClass() + wxT(
">" ) );
644 std::vector<MSG_PANEL_ITEM> items;
684 if( aField ==
nullptr )
692 caption.Printf(
_(
"Edit '%s' Field" ), aField->
GetName() );
709 commit.
Push( caption );
752 int& aSymbolLastPinNumber )
758 aSymbolLastPinNumber++;
759 aNewPin->
SetNumber( wxString::Format( wxT(
"%i" ), aSymbolLastPinNumber ) );
780 commit.
Push(
_(
"Edit Pins" ) );
824 wxString promptText = wxString::Format(
_(
"Enter display name for unit %s" ),
826 wxString currentvalue;
833 wxTextEntryDialog dlg(
m_frame, promptText,
_(
"Set Unit Display Name" ), currentvalue );
835 if( dlg.ShowModal() == wxID_OK )
885 int retVal =
Copy( aEvent );
899 if( !symbol || !selection.
GetSize() )
909 if( !item.IsSelected() )
923 std::string prettyData = formatter.
GetString();
938 if( selection.Empty() )
943 if( selection.IsHover() )
955 if( !symbol || symbol->
IsAlias() )
964 if( newParts.empty() || !newParts[0] )
967 newPart = newParts[0];
974 wxString pasteText( clipboardData );
978 if( pasteText.Length() > 5000 )
979 pasteText = pasteText.Left( 5000 ) + wxT(
"..." );
1015 if( !selection.
Empty() )
1020 commit.
Push(
_(
"Paste" ) );
1035 if( selection.
GetSize() == 0 )
1040 std::vector<EDA_ITEM*> oldItems;
1041 std::vector<EDA_ITEM*> newItems;
1043 std::copy( selection.
begin(), selection.
end(), std::back_inserter( oldItems ) );
1044 std::sort( oldItems.begin(), oldItems.end(), [](
EDA_ITEM* a,
EDA_ITEM* b )
1048 if( a->Type() != b->Type() )
1049 return a->Type() < b->Type();
1052 if( a->Type() == SCH_PIN_T )
1054 const wxString& aNum = static_cast<SCH_PIN*>( a )->GetNumber();
1055 const wxString& bNum = static_cast<SCH_PIN*>( b )->GetNumber();
1057 cmp = StrNumCmp( aNum, bNum );
1061 if( aNum.IsNumber() && bNum.IsNumber() && cmp != 0 )
1083 newPin->
SetNumber( wxString::Format( wxT(
"%i" ), symbol->GetMaxPinNumber() + 1 ) );
1089 newItems.push_back( newItem );
1091 symbol->AddDrawItem( newItem );
1092 getView()->Add( newItem );
1098 selection.SetReferencePoint( getViewControls()->GetCursorPosition(
true ) );
1101 commit.Push(
_(
"Duplicate" ) );
1114 if( selection.Empty() )
1118 bool allSameType =
true;
1121 if( item->Type() != type )
1123 allSameType =
false;
1142 switch( item->Type() )
1152 if( bbox && bbox->Contains( mousePosition ) )
1154 std::optional<wxString> nextNumber =
1159 pin.SetNumber( *nextNumber );
1168 if( bbox && bbox->Contains( mousePosition ) )
1170 std::optional<wxString> nextName =
1175 pin.SetName( *nextName );
1186 std::optional<wxString> newLabel =
1201 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)