23#include "tl/expected.hpp"
28#include <wx/mstream.h>
29#include <wx/dcmemory.h>
72constexpr int clipboardMaxBitmapSize = 4096;
73constexpr double clipboardBboxInflation = 0.02;
76void appendMimeData( std::vector<CLIPBOARD_MIME_DATA>& aMimeData,
const wxString& aMimeType,
77 const wxMemoryBuffer& aBuffer )
79 if( aBuffer.GetDataLen() == 0 )
85 aMimeData.push_back( entry );
89void appendMimeData( std::vector<CLIPBOARD_MIME_DATA>& aMimeData,
const wxString& aMimeType,
97 entry.
m_image = std::move( aImage );
98 aMimeData.push_back( std::move( entry ) );
103 int aUnit,
int aBodyStyle, wxMemoryBuffer& aBuffer )
109 wxFileName tempFile( wxFileName::CreateTempFileName( wxS(
"kicad_symbol_svg" ) ) );
113 if( !
PlotSymbolToSVG( aSymbol, aSymbol, aUnit, aBodyStyle, aBBox, renderSettings,
false,
114 tempFile.GetFullPath() ) )
116 wxRemoveFile( tempFile.GetFullPath() );
121 wxRemoveFile( tempFile.GetFullPath() );
127 int aUnit,
int aBodyStyle,
int aWidth,
int aHeight,
128 double aViewScale,
const wxColour& aBgColor )
130 wxBitmap bitmap( aWidth, aHeight, 24 );
132 dc.SelectObject( bitmap );
133 dc.SetBackground( wxBrush( aBgColor ) );
145 std::unique_ptr<KIGFX::SCH_PAINTER> painter = std::make_unique<KIGFX::SCH_PAINTER>( gal );
146 std::unique_ptr<KIGFX::VIEW> view = std::make_unique<KIGFX::VIEW>();
151 view->SetPainter( painter.get() );
153 view->SetScale( 1.0 );
157 std::vector<std::unique_ptr<SCH_ITEM>> clonedItems;
163 && item.GetUnit() != aUnit )
170 && item.GetBodyStyle() != aBodyStyle )
176 clonedItems.emplace_back( clone );
185 COLOR4D bgColor4D( aBgColor.Red() / 255.0, aBgColor.Green() / 255.0,
186 aBgColor.Blue() / 255.0, 1.0 );
191 view->SetLayerVisible( i,
true );
205 double inch2Iu = 1000.0 *
schIUScale.IU_PER_MILS;
206 VECTOR2D pageSizeIn( (
double) aWidth / ppi, (
double) aHeight / ppi );
208 galPrint->SetSheetSize( pageSizeIn );
213 double zoomFactor = 2.0 * aViewScale * inch2Iu / ppi;
216 view->SetCenter( aBBox.
Centre() );
217 view->SetScale( aViewScale * zoomFactor );
224 view->UseDrawPriority(
true );
231 dc.SelectObject( wxNullBitmap );
232 return bitmap.ConvertToImage();
237 const BOX2I& aBBox,
int aUnit,
int aBodyStyle )
241 if( size.
x <= 0 || size.
y <= 0 )
242 return tl::make_unexpected(
"Invalid image size" + std::to_string( size.
x ) +
"x" + std::to_string( size.
y ) );
246 int bitmapWidth =
KiROUND( size.
x * viewScale );
247 int bitmapHeight =
KiROUND( size.
y * viewScale );
250 if( bitmapWidth > clipboardMaxBitmapSize || bitmapHeight > clipboardMaxBitmapSize )
252 double scaleDown = (double) clipboardMaxBitmapSize / std::max( bitmapWidth, bitmapHeight );
253 bitmapWidth =
KiROUND( bitmapWidth * scaleDown );
254 bitmapHeight =
KiROUND( bitmapHeight * scaleDown );
255 viewScale *= scaleDown;
258 if( bitmapWidth <= 0 || bitmapHeight <= 0 )
259 return tl::make_unexpected(
"Invalid image size" + std::to_string( bitmapWidth ) +
"x"
260 + std::to_string( bitmapHeight ) );
263 wxImage imageOnWhite = renderSymbolToBitmap( aFrame, aSymbol, aBBox, aUnit, aBodyStyle, bitmapWidth, bitmapHeight,
264 viewScale, *wxWHITE );
265 wxImage imageOnBlack = renderSymbolToBitmap( aFrame, aSymbol, aBBox, aUnit, aBodyStyle, bitmapWidth, bitmapHeight,
266 viewScale, *wxBLACK );
268 if( !imageOnWhite.IsOk() || !imageOnBlack.IsOk() )
269 return tl::make_unexpected(
"Failed to render symbol to white/black bitmaps" );
300 wxASSERT_MSG( drawingTools,
"eeschema.SymbolDrawing tool is not available" );
302 auto haveSymbolCondition =
311 if( !
m_frame->IsSymbolEditable() )
326 auto swapSelectionCondition =
338 const auto canConvertStackedPins =
342 if( sel.Size() >= 2 )
344 std::vector<SCH_PIN*> pins;
349 pins.push_back(
static_cast<SCH_PIN*
>( item ) );
353 VECTOR2I pos = pins[0]->GetPosition();
354 for(
size_t i = 1; i < pins.size(); ++i )
356 if( pins[i]->GetPosition() != pos )
363 if( sel.Size() == 1 && sel.Front()->Type() ==
SCH_PIN_T )
373 int coLocatedCount = 0;
377 if(
pin->GetPosition() == pos )
381 if( coLocatedCount >= 2 )
390 const auto canExplodeStackedPin =
393 if( sel.Size() != 1 || sel.Front()->Type() !=
SCH_PIN_T )
398 std::vector<wxString> stackedNumbers =
pin->GetStackedPinNumbers( &isValid );
399 return isValid && stackedNumbers.size() > 1;
486 commit = &localCommit;
496 for(
unsigned ii = 0; ii < selection.
GetSize(); ii++ )
499 item->
Rotate( rotPoint, ccw );
500 m_frame->UpdateItem( item,
false,
true );
512 if( !localCommit.
Empty() )
513 localCommit.
Push(
_(
"Rotate" ) );
538 switch( item->
Type() )
562 m_frame->UpdateItem( item,
false,
true );
568 for(
unsigned ii = 0; ii < selection.
GetSize(); ii++ )
577 m_frame->UpdateItem( item,
false,
true );
600 if( selection.
Size() < 2 )
610 for(
size_t i = 0; i < sorted.size() - 1; i++ )
616 std::swap( aPos, bPos );
643 m_frame->UpdateItem( a,
false,
true );
644 m_frame->UpdateItem( b,
false,
true );
648 for(
EDA_ITEM* selected : selection )
680 std::deque<EDA_ITEM*> items =
m_selectionTool->RequestSelection().GetItems();
691 std::set<SCH_ITEM*> toDelete;
692 int fieldsHidden = 0;
693 int fieldsAlreadyHidden = 0;
702 toDelete.insert( curr_pin );
706 if(
m_frame->SynchronizePins() )
708 std::vector<bool> got_unit( symbol->
GetUnitCount() + 1 );
710 got_unit[curr_pin->
GetUnit()] =
true;
714 if( got_unit[
pin->GetUnit()] )
717 if(
pin->GetPosition() != pos )
729 toDelete.insert(
pin );
730 got_unit[
pin->GetUnit()] =
true;
746 fieldsAlreadyHidden++;
751 toDelete.insert( schItem );
758 if( toDelete.size() == 0 )
760 if( fieldsHidden == 1 )
761 commit.
Push(
_(
"Hide Field" ) );
762 else if( fieldsHidden > 1 )
763 commit.
Push(
_(
"Hide Fields" ) );
764 else if( fieldsAlreadyHidden > 0 )
765 m_frame->ShowInfoBarError(
_(
"Use the Symbol Properties dialog to remove fields." ) );
769 commit.
Push(
_(
"Delete" ) );
778 bool aCursorMovedByKeyboard )
780 if( aCursorMovedByKeyboard )
785 return numberBox->Contains( aMousePos );
804 ( !
m_frame->GetCurSymbol() ||
m_frame->GetCurSymbol()->GetLibId() != treeLibId ) )
815 else if( selection.
Size() == 1 )
823 switch( item->
Type() )
830 const bool keyboardCursor =
855 wxFAIL_MSG( wxT(
"Unhandled item <" ) + item->
GetClass() + wxT(
">" ) );
859 else if( selection.
Size() > 1 )
865 if( !
frame()->GetPropertiesPanel()->IsShownOnScreen() )
867 infobar->
AddLink(
_(
"Show Properties panel" ),
868 [
this]( wxHyperlinkEvent& )
870 frame()->ToggleProperties();
875 infobar->
ShowMessageFor(
_(
"Use Properties panel to edit properties common to selected items." ),
876 8000, wxICON_INFORMATION );
894 m_frame->GetCanvas()->Refresh();
900 std::vector<MSG_PANEL_ITEM> items;
917 m_frame->GetCanvas()->Refresh();
933 m_frame->GetCanvas()->Refresh();
940 if( aField ==
nullptr )
948 caption.Printf(
_(
"Edit '%s' Field" ), aField->
GetName() );
962 commit.
Push( caption );
964 m_frame->GetCanvas()->Refresh();
965 m_frame->UpdateSymbolMsgPanelInfo();
978 if( !bufferedSymbol )
996 wxString newName = tempSymbol.
GetName();
1001 if( newName != symbolName )
1010 LIB_ID newLibId( libName, newName );
1011 wxDataViewItem treeItem = libMgr.
GetAdapter()->FindItem( newLibId );
1012 m_frame->UpdateLibraryTree( treeItem, &tempSymbol );
1013 m_frame->GetLibTree()->SelectLibId( newLibId );
1034 m_frame->RebuildSymbolUnitAndBodyStyleLists();
1041 m_frame->UpdateLibraryTree( treeItem, symbol );
1075 m_frame->RebuildSymbolUnitAndBodyStyleLists();
1093 wxCHECK( selTool, -1 );
1095 std::vector<SCH_PIN*> selectedPins;
1104 selectedPins.push_back( pinItem );
1117 commit.
Push(
_(
"Edit Pins" ) );
1133 wxCHECK( selTool, -1 );
1138 std::vector<SCH_PIN*> pinsToConvert;
1148 if(
pin->GetPosition() == pos )
1149 pinsToConvert.push_back(
pin );
1158 pinsToConvert.push_back(
static_cast<SCH_PIN*
>( item ) );
1162 if( pinsToConvert.size() < 2 )
1164 m_frame->ShowInfoBarError(
_(
"At least two pins are needed to convert to stacked pins" ) );
1169 VECTOR2I pos = pinsToConvert[0]->GetPosition();
1170 for(
size_t i = 1; i < pinsToConvert.size(); ++i )
1172 if( pinsToConvert[i]->GetPosition() != pos )
1174 m_frame->ShowInfoBarError(
_(
"All pins must be at the same location" ) );
1185 std::sort( pinsToConvert.begin(), pinsToConvert.end(),
1188 wxString numA = a->GetNumber();
1189 wxString numB = b->GetNumber();
1193 bool aIsNumeric = numA.ToLong( &longA );
1194 bool bIsNumeric = numB.ToLong( &longB );
1197 if( aIsNumeric && bIsNumeric )
1198 return longA < longB;
1201 if( aIsNumeric && !bIsNumeric )
1203 if( !aIsNumeric && bIsNumeric )
1211 wxString stackedNotation = wxT(
"[");
1214 auto collapseRanges =
1217 if( pinsToConvert.empty() )
1223 std::map<wxString, std::vector<long>> prefixGroups;
1224 std::vector<wxString> nonNumericPins;
1229 wxString pinNumber =
pin->GetNumber();
1232 if( pinNumber.IsEmpty() )
1234 nonNumericPins.push_back( wxT(
"(empty)") );
1239 wxString numericPart;
1242 size_t numStart = pinNumber.length();
1243 for(
int i = pinNumber.length() - 1; i >= 0; i-- )
1245 if( !wxIsdigit( pinNumber[i] ) )
1255 if( numStart < pinNumber.length() )
1257 prefix = pinNumber.Left( numStart );
1258 numericPart = pinNumber.Mid( numStart );
1262 if( numericPart.ToLong( &numValue ) && numValue >= 0 )
1264 prefixGroups[prefix].push_back( numValue );
1269 nonNumericPins.push_back( pinNumber );
1274 nonNumericPins.push_back( pinNumber );
1279 for(
auto& [prefix, numbers] : prefixGroups )
1289 std::sort( numbers.begin(), numbers.end() );
1294 while( i < numbers.size() )
1299 long start = numbers[i];
1303 while( i + 1 < numbers.size() && numbers[i + 1] == numbers[i] + 1 )
1310 if(
end > start + 1 )
1311 result += wxString::Format( wxT(
"%s%ld-%s%ld"), escPrefix, start, escPrefix,
end );
1312 else if(
end == start + 1 )
1313 result += wxString::Format( wxT(
"%s%ld,%s%ld"), escPrefix, start, escPrefix,
end );
1315 result += wxString::Format( wxT(
"%s%ld"), escPrefix, start );
1322 for(
const wxString& nonNum : nonNumericPins )
1333 stackedNotation += collapseRanges();
1334 stackedNotation += wxT(
"]");
1337 SCH_PIN* masterPin = pinsToConvert[0];
1338 masterPin->
SetNumber( stackedNotation );
1341 wxLogTrace(
traceStackedPins, wxString::Format( wxT(
"Converting %zu pins to stacked notation '%s'" ),
1342 pinsToConvert.size(), stackedNotation ) );
1346 std::vector<SCH_PIN*> pinsToRemove;
1347 for(
size_t i = 1; i < pinsToConvert.size(); ++i )
1349 SCH_PIN* pinToRemove = pinsToConvert[i];
1352 wxLogTrace(
traceStackedPins, wxString::Format( wxT(
"Will remove pin '%s' at position (%d, %d)" ),
1357 pinsToRemove.push_back( pinToRemove );
1366 commit.
Push(
_(
"Convert Stacked Pins" ) );
1381 wxCHECK( selTool, -1 );
1387 m_frame->ShowInfoBarError(
_(
"Select a single pin with stacked notation to explode" ) );
1395 std::vector<wxString> stackedNumbers =
pin->GetStackedPinNumbers( &isValid );
1397 if( !isValid || stackedNumbers.size() <= 1 )
1399 m_frame->ShowInfoBarError(
_(
"Selected pin does not have valid stacked notation" ) );
1409 std::sort( stackedNumbers.begin(), stackedNumbers.end(),
1410 [](
const wxString& a,
const wxString& b )
1414 if( a.ToLong( &numA ) && b.ToLong( &numB ) )
1422 pin->SetNumber( stackedNumbers[0] );
1423 pin->SetVisible(
true );
1426 for(
size_t i = 1; i < stackedNumbers.size(); ++i )
1453 commit.
Push(
_(
"Explode Stacked Pin" ) );
1468 m_frame->ShowInfoBarError(
_(
"Symbol is not derived from another symbol." ) );
1490 m_frame->GetSymbolFromUndoList();
1506 m_frame->GetSymbolFromRedoList();
1516 int retVal =
Copy( aEvent );
1530 if( !symbol || !selection.
GetSize() )
1540 if( !item.IsSelected() )
1554 std::string prettyData = formatter.
GetString();
1558 std::vector<CLIPBOARD_MIME_DATA> mimeData;
1575 bbox.
GetHeight() * clipboardBboxInflation );
1578 std::unique_ptr<LIB_SYMBOL> plotSymbol = std::make_unique<LIB_SYMBOL>( *symbol );
1581 for(
SCH_ITEM& item : plotSymbol->GetDrawItems() )
1589 for(
EDA_ITEM* selItem : selection )
1593 if( selSchItem->
Type() == item.Type()
1594 && selSchItem->
GetPosition() == item.GetPosition() )
1606 std::unique_ptr<LIB_SYMBOL> cleanSymbol = std::make_unique<LIB_SYMBOL>( *plotSymbol );
1609 int unit =
m_frame->GetUnit();
1610 int bodyStyle =
m_frame->GetBodyStyle();
1612 wxMemoryBuffer svgBuffer;
1614 if( plotSymbolToSvg( *
m_frame, *cleanSymbol, bbox, unit, bodyStyle, svgBuffer ) )
1615 appendMimeData( mimeData, wxS(
"image/svg+xml" ), svgBuffer );
1617 tl::expected<wxImage, std::string> pngImage =
1618 renderSymbolToImageWithAlpha( *
m_frame, *cleanSymbol, bbox, unit, bodyStyle );
1622 wxASSERT( pngImage->IsOk() );
1623 appendMimeData( mimeData, wxS(
"image/png" ), std::move( *pngImage ) );
1627 wxLogWarning( wxS(
"Failed to render symbol to PNG: " ) + wxString::FromUTF8( pngImage.error() ) );
1643 if( selection.Empty() )
1648 if( selection.IsHover() )
1669 if( newParts.empty() || !newParts[0] )
1672 newPart = newParts[0];
1679 wxString pasteText( clipboardData );
1683 if( pasteText.Length() > 5000 )
1684 pasteText = pasteText.Left( 5000 ) + wxT(
"..." );
1720 if( !selection.
Empty() )
1725 commit.
Push(
_(
"Paste" ) );
1740 if( selection.
GetSize() == 0 )
1745 std::vector<EDA_ITEM*> oldItems;
1746 std::vector<EDA_ITEM*> newItems;
1748 std::copy( selection.
begin(), selection.
end(), std::back_inserter( oldItems ) );
1749 std::sort( oldItems.begin(), oldItems.end(), [](
EDA_ITEM* a,
EDA_ITEM* b )
1753 if( a->Type() != b->Type() )
1754 return a->Type() < b->Type();
1757 if( a->Type() == SCH_PIN_T )
1759 const wxString& aNum = static_cast<SCH_PIN*>( a )->GetNumber();
1760 const wxString& bNum = static_cast<SCH_PIN*>( b )->GetNumber();
1762 cmp = StrNumCmp( aNum, bNum );
1766 if( aNum.IsNumber() && bNum.IsNumber() && cmp != 0 )
1788 newPin->
SetNumber( wxString::Format( wxT(
"%i" ), symbol->GetMaxPinNumber() + 1 ) );
1794 newItems.push_back( newItem );
1796 symbol->AddDrawItem( newItem );
1797 getView()->Add( newItem );
1803 selection.SetReferencePoint( getViewControls()->GetCursorPosition(
true ) );
1806 commit.Push(
_(
"Duplicate" ) );
constexpr EDA_IU_SCALE schIUScale
std::optional< BOX2I > OPT_BOX2I
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static TOOL_ACTION decrementPrimary
static TOOL_ACTION cancelInteractive
static TOOL_ACTION unselectAll
static TOOL_ACTION decrementSecondary
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)
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr size_type GetHeight() const
constexpr const SizeVec & GetSize() const
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)
void SelectPinMapPage()
Switch the notebook to the Pin Map page (issue #2282).
bool GetApplyToAllConversions()
bool GetApplyToAllUnits()
Dialog to update or change schematic library symbols.
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)
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
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)
EDA_ITEM * GetParent() const
virtual void SetParent(EDA_ITEM *aParent)
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)
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
A color representation with 4 components: red, green, blue, alpha.
GAL_ANTIALIASING_MODE antialiasing_mode
static std::unique_ptr< GAL_PRINT > Create(GAL_DISPLAY_OPTIONS &aOptions, wxDC *aDC)
Abstract interface for drawing on a 2D-surface.
void SetZoomFactor(double aZoomFactor)
void SetLookAtPoint(const VECTOR2D &aPoint)
Get/set the Point in world space to look at.
virtual void ClearScreen()
Clear the screen.
void SetWorldUnitLength(double aWorldUnitLength)
Set the unit length.
void SetClearColor(const COLOR4D &aColor)
virtual double GetNativeDPI() const =0
virtual bool HasNativeLandscapeRotation() const =0
int GetDefaultPenWidth() const
void SetDefaultPenWidth(int aWidth)
void SetIsPrinting(bool isPrinting)
const VC_SETTINGS & GetSettings() const
Return the current VIEW_CONTROLS settings.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
static constexpr int VIEW_MAX_LAYERS
Maximum number of layers that may be shown.
A logical library item identifier and consists of various portions much like a URI.
bool IsValid() const
Check if this LID_ID is valid.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Symbol library management helper that is specific to the symbol library editor frame.
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & GetAdapter()
Return the adapter object that provides the stored data.
Define a library symbol object.
const LIB_ID & GetLibId() const override
bool UnitsLocked() const
Check whether symbol units are interchangeable.
bool CanUpdateFieldsFromParent() const
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
wxString GetName() const override
void RemoveDrawItem(SCH_ITEM *aItem)
Remove draw aItem from list.
int GetUnitCount() const override
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const override
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
OPT_BOX2I GetPinNumberBBox()
Get the bounding box of the pin number, if there is one.
static TOOL_ACTION rotateCCW
static TOOL_ACTION editSymbolPinMaps
static TOOL_ACTION mirrorV
static TOOL_ACTION convertStackedPins
static TOOL_ACTION pinTable
static TOOL_ACTION properties
static TOOL_ACTION rotateCW
static TOOL_ACTION mirrorH
static TOOL_ACTION symbolProperties
static TOOL_ACTION explodeStackedPin
static TOOL_ACTION updateSymbolFields
SCH_RENDER_SETTINGS * GetRenderSettings()
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Commit for the schematic and symbol editors.
void Revert() override
Revert the commit by restoring the modified items state.
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the KIGFX::VIEW instance used in the panel.
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 aDoClone=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 SetVisible(bool aVisible)
void SetOrientation(PIN_ORIENTATION aOrientation)
void SetName(const wxString &aName)
void SetPosition(const VECTOR2I &aPos) override
const wxString & GetName() const
void SetLength(int aLength)
PIN_ORIENTATION GetOrientation() const
void SetNumberTextSize(int aSize)
void SetShape(GRAPHIC_PINSHAPE aShape)
VECTOR2I GetPosition() const override
PIN_LAYOUT_CACHE & GetLayoutCache() const
Get the layout cache associated with this pin.
void SetType(ELECTRICAL_PINTYPE aType)
const wxString & GetNumber() const
ELECTRICAL_PINTYPE GetType() const
void SetNameTextSize(int aSize)
void SetBackgroundColor(const COLOR4D &aColor) override
Set the background color.
void LoadColors(const COLOR_SETTINGS *aSettings) override
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
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.
The symbol library editor main window.
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
LIB_SYMBOL * GetBufferedSymbol(const wxString &aSymbolName, const wxString &aLibrary)
Return the symbol copy from the buffer.
bool UpdateSymbolAfterRename(LIB_SYMBOL *aSymbol, const wxString &aOldSymbolName, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol when the name has changed.
void SetSymbolModified(const wxString &aSymbolName, const wxString &aLibrary)
bool UpdateSymbol(LIB_SYMBOL *aSymbol, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol.
A modified version of the wxInfoBar class that allows us to:
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
void AddLink(const wxString &aLinkText, const std::function< void(wxHyperlinkEvent &)> &aFn)
Add a hypertext link to the infobar.
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
std::string GetClipboardUTF8()
Return the information currently stored in the system clipboard.
#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
const wxChar *const traceStackedPins
Flag to enable debug output for stacked pins handling in symbol/pin code.
bool LoadFileToMemory(const wxString &aFileName, wxMemoryBuffer &aBuffer)
Load the contents of a file into a memory buffer.
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin.
PIN_ORIENTATION
The symbol library pin object orientations.
tl::expected< wxImage, std::string > CreateAlphaImageFromTwoRenders(const wxImage &aOnWhite, const wxImage &aOnBlack)
Combine two opaque renders of the same content into a single image with an alpha channel.
std::vector< EDA_ITEM * > EDA_ITEMS
bool PlotSymbolToSVG(LIB_SYMBOL &aDrawSymbol, LIB_SYMBOL &aFieldsSymbol, int aUnit, int aBodyStyle, const BOX2I &aBBox, SCH_RENDER_SETTINGS &aRenderSettings, bool aBlackAndWhite, const wxString &aFileName, REPORTER *aReporter)
Plot a single symbol variant (unit and body style) to an SVG file.
constexpr double SCH_WORLD_UNIT(1e-7/0.0254)
wxString TitleCaps(const wxString &aString)
Capitalize the first letter in each word.
wxString EscapeStackedPinItem(const wxString &aPinNumber)
Escape the characters that carry structural meaning inside stacked pin notation ('[',...
std::optional< wxBitmap > m_image
Optional bitmap image to add to clipboard via wxBitmapDataObject.
bool m_lastKeyboardCursorPositionValid
Is last cursor motion event coming from keyboard arrow cursor motion action.
wxString result
Test unit parsing edge cases and error handling.
constexpr GR_TEXT_H_ALIGN_T GetFlippedAlignment(GR_TEXT_H_ALIGN_T aAlign)
Get the reverse alignment: left-right are swapped, others are unchanged.
wxLogTrace helper definitions.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
constexpr int LexicographicalCompare(const VECTOR2< T > &aA, const VECTOR2< T > &aB)
#define ZOOM_MIN_LIMIT_EESCHEMA
#define ZOOM_MAX_LIMIT_EESCHEMA