87#include <wx/filedlg.h>
89#include <wx/treectrl.h>
101#include <wx/filefn.h>
102#include <wx/mstream.h>
103#include <wx/clipbrd.h>
104#include <wx/imagpng.h>
120constexpr int clipboardMaxBitmapSize = 4096;
121constexpr double clipboardBboxInflation = 0.02;
124bool loadFileToBuffer(
const wxString& aFileName, wxMemoryBuffer& aBuffer )
126 wxFFile file( aFileName, wxS(
"rb" ) );
128 if( !file.IsOpened() )
131 wxFileOffset size = file.Length();
136 void* data = aBuffer.GetWriteBuf( size );
138 if( file.Read( data, size ) !=
static_cast<size_t>( size ) )
140 aBuffer.UngetWriteBuf( 0 );
144 aBuffer.UngetWriteBuf( size );
149std::vector<SCH_ITEM*> collectSelectionItems(
const SCH_SELECTION& aSelection )
151 std::vector<SCH_ITEM*> items;
152 items.reserve( aSelection.
GetSize() );
159 items.push_back( schItem );
172 bbox.
GetHeight() * clipboardBboxInflation );
178bool generateHtmlFromPngData(
const wxMemoryBuffer& aPngData, wxMemoryBuffer& aHtmlBuffer )
180 if( aPngData.GetDataLen() == 0 )
183 std::vector<uint8_t> pngVec(
static_cast<const uint8_t*
>( aPngData.GetData() ),
184 static_cast<const uint8_t*
>( aPngData.GetData() ) + aPngData.GetDataLen() );
186 std::vector<uint8_t> base64Data;
189 std::string html =
"<img src=\"data:image/png;base64,";
190 html.append(
reinterpret_cast<const char*
>( base64Data.data() ), base64Data.size() );
191 html.append(
"\" />" );
193 aHtmlBuffer.SetDataLen( 0 );
194 aHtmlBuffer.AppendData( html.data(), html.size() );
201 wxMemoryBuffer& aBuffer )
207 std::unique_ptr<SVG_PLOTTER> plotter = std::make_unique<SVG_PLOTTER>();
208 plotter->SetRenderSettings( &renderSettings );
214 plotter->SetPageSettings( pageInfo );
215 plotter->SetColorMode(
true );
218 plotter->SetViewport( plot_offset,
schIUScale.IU_PER_MILS / 10, 1.0,
false );
219 plotter->SetCreator( wxT(
"Eeschema-SVG" ) );
221 wxFileName tempFile( wxFileName::CreateTempFileName( wxS(
"kicad_svg" ) ) );
223 if( !plotter->OpenFile( tempFile.GetFullPath() ) )
225 wxRemoveFile( tempFile.GetFullPath() );
233 plotter->StartPlot( wxT(
"1" ) );
234 aFrame->
GetScreen()->
Plot( plotter.get(), plotOpts, collectSelectionItems( aSelection ) );
238 bool ok = loadFileToBuffer( tempFile.GetFullPath(), aBuffer );
239 wxRemoveFile( tempFile.GetFullPath() );
250 int aWidth,
int aHeight,
bool aUseAlpha,
bool aIncludeDrawingSheet )
252 wxImage
image( aWidth, aHeight,
false );
257 double actualPPI = std::max( actualPPI_x, actualPPI_y );
259 VECTOR2D pageSizeIn( (
double) aWidth / actualPPI, (
double) aHeight / actualPPI );
271 std::unique_ptr<KIGFX::SCH_PAINTER> painter = std::make_unique<KIGFX::SCH_PAINTER>( gal.get() );
272 std::unique_ptr<KIGFX::VIEW> view = std::make_unique<KIGFX::VIEW>();
274 painter->SetSchematic( &aFrame->
Schematic() );
275 view->SetGAL( gal.get() );
276 view->SetPainter( painter.get() );
278 view->SetScale( 1.0 );
281 gal->SetSheetSize( pageSizeIn );
285 std::vector<std::unique_ptr<SCH_ITEM>> clonedItems;
286 clonedItems.reserve( aSelection.
GetSize() );
296 clonedItems.emplace_back( clone );
313 view->SetLayerVisible( i,
true );
320 std::unique_ptr<DS_PROXY_VIEW_ITEM> drawingSheet;
322 if( aIncludeDrawingSheet )
338 view->Add( drawingSheet.get() );
341 view->SetCenter( aBBox.
Centre() );
342 view->UseDrawPriority(
true );
358 const BOX2I& aBBox,
bool aUseAlpha,
bool aIncludeDrawingSheet )
360 const double c_targetPPI = 300;
361 const double c_targetPixelsPerMM = c_targetPPI / 25.4;
365 if( size.
x <= 0 || size.
y <= 0 )
372 if( bitmapWidth > clipboardMaxBitmapSize || bitmapHeight > clipboardMaxBitmapSize )
374 double scaleDown = (double) clipboardMaxBitmapSize / std::max( bitmapWidth, bitmapHeight );
375 bitmapWidth =
KiROUND( bitmapWidth * scaleDown );
376 bitmapHeight =
KiROUND( bitmapHeight * scaleDown );
379 if( bitmapWidth <= 0 || bitmapHeight <= 0 )
382 wxImage
result = renderSelectionToBitmap( aFrame, aSelection, aBBox, bitmapWidth, bitmapHeight, aUseAlpha,
383 aIncludeDrawingSheet );
422 wxFileDialog dlg(
m_frame,
_(
"Schematic Files" ), curr_fn.GetPath(), curr_fn.GetFullName(),
427 if( dlg.ShowModal() == wxID_CANCEL )
432 m_frame->saveSchematicFile( curr_sheet, newFilename );
444 bool wasOnSubsheet = (
m_frame->GetCurrentSheet().Last() != &root );
459 msg.Printf(
_(
"Revert '%s' (and all sub-sheets) to last version saved?" ), schematic.
GetFileName() );
488 m_frame->ShowSchematicSetupDialog();
510 m_frame->GetCanvas()->GetView()->MarkDirty();
512 m_frame->GetCanvas()->Refresh();
518 m_frame->RollbackSchematicFromUndo();
541 m_frame->GetCanvas()->GetBackend() );
550 m_frame->GetCanvas()->GetBackend() );
568 if( aRunningOnDemand )
578 m_frame->GetCanvas()->Refresh();
592 m_frame->GetCanvas()->Refresh(
true );
641 m_frame->SendSelectItemsToPcb( selection.GetItemsSortedBySelectionOrder(), aForce );
647 bool savePowerSymbols =
false;
653 targetLib =
m_frame->SelectLibrary(
_(
"Export Symbols" ),
_(
"Export symbols to library:" ),
654 { {
_(
"Include power symbols in export" ), &savePowerSymbols },
655 {
_(
"Update schematic symbols to link to exported symbols" ), &map }
658 if( targetLib.empty() )
663 sheets.
GetSymbols( symbols, savePowerSymbols );
665 std::map<LIB_ID, LIB_SYMBOL*> libSymbols;
666 std::map<LIB_ID, std::vector<SCH_SYMBOL*>> symbolMap;
668 for(
size_t i = 0; i < symbols.
GetCount(); ++i )
674 if( libSymbols.count(
id ) )
677 "Two symbols have the same LIB_ID but are different!" );
681 libSymbols[id] = libSymbol;
684 symbolMap[id].emplace_back( symbol );
691 auto optRow = adapter->
GetRow( targetLib );
692 wxCHECK( optRow, 0 );
701 for(
const std::pair<const LIB_ID, LIB_SYMBOL*>& it : libSymbols )
708 pi->SaveSymbol( dest.GetFullPath(), newSym );
712 msg.Printf(
_(
"Error saving symbol %s to library '%s'." ), newSym->
GetName(), row->
Nickname() );
713 msg += wxS(
"\n\n" ) + ioe.
What();
723 for(
SCH_SYMBOL* symbol : symbolMap[it.first] )
727 wxCHECK2( parentScreen,
continue );
730 symbol->SetLibId(
id );
738 std::set<SCH_SCREEN*> processedScreens;
744 if( processedScreens.find( ( screen ) ) == processedScreens.end() )
746 processedScreens.insert( screen );
751 commit.
Push( wxS(
"Update Library Identifiers" ) );
758#define HITTEST_THRESHOLD_PIXELS 5
770 blocking_win->Close(
true );
792 wxString variant =
m_frame->Schematic().GetCurrentVariant();
803 if( !symbol || !libPin )
811 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
812 embeddedFilesStack.push_back(
m_frame->Schematic().GetEmbeddedFiles() );
815 embeddedFilesStack.push_back( symbolEmbeddedFile );
826 std::vector<std::string> currentNames =
model.SpiceGenerator().CurrentNames( spiceItem );
828 if( currentNames.size() == 0 )
832 else if( currentNames.size() == 1 )
840 int modelPinIndex =
model.FindModelPinIndex( libPin->
GetNumber().ToStdString() );
844 wxString
name = currentNames.at( modelPinIndex );
855 else if( item->
IsType( { SCH_ITEM_LOCATE_WIRE_T } ) || item->
IsType( { SCH_JUNCTION_T } ) )
875 collector.
Collect(
m_frame->GetScreen(), { SCH_ITEM_LOCATE_WIRE_T,
877 SCH_SHEET_PIN_T }, aPos );
909 wxString connectionName = ( conn ) ? conn->
Name() : wxString( wxS(
"" ) );
911 if(
m_frame->GetHighlightedConnection() != connectionName )
913 m_frame->SetHighlightedConnection( connectionName );
921 [
this](
const int& aFinalState )
926 if( !
m_frame->GetHighlightedConnection().IsEmpty() )
928 m_frame->SetHighlightedConnection( wxEmptyString );
971 item = item->GetParent();
984 blocking_win->Close(
true );
986 static_cast<SIMULATOR_FRAME*
>( simFrame )->AddTuner( sheetPath, symbol );
1000 collector.
Collect(
m_frame->GetScreen(), { SCH_SYMBOL_T, SCH_FIELD_T }, aPos );
1008 item =
static_cast<SCH_FIELD*
>( item )->GetParentSymbol();
1023 [
this](
const int& aFinalState )
1055 if( aPosition !=
CLEAR )
1059 if(
erc.TestDuplicateSheetNames(
false ) > 0 )
1061 wxMessageBox(
_(
"Error: duplicate sub-sheet names found in current sheet." ) );
1079 std::vector<SCH_PIN*> pins = symbol->
GetPins();
1081 if( pins.size() == 1 )
1082 conn = pins[0]->Connection();
1092 wxString connName = ( conn ) ? conn->Name() : wxString( wxS(
"" ) );
1096 editFrame->SetStatusText( wxT(
"" ) );
1099 editorControl->SetHighlightBusMembers(
false );
1107 editorControl->SetHighlightBusMembers(
false );
1113 editorControl->SetHighlightBusMembers( !editorControl->GetHighlightBusMembers() );
1123 editorControl->UpdateNetHighlighting(
dummy );
1154 std::vector<std::pair<SCH_CONNECTION*, VECTOR2D>> selectedConns;
1163 selectedConns.emplace_back( conn, item->GetPosition() );
1166 if( selectedConns.empty() )
1168 m_frame->ShowInfoBarError(
_(
"No nets selected." ) );
1175 const auto getNetNamePattern =
1178 wxString netName = aConn.Name();
1185 return prefix + wxT(
"*" );
1187 return prefix + wxT(
".*" );
1192 return std::nullopt;
1198 std::set<wxString> netNames;
1200 for(
const auto& [conn, pos] : selectedConns )
1202 std::optional<wxString> netNamePattern = getNetNamePattern( *conn );
1204 if( !netNamePattern )
1207 m_frame->ShowInfoBarError(
_(
"All selected nets must be labeled to assign a netclass." ) );
1211 netNames.insert( *netNamePattern );
1214 wxCHECK( !netNames.empty(), 0 );
1217 [&](
const std::vector<wxString>& aNetNames )
1219 for( SCH_ITEM* item : screen->Items() )
1221 bool redraw = item->IsBrightened();
1222 SCH_CONNECTION* itemConn = item->Connection();
1224 if( itemConn && alg::contains( aNetNames, itemConn->Name() ) )
1225 item->SetBrightened();
1227 item->ClearBrightened();
1229 redraw |= item->IsBrightened();
1231 if( item->Type() == SCH_SYMBOL_T )
1233 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1235 redraw |= symbol->HasBrightenedPins();
1237 symbol->ClearBrightenedPins();
1239 for( SCH_PIN* pin : symbol->GetPins() )
1241 SCH_CONNECTION* pin_conn = pin->Connection();
1243 if( pin_conn && alg::contains( aNetNames, pin_conn->Name() ) )
1245 pin->SetBrightened();
1250 else if( item->Type() == SCH_SHEET_T )
1252 for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
1254 SCH_CONNECTION* pin_conn = pin->Connection();
1256 redraw |= pin->IsBrightened();
1258 if( pin_conn && alg::contains( aNetNames, pin_conn->Name() ) )
1259 pin->SetBrightened();
1261 pin->ClearBrightened();
1263 redraw |= pin->IsBrightened();
1268 getView()->Update( item, KIGFX::VIEW_UPDATE_FLAGS::REPAINT );
1271 m_frame->GetCanvas()->ForceRefresh();
1274 if( dlg.ShowModal() )
1276 getView()->UpdateAllItemsConditionally(
1281 auto invalidateTextVars =
1284 if(
text->HasTextVars() )
1286 text->ClearRenderCache();
1287 text->ClearBoundingBoxCache();
1294 if(
dynamic_cast<SCH_LINE*
>( aItem ) )
1305 item->RunOnChildren(
1306 [&invalidateTextVars](
SCH_ITEM* aChild )
1309 invalidateTextVars(
text );
1314 m_frame->GetScreen()->Update( item,
false );
1318 invalidateTextVars(
text );
1333 if( !selectionTool )
1344 if( !conn->GetNetName().IsEmpty() )
1346 netName = conn->GetNetName();
1353 if( netName.IsEmpty() )
1354 netName =
m_frame->GetHighlightedConnection();
1356 if( netName.IsEmpty() )
1358 m_frame->ShowInfoBarError(
_(
"No connected net selected." ) );
1362 m_frame->FindNetInInspector( netName );
1375 wxString selectedName =
m_frame->GetHighlightedConnection();
1377 std::set<wxString> connNames;
1378 std::vector<EDA_ITEM*> itemsToRedraw;
1380 wxCHECK( screen && connectionGraph, 0 );
1382 if( !selectedName.IsEmpty() )
1384 connNames.emplace( selectedName );
1390 for(
const SCH_ITEM* item : sg->GetItems() )
1392 wxCHECK2( item,
continue );
1396 for(
const std::shared_ptr<SCH_CONNECTION>& member : connection->AllMembers() )
1399 connNames.emplace( member->Name() );
1411 for(
const auto& [
_, bus_sgs] : sg->GetBusParents() )
1414 connNames.emplace( bus_sg->GetNetName() );
1421 if( !item || !item->IsConnectable() )
1436 if( !
pin->IsBrightened() && connNames.count( pin_conn->
Name() ) )
1438 pin->SetBrightened();
1439 redrawItem = symbol;
1441 else if(
pin->IsBrightened() && !connNames.count( pin_conn->
Name() ) )
1443 pin->ClearBrightened();
1444 redrawItem = symbol;
1447 else if(
pin->IsBrightened() )
1449 pin->ClearBrightened();
1450 redrawItem = symbol;
1470 redrawItem = symbol;
1475 redrawItem = symbol;
1481 redrawItem = symbol;
1492 wxCHECK2(
pin,
continue );
1498 if( !
pin->IsBrightened() && connNames.count( pin_conn->
Name() ) )
1500 pin->SetBrightened();
1503 else if(
pin->IsBrightened() && !connNames.count( pin_conn->
Name() ) )
1505 pin->ClearBrightened();
1509 else if(
pin->IsBrightened() )
1511 pin->ClearBrightened();
1522 if( !item->IsBrightened() && connNames.count( itemConn->
Name() ) )
1524 item->SetBrightened();
1527 else if( item->IsBrightened() && !connNames.count( itemConn->
Name() ) )
1529 item->ClearBrightened();
1533 else if( item->IsBrightened() )
1535 item->ClearBrightened();
1541 itemsToRedraw.push_back( redrawItem );
1544 if( itemsToRedraw.size() )
1549 for(
EDA_ITEM* redrawItem : itemsToRedraw )
1552 m_frame->GetCanvas()->Refresh();
1586 if(
m_frame->GetUndoCommandCount() <= 0 )
1595 wxCHECK( undo_list, 0 );
1597 m_frame->PutDataInPreviousState( undo_list );
1601 m_frame->PushCommandToRedoList( undo_list );
1605 m_frame->GetCanvas()->Refresh();
1616 if(
m_frame->GetRedoCommandCount() == 0 )
1628 m_frame->PutDataInPreviousState( list );
1631 list->ReversePickersListOrder();
1632 m_frame->PushCommandToUndoList( list );
1636 m_frame->GetCanvas()->Refresh();
1649 if( selection.Empty() )
1652 if( aUseDuplicateClipboard )
1655 selection.SetScreen(
m_frame->GetScreen() );
1658 for(
EDA_ITEM* item : selection.GetItems() )
1665 else if( item->Type() ==
SCH_FIELD_T && selection.IsHover() )
1669 selection.Add( item->GetParent() );
1674 selection.Remove( item );
1679 static_cast<SCH_ITEM*
>( item )->RunOnChildren(
1682 selection.Add( aChild );
1693 plugin.
Format( &selection, &selPath, schematic, &formatter,
true );
1695 std::string prettyData = formatter.
GetString();
1698 if( !aUseDuplicateClipboard )
1702 result &= wxTheClipboard->Open();
1706 wxDataObjectComposite* data =
new wxDataObjectComposite();
1709 wxCustomDataObject* kicadObj =
new wxCustomDataObject( wxDataFormat(
"application/kicad" ) );
1710 kicadObj->SetData( prettyData.size(), prettyData.data() );
1711 data->Add( kicadObj );
1713 BOX2I selectionBox = expandedSelectionBox( selection );
1718 wxImage
image = renderSelectionToImageForClipboard(
m_frame, selection, selectionBox,
true,
false );
1719 wxMemoryBuffer pngBuffer;
1726 wxMemoryBuffer htmlBuffer;
1728 if( generateHtmlFromPngData( pngBuffer, htmlBuffer ) )
1730 wxCustomDataObject* htmlObj =
new wxCustomDataObject( wxDF_HTML );
1731 htmlObj->SetData( htmlBuffer.GetDataLen(), htmlBuffer.GetData() );
1732 data->Add( htmlObj );
1737 wxLogDebug( wxS(
"Failed to generate bitmap for clipboard" ) );
1741 wxMemoryBuffer svgBuffer;
1743 if( plotSelectionToSvg(
m_frame, selection, selectionBox, svgBuffer ) )
1745 wxCustomDataObject* svgObj =
new wxCustomDataObject( wxDataFormat(
"image/svg+xml" ) );
1746 svgObj->SetData( svgBuffer.GetDataLen(), svgBuffer.GetData() );
1747 data->Add( svgObj );
1751 wxLogDebug( wxS(
"Failed to generate SVG for clipboard" ) );
1756 data->Add(
new wxTextDataObject( wxString::FromUTF8( prettyData ) ) );
1758 result &= wxTheClipboard->SetData( data );
1759 result &= wxTheClipboard->Flush();
1760 wxTheClipboard->Close();
1764 if( selection.IsHover() )
1767 if( aUseDuplicateClipboard )
1800 wxTextEntry* textEntry =
dynamic_cast<wxTextEntry*
>( wxWindow::FindFocus() );
1817 wxTextEntry* textEntry =
dynamic_cast<wxTextEntry*
>( wxWindow::FindFocus() );
1836 if( selection.Empty() )
1841 if( selection.IsHover() )
1849 const KIID_PATH& aClipPath,
bool aForceKeepAnnotations )
1851 wxCHECK(
m_frame && aSymbol, );
1854 bool instanceFound =
false;
1861 if( ( tmp.m_Path.empty() && aClipPath.empty() ) || ( !aClipPath.empty() && tmp.m_Path.
EndsWith( aClipPath ) ) )
1864 instanceFound =
true;
1866 wxLogTrace(
traceSchPaste, wxS(
"Pasting found symbol instance with reference %s, unit %d:\n"
1867 "\tClipboard path: %s\n"
1868 "\tSymbol UUID: %s." ),
1879 pasteLookupPath.push_back( aSymbol->
m_Uuid );
1881 if( !instanceFound )
1883 wxLogTrace(
traceSchPaste, wxS(
"Clipboard symbol instance **not** found:\n\tClipboard path: %s\n"
1884 "\tSymbol UUID: %s." ),
1904 if( !aForceKeepAnnotations )
1913 const KIID_PATH& aClipPath,
bool aForceKeepAnnotations,
1917 wxCHECK( aSheet && aPastedSheets, aPastePath );
1922 aPastedSheets->push_back( sheetPath );
1929 if( item->IsConnectable() )
1930 item->SetConnectivityDirty();
1936 wxCHECK2( symbol,
continue );
1944 pin->SetConnectivityDirty();
1954 wxCHECK2( subsheet,
continue );
1962 pin->SetConnectivityDirty();
1967 newClipPath.push_back( subsheet->
m_Uuid );
1969 updatePastedSheet( subsheet, sheetPath, newClipPath, aForceKeepAnnotations, aPastedSheets, aPastedSymbols );
1973 sheetPath.
GetSymbols( aPastedSymbols[aPastePath] );
1981 wxCHECK( aScreen, );
1989 wxCHECK2( symbol,
continue );
1993 KIID_PATH pathWithSymbol = symbolInstance.m_Path;
1995 pathWithSymbol.push_back( symbol->
m_Uuid );
2010 wxCHECK2( symbol,
continue );
2012 std::vector<KIID_PATH> instancePathsToRemove;
2016 if( instance.m_ProjectName !=
m_frame->Prj().GetProjectName() || instance.m_Path.empty() )
2017 instancePathsToRemove.emplace_back( instance.m_Path );
2021 symbol->RemoveInstance(
path );
2028 wxTextEntry* textEntry =
dynamic_cast<wxTextEntry*
>( wxWindow::FindFocus() );
2037 std::string content;
2052 if( content.empty() )
2058 auto bitmap = std::make_unique<SCH_BITMAP>();
2060 if( bitmap->GetReferenceImage().SetImage( clipImg->ConvertToImage() ) )
2088 "Do you want to continue?" ) );
2094 tempScreen->
Append( text_item );
2100 bool hasTableCells =
false;
2102 for(
EDA_ITEM* item : currentSelection )
2106 hasTableCells =
true;
2119 clipboardTable =
static_cast<SCH_TABLE*
>( item );
2124 if( clipboardTable )
2142 commit.
Push(
_(
"Paste Cells" ) );
2162 bool annotateAutomatic =
m_frame->eeconfig()->m_AnnotatePanel.automatic;
2167 bool forceRemoveAnnotations =
false;
2187 std::vector<SCH_ITEM*> sortedLoadedItems;
2188 bool sheetsPasted =
false;
2193 if( destFn.IsRelative() )
2194 destFn.MakeAbsolute(
m_frame->Prj().GetProjectPath() );
2201 std::map<wxString, SCH_SCREEN*> loadedScreens;
2205 if( item.LastScreen() )
2206 loadedScreens[item.Last()->GetFileName()] = item.LastScreen();
2217 std::set<wxString> existingRefsSet;
2220 existingRefsSet.insert( ref.GetRef() );
2223 std::map<KIID, EDA_ITEM*> itemMap;
2227 std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST> pastedSymbols;
2228 std::map<SCH_SHEET_PATH, SCH_SHEET_LIST> pastedSheets;
2233 sortedLoadedItems.push_back( item );
2235 loadedItems.push_back( item );
2238 sort( sortedLoadedItems.begin(), sortedLoadedItems.end(),
2241 SCH_SHEET* firstSheet = static_cast<SCH_SHEET*>( firstItem );
2242 SCH_SHEET* secondSheet = static_cast<SCH_SHEET*>( secondItem );
2243 return StrNumCmp( firstSheet->GetName(), secondSheet->GetName(), false ) < 0;
2247 for(
SCH_ITEM* item : sortedLoadedItems )
2249 loadedItems.push_back( item );
2256 if( srcFn.IsRelative() )
2257 srcFn.MakeAbsolute(
m_frame->Prj().GetProjectPath() );
2261 if( hierarchy.
TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
2263 auto msg = wxString::Format(
_(
"The pasted sheet '%s'\n"
2264 "was dropped because the destination already has "
2265 "the sheet or one of its subsheets as a parent." ),
2268 loadedItems.pop_back();
2274 tempScreen->
Clear(
false );
2276 for(
EDA_ITEM* item : loadedItems )
2282 wxCHECK2( schItem,
continue );
2297 wxCHECK2( currentScreen,
continue );
2311 if( it !=
end && clipLibSymbol )
2316 if( clipLibSymbol->
IsLocalPower() != it->second->IsLocalPower()
2317 || clipLibSymbol->
IsGlobalPower() != it->second->IsGlobalPower() )
2319 libSymbol =
new LIB_SYMBOL( *clipLibSymbol );
2326 else if( it !=
end )
2330 else if( clipLibSymbol )
2332 libSymbol =
new LIB_SYMBOL( *clipLibSymbol );
2342 if( !existingRefsSet.contains( instance.m_Reference ) )
2344 forceKeepAnnotations = !forceRemoveAnnotations;
2360 if( existingRefsSet.contains( instance.m_Reference ) )
2362 needsNewKiid =
true;
2370 const_cast<KIID&
>( item->m_Uuid ) =
KIID();
2376 pin->SetConnectivityDirty();
2386 pastedSymbols[sheetPath].AddItem( schReference );
2395 wxString baseName = nameField->
GetText();
2396 wxString candidateName = baseName;
2399 while( !baseName.IsEmpty() && wxIsdigit( baseName.Last() ) )
2401 number = baseName.Last() + number;
2402 baseName.RemoveLast();
2407 hierarchy =
m_frame->Schematic().Hierarchy();
2409 int uniquifier = std::max( 0, wxAtoi( number ) ) + 1;
2411 while( existingSheetNames.count( candidateName ) )
2412 candidateName = wxString::Format( wxT(
"%s%d" ), baseName, uniquifier++ );
2414 nameField->
SetText( candidateName );
2415 existingSheetNames.emplace( candidateName );
2423 if( !fn.IsAbsolute() )
2426 fn.Normalize(
FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS, currentSheetFileName.GetPath() );
2430 if( !
m_frame->Schematic().Root().SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ), &existingScreen ) )
2432 if( loadedScreens.count( sheet->
GetFileName() ) > 0 )
2433 existingScreen = loadedScreens.at( sheet->
GetFileName() );
2438 if( existingScreen )
2444 if( !
m_frame->LoadSheetFromFile( sheet, &pasteRoot, fn.GetFullPath() ) )
2451 sheetsPasted =
true;
2454 clipPath.push_back( sheet->
m_Uuid );
2463 pin->SetConnectivityDirty();
2471 ( forceKeepAnnotations && annotateAutomatic ),
2472 &pastedSheets[sheetPath], pastedSymbols );
2481 const_cast<KIID&
>( item->m_Uuid ) =
KIID();
2483 if( srcItem && destItem )
2510 m_frame->Schematic().RefreshHierarchy();
2518 wxString pageNum = wxString::Format(
"%d", page );
2521 pageNum = wxString::Format(
"%d", ++page );
2525 sheetInstance.
m_Path = pastedSheet.Path();
2528 sheetInstance.
m_Path.pop_back();
2534 wxCHECK2( sheet,
continue );
2537 hierarchy.push_back( pastedSheet );
2540 std::vector<KIID_PATH> instancesToRemove;
2544 if( !hierarchy.
HasPath( instance.m_Path ) )
2545 instancesToRemove.push_back( instance.m_Path );
2548 for(
const KIID_PATH& instancePath : instancesToRemove )
2553 m_frame->SetSheetNumberAndCount();
2557 hierarchy =
m_frame->Schematic().Hierarchy();
2560 std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST> annotatedSymbols;
2565 for(
size_t i = 0; i < pastedSymbols[sheetPath].GetCount(); i++ )
2568 annotatedSymbols[sheetPath].AddItem( pastedSymbols[sheetPath][i] );
2571 for(
const SCH_SHEET_PATH& pastedSheetPath : pastedSheets[sheetPath] )
2573 for(
size_t i = 0; i < pastedSymbols[pastedSheetPath].GetCount(); i++ )
2576 annotatedSymbols[pastedSheetPath].AddItem( pastedSymbols[pastedSheetPath][i] );
2581 if( !annotatedSymbols.empty() )
2588 annotatedSymbols[
path].SortByReferenceOnly();
2593 annotatedSymbols[
path].ReannotateDuplicates( existingRefs, annotateAlgo );
2597 annotatedSymbols[
path].ReannotateByOptions( annotateOrder, annotateAlgo, annotateStartNum,
2598 existingRefs,
false, &hierarchy );
2601 annotatedSymbols[
path].UpdateAnnotation();
2604 for(
size_t i = 0; i < annotatedSymbols[
path].GetCount(); i++ )
2605 existingRefs.
AddItem( annotatedSymbols[
path][i] );
2609 annotatedSymbols[pastedSheetPath].SortByReferenceOnly();
2610 annotatedSymbols[pastedSheetPath].SetRefDesTracker( schematicSettings.
m_refDesTracker );
2614 annotatedSymbols[pastedSheetPath].ReannotateDuplicates( existingRefs, annotateAlgo );
2618 annotatedSymbols[pastedSheetPath].ReannotateByOptions( annotateOrder, annotateAlgo,
2619 annotateStartNum, existingRefs,
2620 false, &hierarchy );
2623 annotatedSymbols[pastedSheetPath].UpdateAnnotation();
2626 for(
size_t i = 0; i < annotatedSymbols[pastedSheetPath].GetCount(); i++ )
2627 existingRefs.
AddItem( annotatedSymbols[pastedSheetPath][i] );
2632 m_frame->GetCurrentSheet().UpdateAllScreenReferences();
2650 for(
int i = loadedItems.size() - 1; i >= 0; i-- )
2656 loadedItems.erase( loadedItems.begin() + i );
2669 if( !selection.Empty() )
2673 int closest_dist = INT_MAX;
2678 int dist = ( eventPos - pt ).EuclideanNorm();
2680 if( dist < closest_dist )
2682 selection.SetReferencePoint( pt );
2683 closest_dist = dist;
2688 for(
EDA_ITEM* item : selection.Items() )
2700 processPt(
pin->GetPosition() );
2706 processPt( item->GetPosition() );
2710 if( closest_dist == INT_MAX )
2712 for(
EDA_ITEM* item : selection.Items() )
2714 switch( item->Type() )
2717 processPt(
static_cast<SCH_LINE*
>( item )->GetStartPoint() );
2718 processPt(
static_cast<SCH_LINE*
>( item )->GetEndPoint() );
2738 for(
int ii = 0; ii < shape->
GetPolyShape().TotalVertices(); ++ii )
2745 processPt( shape->
GetEnd() );
2753 processPt( item->GetPosition() );
2762 else if( selection.GetTopLeftItem()->Type() ==
SCH_GROUP_T )
2769 group->RunOnChildren(
2781 selection.SetReferencePoint( item->
GetPosition() );
2783 selection.SetReferencePoint(
group->GetPosition() );
2789 selection.SetReferencePoint( item->
GetPosition() );
2795 commit.
Push(
_(
"Paste" ) );
2799 m_frame->UpdateHierarchyNavigator();
2804 m_frame->RefreshNetNavigator();
2826 if( selection.GetSize() >= 1 )
2829 if( selection.IsHover() )
2837 tableTool->EditTable( aEvent );
2847 m_frame->ShowInfoBarError(
_(
"Symbols with broken library symbol links cannot be edited." ) );
2857 blocking_win->Close(
true );
2886 dlg.
m_FirstRefDes->SetValidator( wxTextValidator( wxFILTER_EMPTY ) );
2900 int startNum = atoi( startRef.
GetRefNumber().utf8_string().c_str() );
2915 if( ref.GetRef() == startRef.
GetRef() )
2917 int num = atoi( ref.GetRefNumber().utf8_string().c_str() );
2919 if( num >= startNum )
2922 wxString fullRef = ref.GetRef();
2928 ref.GetSymbol()->SetRef( &sheet,
From_UTF8( fullRef.c_str() ) );
2933 if( !commit.
Empty() )
2934 commit.
Push(
_(
"Increment Annotations" ) );
3042 sheetSelection.
Add( item );
3049 wxImage
image = renderSelectionToImageForClipboard(
m_frame, sheetSelection, pageBBox,
true,
true );
3055 if( wxTheClipboard->Open() )
3057 wxDataObjectComposite* data =
new wxDataObjectComposite();
3061 wxTheClipboard->SetData( data );
3062 wxTheClipboard->Flush();
3063 wxTheClipboard->Close();
3068 wxLogMessage(
_(
"Cannot create the schematic image" ) );
3123 m_frame->GetCanvas()->Refresh();
3135 m_frame->GetCanvas()->Refresh();
3147 m_frame->GetCanvas()->Refresh();
3159 m_frame->GetCanvas()->Refresh();
3171 m_frame->GetCanvas()->Refresh();
3182 m_frame->GetCanvas()->Refresh();
3191 wxString variant =
m_frame->Schematic().GetCurrentVariant();
3195 m_frame->GetCanvas()->GetView()->UpdateAllItemsConditionally(
3200 auto invalidateTextVars =
3203 if(
text->HasTextVars() )
3205 text->ClearRenderCache();
3206 text->ClearBoundingBoxCache();
3213 item->RunOnChildren(
3214 [&invalidateTextVars](
SCH_ITEM* aChild )
3217 invalidateTextVars(
text );
3221 if( item->GetExcludedFromSim( sheetPath, variant ) )
3226 invalidateTextVars(
text );
3231 m_frame->GetCanvas()->Refresh();
3243 m_frame->RefreshOperatingPointDisplay();
3244 m_frame->GetCanvas()->Refresh();
3256 m_frame->RefreshOperatingPointDisplay();
3257 m_frame->GetCanvas()->Refresh();
3271 m_frame->GetCanvas()->Refresh();
3289 m_frame->eeconfig()->m_Drawing.line_mode++;
3308 m_frame->ScriptingConsoleEnableDisable();
3316 if(
Pgm().GetCommonSettings()->m_Api.enable_server )
3317 Pgm().GetPluginManager().ReloadPlugins();
3325 switch(
static_cast<LINE_MODE>(
m_frame->eeconfig()->m_Drawing.line_mode ) )
3344 std::map<KIID, EDA_ITEM*> ids;
3352 auto it = ids.find( aItem->m_Uuid );
3354 if( it != ids.end() && it->second != aItem )
3357 const_cast<KIID&
>( aItem->m_Uuid ) =
KIID();
3360 ids[ aItem->m_Uuid ] = aItem;
3372 processItem( item );
3385 processItem( item );
3389 item->RunOnChildren(
3392 processItem( item );
3409 errors += duplicates;
3410 details += wxString::Format(
_(
"%d duplicate IDs replaced.\n" ), duplicates );
3413 m_frame->Schematic().RefreshHierarchy();
3420 wxString msg = wxString::Format(
_(
"%d potential problems repaired." ), errors );
3436 if( !
Pgm().GetCommonSettings()->m_Input.hotkey_feedback )
3440 int currentIdx =
m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
3442 wxArrayString gridsLabels;
3445 gridsLabels.Add(
grid.UserUnitsMessageText(
m_frame ) );
3447 if( !
m_frame->GetHotkeyPopup() )
3453 popup->
Popup(
_(
"Grid" ), gridsLabels, currentIdx );
3470 if( selection.Size() != 1 || selection[0]->Type() !=
SCH_GROUP_T )
3475 if( !
group->HasDesignBlockLink() )
3480 std::unique_ptr<DESIGN_BLOCK> designBlock( designBlockPane->
GetDesignBlock(
group->GetDesignBlockLibId(),
3486 msg.Printf(
_(
"Could not find design block %s." ),
group->GetDesignBlockLibId().GetUniStringLibId() );
3487 m_frame->GetInfoBar()->ShowMessageFor( msg, 5000, wxICON_WARNING );
3491 if( designBlock->GetSchematicFile().IsEmpty() )
3494 msg.Printf(
_(
"Design block %s does not have a schematic file." ),
3495 group->GetDesignBlockLibId().GetUniStringLibId() );
3496 m_frame->GetInfoBar()->ShowMessageFor( msg, 5000, wxICON_WARNING );
3517 if( selection.Size() != 1 || selection[0]->Type() !=
SCH_GROUP_T )
3522 if( !
group->HasDesignBlockLink() )
3527 std::unique_ptr<DESIGN_BLOCK> designBlock( designBlockPane->
GetDesignBlock(
group->GetDesignBlockLibId(),
3533 msg.Printf(
_(
"Could not find design block %s." ),
group->GetDesignBlockLibId().GetUniStringLibId() );
3534 m_frame->GetInfoBar()->ShowMessageFor( msg, 5000, wxICON_WARNING );
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 pluginsReload
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 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
void SetContentModified(bool aModified=true)
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 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.
Calculate the connectivity of a schematic and generates netlists.
CONNECTION_SUBGRAPH * FindSubgraphByName(const wxString &aNetName, const SCH_SHEET_PATH &aPath)
Return the subgraph for a given net name on a given sheet.
const std::vector< CONNECTION_SUBGRAPH * > & GetAllSubgraphs(const wxString &aNetName) const
A subgraph is a set of items that are electrically connected on a single sheet.
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)
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.
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.
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM * GetParent() const
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
bool IsBrightened() const
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
EE_TYPE OfType(KICAD_T aType) const
static const TOOL_EVENT ClearedEvent
static const TOOL_EVENT GridChangedByKeyEvent
static const TOOL_EVENT SelectedEvent
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
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()
static std::unique_ptr< CAIRO_PRINT_GAL > Create(GAL_DISPLAY_OPTIONS &aOptions, wxImage *aImage, double aDPI)
GAL_ANTIALIASING_MODE antialiasing_mode
The grid style to draw the grid in.
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.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
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) const
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
wxString GetName() const override
bool IsLocalPower() const override
bool IsGlobalPower() const override
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)
Remove formatting wrappers and replace illegal spice net name characters with underscores.
Tree view item data for the net navigator.
static bool ParseBusGroup(const wxString &aGroup, wxString *name, std::vector< wxString > *aMemberList)
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.
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.
virtual bool HasMessage() const
Returns true if any messages were reported.
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.
std::shared_ptr< REFDES_TRACKER > m_refDesTracker
A list of previously used schematic reference designators.
Holds all the data relating to one schematic.
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
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.
const std::map< wxString, wxString > * GetProperties()
SCH_SHEET_PATH & CurrentSheet() const
static TOOL_ACTION showPcbNew
static TOOL_ACTION assignFootprints
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 schematicSetup
static TOOL_ACTION toggleDirectiveLabels
static TOOL_ACTION highlightNetTool
static TOOL_ACTION findNetInInspector
static TOOL_ACTION toggleHiddenFields
static TOOL_ACTION saveCurrSheetCopyAs
static TOOL_ACTION showRemoteSymbolPanel
static TOOL_ACTION repairSchematic
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 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 changeSheet
static TOOL_ACTION highlightNet
static TOOL_ACTION assignNetclass
static TOOL_ACTION annotate
static TOOL_ACTION showDesignBlockPanel
static TOOL_ACTION updateDesignBlockFromSelection
static TOOL_ACTION togglePinAltIcons
static TOOL_ACTION toggleERCExclusions
static TOOL_ACTION updateNetHighlighting
static TOOL_ACTION exportNetlist
static TOOL_ACTION drawSheetOnClipboard
static TOOL_ACTION exportSymbolsToLibrary
static TOOL_ACTION toggleHiddenPins
static TOOL_ACTION selectOnPCB
static TOOL_ACTION addVariant
SCH_RENDER_SETTINGS * GetRenderSettings()
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.
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.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString Name(bool aIgnoreSheet=false) const
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)
Remove any net highlighting.
int ClearHighlight(const TOOL_EVENT &aEvent)
Update net highlighting after an edit.
int FindNetInInspector(const TOOL_EVENT &aEvent)
int EditSymbolFields(const TOOL_EVENT &aEvent)
bool m_duplicateIsHoverSelection
int GenerateBOMLegacy(const TOOL_EVENT &aEvent)
int HighlightNetCursor(const TOOL_EVENT &aEvent)
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)
Equivalent to the above, but initiated by the user.
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)
Clipboard support.
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 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 SimTune(const TOOL_EVENT &aEvent)
Highlight net under the cursor.
int EditSymbolLibraryLinks(const TOOL_EVENT &aEvent)
int New(const TOOL_EVENT &aEvent)
std::map< wxString, SCH_SCREEN * > m_supplementaryClipboard
int ExplicitCrossProbeToPcb(const TOOL_EVENT &aEvent)
int ToggleOPCurrents(const TOOL_EVENT &aEvent)
int ShowPcbNew(const TOOL_EVENT &aEvent)
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Launch a tool to highlight nets.
int ToggleERCErrors(const TOOL_EVENT &aEvent)
int TogglePythonConsole(const TOOL_EVENT &aEvent)
int ShowHierarchy(const TOOL_EVENT &aEvent)
int OnAngleSnapModeChanged(const TOOL_EVENT &aEvent)
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
bool m_highlightBusMembers
int ShowNetNavigator(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 ToggleLibraryTree(const TOOL_EVENT &aEvent)
int RepairSchematic(const TOOL_EVENT &aEvent)
std::set< SCH_SYMBOL * > m_pastedSymbols
void prunePastedSymbolInstances()
Remove all pasted symbol instances that do not belong to the current project.
int Cut(const TOOL_EVENT &aEvent)
int ToggleProperties(const TOOL_EVENT &aEvent)
std::map< KIID_PATH, SCH_SYMBOL_INSTANCE > m_clipboardSymbolInstances
int Save(const TOOL_EVENT &aEvent)
bool RescueSymbolLibTableProject(bool aRunningOnDemand)
Notifies pcbnew about the selected item.
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 Plot(const TOOL_EVENT &aEvent)
int Print(const TOOL_EVENT &aEvent)
int Revert(const TOOL_EVENT &aEvent)
int GenerateBOM(const TOOL_EVENT &aEvent)
int ReloadPlugins(const TOOL_EVENT &aEvent)
void setPastedSymbolInstances(const SCH_SCREEN *aScreen)
int ToggleHiddenFields(const TOOL_EVENT &aEvent)
Schematic editor (Eeschema) main window.
void ToggleProperties() override
SCH_DESIGN_BLOCK_PANE * GetDesignBlockPane() const
void ToggleNetNavigator()
void ToggleLibraryTree() override
void SetHighlightedConnection(const wxString &aConnection, const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr)
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SendCrossProbeClearHighlight()
Tell Pcbnew to clear the existing highlighted net, if one exists.
SCH_SHEET_PATH & GetCurrentSheet() const
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, PROGRESS_REPORTER *aProgressReporter=nullptr)
Generate the connection data for the entire schematic hierarchy.
const SCH_ITEM * GetSelectedNetNavigatorItem() const
SCHEMATIC & Schematic() const
void ToggleSearch()
Toggle the show/hide state of Search pane.
wxString GetFullScreenDesc() const override
void ToggleSchematicHierarchy()
Toggle the show/hide state of the left side schematic navigation panel.
const wxString & GetHighlightedConnection() const
void UpdateNetHighlightStatus()
wxString GetScreenDesc() const override
Return a human-readable description of the current screen.
void SelectNetNavigatorItem(const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr)
void SetCrossProbeConnection(const SCH_CONNECTION *aConnection)
Send a connection (net or bus) to Pcbnew for highlighting.
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 #SCH_FILE_T from the corresponding plugin type name: "kicad", "legacy",...
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual bool IsConnectable() const
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)
bool IsConnectivityDirty() const
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.
virtual std::vector< VECTOR2I > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Segment description base class to describe items which have 2 end points (track, wire,...
SCH_PIN * GetLibPin() const
const wxString & GetNumber() const
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()
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 Clear(bool aFree=true)
Delete all draw items and clears the project settings.
void UpdateSymbolLinks(REPORTER *aReporter=nullptr)
Initialize the LIB_SYMBOL reference for each SCH_SYMBOL found in this schematic from the project #SYM...
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
SCHEMATIC * Schematic() const
const TITLE_BLOCK & GetTitleBlock() const
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 FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
Fill an item cache for temporary use when many items need to be fetched.
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.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
bool PageNumberExists(const wxString &aPageNumber) const
bool ContainsSheet(const SCH_SHEET *aSheet) const
bool HasPath(const KIID_PATH &aPath) const
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...
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, 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.
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 GetFileName() const
Return the filename corresponding to this sheet.
void RemoveInstance(const KIID_PATH &aInstancePath)
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
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::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)
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, const std::vector< SCH_PIN * > &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.
A wrapper for reporting to a wxString object.
const wxString & GetMessages() const
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)
#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
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.
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
#define KICTL_REVERT
reverting to a previously-saved (KiCad) file.
@ 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.
@ 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 highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
#define HITTEST_THRESHOLD_PIXELS
Class to handle a set of SCH_ITEMs.
std::vector< EDA_ITEM * > EDA_ITEMS
ANNOTATE_ORDER_T
Schematic annotation order options.
ANNOTATE_ALGO_T
Schematic annotation type options.
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.
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
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
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