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 =
183 commit = &localCommit;
193 for(
unsigned ii = 0; ii < selection.
GetSize(); ii++ )
196 item->
Rotate( rotPoint, ccw );
209 if( !localCommit.
Empty() )
210 localCommit.
Push(
_(
"Rotate" ) );
235 switch( item->
Type() )
265 for(
unsigned ii = 0; ii < selection.
GetSize(); ii++ )
309 if( selection.
Size() < 2 )
319 for(
size_t i = 0; i < sorted.size() - 1; i++ )
325 std::swap( aPos, bPos );
357 for(
EDA_ITEM* selected : selection )
400 std::set<SCH_ITEM*> toDelete;
401 int fieldsHidden = 0;
402 int fieldsAlreadyHidden = 0;
411 toDelete.insert( curr_pin );
417 std::vector<bool> got_unit( symbol->
GetUnitCount() + 1 );
419 got_unit[curr_pin->
GetUnit()] =
true;
423 if( got_unit[
pin->GetUnit()] )
426 if(
pin->GetPosition() != pos )
438 toDelete.insert(
pin );
439 got_unit[
pin->GetUnit()] =
true;
455 fieldsAlreadyHidden++;
460 toDelete.insert( schItem );
467 if( toDelete.size() == 0 )
469 if( fieldsHidden == 1 )
470 commit.
Push(
_(
"Hide Field" ) );
471 else if( fieldsHidden > 1 )
472 commit.
Push(
_(
"Hide Fields" ) );
473 else if( fieldsAlreadyHidden > 0 )
478 commit.
Push(
_(
"Delete" ) );
486#define HITTEST_THRESHOLD_PIXELS 5
504 [
this](
const VECTOR2D& aPosition ) ->
bool
527 for(
int i = collector.GetCount() - 1; i >= 0; --i )
529 if( !selectionTool->
Selectable( collector[ i ] ) )
530 collector.Remove( i );
533 if( collector.GetCount() > 1 )
536 EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] :
nullptr;
551 [
this](
const int& aFinalState )
575 else if( selection.
Size() == 1 )
583 switch( item->
Type() )
593 bool mouseOverNumber =
false;
596 mouseOverNumber = numberBox->Contains( mousePos );
600 pinTool->EditPinProperties( &
pin, mouseOverNumber );
621 wxFAIL_MSG( wxT(
"Unhandled item <" ) + item->
GetClass() + wxT(
">" ) );
648 std::vector<MSG_PANEL_ITEM> items;
688 if( aField ==
nullptr )
696 caption.Printf(
_(
"Edit '%s' Field" ), aField->
GetName() );
710 commit.
Push( caption );
753 int& aSymbolLastPinNumber )
759 aSymbolLastPinNumber++;
760 aNewPin->
SetNumber( wxString::Format( wxT(
"%i" ), aSymbolLastPinNumber ) );
775 wxCHECK( selTool, -1 );
777 std::vector<SCH_PIN*> selectedPins;
786 selectedPins.push_back( pinItem );
799 commit.
Push(
_(
"Edit Pins" ) );
843 wxString promptText = wxString::Format(
_(
"Enter display name for unit %s" ),
845 wxString currentvalue;
850 wxTextEntryDialog dlg(
m_frame, promptText,
_(
"Set Unit Display Name" ), currentvalue );
852 if( dlg.ShowModal() == wxID_OK )
902 int retVal =
Copy( aEvent );
916 if( !symbol || !selection.
GetSize() )
926 if( !item.IsSelected() )
940 std::string prettyData = formatter.
GetString();
955 if( selection.Empty() )
960 if( selection.IsHover() )
981 if( newParts.empty() || !newParts[0] )
984 newPart = newParts[0];
991 wxString pasteText( clipboardData );
995 if( pasteText.Length() > 5000 )
996 pasteText = pasteText.Left( 5000 ) + wxT(
"..." );
1032 if( !selection.
Empty() )
1037 commit.
Push(
_(
"Paste" ) );
1052 if( selection.
GetSize() == 0 )
1057 std::vector<EDA_ITEM*> oldItems;
1058 std::vector<EDA_ITEM*> newItems;
1060 std::copy( selection.
begin(), selection.
end(), std::back_inserter( oldItems ) );
1061 std::sort( oldItems.begin(), oldItems.end(), [](
EDA_ITEM* a,
EDA_ITEM* b )
1065 if( a->Type() != b->Type() )
1066 return a->Type() < b->Type();
1069 if( a->Type() == SCH_PIN_T )
1071 const wxString& aNum = static_cast<SCH_PIN*>( a )->GetNumber();
1072 const wxString& bNum = static_cast<SCH_PIN*>( b )->GetNumber();
1074 cmp = StrNumCmp( aNum, bNum );
1078 if( aNum.IsNumber() && bNum.IsNumber() && cmp != 0 )
1100 newPin->
SetNumber( wxString::Format( wxT(
"%i" ), symbol->GetMaxPinNumber() + 1 ) );
1106 newItems.push_back( newItem );
1108 symbol->AddDrawItem( newItem );
1109 getView()->Add( newItem );
1115 selection.SetReferencePoint( getViewControls()->GetCursorPosition(
true ) );
1118 commit.Push(
_(
"Duplicate" ) );
1131 if( selection.Empty() )
1135 bool allSameType =
true;
1138 if( item->Type() != type )
1140 allSameType =
false;
1160 commit = &localCommit;
1162 const auto modifyItem = [&](
EDA_ITEM& aItem )
1172 switch( item->Type() )
1182 if( bbox && bbox->Contains( mousePosition ) )
1184 std::optional<wxString> nextNumber =
1189 pin.SetNumber( *nextNumber );
1198 if( bbox && bbox->Contains( mousePosition ) )
1200 std::optional<wxString> nextName =
1205 pin.SetName( *nextName );
1216 std::optional<wxString> newLabel =
1220 modifyItem( label );
1231 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 selectionActivate
Activation of the selection tool.
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 selectionClear
Clear the current selection.
static TOOL_ACTION copyAsText
static TOOL_ACTION refreshPreview
static TOOL_ACTION selectAll
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
This class is setup in expectation of its children possibly using Kiway player so DIALOG_SHIM::ShowQu...
void UpdateField(SCH_FIELD *aField)
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)
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 HasUnitDisplayName(int aUnit) const
Return true if the given unit aUnit has a display name defined.
std::vector< SCH_PIN * > GetPins(int aUnit, int aBodyStyle) const
Return a list of pin object pointers from the draw item list.
bool UnitsLocked() const
Check whether symbol units are interchangeable.
static wxString LetterSubReference(int aUnit, wxChar aInitialLetter)
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
void RemoveDrawItem(SCH_ITEM *aItem)
Remove draw aItem from list.
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.
wxString GetUnitDisplayName(int aUnit, bool aLabel) const override
Return the user-defined display name for aUnit for symbols with units.
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.
static TOOL_ACTION rotateCCW
static TOOL_ACTION mirrorV
static TOOL_ACTION pinTable
static TOOL_ACTION properties
static TOOL_ACTION rotateCW
static TOOL_ACTION setUnitDisplayName
static TOOL_ACTION mirrorH
static TOOL_ACTION symbolProperties
static TOOL_ACTION updateSymbolFields
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
Execute the changes.
virtual void Revert() override
Revert the commit by restoring the modified items state.
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,...
SCH_ITEM * Duplicate(bool addToParentGroup, SCH_COMMIT *aCommit=nullptr, bool doClone=false) const
Routine to create a new copy of given item.
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.
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.
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)