22#include "tl/expected.hpp"
27#include <wx/mstream.h>
28#include <wx/dcmemory.h>
71constexpr int clipboardMaxBitmapSize = 4096;
72constexpr double clipboardBboxInflation = 0.02;
75void appendMimeData( std::vector<CLIPBOARD_MIME_DATA>& aMimeData,
const wxString& aMimeType,
76 const wxMemoryBuffer& aBuffer )
78 if( aBuffer.GetDataLen() == 0 )
84 aMimeData.push_back( entry );
88void appendMimeData( std::vector<CLIPBOARD_MIME_DATA>& aMimeData,
const wxString& aMimeType,
96 entry.
m_image = std::move( aImage );
97 aMimeData.push_back( std::move( entry ) );
102 int aUnit,
int aBodyStyle, wxMemoryBuffer& aBuffer )
108 wxFileName tempFile( wxFileName::CreateTempFileName( wxS(
"kicad_symbol_svg" ) ) );
112 if( !
PlotSymbolToSVG( aSymbol, aSymbol, aUnit, aBodyStyle, aBBox, renderSettings,
false,
113 tempFile.GetFullPath() ) )
115 wxRemoveFile( tempFile.GetFullPath() );
120 wxRemoveFile( tempFile.GetFullPath() );
126 int aUnit,
int aBodyStyle,
int aWidth,
int aHeight,
127 double aViewScale,
const wxColour& aBgColor )
129 wxBitmap bitmap( aWidth, aHeight, 24 );
131 dc.SelectObject( bitmap );
132 dc.SetBackground( wxBrush( aBgColor ) );
144 std::unique_ptr<KIGFX::SCH_PAINTER> painter = std::make_unique<KIGFX::SCH_PAINTER>( gal );
145 std::unique_ptr<KIGFX::VIEW> view = std::make_unique<KIGFX::VIEW>();
150 view->SetPainter( painter.get() );
152 view->SetScale( 1.0 );
156 std::vector<std::unique_ptr<SCH_ITEM>> clonedItems;
160 if( aUnit && item.GetUnit() && item.GetUnit() != aUnit )
163 if( aBodyStyle && item.GetBodyStyle() && item.GetBodyStyle() != aBodyStyle )
167 clonedItems.emplace_back( clone );
176 COLOR4D bgColor4D( aBgColor.Red() / 255.0, aBgColor.Green() / 255.0,
177 aBgColor.Blue() / 255.0, 1.0 );
182 view->SetLayerVisible( i,
true );
196 double inch2Iu = 1000.0 *
schIUScale.IU_PER_MILS;
197 VECTOR2D pageSizeIn( (
double) aWidth / ppi, (
double) aHeight / ppi );
199 galPrint->SetSheetSize( pageSizeIn );
204 double zoomFactor = 2.0 * aViewScale * inch2Iu / ppi;
207 view->SetCenter( aBBox.
Centre() );
208 view->SetScale( aViewScale * zoomFactor );
215 view->UseDrawPriority(
true );
222 dc.SelectObject( wxNullBitmap );
223 return bitmap.ConvertToImage();
228 const BOX2I& aBBox,
int aUnit,
int aBodyStyle )
232 if( size.
x <= 0 || size.
y <= 0 )
233 return tl::make_unexpected(
"Invalid image size" + std::to_string( size.
x ) +
"x" + std::to_string( size.
y ) );
237 int bitmapWidth =
KiROUND( size.
x * viewScale );
238 int bitmapHeight =
KiROUND( size.
y * viewScale );
241 if( bitmapWidth > clipboardMaxBitmapSize || bitmapHeight > clipboardMaxBitmapSize )
243 double scaleDown = (double) clipboardMaxBitmapSize / std::max( bitmapWidth, bitmapHeight );
244 bitmapWidth =
KiROUND( bitmapWidth * scaleDown );
245 bitmapHeight =
KiROUND( bitmapHeight * scaleDown );
246 viewScale *= scaleDown;
249 if( bitmapWidth <= 0 || bitmapHeight <= 0 )
250 return tl::make_unexpected(
"Invalid image size" + std::to_string( bitmapWidth ) +
"x"
251 + std::to_string( bitmapHeight ) );
254 wxImage imageOnWhite = renderSymbolToBitmap( aFrame, aSymbol, aBBox, aUnit, aBodyStyle, bitmapWidth, bitmapHeight,
255 viewScale, *wxWHITE );
256 wxImage imageOnBlack = renderSymbolToBitmap( aFrame, aSymbol, aBBox, aUnit, aBodyStyle, bitmapWidth, bitmapHeight,
257 viewScale, *wxBLACK );
259 if( !imageOnWhite.IsOk() || !imageOnBlack.IsOk() )
260 return tl::make_unexpected(
"Failed to render symbol to white/black bitmaps" );
291 wxASSERT_MSG( drawingTools,
"eeschema.SymbolDrawing tool is not available" );
293 auto haveSymbolCondition =
302 if( !
m_frame->IsSymbolEditable() )
317 auto swapSelectionCondition =
329 const auto canConvertStackedPins =
333 if( sel.Size() >= 2 )
335 std::vector<SCH_PIN*> pins;
340 pins.push_back(
static_cast<SCH_PIN*
>( item ) );
344 VECTOR2I pos = pins[0]->GetPosition();
345 for(
size_t i = 1; i < pins.size(); ++i )
347 if( pins[i]->GetPosition() != pos )
354 if( sel.Size() == 1 && sel.Front()->Type() ==
SCH_PIN_T )
364 int coLocatedCount = 0;
368 if(
pin->GetPosition() == pos )
372 if( coLocatedCount >= 2 )
381 const auto canExplodeStackedPin =
384 if( sel.Size() != 1 || sel.Front()->Type() !=
SCH_PIN_T )
389 std::vector<wxString> stackedNumbers =
pin->GetStackedPinNumbers( &isValid );
390 return isValid && stackedNumbers.size() > 1;
477 commit = &localCommit;
487 for(
unsigned ii = 0; ii < selection.
GetSize(); ii++ )
490 item->
Rotate( rotPoint, ccw );
491 m_frame->UpdateItem( item,
false,
true );
503 if( !localCommit.
Empty() )
504 localCommit.
Push(
_(
"Rotate" ) );
529 switch( item->
Type() )
553 m_frame->UpdateItem( item,
false,
true );
559 for(
unsigned ii = 0; ii < selection.
GetSize(); ii++ )
568 m_frame->UpdateItem( item,
false,
true );
591 if( selection.
Size() < 2 )
601 for(
size_t i = 0; i < sorted.size() - 1; i++ )
607 std::swap( aPos, bPos );
634 m_frame->UpdateItem( a,
false,
true );
635 m_frame->UpdateItem( b,
false,
true );
639 for(
EDA_ITEM* selected : selection )
671 std::deque<EDA_ITEM*> items =
m_selectionTool->RequestSelection().GetItems();
682 std::set<SCH_ITEM*> toDelete;
683 int fieldsHidden = 0;
684 int fieldsAlreadyHidden = 0;
693 toDelete.insert( curr_pin );
697 if(
m_frame->SynchronizePins() )
699 std::vector<bool> got_unit( symbol->
GetUnitCount() + 1 );
701 got_unit[curr_pin->
GetUnit()] =
true;
705 if( got_unit[
pin->GetUnit()] )
708 if(
pin->GetPosition() != pos )
720 toDelete.insert(
pin );
721 got_unit[
pin->GetUnit()] =
true;
737 fieldsAlreadyHidden++;
742 toDelete.insert( schItem );
749 if( toDelete.size() == 0 )
751 if( fieldsHidden == 1 )
752 commit.
Push(
_(
"Hide Field" ) );
753 else if( fieldsHidden > 1 )
754 commit.
Push(
_(
"Hide Fields" ) );
755 else if( fieldsAlreadyHidden > 0 )
756 m_frame->ShowInfoBarError(
_(
"Use the Symbol Properties dialog to remove fields." ) );
760 commit.
Push(
_(
"Delete" ) );
769 bool aCursorMovedByKeyboard )
771 if( aCursorMovedByKeyboard )
776 return numberBox->Contains( aMousePos );
795 ( !
m_frame->GetCurSymbol() ||
m_frame->GetCurSymbol()->GetLibId() != treeLibId ) )
806 else if( selection.
Size() == 1 )
814 switch( item->
Type() )
821 const bool keyboardCursor =
846 wxFAIL_MSG( wxT(
"Unhandled item <" ) + item->
GetClass() + wxT(
">" ) );
850 else if( selection.
Size() > 1 )
856 if( !
frame()->GetPropertiesPanel()->IsShownOnScreen() )
858 infobar->
AddLink(
_(
"Show Properties panel" ),
859 [
this]( wxHyperlinkEvent& )
861 frame()->ToggleProperties();
866 infobar->
ShowMessageFor(
_(
"Use Properties panel to edit properties common to selected items." ),
867 8000, wxICON_INFORMATION );
885 m_frame->GetCanvas()->Refresh();
891 std::vector<MSG_PANEL_ITEM> items;
908 m_frame->GetCanvas()->Refresh();
924 m_frame->GetCanvas()->Refresh();
931 if( aField ==
nullptr )
939 caption.Printf(
_(
"Edit '%s' Field" ), aField->
GetName() );
953 commit.
Push( caption );
955 m_frame->GetCanvas()->Refresh();
956 m_frame->UpdateSymbolMsgPanelInfo();
969 if( !bufferedSymbol )
987 wxString newName = tempSymbol.
GetName();
992 if( newName != symbolName )
1001 LIB_ID newLibId( libName, newName );
1002 wxDataViewItem treeItem = libMgr.
GetAdapter()->FindItem( newLibId );
1003 m_frame->UpdateLibraryTree( treeItem, &tempSymbol );
1004 m_frame->GetLibTree()->SelectLibId( newLibId );
1025 m_frame->RebuildSymbolUnitAndBodyStyleLists();
1032 m_frame->UpdateLibraryTree( treeItem, symbol );
1066 m_frame->RebuildSymbolUnitAndBodyStyleLists();
1084 wxCHECK( selTool, -1 );
1086 std::vector<SCH_PIN*> selectedPins;
1095 selectedPins.push_back( pinItem );
1108 commit.
Push(
_(
"Edit Pins" ) );
1124 wxCHECK( selTool, -1 );
1129 std::vector<SCH_PIN*> pinsToConvert;
1139 if(
pin->GetPosition() == pos )
1140 pinsToConvert.push_back(
pin );
1149 pinsToConvert.push_back(
static_cast<SCH_PIN*
>( item ) );
1153 if( pinsToConvert.size() < 2 )
1155 m_frame->ShowInfoBarError(
_(
"At least two pins are needed to convert to stacked pins" ) );
1160 VECTOR2I pos = pinsToConvert[0]->GetPosition();
1161 for(
size_t i = 1; i < pinsToConvert.size(); ++i )
1163 if( pinsToConvert[i]->GetPosition() != pos )
1165 m_frame->ShowInfoBarError(
_(
"All pins must be at the same location" ) );
1176 std::sort( pinsToConvert.begin(), pinsToConvert.end(),
1179 wxString numA = a->GetNumber();
1180 wxString numB = b->GetNumber();
1184 bool aIsNumeric = numA.ToLong( &longA );
1185 bool bIsNumeric = numB.ToLong( &longB );
1188 if( aIsNumeric && bIsNumeric )
1189 return longA < longB;
1192 if( aIsNumeric && !bIsNumeric )
1194 if( !aIsNumeric && bIsNumeric )
1202 wxString stackedNotation = wxT(
"[");
1205 auto collapseRanges = [&]() -> wxString
1207 if( pinsToConvert.empty() )
1213 std::map<wxString, std::vector<long>> prefixGroups;
1214 std::vector<wxString> nonNumericPins;
1219 wxString pinNumber =
pin->GetNumber();
1222 if( pinNumber.IsEmpty() )
1224 nonNumericPins.push_back( wxT(
"(empty)") );
1229 wxString numericPart;
1232 size_t numStart = pinNumber.length();
1233 for(
int i = pinNumber.length() - 1; i >= 0; i-- )
1235 if( !wxIsdigit( pinNumber[i] ) )
1244 if( numStart < pinNumber.length() )
1246 prefix = pinNumber.Left( numStart );
1247 numericPart = pinNumber.Mid( numStart );
1250 if( numericPart.ToLong( &numValue ) && numValue >= 0 )
1252 prefixGroups[prefix].push_back( numValue );
1257 nonNumericPins.push_back( pinNumber );
1262 nonNumericPins.push_back( pinNumber );
1267 for(
auto& [prefix, numbers] : prefixGroups )
1277 std::sort( numbers.begin(), numbers.end() );
1281 while( i < numbers.size() )
1286 long start = numbers[i];
1290 while( i + 1 < numbers.size() && numbers[i + 1] == numbers[i] + 1 )
1297 if(
end > start + 1 )
1298 result += wxString::Format( wxT(
"%s%ld-%s%ld"), escPrefix, start, escPrefix,
end );
1299 else if(
end == start + 1 )
1300 result += wxString::Format( wxT(
"%s%ld,%s%ld"), escPrefix, start, escPrefix,
end );
1302 result += wxString::Format( wxT(
"%s%ld"), escPrefix, start );
1309 for(
const wxString& nonNum : nonNumericPins )
1319 stackedNotation += collapseRanges();
1320 stackedNotation += wxT(
"]");
1323 SCH_PIN* masterPin = pinsToConvert[0];
1324 masterPin->
SetNumber( stackedNotation );
1328 wxString::Format(
"Converting %zu pins to stacked notation '%s'",
1329 pinsToConvert.size(), stackedNotation ) );
1333 std::vector<SCH_PIN*> pinsToRemove;
1334 for(
size_t i = 1; i < pinsToConvert.size(); ++i )
1336 SCH_PIN* pinToRemove = pinsToConvert[i];
1340 wxString::Format(
"Will remove pin '%s' at position (%d, %d)",
1345 pinsToRemove.push_back( pinToRemove );
1354 commit.
Push( wxString::Format(
_(
"Convert %zu Stacked Pins to '%s'" ),
1355 pinsToConvert.size(), stackedNotation ) );
1370 wxCHECK( selTool, -1 );
1376 m_frame->ShowInfoBarError(
_(
"Select a single pin with stacked notation to explode" ) );
1384 std::vector<wxString> stackedNumbers =
pin->GetStackedPinNumbers( &isValid );
1386 if( !isValid || stackedNumbers.size() <= 1 )
1388 m_frame->ShowInfoBarError(
_(
"Selected pin does not have valid stacked notation" ) );
1398 std::sort( stackedNumbers.begin(), stackedNumbers.end(),
1399 [](
const wxString& a,
const wxString& b )
1403 if( a.ToLong( &numA ) && b.ToLong( &numB ) )
1411 pin->SetNumber( stackedNumbers[0] );
1412 pin->SetVisible(
true );
1415 for(
size_t i = 1; i < stackedNumbers.size(); ++i )
1442 commit.
Push(
_(
"Explode Stacked Pin" ) );
1457 m_frame->ShowInfoBarError(
_(
"Symbol is not derived from another symbol." ) );
1479 m_frame->GetSymbolFromUndoList();
1495 m_frame->GetSymbolFromRedoList();
1505 int retVal =
Copy( aEvent );
1519 if( !symbol || !selection.
GetSize() )
1529 if( !item.IsSelected() )
1543 std::string prettyData = formatter.
GetString();
1547 std::vector<CLIPBOARD_MIME_DATA> mimeData;
1564 bbox.
GetHeight() * clipboardBboxInflation );
1567 std::unique_ptr<LIB_SYMBOL> plotSymbol = std::make_unique<LIB_SYMBOL>( *symbol );
1570 for(
SCH_ITEM& item : plotSymbol->GetDrawItems() )
1578 for(
EDA_ITEM* selItem : selection )
1582 if( selSchItem->
Type() == item.Type()
1583 && selSchItem->
GetPosition() == item.GetPosition() )
1595 std::unique_ptr<LIB_SYMBOL> cleanSymbol = std::make_unique<LIB_SYMBOL>( *plotSymbol );
1598 int unit =
m_frame->GetUnit();
1599 int bodyStyle =
m_frame->GetBodyStyle();
1601 wxMemoryBuffer svgBuffer;
1603 if( plotSymbolToSvg( *
m_frame, *cleanSymbol, bbox, unit, bodyStyle, svgBuffer ) )
1604 appendMimeData( mimeData, wxS(
"image/svg+xml" ), svgBuffer );
1606 tl::expected<wxImage, std::string> pngImage =
1607 renderSymbolToImageWithAlpha( *
m_frame, *cleanSymbol, bbox, unit, bodyStyle );
1611 wxASSERT( pngImage->IsOk() );
1612 appendMimeData( mimeData, wxS(
"image/png" ), std::move( *pngImage ) );
1616 wxLogWarning( wxS(
"Failed to render symbol to PNG: " ) + wxString::FromUTF8( pngImage.error() ) );
1632 if( selection.Empty() )
1637 if( selection.IsHover() )
1658 if( newParts.empty() || !newParts[0] )
1661 newPart = newParts[0];
1668 wxString pasteText( clipboardData );
1672 if( pasteText.Length() > 5000 )
1673 pasteText = pasteText.Left( 5000 ) + wxT(
"..." );
1709 if( !selection.
Empty() )
1714 commit.
Push(
_(
"Paste" ) );
1729 if( selection.
GetSize() == 0 )
1734 std::vector<EDA_ITEM*> oldItems;
1735 std::vector<EDA_ITEM*> newItems;
1737 std::copy( selection.
begin(), selection.
end(), std::back_inserter( oldItems ) );
1738 std::sort( oldItems.begin(), oldItems.end(), [](
EDA_ITEM* a,
EDA_ITEM* b )
1742 if( a->Type() != b->Type() )
1743 return a->Type() < b->Type();
1746 if( a->Type() == SCH_PIN_T )
1748 const wxString& aNum = static_cast<SCH_PIN*>( a )->GetNumber();
1749 const wxString& bNum = static_cast<SCH_PIN*>( b )->GetNumber();
1751 cmp = StrNumCmp( aNum, bNum );
1755 if( aNum.IsNumber() && bNum.IsNumber() && cmp != 0 )
1777 newPin->
SetNumber( wxString::Format( wxT(
"%i" ), symbol->GetMaxPinNumber() + 1 ) );
1783 newItems.push_back( newItem );
1785 symbol->AddDrawItem( newItem );
1786 getView()->Add( newItem );
1792 selection.SetReferencePoint( getViewControls()->GetCursorPosition(
true ) );
1795 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
The grid style to draw the grid in.
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.
std::vector< SCH_PIN * > GetPins() const override
int GetUnitCount() const override
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.
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.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #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 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 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