73#include <wx/srchctrl.h>
74#include <wx/tokenzr.h>
76#include <wx/hyperlink.h>
80using namespace std::placeholders;
110 m_aboutTitle =
_HKI(
"KiCad Footprint Library Browser" );
115 m_magneticItems.graphics =
true;
127 m_libListWidth = 200;
130 wxPanel* libPanel =
new wxPanel(
this );
131 wxSizer* libSizer =
new wxBoxSizer( wxVERTICAL );
134 wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
135 m_libFilter->SetDescriptiveText(
_(
"Filter" ) );
136 libSizer->Add( m_libFilter, 0, wxEXPAND, 5 );
139 0,
nullptr, wxLB_HSCROLL | wxNO_BORDER );
140 libSizer->Add( m_libList, 1, wxEXPAND, 5 );
142 libPanel->SetSizer( libSizer );
145 wxPanel* fpPanel =
new wxPanel(
this );
146 wxSizer* fpSizer =
new wxBoxSizer( wxVERTICAL );
149 wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
150 m_fpFilter->SetDescriptiveText(
_(
"Filter" ) );
151 m_fpFilter->SetToolTip(
152 _(
"Filter on footprint name, keywords, description and pad count.\n"
153 "Search terms are separated by spaces. All search terms must match.\n"
154 "A term which is a number will also match against the pad count." ) );
155 fpSizer->Add( m_fpFilter, 0, wxEXPAND, 5 );
160 m_libFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT(
"qb" ) ).y + 10 ) );
161 m_fpFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT(
"qb" ) ).y + 10 ) );
165 0,
nullptr, wxLB_HSCROLL | wxNO_BORDER );
167 m_fpList->Connect( wxEVT_LEFT_DCLICK,
170 fpSizer->Add( m_fpList, 1, wxEXPAND, 5 );
172 fpPanel->SetSizer( fpSizer );
176 m_canvasType = loadCanvasTypeSetting();
179 GetGalDisplayOptions(), m_canvasType );
180 SetCanvas( drawPanel );
182 SetBoard(
new BOARD() );
198 SetScreen(
new PCB_SCREEN( GetPageSizeIU() ) );
200 GetScreen()->m_Center =
true;
202 GetGalDisplayOptions().m_axesEnabled =
true;
217 m_toolManager->RegisterTool(
new ZOOM_TOOL );
222 m_toolManager->InitTools();
223 m_toolManager->InvokeTool(
"common.InteractiveSelection" );
232 ReCreateLibraryList();
239 if( getCurNickname().size() && getCurFootprintName().size() )
244 id.SetLibItemName( getCurFootprintName() );
246 FOOTPRINT* footprint = loadFootprint(
id );
251 setFPWatcher( footprint );
259 m_auimgr.SetManagedWindow(
this );
262 m_auimgr.AddPane( m_tbTopMain,
EDA_PANE().VToolbar().Name(
"TopMainToolbar" ).Top().Layer(6) );
263 m_auimgr.AddPane( m_tbLeft,
EDA_PANE().VToolbar().Name(
"LeftToolbar" ).
Left().Layer(3) );
264 m_auimgr.AddPane( m_messagePanel,
EDA_PANE().Messages().Name(
"MsgPanel" ).Bottom().Layer(6) );
267 m_auimgr.AddPane( libPanel,
EDA_PANE().Palette().Name(
"Libraries" ).
Left().Layer(2)
268 .CaptionVisible(
false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
269 m_auimgr.AddPane( fpPanel,
EDA_PANE().Palette().Name(
"Footprints" ).
Left().Layer(1)
270 .CaptionVisible(
false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
272 m_auimgr.AddPane( GetCanvas(),
EDA_PANE().Canvas().Name(
"DrawFrame" ).
Center() );
277 if( m_libListWidth > 0 )
278 SetAuiPaneSize( m_auimgr, m_auimgr.GetPane(
"Libraries" ), m_libListWidth, -1 );
280 if( m_fpListWidth > 0 )
281 SetAuiPaneSize( m_auimgr, m_auimgr.GetPane(
"Footprints" ), m_fpListWidth, -1 );
284 GetCanvas()->SetCanFocus(
false );
285 GetCanvas()->GetGAL()->SetAxesEnabled(
true );
290 GetCanvas()->GetView()->SetScale( cfg->m_FootprintViewerZoom );
295 ReCreateFootprintList();
310 GetCanvas()->SetEvtHandlerEnabled(
false );
311 m_fpList->Disconnect( wxEVT_LEFT_DCLICK,
330 std::vector<MSG_PANEL_ITEM> msgItems;
331 fp->GetMsgPanelInfo(
this, msgItems );
346 auto addToBoardCond =
349 return (
GetBoard()->GetFirstFootprint() !=
nullptr );
352#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
353#define CHECK( x ) ACTION_CONDITIONS().Check( x )
411 std::vector<wxString> pinnedMatches;
412 std::vector<wxString> otherMatches;
415 [&](
const wxString& aNickname )
420 pinnedMatches.push_back( aNickname );
424 otherMatches.push_back( aNickname );
430 for(
const wxString& nickname : nicknames )
435 wxStringTokenizer tokenizer(
m_libFilter->GetValue(),
" \t\r\n", wxTOKEN_STRTOK );
437 while( tokenizer.HasMoreTokens() )
439 const wxString term = tokenizer.GetNextToken().Lower();
442 for(
const wxString& nickname : nicknames )
444 if( matcher.
Find( nickname.Lower() ) )
450 for(
const wxString& nickname : pinnedMatches )
453 for(
const wxString& nickname : otherMatches )
459 if(
index == wxNOT_FOUND )
464 wxCommandEvent
dummy;
476 wxCommandEvent
dummy;
497 std::vector<FOOTPRINT*> footprints = adapter->
GetFootprints( nickname,
true );
499 if( footprints.empty() )
502 std::set<wxString> excludes;
506 wxStringTokenizer tokenizer(
m_fpFilter->GetValue(),
" \t\r\n", wxTOKEN_STRTOK );
508 while( tokenizer.HasMoreTokens() )
510 const wxString filterTerm = tokenizer.GetNextToken().Lower();
530 if( !excludes.count( fpName ) )
534 int index = wxNOT_FOUND;
539 if(
index == wxNOT_FOUND )
546 wxCommandEvent
dummy;
559 wxCommandEvent
dummy;
587 if( aEvent.GetKeyCode() == WXK_UP )
594 else if( aEvent.GetKeyCode() == WXK_DOWN )
601 else if( aEvent.GetKeyCode() == WXK_TAB &&
m_libFilter->HasFocus() )
603 if( !aEvent.ShiftDown() )
608 else if( aEvent.GetKeyCode() == WXK_TAB &&
m_fpFilter->HasFocus() )
610 if( aEvent.ShiftDown() )
615 else if( ( aEvent.GetKeyCode() == WXK_RETURN || aEvent.GetKeyCode() == WXK_NUMPAD_ENTER )
629 int prev = aListBox->GetSelection() - 1;
633 aListBox->SetSelection( prev );
634 aListBox->EnsureVisible( prev );
636 wxCommandEvent
dummy;
648 int next = aListBox->GetSelection() + 1;
650 if(
next < (
int)aListBox->GetCount() )
652 aListBox->SetSelection(
next );
653 aListBox->EnsureVisible(
next );
655 wxCommandEvent
dummy;
718 pad->SetNet( netinfo );
736 if(
GetBoard()->GetFirstFootprint() )
740 if( pcbframe ==
nullptr )
751 DisplayError(
this,
_(
"Previous footprint placement still in progress." ) );
757 if( blocking_dialog )
758 blocking_dialog->Close(
true );
775 pad->SetNetCode( 0 );
786 commit.
Add( newFootprint );
792 commit.
Push(
_(
"Insert Footprint" ) );
822 int maxWidth = cfg->m_FootprintViewer.state.size_x - 80;
855 return &cfg->m_FootprintViewer;
857 wxFAIL_MSG( wxT(
"FOOTPRINT_CHOOSER not running with PCBNEW_SETTINGS" ) );
906 if( event.GetActive() )
912 if( libNicknames.size() !=
m_libList->GetCount() )
916 for(
unsigned ii = 0; ii < libNicknames.size(); ii++ )
918 if( libNicknames[ii] !=
m_libList->GetBaseString( ii ) )
989 title =
_(
"[no library selected]" );
993 title =
_(
"[no library selected]" );
996 title += wxT(
" \u2014 " ) +
_(
"Footprint Library Browser" );
1011 if( selection != wxNOT_FOUND && selection < (
int)
m_fpList->GetCount() - 1 )
1017 if( selection != wxNOT_FOUND && selection > 0 )
1021 if( selection != wxNOT_FOUND )
1023 m_fpList->SetSelection( selection );
1024 m_fpList->EnsureVisible( selection );
1030 selectionTool->ClearSelection(
true );
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 cursorSmallCrosshairs
static TOOL_ACTION toggleBoundingBoxes
static TOOL_ACTION centerContents
static TOOL_ACTION measureTool
static TOOL_ACTION selectionTool
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION zoomTool
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION cursor45Crosshairs
static TOOL_ACTION cursorFullCrosshairs
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...
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
wxString m_ColorTheme
Active color theme name.
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
std::shared_ptr< NET_SETTINGS > m_NetSettings
int m_SolderMaskExpansion
Handle actions specific to the board editor in PcbNew.
bool PlacingFootprint() const
Re-entrancy checker for above.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
void RemoveUnusedNets(BOARD_COMMIT *aCommit)
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
Handle actions that are shared between different applications.
Used to store the component pin name to net name (and pin function) associations stored in a netlist.
const wxString & GetPinFunction() const
virtual APP_SETTINGS_BASE * config() const
Return 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.
ACTION_TOOLBAR * m_tbTopMain
int ScoreTerms(std::vector< SEARCH_TERM > &aWeightedTerms)
bool Find(const wxString &aTerm, int &aMatchersTriggered, int &aPosition)
Look in all existing matchers, return the earliest match of any of the existing.
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
GAL_DISPLAY_OPTIONS_IMPL & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
virtual void UpdateMsgPanel()
Redraw the message panel.
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
void SetFlags(EDA_ITEM_FLAGS aMask)
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
virtual void SetParent(EDA_ITEM *aParent)
Specialization of the wxAuiPaneInfo class for KiCad panels.
SELECTION_CONDITION BoundingBoxes()
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 CursorSmallCrosshairs()
Create a functor testing if the cursor is full screen in a frame.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
SELECTION_CONDITION Cursor45Crosshairs()
SELECTION_CONDITION CursorFullCrosshairs()
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
A color representation with 4 components: red, green, blue, alpha.
bool m_axesEnabled
Crosshair drawing mode.
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
void Clear()
Remove all items from the view.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
MAIL_T Command()
Returns the MAIL_T associated with this mail.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
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.
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
std::vector< wxString > GetLibraryNames() const
Returns a list of library nicknames that are available (skips any that failed to load)
std::optional< wxString > GetFullURI(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, bool aSubstituted=false)
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
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.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
static const wxString GetPinningSymbol()
void SetClearance(int aClearance)
Handle the data for a net.
void SetNetname(const wxString &aNewName)
Set the long netname to aNetName, the short netname to the last token in the long netname's path,...
std::shared_ptr< NETCLASS > GetDefaultNetclass()
Gets the default netclass for the project.
DISPLAY_OPTIONS m_Display
FLIP_DIRECTION m_FlipDirection
int m_FootprintViewerFPListWidth
int m_FootprintViewerLibListWidth
Gather all the actions that are shared by tools.
static TOOL_ACTION padDisplayMode
static TOOL_ACTION rehatchShapes
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
static TOOL_ACTION fpAutoZoom
static TOOL_ACTION textOutlines
Display texts as lines.
static TOOL_ACTION showPadNumbers
static TOOL_ACTION placeFootprint
static TOOL_ACTION saveFpToBoard
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void setFPWatcher(FOOTPRINT *aFootprint)
Create or removes a watcher on the specified footprint.
PCBNEW_SETTINGS * GetPcbNewSettings() const
PCB_BASE_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName)
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
PCB_DISPLAY_OPTIONS m_displayOptions
void PlaceFootprint(FOOTPRINT *aFootprint, bool aRecreateRatsnest=true, std::optional< VECTOR2I > aPosition=std::nullopt)
Place aFootprint at the current cursor position (or provided one) and updates footprint coordinates w...
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
Handle actions that are shared between different frames in PcbNew.
void UpdateColors()
Update the color settings in the painter and GAL.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void DisplayBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr)
Add all items from the current board to the VIEW, so they can be displayed by GAL.
Group generic conditions for PCB editor states.
SELECTION_CONDITION PadFillDisplay()
Create a functor that tests if the frame fills the pads.
SELECTION_CONDITION GraphicsFillDisplay()
Create a functor that tests if the frame fills graphics items.
SELECTION_CONDITION FootprintViewerAutoZoom()
Create a functor that tests if the footprint viewer should auto zoom on new footprints.
SELECTION_CONDITION PadNumbersDisplay()
Create a functor that tests if the pad numbers are displayed.
SELECTION_CONDITION TextFillDisplay()
Create a functor that tests if the frame fills text items.
The main frame for Pcbnew.
bool m_FootprintViewerAutoZoomOnSelect
true to use automatic zoom on fp selection
double m_FootprintViewerZoom
The last zoom level used (0 for auto)
virtual COMMON_SETTINGS * GetCommonSettings() const
virtual LIBRARY_MANAGER & GetLibraryManager() const
The backing store for a PROJECT, in JSON format.
static FOOTPRINT_LIBRARY_ADAPTER * FootprintLibAdapter(PROJECT *aProject)
@ PCB_FOOTPRINT_VIEWER_FP_NAME
@ PCB_FOOTPRINT_VIEWER_LIB_NICKNAME
virtual PROJECT_FILE & GetProjectFile() const
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...
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
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.
Declaration of the eda_3d_viewer class.
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define FOOTPRINT_VIEWER_FRAME_NAME
#define IGNORE_PARENT_GROUP
#define IS_NEW
New item, just created.
Abstract pattern-matching tool and implementations.
Message panel definition file.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
@ ID_MODVIEW_FOOTPRINT_LIST
@ ID_MODVIEW_FOOTPRINT_FILTER
static PGM_BASE * process
PGM_BASE & Pgm()
The global program "get" accessor.
T * GetToolbarSettings(const wxString &aFilename)
T * GetAppSettings(const char *aFilename)
KIWAY Kiway(KFCTL_STANDALONE)
std::vector< FAB_LAYER_COLOR > dummy
std::vector< wxString > pinned_fp_libs
bool m_ShowGlobalRatsnest
Store the common settings that are saved and loaded for each window / frame.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
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.