67#include <wx/srchctrl.h>
68#include <wx/tokenzr.h>
70#include <wx/hyperlink.h>
74using namespace std::placeholders;
79#define PREVIOUS_PART 2
116 m_aboutTitle =
_HKI(
"KiCad Footprint Library Browser" );
121 m_magneticItems.graphics =
true;
133 m_libListWidth = 200;
136 wxPanel* libPanel =
new wxPanel(
this );
137 wxSizer* libSizer =
new wxBoxSizer( wxVERTICAL );
140 wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
141 m_libFilter->SetDescriptiveText(
_(
"Filter" ) );
142 libSizer->Add( m_libFilter, 0, wxEXPAND, 5 );
145 0,
nullptr, wxLB_HSCROLL | wxNO_BORDER );
146 libSizer->Add( m_libList, 1, wxEXPAND, 5 );
148 libPanel->SetSizer( libSizer );
151 wxPanel* fpPanel =
new wxPanel(
this );
152 wxSizer* fpSizer =
new wxBoxSizer( wxVERTICAL );
155 wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
156 m_fpFilter->SetDescriptiveText(
_(
"Filter" ) );
157 m_fpFilter->SetToolTip(
158 _(
"Filter on footprint name, keywords, description and pad count.\n"
159 "Search terms are separated by spaces. All search terms must match.\n"
160 "A term which is a number will also match against the pad count." ) );
161 fpSizer->Add( m_fpFilter, 0, wxEXPAND, 5 );
166 m_libFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT(
"qb" ) ).y + 10 ) );
167 m_fpFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT(
"qb" ) ).y + 10 ) );
171 0,
nullptr, wxLB_HSCROLL | wxNO_BORDER );
173 m_fpList->Connect( wxEVT_LEFT_DCLICK,
176 fpSizer->Add( m_fpList, 1, wxEXPAND, 5 );
178 fpPanel->SetSizer( fpSizer );
182 m_canvasType = loadCanvasTypeSetting();
185 GetGalDisplayOptions(), m_canvasType );
186 SetCanvas( drawPanel );
188 SetBoard(
new BOARD() );
204 SetScreen(
new PCB_SCREEN( GetPageSizeIU() ) );
206 GetScreen()->m_Center =
true;
208 GetGalDisplayOptions().m_axesEnabled =
true;
223 m_toolManager->RegisterTool(
new ZOOM_TOOL );
228 m_toolManager->InitTools();
229 m_toolManager->InvokeTool(
"pcbnew.InteractiveSelection" );
235 ReCreateOptToolbar();
237 ReCreateLibraryList();
244 if( getCurNickname().size() && getCurFootprintName().size() )
249 id.SetLibItemName( getCurFootprintName() );
251 FOOTPRINT* footprint = loadFootprint(
id );
256 setFPWatcher( footprint );
262 m_auimgr.SetManagedWindow(
this );
265 m_auimgr.AddPane( m_mainToolBar,
EDA_PANE().VToolbar().Name(
"MainToolbar" ).Top().Layer(6) );
266 m_auimgr.AddPane( m_optionsToolBar,
EDA_PANE().VToolbar().Name(
"OptToolbar" ).
Left().Layer(3) );
267 m_auimgr.AddPane( m_messagePanel,
EDA_PANE().Messages().Name(
"MsgPanel" ).Bottom().Layer(6) );
270 m_auimgr.AddPane( libPanel,
EDA_PANE().Palette().Name(
"Libraries" ).
Left().Layer(2)
271 .CaptionVisible(
false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
272 m_auimgr.AddPane( fpPanel,
EDA_PANE().Palette().Name(
"Footprints" ).
Left().Layer(1)
273 .CaptionVisible(
false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
275 m_auimgr.AddPane( GetCanvas(),
EDA_PANE().Canvas().Name(
"DrawFrame" ).
Center() );
280 if( m_libListWidth > 0 )
281 SetAuiPaneSize( m_auimgr, m_auimgr.GetPane(
"Libraries" ), m_libListWidth, -1 );
283 if( m_fpListWidth > 0 )
284 SetAuiPaneSize( m_auimgr, m_auimgr.GetPane(
"Footprints" ), m_fpListWidth, -1 );
287 GetCanvas()->SetCanFocus(
false );
288 GetCanvas()->GetGAL()->SetAxesEnabled(
true );
299 toolOpt->SetState( wxAUI_BUTTON_STATE_CHECKED );
301 toolOpt->SetState( 0 );
306 ReCreateFootprintList();
321 GetCanvas()->SetEvtHandlerEnabled(
false );
322 m_fpList->Disconnect( wxEVT_LEFT_DCLICK,
341 std::vector<MSG_PANEL_ITEM> msgItems;
342 fp->GetMsgPanelInfo(
this, msgItems );
357#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
358#define CHECK( x ) ACTION_CONDITIONS().Check( x )
414 std::vector<wxString> pinnedMatches;
415 std::vector<wxString> otherMatches;
418 [&](
const wxString& aNickname )
423 pinnedMatches.push_back( aNickname );
427 otherMatches.push_back( aNickname );
433 for(
const wxString& nickname : nicknames )
438 wxStringTokenizer tokenizer(
m_libFilter->GetValue() );
440 while( tokenizer.HasMoreTokens() )
442 const wxString term = tokenizer.GetNextToken().Lower();
445 for(
const wxString& nickname : nicknames )
447 if( matcher.
Find( nickname.Lower() ) )
453 for(
const wxString& nickname : pinnedMatches )
456 for(
const wxString& nickname : otherMatches )
462 if( index == wxNOT_FOUND )
467 wxCommandEvent
dummy;
479 wxCommandEvent
dummy;
500 if( fp_info_list->GetErrorCount() )
502 fp_info_list->DisplayErrors(
this );
506 if( fp_info_list->GetList().empty() )
510 std::set<wxString> excludes;
514 wxStringTokenizer tokenizer(
m_fpFilter->GetValue() );
516 while( tokenizer.HasMoreTokens() )
518 const wxString filterTerm = tokenizer.GetNextToken().Lower();
521 for(
const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
523 std::vector<SEARCH_TERM> searchTerms = footprint->GetSearchTerms();
524 int matched = matcher.
ScoreTerms( searchTerms );
526 if( filterTerm.IsNumber() && wxAtoi( filterTerm ) == (
int)footprint->
GetPadCount() )
530 excludes.insert( footprint->GetFootprintName() );
535 for(
const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
537 if( !excludes.count( footprint->GetFootprintName() ) )
538 m_fpList->Append( footprint->GetFootprintName() );
543 if( index == wxNOT_FOUND )
550 wxCommandEvent
dummy;
560 m_fpList->SetSelection( index,
true );
588 if( aEvent.GetKeyCode() == WXK_UP )
595 else if( aEvent.GetKeyCode() == WXK_DOWN )
602 else if( aEvent.GetKeyCode() == WXK_TAB &&
m_libFilter->HasFocus() )
604 if( !aEvent.ShiftDown() )
609 else if( aEvent.GetKeyCode() == WXK_TAB &&
m_fpFilter->HasFocus() )
611 if( aEvent.ShiftDown() )
616 else if( ( aEvent.GetKeyCode() == WXK_RETURN || aEvent.GetKeyCode() == WXK_NUMPAD_ENTER )
619 wxCommandEvent
dummy;
631 int prev = aListBox->GetSelection() - 1;
635 aListBox->SetSelection( prev );
636 aListBox->EnsureVisible( prev );
638 wxCommandEvent
dummy;
650 int next = aListBox->GetSelection() + 1;
652 if(
next < (
int)aListBox->GetCount() )
654 aListBox->SetSelection(
next );
655 aListBox->EnsureVisible(
next );
657 wxCommandEvent
dummy;
720 pad->SetNet( netinfo );
737 if(
GetBoard()->GetFirstFootprint() )
742 if( pcbframe ==
nullptr )
752 DisplayError(
this,
_(
"Previous footprint placement still in progress." ) );
758 if( blocking_dialog )
759 blocking_dialog->Close(
true );
776 pad->SetNetCode( 0 );
787 commit.
Add( newFootprint );
793 commit.
Push(
_(
"Insert Footprint" ) );
856 wxCHECK_MSG( cfg,
nullptr, wxT(
"config not existing" ) );
879 if( aEnvVarsChanged )
910 if( event.GetActive() )
916 if( libNicknames.size() !=
m_libList->GetCount() )
920 for(
unsigned ii = 0; ii < libNicknames.size(); ii++ )
943 aEvent.Enable(
GetBoard()->GetFirstFootprint() !=
nullptr );
991 switch( event.GetId() )
1002 wxString
id = wxString::Format( wxT(
"%i" ), event.GetId() );
1003 wxFAIL_MSG( wxT(
"FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList error: id = " ) +
id );
1023 title =
_(
"[no library selected]" );
1028 title =
_(
"[no library selected]" );
1031 title += wxT(
" \u2014 " ) +
_(
"Footprint Library Browser" );
1046 if( selection != wxNOT_FOUND && selection < (
int)
m_fpList->GetCount() - 1 )
1052 if( selection != wxNOT_FOUND && selection > 0 )
1056 if( selection != wxNOT_FOUND )
1058 m_fpList->SetSelection( selection );
1059 m_fpList->EnsureVisible( selection );
1065 selectionTool->ClearSelection(
true );
1098 if( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED )
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 millimetersUnits
static TOOL_ACTION milsUnits
static TOOL_ACTION toggleBoundingBoxes
static TOOL_ACTION centerContents
static TOOL_ACTION inchesUnits
static TOOL_ACTION toggleCursorStyle
static TOOL_ACTION measureTool
static TOOL_ACTION selectionTool
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION zoomTool
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
Revert the commit by restoring the modified items state.
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.
Information pertinent to a Pcbnew printed circuit board.
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)
Notify observers that aItem has been added.
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
const COMPONENT_NET & GetNet(unsigned aIndex) const
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
int ScoreTerms(std::vector< SEARCH_TERM > &aWeightedTerms)
bool Find(const wxString &aTerm, int &aMatchersTriggered, int &aPosition)
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.
ACTION_TOOLBAR * m_mainToolBar
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 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.
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
FOOTPRINT * FootprintLoad(const wxString &aNickname, const wxString &aFootprintName, bool aKeepUUID=false)
Load a footprint having aFootprintName from the library given by aNickname.
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
Fullscreen crosshair or small cross.
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.
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
MAIL_T Command()
Returns the MAIL_T associated with this mail.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
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.
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.
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
static const wxString GetPinningSymbol()
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,...
double m_FootprintViewerZoom
The last zoom level used (0 for auto)
DISPLAY_OPTIONS m_Display
bool m_FootprintViewerAutoZoomOnSelect
true to use automatic zoom on fp selection
WINDOW_SETTINGS m_FootprintViewer
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 selectionClear
Clear the current selection.
static TOOL_ACTION graphicsOutlines
Display footprint graphics as outlines.
static TOOL_ACTION textOutlines
Display texts as lines.
static TOOL_ACTION showPadNumbers
static TOOL_ACTION placeFootprint
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)
Creates (or removes) a watcher on the specified footprint.
PCBNEW_SETTINGS * GetPcbNewSettings() const
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.
void PlaceFootprint(FOOTPRINT *aFootprint, bool aRecreateRatsnest=true)
Places aFootprint at the current cursor position and updates footprint coordinates with the new posit...
PCB_DISPLAY_OPTIONS m_displayOptions
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
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 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.
virtual COMMON_SETTINGS * GetCommonSettings() const
virtual SETTINGS_MANAGER & GetSettingsManager() const
The backing store for a PROJECT, in JSON format.
static FP_LIB_TABLE * PcbFootprintLibs(PROJECT *aProject)
Return the table of footprint libraries without Kiway.
@ 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...
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
wxString GetBaseString(int n) const
int FindString(const wxString &s, bool bCase=false) const override
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message 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 IS_NEW
New item, just created.
Abstract pattern-matching tool and implementations.
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnSelectHighlightChoice EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, GERBVIEW_FRAME::OnUpdateLayerSelectBox) void GERBVIEW_FRAME
Message panel definition file.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
@ ID_ADD_FOOTPRINT_TO_BOARD
@ ID_MODVIEW_FOOTPRINT_LIST
@ ID_FPVIEWER_AUTOZOOM_TOOL
@ ID_MODVIEW_FOOTPRINT_FILTER
static PGM_BASE * process
PGM_BASE & Pgm()
The global Program "get" accessor.
KIWAY Kiway(KFCTL_STANDALONE)
std::vector< FAB_LAYER_COLOR > dummy
std::vector< wxString > pinned_fp_libs
bool m_ShowGlobalRatsnest
Stores 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.