113 wxDefaultPosition, wxDefaultSize,
116 m_showBorderAndTitleBlock =
false;
117 m_canvasType = aBackend;
118 m_aboutTitle =
_(
"KiCad Footprint Editor" );
119 m_selLayerBox =
nullptr;
120 m_settings =
nullptr;
124 wxIconBundle icon_bundle;
127 icon_bundle.AddIcon( icon );
129 icon_bundle.AddIcon( icon );
131 icon_bundle.AddIcon( icon );
133 SetIcons( icon_bundle );
137 m_canvasType = loadCanvasTypeSetting();
139 m_canvasType = aBackend;
142 GetGalDisplayOptions(), m_canvasType );
143 SetCanvas( drawPanel );
144 SetBoard(
new BOARD() );
160 restoreLastFootprint();
171 GetGalDisplayOptions().m_axesEnabled =
true;
175 SetScreen(
new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
187 ReCreateOptToolbar();
195 LoadSettings( GetSettings() );
208 m_auimgr.SetManagedWindow(
this );
212 unsigned int auiFlags = wxAUI_MGR_DEFAULT;
213 #if !defined( _WIN32 ) 216 auiFlags |= wxAUI_MGR_LIVE_RESIZE;
218 m_auimgr.SetFlags( auiFlags );
221 m_auimgr.AddPane( m_mainToolBar,
EDA_PANE().HToolbar().Name(
"MainToolbar" )
223 m_auimgr.AddPane( m_messagePanel,
EDA_PANE().Messages().Name(
"MsgPanel" )
224 .Bottom().Layer( 6 ) );
227 m_auimgr.AddPane( m_optionsToolBar,
EDA_PANE().VToolbar().Name(
"OptToolbar" )
228 .
Left().Layer( 3 ) );
229 m_auimgr.AddPane( m_treePane,
EDA_PANE().Palette().Name(
"Footprints" )
231 .Caption(
_(
"Libraries" ) )
232 .MinSize( 250, 400 ).Resizable() );
234 m_auimgr.AddPane( m_drawToolBar,
EDA_PANE().VToolbar().Name(
"ToolsToolbar" )
237 m_auimgr.AddPane( m_appearancePanel,
EDA_PANE().Name(
"LayersManager" )
239 .Caption(
_(
"Appearance" ) ).PaneBorder(
false )
240 .MinSize( 180, -1 ).BestSize( 180, -1 ) );
241 m_auimgr.AddPane( m_selectionFilterPanel,
EDA_PANE().Palette().Name(
"SelectionFilter" )
242 .
Right().Layer( 3 ).Position( 2 )
243 .Caption(
_(
"Selection Filter" ) ).PaneBorder(
false )
244 .MinSize( 160, -1 ).BestSize( m_selectionFilterPanel->GetBestSize() ) );
247 m_auimgr.AddPane( GetCanvas(),
EDA_PANE().Canvas().Name(
"DrawFrame" )
251 m_auimgr.GetPane(
"SelectionFilter" ).dock_proportion = 0;
255 m_auimgr.GetArtProvider()->SetColour( wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR,
256 wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) );
257 m_auimgr.GetArtProvider()->SetColour( wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR,
258 wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) );
260 FinishAUIInitialization();
262 if( m_settings->m_LibWidth > 0 )
264 wxAuiPaneInfo& treePane = m_auimgr.GetPane(
"Footprints" );
268 treePane.MinSize( m_settings->m_LibWidth, -1 );
273 treePane.Resizable();
278 treePane.MinSize( 250, -1 );
288 setupUnits( GetSettings() );
382 if(
id.GetLibNickname().
empty() )
402 if(
GetBoard()->GetFirstFootprint() )
434 if( libNickname.Length() && footprintName.Length() )
438 id.SetLibItemName( footprintName );
459 msg.Printf(
_(
"Editing %s from board. Saving will update the board only." ),
484 wxFAIL_MSG(
"Plotting not supported in Footprint Editor" );
492 wxFAIL_MSG(
"Plotting not supported in Footprint Editor" );
551 return Pgm().GetSettingsManager().GetColorSettings( currentTheme );
559 wxCHECK( cfg,
nullptr );
570 bool hasGraphicalItem = footprint->
Pads().size() || footprint->
Zones().size();
572 if( !hasGraphicalItem )
579 hasGraphicalItem =
true;
584 if( hasGraphicalItem )
590 BOX2I newFootprintBB( { 0, 0 }, { 0, 0 } );
592 return newFootprintBB;
612 wxString msg =
_(
"Save changes to \"%s\" before closing?" );
638 m_auimgr.GetPane(
"LayersManager" ).Show(
false );
639 m_auimgr.GetPane(
"SelectionFilter" ).Show(
false );
645 if( mgr->
IsProjectOpen() && wxFileName::IsDirWritable(
Prj().GetProjectPath() ) )
668 aEvent.Enable(
GetBoard()->GetFirstFootprint() !=
NULL );
685 bool canInsert = frame && editorFootprint && editorFootprint->
GetLink() ==
niluuid;
688 if( frame && editorFootprint && editorFootprint->
GetLink() !=
niluuid )
696 if( editorFootprint->
GetLink() == candidate->m_Uuid )
704 aEvent.Enable( canInsert );
717 bool tree_shown = tree_pane_info.IsShown();
718 tree_pane_info.Caption(
_(
"Libraries" ) );
721 bool lm_shown = lm_pane_info.IsShown();
722 lm_pane_info.Caption(
_(
"Appearance" ) );
729 lm_pane_info.Show( lm_shown );
730 tree_pane_info.Show( tree_shown );
741 if( !GetTitle().StartsWith(
"*" ) )
751 bool writable =
true;
776 writable ?
"" :
_(
"[Read Only]" ) + wxS(
" " ) );
787 title +=
_(
"Footprint Editor" );
818 progressReporter.Show(
false );
824 auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>(
m_adapter.get() );
826 adapter->AddLibraries();
833 auto adapter = static_cast<FP_TREE_SYNCHRONIZING_ADAPTER*>(
m_adapter.get() );
842 progressReporter.Show(
false );
855 if( target.IsValid() )
857 if( adapter->FindItem( target ) )
867 target.SetLibItemName( wxEmptyString );
914 book->AddPage(
new wxPanel( book ),
_(
"Footprint Editor" ) );
978 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x ) 979 #define CHECK( x ) ACTION_CONDITIONS().Check( x ) 981 auto haveFootprintCond =
987 auto footprintTargettedCond =
1028 auto highContrastCond =
1034 auto boardFlippedCond =
1040 auto footprintTreeCond =
1057 #define CURRENT_EDIT_TOOL( action ) mgr->SetConditions( action, \ 1058 ACTION_CONDITIONS().Enable( haveFootprintCond ).Check( cond.CurrentTool( action ) ) ) 1073 #undef CURRENT_EDIT_TOOL 1102 if( aEnvVarsChanged )
1112 wxString fullFileName;
1118 wxMessageBox(
_(
"No footprint selected." ) );
1122 wxFileName fn(
id.GetLibItemName() );
1125 wxString projectPath = wxPathOnly(
Prj().GetProjectFullName() );
1127 wxFileDialog dlg(
this,
_(
"Footprint Image File Name" ), projectPath,
1128 fn.GetFullName(),
PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1130 if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() )
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
static TOOL_ACTION drawLine
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
bool IsFootprintLibWritable(const wxString &aNickname)
Return true if the library given by aNickname is writable.
show a marker on pads with no nets
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
const UTF8 & GetLibItemName() const
static TOOL_ACTION footprintProperties
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
void ForceRefresh()
Force a redraw.
class FP_TEXT, text in a footprint
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
void ActivateGalCanvas() override
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
SETTINGS_MANAGER * GetSettingsManager() const
bool SaveCanvasImageToFile(EDA_DRAW_FRAME *aFrame, const wxString &aFileName, wxBitmapType aBitmapType)
Save the current view as an image file.
SELECTION_CONDITION HasItems()
Create a functor that tests if there are items in the board.
This file is part of the common library.
static TOOL_ACTION doDelete
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
APPEARANCE_CONTROLS * m_appearancePanel
AUI panel for controlling layer and object visibility and appearance.
static TOOL_ACTION drawArc
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
static SELECTION_CONDITION MoreThan(int aNumber)
Create a functor that tests if the number of selected items is greater than the value given as parame...
FOOTPRINT_EDITOR_SETTINGS * GetFootprintEditorSettings() const
static TOOL_ACTION cleanupGraphics
static TOOL_ACTION zoomTool
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
virtual void Update3DView(bool aReloadRequest, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
SELECTION_CONDITION TextFillDisplay()
Create a functor that tests if the frame fills text items.
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(FOOTPRINT_EDIT_FRAME *aFrame, FP_LIB_TABLE *aLibs)
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION millimetersUnits
void SetCopperLayerCount(int aCount)
static TOOL_ACTION drawPolygon
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
static TOOL_ACTION mirror
Mirroring of selected items.
void AddHotKeys(TOOL_MANAGER *aToolMgr)
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
Manage TOOL_ACTION objects.
static TOOL_ACTION ungroup
A logical library item identifier and consists of various portions much like a URI.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
bool IsValid() const
Check if this LID_ID is valid.
virtual const PCB_PLOT_PARAMS & GetPlotSettings() const
Return the PCB_PLOT_PARAMS for the BOARD owned by this frame.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
static TOOL_ACTION setAnchor
static TOOL_ACTION placeText
not specified: a GAL engine must be set by the client
SELECTION_CONDITION PadFillDisplay()
Create a functor that tests if the frame fills the pads.
const char * c_str() const
bool m_axesEnabled
Fullscreen crosshair or small cross.
wxTreebook * GetTreebook()
PCB_DISPLAY_OPTIONS m_displayOptions
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
static TOOL_ACTION measureTool
void UpdateDisplayOptions()
Return a list of the layer presets created by the user.
static TOOL_ACTION toggleFootprintTree
static TOOL_ACTION rotateCw
Rotation of selected objects.
Multi-thread safe progress reporter dialog, intended for use of tasks that paralleize reporting back ...
void SetCheckboxesFromFilter(SELECTION_FILTER_OPTIONS &aOptions)
bool IsProjectOpen() const
Helper for checking if we have a project open TODO: This should be deprecated along with Prj() once w...
FOOTPRINT * loadFootprint(const LIB_ID &aFootprintId)
Attempts to load aFootprintId from the footprint library table.
FOOTPRINT * GetFirstFootprint() const
Gets the first footprint on the board or nullptr.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
LIB_TREE_NODE * GetCurrentTreeNode() const
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
void DisplayBoard(BOARD *aBoard)
Add all items from the current board to the VIEW, so they can be displayed by GAL.
void SetClearance(int aClearance)
static TOOL_ACTION toggleGrid
Handle actions that are shared between different frames in PcbNew.
static TOOL_ACTION exportFootprint
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Describe the page size and margins of a paper page on which to eventually print or plot.
static TOOL_ACTION inchesUnits
FOOTPRINTS & Footprints()
Non-active layers are shown normally (no high-contrast mode)
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit components, if the user selects the component itself rather than picking an individual...
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
void Regenerate(bool aKeepState)
Regenerate the tree.
Definition of file extensions used in Kicad.
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
#define FOOTPRINT_EDIT_FRAME_NAME
static TOOL_ACTION drawRectangle
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
const BITMAP_OPAQUE icon_modedit_32_xpm[1]
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
EDA_RECT GetBoardBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
virtual void OnSize(wxSizeEvent &event)
Recalculate the size of toolbars and display panel when the frame size changes.
#define KICAD_DEFAULT_DRAWFRAME_STYLE
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board.
Handle actions that are shared between different applications.
void RefreshLibTree()
Refreshes the tree (mainly to update highlighting and asterisking)
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Specialization of the wxAuiPaneInfo class for KiCad panels.
std::vector< LAYER_PRESET > GetUserLayerPresets() const
Update the current layer presets from those saved in the project file.
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...
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
static TOOL_ACTION milsUnits
void UpdateColors()
Update the color settings in the painter and GAL.
wxString PngFileWildcard()
const BITMAP_OPAQUE icon_modedit_xpm[1]
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
SELECTION_CONDITION ContentModified()
Create a functor that tests if the content of the frame is modified.
virtual void SetRString(RSTRING_T aStringId, const wxString &aString)
Store a "retained string", which is any session and project specific string identified in enum RSTRIN...
bool IsMirroredX() const
Return true if view is flipped across the X axis.
SELECTION_CONDITION NoActiveTool()
Create a functor testing if there are no tools active in the frame.
static TOOL_ACTION pasteSpecial
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
static TOOL_ACTION padDisplayMode
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
static TOOL_ACTION rotateCcw
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
static TOOL_ACTION drawCircle
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
virtual void OnModify()
Must be called after a change in order to set the "modify" flag of the current screen and update the ...
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
Gather all the actions that are shared by tools.
static TOOL_ACTION drawRuleArea
Tool that displays edit points allowing to modify items by dragging the points.
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
Declaration of the eda_3d_viewer class.
Common, abstract interface for edit frames.
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
SELECTION_CONDITION GraphicsFillDisplay()
Create a functor that tests if the frame fills graphics items.
static TOOL_ACTION saveAs
PANEL_SELECTION_FILTER * m_selectionFilterPanel
AUI panel for changing the selection tool filter controls.
Information pertinent to a Pcbnew printed circuit board.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
SELECTION_CONDITION UndoAvailable()
Create a functor that tests if there are any items in the undo queue.
NETCLASS * GetDefault() const
The main frame for Pcbnew.
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely saves a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
static bool empty(const wxTextEntryBase *aCtrl)
virtual void AddFootprintToBoard(FOOTPRINT *aFootprint)
Add the given footprint to the board.
wxString GetActiveLayerPreset() const
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
Color settings are a bit different than most of the settings objects in that there can be more than o...
WX_INFOBAR * GetInfoBar()
static TOOL_ACTION deleteTool
virtual const wxString GetProjectName() const
Return the short name of the project.
void OnGridSettings(wxCommandEvent &event)
static TOOL_ACTION toggleCursorStyle
static TOOL_ACTION flipBoard
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnSelectDisplayMode EVT_CHOICE(ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice) EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER
Abstract interface for BOARD_ITEMs capable of storing other items inside.
static TOOL_ACTION gridSetOrigin
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
const BITMAP_OPAQUE icon_modedit_16_xpm[1]
Group generic conditions for PCB editor states.
static constexpr int Millimeter2iu(double mm)
static TOOL_ACTION highContrastMode
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
static TOOL_ACTION selectAll
void OnLayerAlphaChanged()
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings Changes the bit-mask of ena...
void FlushAndRelease(JSON_SETTINGS *aSettings, bool aSave=true)
If the given settings object is registered, save it to disk and unregister it.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
static TOOL_ACTION duplicate
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
static TOOL_ACTION revert
static TOOL_ACTION selectionTool
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
void CenterLibId(const LIB_ID &aLibId)
Ensure that an item is visible (preferably centered).
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
virtual void UpdateMsgPanel()
Redraw the message panel.
Container for design settings for a BOARD object.
static TOOL_ACTION textOutlines
Display texts as lines.
wxString m_ColorTheme
Active color theme name.