49#include <python_scripting.h>
83#include <wx/cmdline.h>
85#include <wx/filedlg.h>
118 m_highlightedConn(
nullptr )
120 m_maximizeByDefault =
true;
123 m_showBorderAndTitleBlock =
true;
124 m_supportsAutoSave =
true;
125 m_syncingPcbToSchSelection =
false;
126 m_aboutTitle =
_HKI(
"KiCad Schematic Editor" );
128 m_findReplaceDialog =
nullptr;
130 m_findReplaceData = std::make_unique<SCH_SEARCH_DATA>();
134 wxIconBundle icon_bundle;
137 icon_bundle.AddIcon( icon );
139 icon_bundle.AddIcon( icon );
141 icon_bundle.AddIcon( icon );
143 SetIcons( icon_bundle );
149 SetCurrentSheet( Schematic().GetSheets()[0] );
156 ReCreateOptToolbar();
161 m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
162 m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
163 m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
164 m_pageSetupData.GetPrintData().SetNoCopies( 1 );
166 m_auimgr.SetManagedWindow(
this );
171 m_auimgr.AddPane( m_mainToolBar,
EDA_PANE().HToolbar().Name( wxS(
"MainToolbar" ) )
174 m_auimgr.AddPane( m_messagePanel,
EDA_PANE().Messages().Name( wxS(
"MsgPanel" ) )
175 .Bottom().Layer( 6 ) );
178 m_auimgr.AddPane( m_hierarchy,
EDA_PANE().Palette().Name( SchematicHierarchyPaneName() )
179 .Caption(
_(
"Schematic Hierarchy" ) )
181 .TopDockable(
false )
182 .BottomDockable(
false )
185 .BestSize( 200, 200 )
186 .FloatingSize( 200, 200 )
188 m_auimgr.AddPane( m_optionsToolBar,
EDA_PANE().VToolbar().Name( wxS(
"OptToolbar" ) )
189 .
Left().Layer( 2 ) );
191 m_auimgr.AddPane( m_drawToolBar,
EDA_PANE().VToolbar().Name( wxS(
"ToolsToolbar" ) )
192 .
Right().Layer( 2 ) );
195 m_auimgr.AddPane( GetCanvas(),
EDA_PANE().Canvas().Name( wxS(
"DrawFrame" ) )
198 FinishAUIInitialization();
201 SwitchCanvas( m_canvasType );
203 GetCanvas()->GetGAL()->SetAxesEnabled(
false );
208 wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
222 hierarchy_pane.Float();
232 hierarchy_pane.Fixed();
236 hierarchy_pane.Resizable();
241 hierarchy_pane.MinSize( 120, 60 );
248 LoadProjectSettings();
258 m_hierarchy->Connect( wxEVT_SIZE,
280 DragAcceptFiles(
true );
287 wxPoint canvas_pos = GetCanvas()->GetScreenPosition();
288 hierarchy_pane.FloatingPosition( canvas_pos.x + 10, canvas_pos.y + 10 );
304 open_dlg->Close(
true );
326 catch(
const nlohmann::detail::type_error& exc )
330 wxLogError( wxT(
"Settings exception '%s' occurred." ), exc.what() );
361 if( hierarchy_pane.rect.width > 50 )
364 hierarchy_pane.best_size.x = hierarchy_pane.rect.width;
419 auto hierarchyNavigatorCond =
426#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
427#define CHECK( x ) ACTION_CONDITIONS().Check( x )
464 if( SCRIPTING::IsWxAvailable() )
470 auto showHiddenPinsCond =
476 auto showHiddenFieldsCond =
483 auto showERCErrorsCond =
490 auto showERCWarningsCond =
497 auto showERCExclusionsCond =
504 auto showOPVoltagesCond =
511 auto showOPCurrentsCond =
518 auto showAnnotateAutomaticallyCond =
525 auto remapSymbolsCondition =
534 auto belowRootSheetCondition =
540 auto navHistoryHasForward =
546 auto navHistoryHasBackward =
552 auto navSchematicHasPreviousSheet =
558 auto navSchematicHasNextSheet =
582#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
636 std::unique_ptr<SCH_ITEM> repeatItem(
static_cast<SCH_ITEM*
>( aItem->
Clone() ) );
639 repeatItem->ClearFlags();
734 for( std::pair<const wxString, LIB_SYMBOL*>& libSymbol : screen->
GetLibSymbols() )
736 wxCHECK2( libSymbol.second,
continue );
737 libSymbol.second->ClearCaches();
740 if(
Schematic().Settings().m_IntersheetRefsShow )
760 &&
Schematic().GetSheets().IsModified() )
769 if( symbolEditor && !symbolEditor->Close() )
774 if( symbolViewer && !symbolViewer->Close() )
779 if( symbolViewer && !symbolViewer->Close() )
786 if( symbolEditor && symbolEditor->IsSymbolFromSchematic() )
788 if( !symbolEditor->CanCloseSymbolFromSchematic(
true ) )
805 wxString msg =
_(
"Save changes to '%s' before closing?" );
810 return SaveProject();
822 open_dlg->Close(
true );
848 if( hierarchy_pane.IsShown() && hierarchy_pane.IsFloating() )
850 hierarchy_pane.Show(
false );
864 if( fn.IsFileWritable() )
865 wxRemoveFile( fn.GetFullPath() );
871 if( autoSaveFileName.IsFileWritable() )
872 wxRemoveFile( autoSaveFileName.GetFullPath() );
905 for(
unsigned i = 0; i < sheetList.size(); i++ )
958 if( !GetTitle().StartsWith( wxS(
"*" ) ) )
967 DisplayError(
this,
_(
"Cannot update the PCB, because the Schematic Editor is opened"
968 " in stand-alone mode. In order to create/update PCBs from"
969 " schematics, launch the KiCad shell and create a project." ) );
990 if( !frame->IsVisible() )
994 if( frame->IsIconized() )
995 frame->Iconize(
false );
1019 wxString findString;
1023 if( selection.
Size() == 1 )
1027 switch( front->
Type() )
1030 findString =
static_cast<SCH_SYMBOL*
>( front )->GetValueFieldText(
true );
1034 findString =
static_cast<SCH_FIELD*
>( front )->GetShownText();
1041 findString =
static_cast<SCH_LABEL_BASE*
>( front )->GetShownText();
1045 findString =
static_cast<SCH_TEXT*
>( front )->GetShownText();
1047 if( findString.Contains( wxT(
"\n" ) ) )
1048 findString = findString.Before(
'\n' );
1062 wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 );
1117 wxFileDialog dlg(
this,
_(
"New Schematic" ), pro_dir, wxEmptyString,
1120 if( dlg.ShowModal() != wxID_CANCEL )
1123 wxFileName create_me = dlg.GetPath();
1126 if( create_me.FileExists() )
1129 msg.Printf(
_(
"Schematic file '%s' already exists." ), create_me.GetFullName() );
1135 wxASSERT_MSG( create_me.IsAbsolute(), wxS(
"wxFileDialog returned non-absolute path" ) );
1150 wxFileDialog dlg(
this,
_(
"Open Schematic" ), pro_dir, wxEmptyString,
1151 wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1153 if( dlg.ShowModal() != wxID_CANCEL )
1165 if( kicad_board.IsOk() && !
Schematic().GetFileName().IsEmpty() )
1168 wxFileName legacy_board( kicad_board );
1170 wxFileName& boardfn = legacy_board;
1172 if( !legacy_board.FileExists() || kicad_board.FileExists() )
1173 boardfn = kicad_board;
1175 if(
Kiface().IsSingle() )
1192 frame->
OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
1195 if( !frame->IsVisible() )
1196 frame->Show(
true );
1199 if( frame->IsIconized() )
1200 frame->Iconize(
false );
1208 wxASSERT(
Kiface().IsSingle() );
1219 if( !
ReadyToNetlist(
_(
"Assigning footprints requires a fully annotated schematic." ) ) )
1235 player->Show(
true );
1251 if( event.GetId() == wxID_EXIT )
1254 if( event.GetId() == wxID_CLOSE ||
Kiface().IsSingle() )
1263 const wxBrush& brush =
1265 aSettings->
GetPrintDC()->SetBackground( brush );
1268 aSettings->
GetPrintDC()->SetLogicalFunction( wxCOPY );
1293 item->RunOnChildren(
1300 text->ClearRenderCache();
1301 text->ClearBoundingBoxCache();
1302 flags |= KIGFX::GEOMETRY | KIGFX::REPAINT;
1310 text->ClearRenderCache();
1311 text->ClearBoundingBoxCache();
1341 if( !
pin->GetOperatingPoint().IsEmpty() )
1344 pin->SetOperatingPoint( wxEmptyString );
1347 if( pins.size() == 2 )
1352 if( !op.IsEmpty() && op != wxS(
"--" ) && op != wxS(
"?" ) )
1354 pins[0]->SetOperatingPoint( op );
1366 for(
const auto& modelPin : model.
GetPins() )
1368 SCH_PIN* symbolPin = symbol->
GetPin( modelPin.get().symbolPinNumber );
1369 wxString signalName = ref + wxS(
":" ) + modelPin.get().name;
1374 if( symbolPin && !op.IsEmpty() && op != wxS(
"--" ) && op != wxS(
"?" ) )
1389 if( !op.IsEmpty() && op != wxS(
"--" ) && op != wxS(
"?" ) )
1394 double length = 0.0;
1396 for(
SCH_ITEM* item : subgraph->GetItems() )
1398 if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T } ) )
1423 if( aItem->
IsType( { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T } ) )
1426 if( label->AutoRotateOnPlacement() )
1429 label->GetPosition(), label->GetTextSpinStyle(), &
GetCurrentSheet() );
1430 if( textSpin != label->GetTextSpinStyle() )
1432 label->SetTextSpinStyle( textSpin );
1436 if( otherLabel != label && otherLabel->
GetText() == label->GetText() )
1450 wxCHECK_RET( aItem !=
nullptr, wxT(
"Cannot add null item to list." ) );
1461 wxT(
"Cannot place sheet pin in invalid schematic sheet." ) );
1463 undoItem = parentSheet;
1471 wxT(
"Cannot place field in invalid schematic symbol." ) );
1473 undoItem = parentSymbol;
1476 if( aItem->
IsNew() )
1489 wxLogMessage( wxT(
"addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
1514 bool connected =
true;
1515 for(
auto i = pts.begin(); i != pts.end(); i++ )
1517 for(
auto j = i + 1; j != pts.end(); j++ )
1554 bool readOnly =
false;
1555 bool unsaved =
false;
1565 title += fn.GetName();
1569 if( sheetPath != title )
1573 title += wxS(
" " ) +
_(
"[Read Only]" );
1576 title += wxS(
" " ) +
_(
"[Unsaved]" );
1580 title =
_(
"[no schematic loaded]" );
1583 title += wxT(
" \u2014 " ) +
_(
"Schematic Editor" );
1599 SCH_ITEM* highlightedItem =
nullptr;
1627 wxLogTrace(
"CONN_PROFILE",
"SchematicCleanUp() %0.4f ms", timer.
msecs() );
1633 std::function<void(
SCH_ITEM* )> changeHandler =
1634 [&](
SCH_ITEM* aChangedItem ) ->
void
1663 text->ClearRenderCache();
1664 text->ClearBoundingBoxCache();
1673 text->ClearRenderCache();
1674 text->ClearBoundingBoxCache();
1685 if( highlightedItem )
1695 field.ClearBoundingBoxCache();
1698 GetCanvas()->GetView()->Update( label );
1742 item->ClearCaches();
1744 for( std::pair<const wxString, LIB_SYMBOL*>& libSymbol : screen->
GetLibSymbols() )
1745 libSymbol.second->ClearCaches();
1786#if defined( __WXMSW__ )
1801 SetStatusText( wxT(
"" ) );
1823 if( aIncludeAllVisible )
1839 if( item != dsAsItem )
1840 bBoxDoc.
Merge( item->GetBoundingBox() );
1869 if( lastItem && lastItem != aItem )
1874 lastBrightenedItemID =
niluuid;
1884 lastBrightenedItemID = aItem->
m_Uuid;
1920 const KIID& aSchematicSymbolUUID )
1922 bool appendToUndo =
false;
1928 if( !principalSymbol )
1931 wxString principalRef;
1933 if( principalSymbol->
IsAnnotated( &principalPath ) )
1934 principalRef = principalSymbol->
GetRef( &principalPath,
false );
1936 std::vector< std::pair<SCH_SYMBOL*, SCH_SHEET_PATH> > otherUnits;
1944 if( candidateSymbol == principalSymbol
1946 && candidateSymbol->
GetRef( &
path,
false ) == principalRef ) )
1948 otherUnits.emplace_back( candidateSymbol,
path );
1953 for(
auto& [ otherUnit,
path ] : otherUnits )
1957 path.LastScreen()->Remove( otherUnit );
1959 if( !otherUnit->IsNew() )
1962 appendToUndo =
true;
1965 otherUnit->SetLibSymbol( aSymbol.
Flatten().release() );
1973 path.LastScreen()->Append( otherUnit );
1987 sch_item->ClearCaches();
2021 item->SetForceVisible(
true );
2024 else if( item->IsBrightened() )
2026 item->SetForceVisible(
false );
2035 item->RunOnChildren(
constexpr EDA_IU_SCALE schIUScale
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
static TOOL_ACTION toggleGrid
static TOOL_ACTION cancelInteractive
static TOOL_ACTION millimetersUnits
static TOOL_ACTION updateFind
static TOOL_ACTION pasteSpecial
static TOOL_ACTION milsUnits
static TOOL_ACTION toggleBoundingBoxes
static TOOL_ACTION duplicate
static TOOL_ACTION inchesUnits
static TOOL_ACTION toggleCursorStyle
static TOOL_ACTION doDelete
static TOOL_ACTION selectionTool
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION deleteTool
static TOOL_ACTION zoomTool
static TOOL_ACTION selectAll
Manage TOOL_ACTION objects.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
Handles how to draw a screen (a board, a schematic ...)
void SetPageNumber(const wxString &aPageNumber)
void SetContentModified(bool aModified=true)
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Handle actions that are shared between different applications.
const NET_MAP & GetNetMap() const
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr)
Updates the connection graph for the given list of sheets.
A subgraph is a set of items that are electrically connected on a single sheet.
wxArrayString GetFindEntries() const
wxArrayString GetReplaceEntries() const
void SetReplaceEntries(const wxArrayString &aEntries)
void SetFindEntries(const wxArrayString &aEntries, const wxString &aFindString)
bool Show(bool show) override
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
SETTINGS_MANAGER * GetSettingsManager() const
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
void ClearFileHistory(FILE_HISTORY *aFileHistory=nullptr)
Removes all files from the file history.
virtual void OnDropFiles(wxDropFilesEvent &aEvent)
Handles event fired when a file is dropped to the window.
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetches the file name from the file history list.
static wxString GetAutoSaveFilePrefix()
wxArrayString m_replaceStringHistoryList
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
virtual void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
void FocusOnLocation(const VECTOR2I &aPos)
Useful to focus on a particular location, in find functions.
virtual void SetScreen(BASE_SCREEN *aScreen)
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
virtual void UpdateMsgPanel()
Redraw the message panel.
void OnGridSettings(wxCommandEvent &event)
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, const std::map< wxString, wxString > *aProperties, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Prints the drawing-sheet (frame and title block).
wxArrayString m_findStringHistoryList
std::unique_ptr< EDA_SEARCH_DATA > m_findReplaceData
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
A base class for most all the KiCad significant classes used in schematics and boards.
virtual const VECTOR2I GetFocusPosition() const
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
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
Specialization of the wxAuiPaneInfo class for KiCad panels.
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual void ClearBoundingBoxCache()
SELECTION_CONDITION BoundingBoxes()
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
SELECTION_CONDITION UndoAvailable()
Create a functor that tests if there are any items in the undo queue.
SELECTION_CONDITION ScriptingConsoleVisible()
Create a functor testing if the python scripting console window is visible.
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
PANEL_ANNOTATE m_AnnotatePanel
Gather all the actions that are shared by tools.
static TOOL_ACTION mirrorV
static TOOL_ACTION remapSymbols
static TOOL_ACTION selectionActivate
Activation of the selection tool.
static TOOL_ACTION toggleAnnotateAuto
static TOOL_ACTION lineMode90
static TOOL_ACTION toggleHiddenPins
static TOOL_ACTION navigateForward
static TOOL_ACTION placeSymbol
static TOOL_ACTION clearSelection
Clears the current selection.
static TOOL_ACTION navigateBack
static TOOL_ACTION showPythonConsole
static TOOL_ACTION toggleERCWarnings
static TOOL_ACTION toggleERCExclusions
static TOOL_ACTION placeClassLabel
static TOOL_ACTION drawWire
static TOOL_ACTION drawCircle
static TOOL_ACTION rotateCCW
static TOOL_ACTION lineModeFree
static TOOL_ACTION drawBus
static TOOL_ACTION toggleERCErrors
static TOOL_ACTION placePower
static TOOL_ACTION drawLines
static TOOL_ACTION toggleOPCurrents
static TOOL_ACTION mirrorH
static TOOL_ACTION highlightNetTool
static TOOL_ACTION rotateCW
static TOOL_ACTION importSheetPin
static TOOL_ACTION leaveSheet
static TOOL_ACTION toggleHiddenFields
static TOOL_ACTION placeGlobalLabel
static TOOL_ACTION ddAppendFile
static TOOL_ACTION placeHierLabel
static TOOL_ACTION drawTextBox
static TOOL_ACTION drawRectangle
static TOOL_ACTION placeImage
static TOOL_ACTION showHierarchy
static TOOL_ACTION placeSchematicText
static TOOL_ACTION toggleOPVoltages
static TOOL_ACTION drawArc
static TOOL_ACTION lineMode45
static TOOL_ACTION drawSheet
static TOOL_ACTION navigateNext
static TOOL_ACTION navigateUp
static TOOL_ACTION placeLabel
static TOOL_ACTION placeBusWireEntry
static TOOL_ACTION placeJunction
static TOOL_ACTION navigatePrevious
static TOOL_ACTION placeNoConnect
Tool that displays edit points allowing to modify items by dragging the points.
EE_TYPE OfType(KICAD_T aType) const
Container for ERC settings.
SEVERITY GetSeverity(int aErrorCode) const
std::set< wxString > m_ErcExclusions
void UpdateHierarchySelection()
Updates the tree's selection to match current page.
void UpdateHierarchyTree()
Update the hierarchical tree of the schematic.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
APP_SETTINGS_BASE * KifaceSettings() const
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void SetDefaultFont(const wxString &aFont)
wxDC * GetPrintDC() const
Contains methods for drawing schematic-specific items.
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 }) override
Set the scaling factor, zooming around a given anchor point.
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.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
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.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Open a project or set of files given by aFileList.
void OnSockRequestServer(wxSocketEvent &evt)
void OnSockRequest(wxSocketEvent &evt)
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
virtual bool PlayerClose(FRAME_T aFrameType, bool doForce)
Call the KIWAY_PLAYER::Close( bool force ) function on the window and if not vetoed,...
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Define a library symbol object.
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
A small class to help profiling.
void Stop()
Save the time when this function was called, and set the counter stane to stop.
double msecs(bool aSinceLast=false)
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
These settings were stored in SCH_BASE_FRAME previously.
TEMPLATES m_TemplateFieldNames
bool m_IntersheetRefsShow
Holds all the data relating to one schematic.
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
CONNECTION_GRAPH * m_connectionGraph
Holds and calculates connectivity information of this schematic.
SCH_SHEET_PATH & CurrentSheet() const override
wxString GetOperatingPoint(const wxString &aNetName, int aPrecision, const wxString &aRange)
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
SCHEMATIC_SETTINGS & Settings() const
CONNECTION_GRAPH * ConnectionGraph() const override
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
void SetProject(PROJECT *aPrj)
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
void RecomputeIntersheetRefs(const std::function< void(SCH_GLOBALLABEL *)> &aItemCallback)
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
ERC_SETTINGS & ErcSettings() const
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
EESCHEMA_SETTINGS * eeconfig() const
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
virtual void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
SCH_SHEET_PATH LocalSheet() const
SCH_ITEM * Parent() const
bool HasDriverChanged() const
void ClearDriverChanged()
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void DisplaySheet(SCH_SCREEN *aScreen)
Group generic conditions for PCB editor states.
SELECTION_CONDITION LineMode(LINE_MODE aMode)
Create a functor that tests if the frame is in the specified line drawing mode.
Handle actions specific to the schematic editor.
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Launch a tool to highlight nets.
Schematic editor (Eeschema) main window.
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
bool IsContentModified() const override
Get if the current schematic has been modified but not saved.
void RefreshOperatingPointDisplay()
Refresh the display of any operating points.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
EDA_ITEM * GetItem(const KIID &aId) const override
Fetch an item by KIID.
const wxString & getAutoSaveFileName() const
std::vector< std::unique_ptr< SCH_ITEM > > m_items_to_repeat
For the repeat-last-item cmd.
const SCH_CONNECTION * GetHighlightedConnection() const
bool TrimWire(const VECTOR2I &aStart, const VECTOR2I &aEnd)
If any single wire passes through both points, remove the portion between the two points,...
void OnOpenCvpcb(wxCommandEvent &event)
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
void ShowAllIntersheetRefs(bool aShow)
void SaveProjectLocalSettings() override
Save changes to the project settings to the project (.pro) file.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Open a project or set of files given by aFileList.
void doCloseWindow() override
void AddItemToScreenAndUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
Add an item to the schematic and adds the changes to the undo/redo container.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool ReadyToNetlist(const wxString &aAnnotateMessage)
Check if we are ready to write a netlist file for the current schematic.
void ShowFindReplaceDialog(bool aReplace)
Run the Find or Find & Replace dialog.
void UpdateHierarchySelection()
Update the hierarchy navigation tree selection (cross-probe from schematic to hierarchy pane).
void SetScreen(BASE_SCREEN *aScreen) override
void OnFindDialogClose()
Notification that the Find dialog has closed.
void SaveSymbolToSchematic(const LIB_SYMBOL &aSymbol, const KIID &aSchematicSymbolUUID)
Update a schematic symbol from a LIB_SYMBOL.
void onSize(wxSizeEvent &aEvent)
void RecordERCExclusions()
Scan existing markers and record data from any that are Excluded.
void ShowChangedLanguage() override
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
Create a copy of the current schematic item, and put it in the undo list.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
void HardRedraw() override
Rebuild the GAL and redraw the screen.
void OnClearFileHistory(wxCommandEvent &aEvent)
bool GetShowAllPins() const override
Allow edit frame to show/hide hidden pins.
void OnAppendProject(wxCommandEvent &event)
SCHEMATIC * m_schematic
The currently loaded schematic.
void ClearFindReplaceStatus()
SCH_SHEET_PATH & GetCurrentSheet() const
void OnLoadFile(wxCommandEvent &event)
SCHEMATIC & Schematic() const
void updateTitle()
Set the main window title bar text.
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
void OnUpdatePCB(wxCommandEvent &event)
void RecomputeIntersheetRefs()
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
void sendNetlistToCvpcb()
Send the KiCad netlist over to CVPCB.
void OnOpenPcbnew(wxCommandEvent &event)
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void OnPageSettingsChange() override
Called when modifying the page settings.
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
void initScreenZoom()
Initialize the zoom value of the current screen and mark the screen as zoom-initialized.
void OnImportProject(wxCommandEvent &event)
static const wxString SchematicHierarchyPaneName()
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void ShowFindReplaceStatus(const wxString &aMsg, int aStatusTime)
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
void SetHighlightedConnection(const SCH_CONNECTION *aConnection)
virtual void PrintPage(const RENDER_SETTINGS *aSettings) override
Plot or print the current sheet to the clipboard.
int GetSchematicJunctionSize()
void DisplayCurrentSheet()
Draw the current sheet on the display.
void ResolveERCExclusions()
Update markers to match recorded exclusions.
~SCH_EDIT_FRAME() override
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
void UpdateNetHighlightStatus()
wxString GetScreenDesc() const override
Return a human-readable description of the current screen.
DIALOG_SCH_FIND * m_findReplaceDialog
void UpdateHierarchyNavigator()
Update the hierarchy navigation tree and history.
void AddCopyForRepeatItem(const SCH_ITEM *aItem)
void OnResizeHierarchyNavigator(wxSizeEvent &aEvent)
wxString GetCurrentFileName() const override
Get the full filename + path of the currently opened file in the frame.
SCH_JUNCTION * AddJunction(SCH_SCREEN *aScreen, const VECTOR2I &aPos, bool aAppendToUndo, bool aFinal=true)
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void OnExit(wxCommandEvent &event)
void AutoRotateItem(SCH_SCREEN *aScreen, SCH_ITEM *aItem)
Automatically set the rotation of an item (if the item supports it)
HIERARCHY_PANE * m_hierarchy
SEVERITY GetSeverity(int aErrorCode) const override
void FocusOnItem(SCH_ITEM *aItem)
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual bool IsConnectable() const
SCH_ITEM_SET & ConnectedItems(const SCH_SHEET_PATH &aPath)
Retrieve the set of items connected to this item on the given sheet.
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
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.
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
std::vector< SCH_FIELD > & GetFields()
Segment description base class to describe items which have 2 end points (track, wire,...
void SetOperatingPoint(const wxString &aText)
const wxString & GetOperatingPoint() const
wxString Serialize() const
void SetOperatingPoint(const wxString &aText)
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
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)
std::map< wxString, LIB_SYMBOL * > & GetLibSymbols()
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
void Print(const RENDER_SETTINGS *aSettings)
Print all the items in the screen to aDC.
const wxString & GetFileName() const
const KIID & GetUuid() const
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
bool IsExplicitJunctionNeeded(const VECTOR2I &aPosition) const
Indicates that a junction dot is necessary at the given location, and does not yet exist.
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
TEXT_SPIN_STYLE GetLabelOrientationForPoint(const VECTOR2I &aPosition, TEXT_SPIN_STYLE aDefaultOrientation, const SCH_SHEET_PATH *aSheet) const
bool CheckIfOnDrawList(const SCH_ITEM *aItem) const
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) const
Fetch a SCH_ITEM by ID.
bool IsModified() const
Check the entire hierarchy for any modifications.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false) const
Return the sheet path in a human readable form made from the sheet names.
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SCREEN * LastScreen()
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
void clear()
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.
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
bool IsAnnotated(const SCH_SHEET_PATH *aSheet)
Check if the symbol has a valid annotation (reference) for the given sheet path.
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
int Size() const
Returns the number of selected parts.
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< LIB_PIN * > &aPins)
std::vector< std::reference_wrapper< const PIN > > GetPins() const
const SPICE_GENERATOR & SpiceGenerator() const
virtual std::string ItemName(const SPICE_ITEM &aItem) const
The symbol library editor main window.
Symbol library viewer main window.
void AddTemplateFieldNames(const wxString &aSerializedFieldNames)
Add a serialized list of template field names.
void DeleteAllFieldNameTemplates(bool aGlobal)
Delete the entire contents.
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
This file is part of the common library.
#define DIALOG_ERC_WINDOW_NAME
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define SCH_EDIT_FRAME_NAME
#define IS_NEW
New item, just created.
@ ID_IMPORT_NON_KICAD_SCH
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
const wxString PCBNEW_EXE
@ FRAME_SCH_SYMBOL_EDITOR
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback)
Call the executable file aEditorName with the parameter aFileName.
const std::string LegacyPcbFileExtension
const std::string NetlistFileExtension
const std::string KiCadSchematicFileExtension
wxString KiCadSchematicFileWildcard()
wxString LegacySchematicFileWildcard()
wxString AllSchematicFilesWildcard()
@ ID_EDA_SOCKET_EVENT_SERV
void ignore_unused(const T &)
#define KICTL_CREATE
caller thinks requested project files may not exist.
@ LAYER_SCHEMATIC_BACKGROUND
EESCHEMA_SETTINGS * eeconfig()
@ REPAINT
Item needs to be redrawn.
@ GEOMETRY
Position or shape has changed.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
#define CURRENT_TOOL(action)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
int hierarchy_panel_docked_width
int hierarchy_panel_float_width
int hierarchy_panel_float_height
bool schematic_hierarchy_float
bool show_schematic_hierarchy
Definition for symbol library class.
Definition of file extensions used in Kicad.
void SetAuiPaneSize(wxAuiManager &aManager, wxAuiPaneInfo &aPane, int aWidth, int aHeight)
Sets the size of an AUI pane, working around http://trac.wxwidgets.org/ticket/13180.