28#include <unordered_set>
31#include <wx/clipbrd.h>
33#include <wx/filedlg.h>
35#include <wx/imagpng.h>
39#include <wx/mstream.h>
40#include <wx/textdlg.h>
41#include <wx/treectrl.h>
126constexpr int clipboardMaxBitmapSize = 4096;
127constexpr double clipboardBboxInflation = 0.02;
130std::vector<SCH_ITEM*> collectSelectionItems(
const SCH_SELECTION& aSelection )
132 std::vector<SCH_ITEM*> items;
133 items.reserve( aSelection.
GetSize() );
140 items.push_back( schItem );
153 bbox.
GetHeight() * clipboardBboxInflation );
159bool generateHtmlFromPngData(
const wxMemoryBuffer& aPngData, wxMemoryBuffer& aHtmlBuffer )
161 if( aPngData.GetDataLen() == 0 )
164 std::vector<uint8_t> pngVec(
static_cast<const uint8_t*
>( aPngData.GetData() ),
165 static_cast<const uint8_t*
>( aPngData.GetData() ) + aPngData.GetDataLen() );
167 std::vector<uint8_t> base64Data;
170 std::string html =
"<img src=\"data:image/png;base64,";
171 html.append(
reinterpret_cast<const char*
>( base64Data.data() ), base64Data.size() );
172 html.append(
"\" />" );
174 aHtmlBuffer.SetDataLen( 0 );
175 aHtmlBuffer.AppendData( html.data(), html.size() );
182 wxMemoryBuffer& aBuffer )
187 renderSettings.m_ShowHiddenPins =
false;
188 renderSettings.m_ShowHiddenFields =
false;
190 std::unique_ptr<SVG_PLOTTER> plotter = std::make_unique<SVG_PLOTTER>();
191 plotter->SetRenderSettings( &renderSettings );
197 plotter->SetPageSettings( pageInfo );
198 plotter->SetColorMode(
true );
201 plotter->SetViewport( plot_offset,
schIUScale.IU_PER_MILS / 10, 1.0,
false );
202 plotter->SetCreator( wxT(
"Eeschema-SVG" ) );
204 wxFileName tempFile( wxFileName::CreateTempFileName( wxS(
"kicad_svg" ) ) );
206 if( !plotter->OpenFile( tempFile.GetFullPath() ) )
208 wxRemoveFile( tempFile.GetFullPath() );
216 plotter->StartPlot( wxT(
"1" ) );
217 aFrame->
GetScreen()->
Plot( plotter.get(), plotOpts, collectSelectionItems( aSelection ) );
222 wxRemoveFile( tempFile.GetFullPath() );
233 int aWidth,
int aHeight,
bool aUseAlpha,
bool aIncludeDrawingSheet )
235 wxImage
image( aWidth, aHeight,
false );
240 double actualPPI = std::max( actualPPI_x, actualPPI_y );
242 VECTOR2D pageSizeIn( (
double) aWidth / actualPPI, (
double) aHeight / actualPPI );
254 std::unique_ptr<KIGFX::SCH_PAINTER> painter = std::make_unique<KIGFX::SCH_PAINTER>( gal.get() );
255 std::unique_ptr<KIGFX::VIEW> view = std::make_unique<KIGFX::VIEW>();
257 painter->SetSchematic( &aFrame->
Schematic() );
258 view->SetGAL( gal.get() );
259 view->SetPainter( painter.get() );
261 view->SetScale( 1.0 );
264 gal->SetSheetSize( pageSizeIn );
268 std::vector<std::unique_ptr<SCH_ITEM>> clonedItems;
269 clonedItems.reserve( aSelection.
GetSize() );
279 clonedItems.emplace_back( clone );
296 view->SetLayerVisible( i,
true );
303 std::unique_ptr<DS_PROXY_VIEW_ITEM> drawingSheet;
305 if( aIncludeDrawingSheet )
323 drawingSheet->SetVariantName(
TO_UTF8( currentVariant ) );
324 drawingSheet->SetVariantDesc(
TO_UTF8( variantDesc ) );
326 view->Add( drawingSheet.get() );
329 view->SetCenter( aBBox.
Centre() );
330 view->UseDrawPriority(
true );
346 const BOX2I& aBBox,
bool aUseAlpha,
bool aIncludeDrawingSheet )
348 const double c_targetPPI = 300;
349 const double c_targetPixelsPerMM = c_targetPPI / 25.4;
353 if( size.
x <= 0 || size.
y <= 0 )
360 if( bitmapWidth > clipboardMaxBitmapSize || bitmapHeight > clipboardMaxBitmapSize )
362 double scaleDown = (double) clipboardMaxBitmapSize / std::max( bitmapWidth, bitmapHeight );
363 bitmapWidth =
KiROUND( bitmapWidth * scaleDown );
364 bitmapHeight =
KiROUND( bitmapHeight * scaleDown );
367 if( bitmapWidth <= 0 || bitmapHeight <= 0 )
370 wxImage
result = renderSelectionToBitmap( aFrame, aSelection, aBBox, bitmapWidth, bitmapHeight, aUseAlpha,
371 aIncludeDrawingSheet );
410 wxFileDialog dlg(
m_frame,
_(
"Schematic Files" ), curr_fn.GetPath(), curr_fn.GetFullName(),
415 if( dlg.ShowModal() == wxID_CANCEL )
420 m_frame->saveSchematicFile( curr_sheet, newFilename,
true );
428 msg.Printf(
_(
"Revert '%s' (and all sub-sheets) to last version saved?" ),
m_frame->Schematic().GetFileName() );
441 m_frame->ShowSchematicSetupDialog();
463 m_frame->GetCanvas()->GetView()->MarkDirty();
465 m_frame->GetCanvas()->Refresh();
471 m_frame->RollbackSchematicFromUndo();
494 m_frame->GetCanvas()->GetBackend() );
503 m_frame->GetCanvas()->GetBackend() );
521 if( aRunningOnDemand )
531 m_frame->GetCanvas()->Refresh();
545 m_frame->GetCanvas()->Refresh(
true );
573 m_frame->Schematic().OnSchSelectionChanged();
595 m_frame->SendSelectItemsToPcb( selection.GetItemsSortedBySelectionOrder(), aForce );
601 const wxString title =
_(
"Export for Older KiCad Version" );
604 if(
m_frame->IsContentModified() )
606 int answer = wxMessageBox(
_(
"You have unsaved changes. Save them before exporting?" ), title,
607 wxYES_NO | wxCANCEL | wxICON_WARNING,
m_frame );
609 if( answer == wxCANCEL )
612 if( answer == wxYES && !
m_frame->SaveProject() )
614 wxMessageBox(
_(
"The schematic was not saved. Nothing was exported." ), title, wxOK | wxICON_ERROR,
620 const wxString schematic =
m_frame->Schematic().RootScreen()->GetFileName();
631 wxFileName out( aPass.
m_folder, wxEmptyString );
632 out.AppendDir( wxFileName( schematic ).
GetName() );
649 bool savePowerSymbols =
false;
655 targetLib =
m_frame->SelectLibrary(
_(
"Export Symbols" ),
_(
"Export symbols to library:" ),
656 { {
_(
"Include power symbols in export" ), &savePowerSymbols },
657 {
_(
"Update schematic symbols to link to exported symbols" ), &map }
660 if( targetLib.empty() )
667 std::map<LIB_ID, LIB_SYMBOL*> libSymbols;
668 std::map<LIB_ID, std::vector<SCH_SYMBOL*>> symbolMap;
670 for(
size_t i = 0; i < symbols.
GetCount(); ++i )
676 if( libSymbols.count(
id ) )
679 "Two symbols have the same LIB_ID but are different!" );
683 libSymbols[id] = libSymbol;
686 symbolMap[id].emplace_back( symbol );
693 auto optRow = adapter->
GetRow( targetLib );
694 wxCHECK( optRow, 0 );
703 for(
const std::pair<const LIB_ID, LIB_SYMBOL*>& it : libSymbols )
706 std::unique_ptr<LIB_SYMBOL> newSym = origSym->
Flatten();
707 const wxString newSymName = newSym->GetName();
711 pi->SaveSymbol( dest.GetFullPath(), std::move( newSym ) );
715 msg.Printf(
_(
"Error saving symbol %s to library '%s'." ), newSymName, row->
Nickname() );
716 msg += wxS(
"\n\n" ) + ioe.
What();
726 for(
SCH_SYMBOL* symbol : symbolMap[it.first] )
730 wxCHECK2( parentScreen,
continue );
733 symbol->SetLibId(
id );
741 std::set<SCH_SCREEN*> processedScreens;
747 if( processedScreens.find( ( screen ) ) == processedScreens.end() )
749 processedScreens.insert( screen );
754 commit.
Push( wxS(
"Update Library Identifiers" ) );
761#define HITTEST_THRESHOLD_PIXELS 5
765 static const std::vector<KICAD_T> voltageProbeTypes = {
778 blocking_win->Close(
true );
803 wxString variant =
m_frame->Schematic().GetCurrentVariant();
814 if( !symbol || !libPin )
822 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
823 embeddedFilesStack.push_back(
m_frame->Schematic().GetEmbeddedFiles() );
829 embeddedFilesStack.push_back( symbolEmbeddedFile );
840 std::vector<std::string> currentNames =
model.SpiceGenerator().CurrentNames( spiceItem );
842 if( currentNames.size() == 0 )
846 else if( currentNames.size() == 1 )
854 int modelPinIndex =
model.FindModelPinIndex( libPin->
GetNumber().ToStdString() );
858 wxString
name = currentNames.at( modelPinIndex );
869 else if( item->
IsType( voltageProbeTypes ) )
879 wxString spiceNet = *
name;
895 wxString connectionName;
897 if( item && item->IsType( voltageProbeTypes ) )
906 else if( item && item->Type() !=
SCH_PIN_T )
927 if(
m_frame->GetHighlightedConnection() != connectionName )
929 m_frame->SetHighlightedConnection( connectionName );
937 [
this](
const int& aFinalState )
942 if( !
m_frame->GetHighlightedConnection().IsEmpty() )
944 m_frame->SetHighlightedConnection( wxEmptyString );
987 item = item->GetParent();
1000 blocking_win->Close(
true );
1002 static_cast<SIMULATOR_FRAME*
>( simFrame )->AddTuner( sheetPath, symbol );
1016 collector.
Collect(
m_frame->GetScreen(), { SCH_SYMBOL_T, SCH_FIELD_T }, aPos );
1024 item =
static_cast<SCH_FIELD*
>( item )->GetParentSymbol();
1039 [
this](
const int& aFinalState )
1081 wxLogTrace(
"KICAD_SCH_HIGHLIGHT",
"highlightNet: pos=(%f,%f) clear=%d", aPosition.
x, aPosition.
y,
1082 ( aPosition ==
CLEAR ) );
1086 std::optional<wxString> connName;
1090 if( aPosition !=
CLEAR )
1094 if(
erc.TestDuplicateSheetNames(
false ) > 0 )
1096 wxMessageBox(
_(
"Error: duplicate sub-sheet names found in current sheet." ) );
1102 wxLogTrace(
"KICAD_SCH_HIGHLIGHT",
"highlightNet: item=%p type=%d", (
void*) item, item ? (
int) item->
Type()
1111 symbol =
dynamic_cast<SCH_SYMBOL*
>( item->GetParent() );
1115 std::vector<SCH_PIN*> pins = symbol->
GetPins( &aSheetPath );
1117 if( pins.size() == 1 )
1118 connName = pins[0]->GetConnectionName( &editFrame->
GetCurrentSheet() );
1128 if( !connName || connName->IsEmpty() )
1130 wxLogTrace(
"KICAD_SCH_HIGHLIGHT",
"highlightNet: no connection under cursor" );
1131 editFrame->SetStatusText( wxT(
"" ) );
1136 editorControl->SetHighlightBusMembers(
false );
1144 wxLogTrace(
"KICAD_SCH_HIGHLIGHT",
"highlightNet: setting highlighted connection to %s", *connName );
1145 editorControl->SetHighlightBusMembers(
false );
1159 editorControl->SetHighlightBusMembers(
false );
1163 editorControl->SetHighlightBusMembers( !editorControl->GetHighlightBusMembers() );
1174 editorControl->UpdateNetHighlighting(
dummy );
1175 wxLogTrace(
"KICAD_SCH_HIGHLIGHT",
"highlightNet: done" );
1198 auto& chains =
m_frame->Schematic().NetChains();
1202 const auto name = item ? item->GetConnectionName( &
m_frame->GetCurrentSheet() ) : std::nullopt;
1204 wxString newConnection;
1210 newChain =
chain->GetName();
1212 if( !
chain->GetNets().empty() )
1213 m_frame->SendCrossProbeNetName( *
chain->GetNets().begin() );
1217 newConnection = *
name;
1223 m_frame->SendCrossProbeClearHighlight();
1227 m_frame->SetHighlightedNetChain( newChain );
1228 m_frame->SetHighlightedConnection( newConnection );
1229 m_frame->UpdateNetHighlightStatus();
1265 for(
const auto& [symbol, screen] : chains.GetBridgeSymbols( *
chain, net ) )
1267 commit.
Modify( symbol, screen );
1271 commit.
Push(
_(
"Remove from Net Chain" ) );
1283 m_frame->SetHighlightedNetChain( wxEmptyString );
1300 const auto getNetNamePattern =
1301 [](
const auto& aConn ) -> std::optional<wxString>
1303 wxString netName = aConn.Name();
1310 return prefix + wxT(
"*" );
1312 return prefix + wxT(
".*" );
1317 return std::nullopt;
1323 std::set<wxString> netNames;
1328 std::optional<wxString> netNamePattern;
1332 const auto connection = schematic.Connectivity().Connection( schItem->
m_Uuid,
path.PathRef() );
1337 netNamePattern = getNetNamePattern( *connection );
1346 netNamePattern = getNetNamePattern( *connection );
1349 if( !netNamePattern )
1352 m_frame->ShowInfoBarError(
_(
"All selected nets must be labeled to assign a netclass." ) );
1356 netNames.insert( *netNamePattern );
1359 if( netNames.empty() )
1361 m_frame->ShowInfoBarError(
_(
"No nets selected." ) );
1368 [&](
const std::vector<wxString>& aNetNames )
1370 std::unordered_set<SCH_ITEM*> highlighted;
1371 const SCH_CONNECTIVITY::NAVIGATION_QUERY query( schematic );
1373 for( const wxString& name : aNetNames )
1374 query.CollectNetItems( name, path, highlighted );
1376 for( SCH_ITEM* item : screen->Items() )
1378 bool redraw = setNetHighlight( item, highlighted.contains( item ) );
1380 item->RunOnChildren(
1381 [&]( SCH_ITEM* aChild )
1383 redraw |= setNetHighlight( aChild, highlighted.contains( aChild ) );
1385 RECURSE_MODE::NO_RECURSE );
1388 getView()->Update( item, KIGFX::VIEW_UPDATE_FLAGS::REPAINT );
1391 m_frame->GetCanvas()->ForceRefresh();
1394 if( dlg.ShowModal() )
1396 getView()->UpdateAllItemsConditionally(
1401 auto invalidateTextVars =
1404 if(
text->HasTextVars() )
1406 text->ClearRenderCache();
1407 text->ClearBoundingBoxCache();
1414 if(
dynamic_cast<SCH_LINE*
>( aItem ) )
1424 invalidateTextVars(
text );
1428 item->RunOnChildren(
1429 [&invalidateTextVars](
SCH_ITEM* aChild )
1432 invalidateTextVars(
text );
1437 m_frame->GetScreen()->UpdateDisplayBounds( item );
1453 if( !selectionTool )
1470 const auto connection =
m_frame->Schematic().Connectivity().Connection(
1473 if( connection && !connection->IsUnconnected() )
1474 netName = connection->Name();
1478 netName = connection->GetNetName();
1481 if( !netName.IsEmpty() )
1486 if( netName.IsEmpty() )
1487 netName =
m_frame->GetHighlightedConnection();
1489 if( netName.IsEmpty() )
1491 m_frame->ShowInfoBarError(
_(
"No connected net selected." ) );
1495 m_frame->FindNetInInspector( netName );
1507 wxCHECK( screen, 0 );
1509 const wxString selectedName =
m_frame->GetHighlightedConnection();
1510 const wxString chainName =
m_frame->GetHighlightedNetChain();
1512 :
m_frame->Schematic().NetChains().GetNetChainByName( chainName );
1513 std::unordered_set<SCH_ITEM*> highlighted;
1515 if( !selectedName.IsEmpty() ||
chain )
1519 if( !selectedName.IsEmpty() )
1524 for(
const wxString&
name :
chain->GetNets() )
1529 bool changed =
false;
1538 bool powerHighlight =
false;
1540 if( symbol && symbol->
IsPower() )
1542 std::vector<SCH_PIN*> pins = symbol->
GetPins( &sheetPath );
1543 powerHighlight = !pins.empty() && highlighted.contains( pins.front() );
1549 bool highlight = highlighted.contains( child );
1553 const auto* field =
static_cast<SCH_FIELD*
>( child );
1569 m_frame->GetCanvas()->Refresh();
1610 DisplayError( editFrame,
_(
"Unable to replace the net chain terminal pin." ) );
1633 if(
SCH_NETCHAIN* sig = chains.GetNetChainForNet( *netName ) )
1635 const wxString oldName = sig->GetName();
1636 const wxString newName = wxGetTextFromUser(
_(
"Net chain name:" ),
_(
"Name Net Chain" ), oldName );
1638 if( newName.IsEmpty() || newName == oldName )
1643 DisplayError( editFrame,
_(
"Chain name cannot contain spaces, quotes, or parentheses." ) );
1647 if( !chains.RenameCommittedNetChain( oldName, newName ) )
1649 DisplayError( editFrame, wxString::Format(
_(
"Unable to rename net chain '%s' to '%s'." ),
1650 oldName, newName ) );
1669 if( selection.GetSize() != 2 )
1675 if( !
pinA || !pinB )
1685 DisplayError( editFrame,
_(
"No potential net chain connects the selected pins." ) );
1690 for(
const wxString& net : potential->
GetNets() )
1692 if(
SCH_NETCHAIN* owner = chains.GetNetChainForNet( net ) )
1694 DisplayError( editFrame, wxString::Format(
_(
"The selected pins are already in net chain '%s'." ),
1695 owner->GetName() ) );
1704 wxString msg = wxString::Format(
_(
"Create Net Chain between %s:%s and %s:%s" ),
1723 int dx = bbox.
GetWidth() / 4;
if( dx < 100 ) dx = 100;
1724 int dy = bbox.
GetHeight() / 4;
if( dy < 100 ) dy = 100;
1726 if(
auto canvas = editFrame->
GetCanvas() )
1728 canvas->GetView()->SetCenter( bbox.
GetCenter() );
1730 auto view = canvas->GetView();
1733 BOX2D viewBox = view->GetBoundary();
1736 double scale = std::min( scaleX, scaleY );
1738 view->SetScale(
scale );
1742 const auto restoreHighlight =
1751 wxString
name = wxGetTextFromUser( msg,
_(
"Create Net Chain" ), suggestion, editFrame );
1753 if(
name.IsEmpty() )
1762 DisplayError( editFrame,
_(
"Chain name cannot contain spaces, quotes, or parentheses." ) );
1766 if( chains.GetNetChainByName(
name ) )
1769 DisplayError( editFrame, wxString::Format(
_(
"A net chain named '%s' already exists." ),
name ) );
1773 if( !chains.CreateNetChainFromPotential( potential,
name ) )
1776 DisplayError( editFrame, wxString::Format(
_(
"Unable to create net chain '%s'." ),
name ) );
1787 editFrame->Refresh();
1805 std::vector<SCH_SYMBOL*> symbols;
1810 symbols.push_back( sym );
1813 if( symbols.size() >= 1 )
1816 if( symbols.size() >= 2 )
1820 if( symbols.empty() && sel.
GetSize() == 1 )
1824 if( schItem && schItem->
IsType( { SCH_PIN_T, SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } ) )
1843 if(
m_frame->GetUndoCommandCount() <= 0 )
1852 wxCHECK( undo_list, 0 );
1854 m_frame->PutDataInPreviousState( undo_list );
1858 m_frame->PushCommandToRedoList( undo_list );
1862 m_frame->GetCanvas()->Refresh();
1873 if(
m_frame->GetRedoCommandCount() == 0 )
1885 m_frame->PutDataInPreviousState( list );
1888 list->ReversePickersListOrder();
1889 m_frame->PushCommandToUndoList( list );
1893 m_frame->GetCanvas()->Refresh();
1906 if( selection.Empty() )
1909 if( aUseDuplicateClipboard )
1912 selection.SetScreen(
m_frame->GetScreen() );
1915 for(
EDA_ITEM* item : selection.GetItems() )
1922 else if( item->Type() ==
SCH_FIELD_T && selection.IsHover() )
1926 selection.Add( item->GetParent() );
1931 selection.Remove( item );
1936 static_cast<SCH_ITEM*
>( item )->RunOnChildren(
1939 selection.Add( aChild );
1950 plugin.
Format( &selection, &selPath, schematic, &formatter,
true );
1952 std::string prettyData = formatter.
GetString();
1955 if( !aUseDuplicateClipboard )
1959 result &= wxTheClipboard->Open();
1963 wxDataObjectComposite* data =
new wxDataObjectComposite();
1966 wxCustomDataObject* kicadObj =
new wxCustomDataObject( wxDataFormat(
"application/kicad" ) );
1967 kicadObj->SetData( prettyData.size(), prettyData.data() );
1968 data->Add( kicadObj );
1970 BOX2I selectionBox = expandedSelectionBox( selection );
1975 wxImage
image = renderSelectionToImageForClipboard(
m_frame, selection, selectionBox,
true,
false );
1976 wxMemoryBuffer pngBuffer;
1983 wxMemoryBuffer htmlBuffer;
1985 if( generateHtmlFromPngData( pngBuffer, htmlBuffer ) )
1987 wxCustomDataObject* htmlObj =
new wxCustomDataObject( wxDF_HTML );
1988 htmlObj->SetData( htmlBuffer.GetDataLen(), htmlBuffer.GetData() );
1989 data->Add( htmlObj );
1994 wxMemoryBuffer svgBuffer;
1996 if( plotSelectionToSvg(
m_frame, selection, selectionBox, svgBuffer ) )
1998 wxCustomDataObject* svgObj =
new wxCustomDataObject( wxDataFormat(
"image/svg+xml" ) );
1999 svgObj->SetData( svgBuffer.GetDataLen(), svgBuffer.GetData() );
2000 data->Add( svgObj );
2005 data->Add(
new wxTextDataObject( wxString::FromUTF8( prettyData ) ) );
2007 result &= wxTheClipboard->SetData( data );
2008 result &= wxTheClipboard->Flush();
2009 wxTheClipboard->Close();
2013 if( selection.IsHover() )
2016 if( aUseDuplicateClipboard )
2049 wxTextEntry* textEntry =
dynamic_cast<wxTextEntry*
>( wxWindow::FindFocus() );
2066 wxTextEntry* textEntry =
dynamic_cast<wxTextEntry*
>( wxWindow::FindFocus() );
2085 if( selection.Empty() )
2090 if( selection.IsHover() )
2098 const KIID_PATH& aClipPath,
bool aForceKeepAnnotations )
2100 wxCHECK(
m_frame && aSymbol, );
2103 bool instanceFound =
false;
2110 if( ( tmp.m_Path.empty() && aClipPath.empty() ) || ( !aClipPath.empty() && tmp.m_Path.
EndsWith( aClipPath ) ) )
2113 instanceFound =
true;
2115 wxLogTrace(
traceSchPaste, wxS(
"Pasting found symbol instance with reference %s, unit %d:\n"
2116 "\tClipboard path: %s\n"
2117 "\tSymbol UUID: %s." ),
2128 pasteLookupPath.push_back( aSymbol->
m_Uuid );
2130 if( !instanceFound )
2132 wxLogTrace(
traceSchPaste, wxS(
"Clipboard symbol instance **not** found:\n\tClipboard path: %s\n"
2133 "\tSymbol UUID: %s." ),
2153 if( !aForceKeepAnnotations )
2162 const KIID_PATH& aClipPath,
bool aForceKeepAnnotations,
2166 wxCHECK( aSheet && aPastedSheets, aPastePath );
2171 aPastedSheets->push_back( sheetPath );
2180 if( item->IsConnectable() )
2181 item->SetConnectivityDirty();
2187 wxCHECK2( symbol,
continue );
2201 pin->SetConnectivityDirty();
2211 wxCHECK2( subsheet,
continue );
2224 pin->SetConnectivityDirty();
2229 newClipPath.push_back( subsheet->
m_Uuid );
2231 updatePastedSheet( subsheet, sheetPath, newClipPath, aForceKeepAnnotations, aPastedSheets, aPastedSymbols );
2247 wxCHECK2( symbol,
continue );
2256 const wxString& aLibSymbolName )
2263 if( aClipboardScreen )
2265 auto clipIt = aClipboardScreen->
GetLibSymbols().find( aLibSymbolName );
2268 return clipIt->second;
2273 auto destIt = aDestScreen->
GetLibSymbols().find( aLibSymbolName );
2276 return destIt->second;
2285 wxTextEntry* textEntry =
dynamic_cast<wxTextEntry*
>( wxWindow::FindFocus() );
2294 std::string content;
2309 if( content.empty() )
2315 auto bitmap = std::make_unique<SCH_BITMAP>();
2317 if( bitmap->GetReferenceImage().SetImage( clipImg->ConvertToImage() ) )
2345 "Do you want to continue?" ) );
2351 tempScreen->
Append( text_item );
2357 bool hasTableCells =
false;
2359 for(
EDA_ITEM* item : currentSelection )
2363 hasTableCells =
true;
2376 clipboardTable =
static_cast<SCH_TABLE*
>( item );
2381 if( clipboardTable )
2399 commit.
Push(
_(
"Paste Cells" ) );
2415 bool annotateAutomatic =
m_frame->eeconfig()->m_AnnotatePanel.automatic;
2420 bool forceRemoveAnnotations =
false;
2440 std::vector<SCH_ITEM*> sortedLoadedItems;
2441 bool sheetsPasted =
false;
2446 if( destFn.IsRelative() )
2447 destFn.MakeAbsolute(
m_frame->Prj().GetProjectPath() );
2454 std::map<wxString, SCH_SCREEN*> loadedScreens;
2458 if( item.LastScreen() )
2459 loadedScreens[item.Last()->GetFileName()] = item.LastScreen();
2464 std::set<wxString> existingSuffixes;
2465 std::set<wxString> composedSuffixes;
2471 composedSuffixes.insert(
m_frame->Schematic().GetRefSuffix(
path ) );
2478 existingSuffixes.insert( suffixField->GetText() );
2479 existingSuffixes.insert( sheet->
GetRefSuffix( parentPath ) );
2488 std::set<wxString> existingRefsSet;
2491 existingRefsSet.insert( ref.GetRef() );
2494 std::unordered_map<KIID, EDA_ITEM*> itemMap;
2498 std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST> pastedSymbols;
2499 std::map<SCH_SHEET_PATH, SCH_SHEET_LIST> pastedSheets;
2504 sortedLoadedItems.push_back( item );
2506 loadedItems.push_back( item );
2509 sort( sortedLoadedItems.begin(), sortedLoadedItems.end(),
2512 SCH_SHEET* firstSheet = static_cast<SCH_SHEET*>( firstItem );
2513 SCH_SHEET* secondSheet = static_cast<SCH_SHEET*>( secondItem );
2514 return StrNumCmp( firstSheet->GetName(), secondSheet->GetName(), CMP_T::CASE_SENSITIVE ) < 0;
2518 for(
SCH_ITEM* item : sortedLoadedItems )
2520 loadedItems.push_back( item );
2527 if( srcFn.IsRelative() )
2528 srcFn.MakeAbsolute(
m_frame->Prj().GetProjectPath() );
2532 if( hierarchy.
TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
2534 auto msg = wxString::Format(
_(
"The pasted sheet '%s'\n"
2535 "was dropped because the destination already has "
2536 "the sheet or one of its subsheets as a parent." ),
2539 loadedItems.pop_back();
2545 tempScreen->
Clear(
false );
2547 for(
EDA_ITEM* item : loadedItems )
2553 wxCHECK2( schItem,
continue );
2567 wxCHECK2( currentScreen,
continue );
2577 wxString key = alternate.Format().wx_str();
2582 currentScreen->
AddLibSymbol( key, it->second->Flatten() );
2589 if( !existingRefsSet.contains( instance.m_Reference ) )
2591 forceKeepAnnotations = !forceRemoveAnnotations;
2607 if( existingRefsSet.contains( instance.m_Reference ) )
2609 needsNewKiid =
true;
2617 const_cast<KIID&
>( item->m_Uuid ) =
KIID();
2623 pin->SetConnectivityDirty();
2633 pastedSymbols[sheetPath].AddItem( schReference );
2642 wxString baseName = nameField->
GetText();
2643 wxString candidateName = baseName;
2646 while( !baseName.IsEmpty() && wxIsdigit( baseName.Last() ) )
2648 number = baseName.Last() + number;
2649 baseName.RemoveLast();
2654 hierarchy =
m_frame->Schematic().Hierarchy();
2656 int uniquifier = std::max( 0, wxAtoi( number ) ) + 1;
2658 while( existingSheetNames.count( candidateName ) )
2659 candidateName = wxString::Format( wxT(
"%s%d" ), baseName, uniquifier++ );
2661 nameField->
SetText( candidateName );
2662 existingSheetNames.emplace( candidateName );
2670 if( !fn.IsAbsolute() )
2673 fn.Normalize(
FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS, currentSheetFileName.GetPath() );
2677 if( !
m_frame->Schematic().Root().SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ), &existingScreen ) )
2679 if( loadedScreens.count( sheet->
GetFileName() ) > 0 )
2680 existingScreen = loadedScreens.at( sheet->
GetFileName() );
2685 if( existingScreen )
2691 if( !
m_frame->LoadSheetFromFile( sheet, &pasteRoot, fn.GetFullPath() ) )
2695 sheetsPasted =
true;
2701 wxString pastedSuffix = suffixField->
GetText();
2705 auto composedBelowPaste =
2708 std::vector<wxString> composed;
2716 for(
size_t ii = 0; ii < subPath.size(); ++ii )
2726 auto resolvesTaken =
2727 [&](
const wxString& aCandidate )
2729 suffixField->
SetText( aCandidate );
2733 if( existingSuffixes.contains( sheet->
GetRefSuffix( parentPath ) ) )
2737 for(
const wxString& composed : composedBelowPaste() )
2739 if( composedSuffixes.contains( composed ) )
2746 if(
m_frame->Schematic().Settings().m_IncrementPastedSuffix )
2749 suffixField->
SetText( pastedSuffix );
2750 existingSuffixes.insert( pastedSuffix );
2753 existingSuffixes.insert( sheet->
GetRefSuffix( parentPath ) );
2755 for(
const wxString& composed : composedBelowPaste() )
2756 composedSuffixes.insert( composed );
2760 clipPath.push_back( sheet->
m_Uuid );
2769 pin->SetConnectivityDirty();
2777 ( forceKeepAnnotations && annotateAutomatic ),
2778 &pastedSheets[sheetPath], pastedSymbols );
2787 const_cast<KIID&
>( item->m_Uuid ) =
KIID();
2789 if( srcItem && destItem )
2800 if( !
group->GetName().IsEmpty() )
2824 m_frame->Schematic().RefreshHierarchy();
2833 wxString pageNum = wxString::Format(
"%d", page );
2836 pageNum = wxString::Format(
"%d", ++page );
2838 int virtualPageNumber = page;
2845 pastedSheet.SetVirtualPageNumber( virtualPageNumber );
2849 sheetInstance.
m_Path = pastedSheet.Path();
2852 sheetInstance.
m_Path.pop_back();
2858 wxCHECK2( sheet,
continue );
2861 hierarchy.push_back( pastedSheet );
2864 std::vector<KIID_PATH> instancesToRemove;
2868 if( !hierarchy.
HasPath( instance.m_Path ) )
2869 instancesToRemove.push_back( instance.m_Path );
2872 for(
const KIID_PATH& instancePath : instancesToRemove )
2877 for(
auto&[
path, refs] : pastedSymbols )
2881 if( ref.GetSheetPath() == pastedSheet )
2883 ref.GetSheetPath().SetVirtualPageNumber( virtualPageNumber );
2884 ref.SetSheetNumber( virtualPageNumber );
2891 m_frame->SetSheetNumberAndCount();
2895 hierarchy =
m_frame->Schematic().Hierarchy();
2898 std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST> annotatedSymbols;
2903 for(
size_t i = 0; i < pastedSymbols[sheetPath].GetCount(); i++ )
2906 annotatedSymbols[sheetPath].AddItem( pastedSymbols[sheetPath][i] );
2909 for(
const SCH_SHEET_PATH& pastedSheetPath : pastedSheets[sheetPath] )
2911 for(
size_t i = 0; i < pastedSymbols[pastedSheetPath].GetCount(); i++ )
2914 annotatedSymbols[pastedSheetPath].AddItem( pastedSymbols[pastedSheetPath][i] );
2919 if( !annotatedSymbols.empty() )
2926 annotatedSymbols[
path].SortByReferenceOnly();
2931 annotatedSymbols[
path].ReannotateDuplicates( existingRefs, annotateAlgo );
2935 annotatedSymbols[
path].ReannotateByOptions( annotateOrder, annotateAlgo, annotateStartNum,
2936 existingRefs,
false, &hierarchy );
2939 annotatedSymbols[
path].UpdateAnnotation();
2942 for(
size_t i = 0; i < annotatedSymbols[
path].GetCount(); i++ )
2943 existingRefs.
AddItem( annotatedSymbols[
path][i] );
2947 annotatedSymbols[pastedSheetPath].SortByReferenceOnly();
2948 annotatedSymbols[pastedSheetPath].SetRefDesTracker( schematicSettings.
m_refDesTracker );
2952 annotatedSymbols[pastedSheetPath].ReannotateDuplicates( existingRefs, annotateAlgo );
2956 annotatedSymbols[pastedSheetPath].ReannotateByOptions( annotateOrder, annotateAlgo,
2957 annotateStartNum, existingRefs,
2958 false, &hierarchy );
2961 annotatedSymbols[pastedSheetPath].UpdateAnnotation();
2964 for(
size_t i = 0; i < annotatedSymbols[pastedSheetPath].GetCount(); i++ )
2965 existingRefs.
AddItem( annotatedSymbols[pastedSheetPath][i] );
2970 m_frame->GetCurrentSheet().UpdateAllScreenReferences();
2987 && !loadedItems.empty() )
3013 for(
int i = loadedItems.size() - 1; i >= 0; i-- )
3019 loadedItems.erase( loadedItems.begin() + i );
3032 if( !selection.Empty() )
3036 int closest_dist = INT_MAX;
3041 int dist = ( eventPos - pt ).EuclideanNorm();
3043 if( dist < closest_dist )
3045 selection.SetReferencePoint( pt );
3046 closest_dist = dist;
3050 std::vector<SCH_ITEM*> anchorCandidates =
FlattenGroups( selection.Items() );
3053 for(
EDA_ITEM* item : anchorCandidates )
3065 processPt(
pin->GetPosition() );
3071 processPt( item->GetPosition() );
3075 if( closest_dist == INT_MAX )
3077 for(
EDA_ITEM* item : anchorCandidates )
3079 switch( item->Type() )
3085 processPt(
static_cast<SCH_LINE*
>( item )->GetStartPoint() );
3086 processPt(
static_cast<SCH_LINE*
>( item )->GetEndPoint() );
3106 for(
int ii = 0; ii < shape->
GetPolyShape().TotalVertices(); ++ii )
3113 processPt( shape->
GetEnd() );
3121 processPt( item->GetPosition() );
3130 else if( selection.GetTopLeftItem()->Type() ==
SCH_GROUP_T )
3137 group->RunOnChildren(
3149 selection.SetReferencePoint( item->
GetPosition() );
3151 selection.SetReferencePoint(
group->GetPosition() );
3157 selection.SetReferencePoint( item->
GetPosition() );
3163 commit.
Push(
_(
"Paste" ) );
3166 m_frame->RefreshNetNavigator();
3187 if( selection.GetSize() >= 1 )
3190 if( selection.IsHover() )
3198 tableTool->EditTable( aEvent );
3208 m_frame->ShowInfoBarError(
_(
"Symbols with broken library symbol links cannot be edited." ) );
3218 blocking_win->Close(
true );
3247 dlg.
m_FirstRefDes->SetValidator( wxTextValidator( wxFILTER_EMPTY ) );
3261 int startNum = atoi( startRef.
GetRefNumber().utf8_string().c_str() );
3276 if( ref.GetRef() == startRef.
GetRef() )
3278 int num = atoi( ref.GetRefNumber().utf8_string().c_str() );
3280 if( num >= startNum )
3283 wxString fullRef = ref.GetRef();
3289 ref.GetSymbol()->SetUserRef( sheet,
From_UTF8( fullRef.c_str() ) );
3294 if( !commit.
Empty() )
3295 commit.
Push(
_(
"Increment Annotations" ) );
3337 if( !
m_frame->Schematic().GetCurrentVariant().IsEmpty() )
3340 _(
"Bulk Edit Symbol Library Links is not available when a design variant is "
3341 "active. Switch to the default variant first." ) );
3422 sheetSelection.
Add( item );
3429 wxImage
image = renderSelectionToImageForClipboard(
m_frame, sheetSelection, pageBBox,
true,
true );
3435 if( wxTheClipboard->Open() )
3437 wxDataObjectComposite* data =
new wxDataObjectComposite();
3441 wxTheClipboard->SetData( data );
3442 wxTheClipboard->Flush();
3443 wxTheClipboard->Close();
3448 wxLogMessage(
_(
"Cannot create the schematic image" ) );
3510 m_frame->GetCanvas()->Refresh();
3524 m_frame->GetCanvas()->Refresh();
3536 m_frame->GetCanvas()->Refresh();
3548 m_frame->GetCanvas()->Refresh();
3560 m_frame->GetCanvas()->Refresh();
3571 m_frame->GetCanvas()->Refresh();
3580 wxString variant =
m_frame->Schematic().GetCurrentVariant();
3584 m_frame->GetCanvas()->GetView()->UpdateAllItemsConditionally(
3589 auto invalidateTextVars =
3592 if(
text->HasTextVars() )
3594 text->ClearRenderCache();
3595 text->ClearBoundingBoxCache();
3602 item->RunOnChildren(
3603 [&invalidateTextVars](
SCH_ITEM* aChild )
3606 invalidateTextVars(
text );
3610 if( item->GetExcludedFromSim( sheetPath, variant ) )
3615 invalidateTextVars(
text );
3620 m_frame->GetCanvas()->Refresh();
3632 m_frame->RefreshOperatingPointDisplay();
3633 m_frame->GetCanvas()->Refresh();
3645 m_frame->RefreshOperatingPointDisplay();
3646 m_frame->GetCanvas()->Refresh();
3660 m_frame->GetCanvas()->Refresh();
3678 m_frame->eeconfig()->m_Drawing.line_mode++;
3698 switch(
static_cast<LINE_MODE>(
m_frame->eeconfig()->m_Drawing.line_mode ) )
3712 if( !
Pgm().GetCommonSettings()->m_Input.hotkey_feedback )
3716 int currentIdx =
m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
3718 wxArrayString gridsLabels;
3721 gridsLabels.Add(
grid.UserUnitsMessageText(
m_frame ) );
3723 if( !
m_frame->GetHotkeyPopup() )
3729 popup->
Popup(
_(
"Grid" ), gridsLabels, currentIdx );
3746 if( selection.Size() != 1 || selection[0]->Type() !=
SCH_GROUP_T )
3751 if( !
group->HasDesignBlockLink() )
3756 std::unique_ptr<DESIGN_BLOCK> designBlock( designBlockPane->
GetDesignBlock(
group->GetDesignBlockLibId(),
3762 if( designBlock->GetSchematicFile().IsEmpty() )
3765 msg.Printf(
_(
"Design block %s does not have a schematic file." ),
3766 group->GetDesignBlockLibId().GetUniStringLibId() );
3767 m_frame->GetInfoBar()->ShowMessageFor( msg, 5000, wxICON_WARNING );
3788 if( selection.Size() != 1 || selection[0]->Type() !=
SCH_GROUP_T )
3793 if( !
group->HasDesignBlockLink() )
3798 std::unique_ptr<DESIGN_BLOCK> designBlock( designBlockPane->
GetDesignBlock(
group->GetDesignBlockLibId(),
constexpr EDA_IU_SCALE schIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static TOOL_ACTION updatePcbFromSchematic
static TOOL_ACTION revert
static TOOL_ACTION saveAs
static TOOL_ACTION exportForOlderVersion
static TOOL_ACTION pickerTool
static TOOL_ACTION showSymbolEditor
static TOOL_ACTION pasteSpecial
static TOOL_ACTION pageSettings
static TOOL_ACTION showSearch
static TOOL_ACTION selectionActivate
Activation of the selection tool.
static TOOL_ACTION duplicate
static TOOL_ACTION showGitCommitPane
static TOOL_ACTION doDelete
static TOOL_ACTION updateSchematicFromPcb
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION showProperties
static TOOL_ACTION copyAsText
static TOOL_ACTION refreshPreview
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
int GetVirtualPageNumber() const
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
const wxString & GetPageNumber() const
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 const Vec GetCenter() const
constexpr size_type GetHeight() const
constexpr const Vec & GetOrigin() const
constexpr const SizeVec & GetSize() const
int GetCount() const
Return the number of objects in the list.
static const COLOR4D CLEAR
COMMIT & Added(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
static PRIORITY GetDriverPriority(SCH_ITEM *aDriver)
Return the priority (higher is more important) of a candidate driver.
void SelectLibId(const LIB_ID &aLibId)
DESIGN_BLOCK * GetDesignBlock(const LIB_ID &aLibId, bool aUseCacheLib, bool aShowErrorMsg, wxString *aErrorMsg=nullptr)
Load design block from design block library table.
Class DIALOG_INCREMENT_ANNOTATIONS_BASE.
wxTextCtrl * m_FirstRefDes
wxRadioButton * m_AllSheets
void SetWksFileName(const wxString &aFilename)
bool Show(bool show) override
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
void ToggleGitCommitPane()
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
EDA_ITEM_FLAGS GetEditFlags() const
virtual EDA_GROUP * GetParentGroup() const
KICAD_T Type() const
Returns the type of object.
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
void SetNetHighlighted(bool aHighlighted)
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
bool IsNetHighlighted() const
Net highlighting must not clear brightening owned by find or picker tools.
virtual void SetParent(EDA_ITEM *aParent)
SHAPE_POLY_SET & GetPolyShape()
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
std::vector< VECTOR2I > GetRectCorners() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
virtual bool IsVisible() const
PANEL_ANNOTATE m_AnnotatePanel
Runs the electrical rules checks and adds a SCH_MARKER for each violation.
static const TOOL_EVENT ClearedEvent
static const TOOL_EVENT GridChangedByKeyEvent
Used for hotkey feedback.
static const TOOL_EVENT SelectedEvent
static const TOOL_EVENT SelectedItemsModified
Selected item had a property changed (except movement)
static const TOOL_EVENT PointSelectedEvent
static const TOOL_EVENT UnselectedEvent
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
std::vector< wxString > m_foundVariants
Variant names found in the schematic when the target drops variants.
wxString m_outputDir
Write downgraded sheets under this fresh folder.
wxString m_variant
Flatten this variant into the export. Empty means the base design.
wxString m_filename
Root schematic file (may be empty to downgrade only libraries)
static std::unique_ptr< CAIRO_PRINT_GAL > Create(GAL_DISPLAY_OPTIONS &aOptions, wxImage *aImage, double aDPI)
GAL_ANTIALIASING_MODE antialiasing_mode
virtual bool HasNativeLandscapeRotation() const =0
void SetLayerColor(int aLayer, const COLOR4D &aColor)
Change the color used to draw a layer.
void SetDefaultFont(const wxString &aFont)
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
void SetIsPrinting(bool isPrinting)
An interface for classes handling user events controlling the view behavior such as zooming,...
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
An abstract base class for deriving all objects that can be added to a VIEW.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
static constexpr int VIEW_MAX_LAYERS
Maximum number of layers that may be shown.
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
void Hide(VIEW_ITEM *aItem, bool aHide=true, bool aHideOverlay=false)
Temporarily hide the item in the view (e.g.
void AddToPreview(VIEW_ITEM *aItem, bool aTakeOwnership=true)
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
bool EndsWith(const KIID_PATH &aPath) const
Test if aPath from the last path towards the first path.
wxString AsString() const
wxString AsString() const
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
std::optional< LIBRARY_TABLE_ROW * > GetRow(const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH) const
Like LIBRARY_MANAGER::GetRow but filtered to the LIBRARY_TABLE_TYPE of this adapter.
std::optional< wxString > GetFullURI(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, bool aSubstituted=false)
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const wxString & Type() const
const wxString & Nickname() const
A logical library item identifier and consists of various portions much like a URI.
int SetLibNickname(const UTF8 &aLibNickname)
Override the logical library name portion of the LIB_ID to aLibNickname.
Define a library symbol object.
const LIB_ID & GetLibId() const override
bool IsPower() const override
void AppendParentEmbeddedFiles(std::vector< EMBEDDED_FILES * > &aStack) const
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
static void ConvertToSpiceMarkup(wxString *aNetName)
Convert an escaped schematic net name to SPICE, preserving literal slashes when mapping ground names.
Tree view item data for the net navigator.
static bool ParseBusGroup(const wxString &aGroup, wxString *name, std::vector< wxString > *aMemberList, size_t *aPrefixEnd=nullptr)
Parse a bus group label into the name and a list of components.
static bool ParseBusVector(const wxString &aBus, wxString *aName, std::vector< wxString > *aMemberList)
Parse a bus vector (e.g.
static REPORTER & GetInstance()
Describe the page size and margins of a paper page on which to eventually print or plot.
void SetHeightMils(double aHeightInMils)
void SetWidthMils(double aWidthInMils)
A holder to handle information on schematic or board items.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
void SetDescription(const wxString &aDescription)
void ReversePickersListOrder()
Reverse the order of pickers stored in this list.
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
static bool RescueProject(wxWindow *aParent, RESCUER &aRescuer, bool aRunningOnDemand)
size_t GetCandidateCount()
Return the number of rescue candidates found.
These are loaded from Eeschema settings but then overwritten by the project settings.
double GetHopOverScale()
Accessor that computes the current hop-over size.
std::shared_ptr< REFDES_TRACKER > m_refDesTracker
A list of previously used schematic reference designators.
bool m_AnnotateReusedSheetSuffixes
Holds all the data relating to one schematic.
SCH_CONNECTIVITY::NETCHAIN_MANAGER & NetChains() const
wxString GetVariantDescription(const wxString &aVariantName) const
Return the description for a variant.
SCHEMATIC_SETTINGS & Settings() const
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
PROJECT & Project() const
Return a reference to the project this schematic is part of.
wxString GetCurrentVariant() const
Return the current variant being edited.
const std::map< wxString, wxString > * GetProperties()
SCH_SHEET_PATH & CurrentSheet() const
static TOOL_ACTION showPcbNew
static TOOL_ACTION createNetChain
static TOOL_ACTION assignFootprints
static TOOL_ACTION copyVariant
static TOOL_ACTION lineModeNext
static TOOL_ACTION toggleOPCurrents
static TOOL_ACTION saveToLinkedDesignBlock
static TOOL_ACTION clearHighlight
static TOOL_ACTION removeVariant
static TOOL_ACTION editSymbolFields
static TOOL_ACTION importFPAssignments
static TOOL_ACTION toggleAnnotateAuto
static TOOL_ACTION editLibSymbolWithLibEdit
static TOOL_ACTION toggleERCWarnings
static TOOL_ACTION editVariantDescription
static TOOL_ACTION schematicSetup
static TOOL_ACTION toggleDirectiveLabels
static TOOL_ACTION highlightNetTool
static TOOL_ACTION removeFromNetChain
static TOOL_ACTION findNetInInspector
static TOOL_ACTION toggleHiddenFields
static TOOL_ACTION saveCurrSheetCopyAs
static TOOL_ACTION showRemoteSymbolPanel
static TOOL_ACTION remapSymbols
static TOOL_ACTION lineMode45
static TOOL_ACTION editSymbolLibraryLinks
static TOOL_ACTION simTune
static TOOL_ACTION generateBOM
static TOOL_ACTION showHierarchy
static TOOL_ACTION highlightNetChain
static TOOL_ACTION showNetNavigator
static TOOL_ACTION markSimExclusions
static TOOL_ACTION placeImage
static TOOL_ACTION editWithLibEdit
static TOOL_ACTION toggleERCErrors
static TOOL_ACTION incrementAnnotations
static TOOL_ACTION rescueSymbols
static TOOL_ACTION angleSnapModeChanged
static TOOL_ACTION placeLinkedDesignBlock
static TOOL_ACTION generateBOMLegacy
static TOOL_ACTION placeDesignBlock
static TOOL_ACTION toggleOPVoltages
static TOOL_ACTION simProbe
static TOOL_ACTION lineMode90
static TOOL_ACTION lineModeFree
static TOOL_ACTION highlightNet
static TOOL_ACTION assignNetclass
static TOOL_ACTION annotate
static TOOL_ACTION showDesignBlockPanel
static TOOL_ACTION updateDesignBlockFromSelection
static TOOL_ACTION replaceTerminalPin
static TOOL_ACTION togglePinAltIcons
static TOOL_ACTION toggleERCExclusions
static TOOL_ACTION updateNetHighlighting
static TOOL_ACTION renameVariant
static TOOL_ACTION createNetChainBetweenPins
static TOOL_ACTION exportNetlist
static TOOL_ACTION drawSheetOnClipboard
static TOOL_ACTION exportSymbolsToLibrary
static TOOL_ACTION toggleHiddenPins
static TOOL_ACTION selectOnPCB
static TOOL_ACTION addVariant
static TOOL_ACTION importNonKicadSchematic
static TOOL_ACTION nameNetChain
SCH_RENDER_SETTINGS * GetRenderSettings()
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
EESCHEMA_SETTINGS * eeconfig() const
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
Base class for a bus or wire entry.
void Collect(SCH_SCREEN *aScreen, const std::vector< KICAD_T > &aScanTypes, const VECTOR2I &aPos, int aUnit=0, int aBodyStyle=0)
Scan a EDA_ITEM using this class's Inspector method which does the collection.
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.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
One UI operation's hierarchy index.
void CollectNetItems(const wxString &aName, const SCH_SHEET_PATH &aSheet, std::unordered_set< SCH_ITEM * > &aItems, bool aIncludeBusParents=false, bool aIncludeBusMembers=false) const
bool ReplaceNetChainTerminalPin(const TERMINAL_CHANGE &aChange)
static wxString NetKeyForItem(const SCH_ITEM &aItem, const SCH_SHEET_PATH &aPath)
bool NetChainsBuilt() const
Returns true once RebuildNetChains() has completed at least once on this graph.
Handle actions specific to the schematic editor.
int PageSetup(const TOOL_EVENT &aEvent)
bool RescueLegacyProject(bool aRunningOnDemand)
int ToggleDirectiveLabels(const TOOL_EVENT &aEvent)
int SaveAs(const TOOL_EVENT &aEvent)
int MarkSimExclusions(const TOOL_EVENT &aEvent)
int Annotate(const TOOL_EVENT &aEvent)
int ShowSchematicSetup(const TOOL_EVENT &aEvent)
int HighlightNet(const TOOL_EVENT &aEvent)
Highlight net under the cursor.
int ClearHighlight(const TOOL_EVENT &aEvent)
Remove any net highlighting.
int FindNetInInspector(const TOOL_EVENT &aEvent)
int EditSymbolFields(const TOOL_EVENT &aEvent)
bool m_duplicateIsHoverSelection
int GenerateBOMLegacy(const TOOL_EVENT &aEvent)
int RemoveFromNetChain(const TOOL_EVENT &aEvent)
int HighlightNetCursor(const TOOL_EVENT &aEvent)
Launch a tool to highlight nets.
int CopyAsText(const TOOL_EVENT &aEvent)
int AddVariant(const TOOL_EVENT &aEvent)
int ImportFPAssignments(const TOOL_EVENT &aEvent)
int ChangeLineMode(const TOOL_EVENT &aEvent)
void doCrossProbeSchToPcb(const TOOL_EVENT &aEvent, bool aForce)
int ExportSymbolsToLibrary(const TOOL_EVENT &aEvent)
int SaveCurrSheetCopyAs(const TOOL_EVENT &aEvent)
Saves the currently-open schematic sheet to an other name.
bool rescueProject(RESCUER &aRescuer, bool aRunningOnDemand)
int CrossProbeToPcb(const TOOL_EVENT &aEvent)
Notifies pcbnew about the selected item.
void SetHighlightBusMembers(bool aHighlightBusMembers)
int CopyVariant(const TOOL_EVENT &aEvent)
int PlaceLinkedDesignBlock(const TOOL_EVENT &aEvent)
int ToggleRemoteSymbolPanel(const TOOL_EVENT &aEvent)
int RemapSymbols(const TOOL_EVENT &aEvent)
int DrawSheetOnClipboard(const TOOL_EVENT &aEvent)
SCH_SHEET_PATH updatePastedSheet(SCH_SHEET *aSheet, const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, bool aForceKeepAnnotations, SCH_SHEET_LIST *aPastedSheets, std::map< SCH_SHEET_PATH, SCH_REFERENCE_LIST > &aPastedSymbols)
int TogglePinAltIcons(const TOOL_EVENT &aEvent)
int RescueSymbols(const TOOL_EVENT &aEvent)
Perform rescue operations to recover old projects from before certain changes were made.
int AssignNetclass(const TOOL_EVENT &aEvent)
std::string m_duplicateClipboard
int ExportNetlist(const TOOL_EVENT &aEvent)
int Open(const TOOL_EVENT &aEvent)
int Paste(const TOOL_EVENT &aEvent)
int ToggleOPVoltages(const TOOL_EVENT &aEvent)
int Copy(const TOOL_EVENT &aEvent)
int SaveToLinkedDesignBlock(const TOOL_EVENT &aEvent)
int ToggleERCWarnings(const TOOL_EVENT &aEvent)
int NextLineMode(const TOOL_EVENT &aEvent)
int Redo(const TOOL_EVENT &aEvent)
int UpdatePCB(const TOOL_EVENT &aEvent)
int RemoveVariant(const TOOL_EVENT &aEvent)
int UpdateFromPCB(const TOOL_EVENT &aEvent)
int ToggleAnnotateAuto(const TOOL_EVENT &aEvent)
int EditVariantDescription(const TOOL_EVENT &aEvent)
int ToggleHiddenPins(const TOOL_EVENT &aEvent)
int Duplicate(const TOOL_EVENT &aEvent)
int IncrementAnnotations(const TOOL_EVENT &aEvent)
bool searchSupplementaryClipboard(const wxString &aSheetFilename, SCH_SCREEN **aScreen)
int GridFeedback(const TOOL_EVENT &aEvent)
int ShowSearch(const TOOL_EVENT &aEvent)
int EditWithSymbolEditor(const TOOL_EVENT &aEvent)
int ReplaceTerminalPin(const TOOL_EVENT &aEvent)
Replace one of a net chain's terminal pins.
int SimTune(const TOOL_EVENT &aEvent)
int EditSymbolLibraryLinks(const TOOL_EVENT &aEvent)
int New(const TOOL_EVENT &aEvent)
int ImportNonKicadSchematic(const TOOL_EVENT &aEvent)
int ShowCreateNetChain(const TOOL_EVENT &aEvent)
std::map< wxString, SCH_SCREEN * > m_supplementaryClipboard
int ExplicitCrossProbeToPcb(const TOOL_EVENT &aEvent)
Equivalent to the above, but initiated by the user.
int ToggleOPCurrents(const TOOL_EVENT &aEvent)
int ShowPcbNew(const TOOL_EVENT &aEvent)
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Update net highlighting after an edit.
int ToggleERCErrors(const TOOL_EVENT &aEvent)
int ShowHierarchy(const TOOL_EVENT &aEvent)
int OnAngleSnapModeChanged(const TOOL_EVENT &aEvent)
void setTransitions() override
Set up handlers for various events.
bool m_highlightBusMembers
static const LIB_SYMBOL * ChoosePasteLibSymbol(const SCH_SCREEN *aClipboardScreen, const SCH_SCREEN *aDestScreen, const wxString &aLibSymbolName)
Choose which cached library symbol a pasted instance should adopt.
int ExportForOlderVersion(const TOOL_EVENT &aEvent)
int ShowNetNavigator(const TOOL_EVENT &aEvent)
int NameNetChain(const TOOL_EVENT &aEvent)
int SimProbe(const TOOL_EVENT &aEvent)
void updatePastedSymbol(SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, bool aForceKeepAnnotations)
int ShowCvpcb(const TOOL_EVENT &aEvent)
int HighlightNetChain(const TOOL_EVENT &aEvent)
Highlight net chain under the cursor.
int ToggleLibraryTree(const TOOL_EVENT &aEvent)
int RenameVariant(const TOOL_EVENT &aEvent)
std::set< SCH_SYMBOL * > m_pastedSymbols
void prunePastedSymbolInstances()
Reconcile every pasted symbol's instances against the current project.
int Cut(const TOOL_EVENT &aEvent)
Clipboard support.
int ToggleProperties(const TOOL_EVENT &aEvent)
int Save(const TOOL_EVENT &aEvent)
bool RescueSymbolLibTableProject(bool aRunningOnDemand)
bool doCopy(bool aUseDuplicateClipboard=false)
copy selection to clipboard or to m_duplicateClipboard
int Undo(const TOOL_EVENT &aEvent)
int ToggleERCExclusions(const TOOL_EVENT &aEvent)
int ToggleGitCommitPane(const TOOL_EVENT &aEvent)
int Plot(const TOOL_EVENT &aEvent)
int CreateNetChainBetweenPins(const TOOL_EVENT &aEvent)
int Print(const TOOL_EVENT &aEvent)
int Revert(const TOOL_EVENT &aEvent)
int GenerateBOM(const TOOL_EVENT &aEvent)
int ToggleHiddenFields(const TOOL_EVENT &aEvent)
Schematic editor (Eeschema) main window.
void ToggleProperties() override
SCH_DESIGN_BLOCK_PANE * GetDesignBlockPane() const
void ToggleNetNavigator()
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
void ToggleLibraryTree() override
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, PROGRESS_REPORTER *aProgressReporter=nullptr, bool aCleanupDone=false)
Generate the connection data for the entire schematic hierarchy.
void SendCrossProbeClearHighlight()
Tell Pcbnew to clear the existing highlighted net, if one exists.
SCH_SHEET_PATH & GetCurrentSheet() const
const SCH_ITEM * GetSelectedNetNavigatorItem() const
SCHEMATIC & Schematic() const
void ToggleSearch()
Toggle the show/hide state of Search pane.
wxString GetFullScreenDesc() const override
const wxString & GetHighlightedNetChain() const
void ToggleSchematicHierarchy()
Toggle the show/hide state of the left side schematic navigation panel.
void SetHighlightedConnection(const wxString &aConnection, const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr, bool aForceNetNavigatorRefresh=false)
void SetHighlightedNetChain(const wxString &aNetChain)
void SetCrossProbeConnection(const wxString &aName)
Send a connection (net or bus) to Pcbnew for highlighting.
const wxString & GetHighlightedConnection() const
void UpdateNetHighlightStatus()
wxString GetScreenDesc() const override
Return a human-readable description of the current screen.
void EditVariantDescription()
void SelectNetNavigatorItem(const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr)
void ToggleRemoteSymbolPanel()
virtual const wxString & GetText() const override
Return the string associated with the text object.
void SetText(const wxString &aText) override
A set of SCH_ITEMs (i.e., without duplicates).
A SCH_IO derivation for loading schematic files using the new s-expression file format.
void LoadContent(LINE_READER &aReader, SCH_SHEET *aSheet, int aVersion=SEXPR_SCHEMATIC_FILE_VERSION)
void Format(SCH_SHEET *aSheet)
static SCH_FILE_T EnumFromStr(const wxString &aFileType)
Return the file type from the corresponding plugin type name: "kicad", "legacy", etc.
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual bool IsConnectable() const
void SetLocked(bool aLocked) override
const SYMBOL * GetParentSymbol() const
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
virtual void SetLastResolvedState(const SCH_ITEM *aItem)
void SetConnectivityDirty(bool aDirty=true)
Set the dirty flag.
bool IsConnectivityDirty() const
std::optional< wxString > GetConnectionName(const SCH_SHEET_PATH *aSheet=nullptr, bool aLocal=false, bool aIgnoreSheet=false) const
Return the active connection name; absent for missing or stale published rows.
virtual void SetUnit(int aUnit)
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
bool HasBusConnection(const SCH_SHEET_PATH *aSheet=nullptr) const
virtual std::vector< VECTOR2I > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Segment description base class to describe items which have 2 end points (track, wire,...
A net chain is a collection of nets that are connected together through passive components.
const std::set< wxString > & GetNets() const
const wxString & GetName() const
static bool IsValidName(const wxString &aName)
SCH_PIN * GetLibPin() const
const wxString & GetNumber() const
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void SortByReferenceOnly()
Sort the list of references by reference.
void SplitReferences()
Attempt to split all reference designators into a name (U) and number (1).
void AddItem(const SCH_REFERENCE &aItem)
A helper to define a symbol's reference designator in a schematic.
void SetRef(const wxString &aReference)
void Split()
Attempt to split the reference designator into a name (U) and number (1).
bool IsSplitNeeded() const
Determine if this reference needs to be split or if it likely already has been.
void SetSheetNumber(int aSheetNumber)
wxString GetRefNumber() const
void SetBackgroundColor(const COLOR4D &aColor) override
Set the background color.
const KIGFX::COLOR4D & GetBackgroundColor() const override
Return current background color settings.
bool m_ShowPinsElectricalType
void LoadColors(const COLOR_SETTINGS *aSettings) override
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
void UpdateSymbolLinks(REPORTER *aReporter=nullptr)
Initialize the LIB_SYMBOL reference for each SCH_SYMBOL found in the full schematic.
void PruneOrphanedSheetInstances(const wxString &aProjectName, const SCH_SHEET_LIST &aValidSheetPaths)
void PruneOrphanedSymbolInstances(const wxString &aProjectName, const SCH_SHEET_LIST &aValidSheetPaths)
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
const PAGE_INFO & GetPageSettings() const
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
void AddLibSymbol(LIB_SYMBOL *aLibSymbol)
Add aLibSymbol to the library symbol map.
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
std::set< wxString > GetSheetNames() const
const std::map< wxString, LIB_SYMBOL * > & GetLibSymbols() const
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
EE_RTREE & Items()
Get the full RTree, usually for iterating.
const wxString & GetFileName() const
void UpdateSymbolLinks(REPORTER *aReporter=nullptr, LEGACY_SYMBOL_LIBS *aLegacyLibs=nullptr, SYMBOL_LIBRARY_ADAPTER *aLibraries=nullptr)
Initialize the LIB_SYMBOL reference for each SCH_SYMBOL found in this schematic from the project LIBR...
SCHEMATIC * Schematic() const
TITLE_BLOCK & GetTitleBlock()
void Plot(PLOTTER *aPlotter, const SCH_PLOT_OPTS &aPlotOpts) const
Plot all the schematic objects to aPlotter.
void MigrateSimModels()
Migrate any symbols having V6 simulation models to their V7 equivalents.
BOX2I GetBoundingBox() const override
VECTOR2I GetCenter() const
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
SCH_SHEET_LIST FindAllSheetsForScreen(const SCH_SCREEN *aScreen) const
Return a SCH_SHEET_LIST with a copy of all the SCH_SHEET_PATH using a particular screen.
int GetLastVirtualPageNumber() const
void FillItemMap(std::unordered_map< KIID, EDA_ITEM * > &aMap) const
Fill an item cache for temporary use when many items need to be fetched.
bool PageNumberExists(const wxString &aPageNumber) const
bool ContainsSheet(const SCH_SHEET *aSheet) const
bool HasPath(const KIID_PATH &aPath) const
void GetSymbols(SCH_REFERENCE_LIST &aReferences, SYMBOL_FILTER aSymbolFilter, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName)
Test every SCH_SHEET_PATH in this SCH_SHEET_LIST to verify if adding the sheets stored in aSrcSheetHi...
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
bool IsSharedPath() const
Determine if this sheet path is shared in a complex hierarchy.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, SYMBOL_FILTER aSymbolFilter, bool aForceIncludeOrphanSymbols=false) const
Adds SCH_REFERENCE object to aReferences for each symbol in the sheet.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCH_SCREEN * LastScreen()
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
wxString ComposeRefSuffix() const
Compose the reference suffixes of every sheet in this path, from the root down.
void pop_back()
Forwarded method from std::vector.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
wxString GetRefSuffix(const SCH_SHEET_PATH &aParentPath) const
Return this sheet's own reference suffix with text variables resolved.
wxString GetFileName() const
Return the filename corresponding to this sheet.
void RemoveInstance(const KIID_PATH &aInstancePath)
static wxString NextRefSuffix(const wxString &aSuffix, const std::set< wxString > &aInUse, const std::function< bool(const wxString &)> &aIsTaken=nullptr)
Return the suffix a pasted copy of a sheet should take.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
void AddInstance(const SCH_SHEET_INSTANCE &aInstance)
SCH_SCREEN * GetScreen() const
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
std::vector< SCH_SHEET_PIN * > & GetPins()
const std::vector< SCH_SHEET_INSTANCE > & GetInstances() const
EMBEDDED_FILES * GetEmbeddedFiles() override
SCH_SYMBOLs don't currently support embedded files, but their LIB_SYMBOL counterparts do.
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
std::vector< LIB_ID > GetVariantSymbolOverrides() const
wxString GetSchSymbolLibraryName() const
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear exiting symbol annotation.
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
const LIB_ID & GetLibId() const override
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit, int aBodyStyle) const override
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
bool IsPower() const override
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
virtual void Add(EDA_ITEM *aItem)
A null aItem is ignored; the selection never holds null members.
const std::deque< EDA_ITEM * > GetItems() const
virtual unsigned int GetSize() const override
Return the number of stored items.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the index-th vertex in a given hole outline within a given outline.
The SIMULATOR_FRAME holds the main user-interface for running simulations.
void AddCurrentTrace(const wxString &aDeviceName)
Add a current trace for a given device to the current plot.
void AddVoltageTrace(const wxString &aNetName)
Add a voltage trace for a given net to the current plot.
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, std::span< const wxString > aPins, REPORTER &aReporter)
void SetFilesStack(std::vector< EMBEDDED_FILES * > aFilesStack)
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
The symbol library editor main window.
bool IsLibraryTreeShown() const override
void LoadSymbol(const wxString &aLibrary, const wxString &aSymbol, int Unit)
void LoadSymbolFromSchematic(SCH_SYMBOL *aSymbol)
Load a symbol from the schematic to edit in place.
void ToggleLibraryTree() override
An interface to the global shared library manager that is schematic-specific and linked to one projec...
Class to handle modifications to the symbol libraries.
Symbol library viewer main window.
virtual const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const =0
A wrapper for reporting to a wxString object.
std::unique_ptr< wxBitmap > GetImageFromClipboard()
Get image data from the clipboard, if there is any.
bool EncodeImageToPng(const wxImage &aImage, wxMemoryBuffer &aOutput)
Encode an image to PNG format with fast compression settings optimized for clipboard use.
bool AddTransparentImageToClipboardData(wxDataObjectComposite *aData, wxImage aImage)
Adds an image to clipboard data in a platform-specific way such that transparency is supported.
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
std::string GetClipboardUTF8()
Return the information currently stored in the system clipboard.
bool AddPngToClipboardData(wxDataObjectComposite *aData, const wxMemoryBuffer &aPngData, const wxImage *aFallbackImage)
Adds pre-encoded PNG data to clipboard in a platform-specific way.
wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
bool InvokeDialogEditSymbolsLibId(SCH_EDIT_FRAME *aCaller)
Run a dialog to modify the LIB_ID of symbols for instance when a symbol has moved from a symbol libra...
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)
void RunExportForOlderVersion(EDA_BASE_FRAME *aFrame, const DOWNGRADE_EXPORT_RUNNER &aRun)
bool RunDowngradeJob(KIWAY &aKiway, KIWAY::FACE_T aFace, JOB_T &aJob, const DOWNGRADE_EXPORT_PASS &aPass, DOWNGRADE_EXPORT_RESULT &aResult)
Fill in the parts of a downgrade job that every editor sets the same way, run it, and hand back its r...
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
#define IS_NEW
New item, just created.
#define ENDPOINT
ends. (Used to support dragging.)
#define IS_MOVING
Item being moved.
#define STARTPOINT
When a line is selected, these flags indicate which.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
@ FRAME_SCH_SYMBOL_EDITOR
bool m_ConnectivityEngine
Use the schematic connectivity engine instead of CONNECTION_GRAPH.
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
static const std::string KiCadSchematicFileExtension
static wxString KiCadSchematicFileWildcard()
static const wxChar traceSchPaste[]
Flag to enable schematic paste debugging output.
#define NET_PLUGIN_CHANGE
Create and shows DIALOG_EXPORT_NETLIST and returns whatever DIALOG_EXPORT_NETLIST::ShowModal() return...
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
bool LoadFileToMemory(const wxString &aFileName, wxMemoryBuffer &aBuffer)
Load the contents of a file into a memory buffer.
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
@ LAYER_SCHEMATIC_DRAWINGSHEET
@ LAYER_SCHEMATIC_PAGE_LIMITS
@ REPAINT
Item needs to be redrawn.
@ GEOMETRY
Position or shape has changed.
@ LAYERS
Layers have changed.
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
void encode(const std::vector< uint8_t > &aInput, std::vector< uint8_t > &aOutput)
#define MAX_PAGE_SIZE_EESCHEMA_MILS
PGM_BASE & Pgm()
The global program "get" accessor.
Plotting engines similar to ps (PostScript, Gerber, svg)
static bool setNetHighlight(SCH_ITEM *aItem, bool aHighlight)
#define HITTEST_THRESHOLD_PIXELS
static void recalculateIfStale(SCH_EDIT_FRAME *aFrame, SCH_ITEM *aItem)
static bool highlightNet(TOOL_MANAGER *aToolMgr, const SCH_SHEET_PATH &aSheetPath, const VECTOR2D &aPosition)
Class to handle a set of SCH_ITEMs.
std::vector< EDA_ITEM * > EDA_ITEMS
ANNOTATE_ORDER_T
Schematic annotation order options.
@ ANNOTATE_SELECTION
Annotate the selection.
ANNOTATE_ALGO_T
Schematic annotation type options.
@ SYMBOL_FILTER_NON_POWER
constexpr double SCH_WORLD_UNIT(1e-7/0.0254)
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
wxString From_UTF8(const char *cstring)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Optional context derived from the user selection that opened the dialog.
wxString toRef
Second selected symbol reference, if any.
wxString fromRef
Selected symbol reference (or first of two)
wxString netName
Net name from a selected pin or wire/bus.
What one pass of an export is asked to do.
wxString m_variant
Variant to flatten, empty for the base design.
bool m_dryRun
Classify only, write nothing.
wxString m_folder
Destination, empty on a dry run.
What the flow needs back from a pass.
std::vector< wxString > m_variantsFound
A dry run fills these so the picker can offer them.
bool show_directive_labels
std::vector< GRID > grids
Common grid settings, available to every frame.
A simple container for sheet instance information.
A simple container for schematic symbol instance information.
static constexpr auto NOT_CONNECTED
@ SHEET_REF_SUFFIX
Optional sheet field appended to the references of the sheet's symbols.
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
IbisParser parser & reporter
const SHAPE_LINE_CHAIN chain
wxString result
Test unit parsing edge cases and error handling.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
Definition of file extensions used in Kicad.
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().
#define ZOOM_MIN_LIMIT_EESCHEMA
#define ZOOM_MAX_LIMIT_EESCHEMA