59 #include <wx/listbox.h> 60 #include <wx/srchctrl.h> 61 #include <wx/tokenzr.h> 62 #include <wx/choice.h> 64 using namespace std::placeholders;
69 #define PREVIOUS_PART -1 102 #define PARENT_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT ) 103 #define MODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP ) 104 #define NONMODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE ) 109 PCB_BASE_FRAME( aKiway, aParent, aFrameType,
_(
"Footprint Library Browser" ),
110 wxDefaultPosition, wxDefaultSize,
138 wxPanel* libPanel =
new wxPanel(
this );
139 wxSizer* libSizer =
new wxBoxSizer( wxVERTICAL );
142 wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
147 0,
nullptr, wxLB_HSCROLL | wxNO_BORDER );
148 libSizer->Add(
m_libList, 1, wxEXPAND, 5 );
150 libPanel->SetSizer( libSizer );
153 wxPanel* fpPanel =
new wxPanel(
this );
154 wxSizer* fpSizer =
new wxBoxSizer( wxVERTICAL );
157 wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
160 _(
"Filter on footprint name, keywords, description and pad count.\n" 161 "Search terms are separated by spaces. All search terms must match.\n" 162 "A term which is a number will also match against the pad count." ) );
168 m_libFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT(
"qb" ) ).y + 10 ) );
169 m_fpFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT(
"qb" ) ).y + 10 ) );
173 0,
nullptr, wxLB_HSCROLL | wxNO_BORDER );
176 fpSizer->Add(
m_fpList, 1, wxEXPAND, 5 );
178 fpPanel->SetSizer( fpSizer );
268 .CaptionVisible(
false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
270 .CaptionVisible(
false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
308 GetCanvas()->SetEvtHandlerEnabled(
false );
328 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x ) 329 #define CHECK( x ) ACTION_CONDITIONS().Check( x ) 395 std::set<wxString> excludes;
399 wxStringTokenizer tokenizer(
m_libFilter->GetValue() );
401 while( tokenizer.HasMoreTokens() )
403 const wxString term = tokenizer.GetNextToken().Lower();
405 int matches, position;
407 for(
const wxString& nickname : nicknames )
409 if( !matcher.
Find( nickname.Lower(), matches, position ) )
410 excludes.insert( nickname );
415 for(
const wxString& nickname : nicknames )
417 if( !excludes.count( nickname ) )
424 if( index == wxNOT_FOUND )
429 wxCommandEvent
dummy;
441 wxCommandEvent
dummy;
460 fp_info_list->ReadFootprintFiles(
Prj().PcbFootprintLibs(), !nickname ?
nullptr : &nickname );
462 if( fp_info_list->GetErrorCount() )
464 fp_info_list->DisplayErrors(
this );
468 if( fp_info_list->GetList().empty() )
472 std::set<wxString> excludes;
476 wxStringTokenizer tokenizer(
m_fpFilter->GetValue() );
478 while( tokenizer.HasMoreTokens() )
480 const wxString term = tokenizer.GetNextToken().Lower();
482 int matches, position;
484 for(
const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
486 wxString search = footprint->GetFootprintName() + wxS(
" " ) + footprint->GetSearchText();
487 bool matched = matcher.
Find( search.Lower(), matches, position );
489 if( !matched && term.IsNumber() )
490 matched = ( wxAtoi( term ) == (int)footprint->GetPadCount() );
493 excludes.insert( footprint->GetFootprintName() );
498 for(
const std::unique_ptr<FOOTPRINT_INFO>& footprint : fp_info_list->GetList() )
500 if( !excludes.count( footprint->GetFootprintName() ) )
501 m_fpList->Append( footprint->GetFootprintName() );
506 if( index == wxNOT_FOUND )
513 wxCommandEvent
dummy;
523 m_fpList->SetSelection( index,
true );
551 if( aEvent.GetKeyCode() == WXK_UP )
558 else if( aEvent.GetKeyCode() == WXK_DOWN )
565 else if( aEvent.GetKeyCode() == WXK_TAB &&
m_libFilter->HasFocus() )
567 if( !aEvent.ShiftDown() )
572 else if( aEvent.GetKeyCode() == WXK_TAB &&
m_fpFilter->HasFocus() )
574 if( aEvent.ShiftDown() )
579 else if( aEvent.GetKeyCode() == WXK_RETURN &&
m_fpList->GetSelection() >= 0 )
581 wxCommandEvent
dummy;
593 int prev = aListBox->GetSelection() - 1;
597 aListBox->SetSelection( prev );
598 aListBox->EnsureVisible( prev );
600 wxCommandEvent
dummy;
612 int next = aListBox->GetSelection() + 1;
614 if(
next < (
int)aListBox->GetCount() )
616 aListBox->SetSelection(
next );
617 aListBox->EnsureVisible(
next );
619 wxCommandEvent
dummy;
717 else if(
GetBoard()->GetFirstFootprint() )
721 if( pcbframe ==
nullptr )
731 DisplayError(
this,
_(
"Previous footprint placement still in progress." ) );
750 pad->SetNetCode( 0 );
762 commit.
Add( newFootprint );
768 commit.
Push( wxT(
"Insert footprint" ) );
813 wxCHECK_MSG( cfg,
nullptr, wxT(
"config not existing" ) );
824 return Pgm().GetSettingsManager().GetColorSettings( settings->m_ColorTheme );
826 return Pgm().GetSettingsManager().GetColorSettings();
834 if( aEnvVarsChanged )
865 if( event.GetActive() )
871 if( libNicknames.size() !=
m_libList->GetCount() )
875 for(
unsigned ii = 0; ii < libNicknames.size(); ii++ )
877 if( libNicknames[ii] !=
m_libList->GetString( ii ) )
898 aEvent.Enable(
GetBoard()->GetFirstFootprint() !=
nullptr );
904 if( aFootprint && !aFootprint->IsEmpty() )
910 fpid.
Parse( *aFootprint,
true );
918 msg.sprintf(
_(
"The current configuration does not include library '%s'. Use " 919 "Manage Footprint Libraries to edit the configuration." ),
925 msg.sprintf(
_(
"Library '%s' is not enabled in the current configuration. Use " 926 "Manage Footprint Libraries to edit the configuration." ),
935 m_libList->SetStringSelection( libraryName );
967 switch( event.GetId() )
979 wxFAIL_MSG( wxT(
"FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList error: id = " ) +
id );
997 title += wxT(
" \u2014 " ) + row->
GetFullURI(
true );
1001 title =
_(
"[no library selected]" );
1004 title += wxT(
" \u2014 " ) +
_(
"Footprint Library Browser" );
1019 if( selection != wxNOT_FOUND && selection < (
int)
m_fpList->GetCount() - 1 )
1025 if( selection != wxNOT_FOUND && selection > 0 )
1029 if( selection != wxNOT_FOUND )
1031 m_fpList->SetSelection( selection );
1032 m_fpList->EnsureVisible( selection );
static TOOL_ACTION selectionClear
Clear the current selection.
virtual bool ShowModal(wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
Show this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until t...
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
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.
const UTF8 & GetLibItemName() const
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
#define FOOTPRINT_VIEWER_FRAME_NAME_MODAL
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
#define IS_NEW
New item, just created.
This file is part of the common library.
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
ACTION_TOOLBAR * m_optionsToolBar
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
virtual void SetScreen(BASE_SCREEN *aScreen)
static TOOL_ACTION zoomTool
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) 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.
SELECTION_CONDITION TextFillDisplay()
Create a functor that tests if the frame fills text items.
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
FOOTPRINT * FootprintLoad(const wxString &aNickname, const wxString &aFootprintName, bool aKeepUUID=false)
Load a footprint having aFootprintName from the library given by aNickname.
void SetFlags(EDA_ITEM_FLAGS aMask)
void resolveCanvasType()
Determines the Canvas type to load (with prompt if required) and initializes m_canvasType.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
ACTION_TOOLBAR * m_mainToolBar
Manage TOOL_ACTION objects.
double m_FootprintViewerZoom
The last zoom level used (0 for auto)
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.
The base class for create windows for drawing purpose.
bool IsValid() const
Check if this LID_ID is valid.
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...
virtual const wxString Problem() const
what was the problem?
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
SELECTION_CONDITION PadFillDisplay()
Create a functor that tests if the frame fills the pads.
virtual void SetParent(EDA_ITEM *aParent)
void PlaceFootprint(FOOTPRINT *aFootprint, bool aRecreateRatsnest=true)
Places aFootprint at the current cursor position and updates footprint coordinates with the new posit...
Abstract pattern-matching tool and implementations.
bool m_axesEnabled
Fullscreen crosshair or small cross.
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...
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
PCB_DISPLAY_OPTIONS m_displayOptions
static TOOL_ACTION measureTool
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Stores the common settings that are saved and loaded for each window / frame.
static TOOL_ACTION centerContents
FOOTPRINT * loadFootprint(const LIB_ID &aFootprintId)
Attempts to load aFootprintId from the footprint library table.
FOOTPRINT * GetFirstFootprint() const
Get 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.
virtual void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
VECTOR2< double > VECTOR2D
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
void Clear()
Remove all items from the view.
void SetClearance(int aClearance)
static TOOL_ACTION toggleGrid
bool m_Center
Center on screen.
Handle actions that are shared between different frames in PcbNew.
static TOOL_ACTION showPadNumbers
EDA_MSG_PANEL * m_messagePanel
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
static TOOL_ACTION inchesUnits
wxChoice * m_zoomSelectBox
bool Find(const wxString &aTerm, int &aMatchersTriggered, int &aPosition)
Handle actions specific to the board editor in PcbNew.
Definition of file extensions used in Kicad.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
An interface for classes handling user events controlling the view behavior such as zooming,...
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
WINDOW_SETTINGS m_FootprintViewer
virtual void SetBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr)
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
#define FOOTPRINT_VIEWER_FRAME_NAME
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Handle actions that are shared between different applications.
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.
bool IsModal() const override
Return true if the frame is shown in our modal mode and false if the frame is shown as an usual frame...
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...
static TOOL_ACTION milsUnits
void UpdateColors()
Update the color settings in the painter and GAL.
bool m_ShowGlobalRatsnest
void SetModal(bool aIsModal)
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
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...
SELECTION_CONDITION PadNumbersDisplay()
Create a functor that tests if the pad numbers are displayed.
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.
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
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 graphicsOutlines
Display footprint graphics as outlines.
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
COLOR4D GetColor(int aLayer) const
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Gather all the actions that are shared by tools.
static TOOL_ACTION placeFootprint
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
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...
SELECTION_CONDITION GraphicsFillDisplay()
Create a functor that tests if the frame fills graphics items.
bool PlacingFootprint() const
Re-entrancy checker for above.
void DismissModal(bool aRetVal, const wxString &aResult=wxEmptyString)
Information pertinent to a Pcbnew printed circuit board.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
void setupUnits(APP_SETTINGS_BASE *aCfg)
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
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...
NETCLASS * GetDefault() const
The main frame for Pcbnew.
PCBNEW_SETTINGS & Settings()
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Revert the commit by restoring the modified items state.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
Color settings are a bit different than most of the settings objects in that there can be more than o...
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
static TOOL_ACTION toggleCursorStyle
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.
Message panel definition file.
Group generic conditions for PCB editor states.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
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.
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
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.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
virtual void UpdateMsgPanel()
Redraw the message panel.
static TOOL_ACTION textOutlines
Display texts as lines.
A color representation with 4 components: red, green, blue, alpha.
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.