61#include <wx/srchctrl.h>
155 wxPanel* libPanel =
new wxPanel(
this );
156 wxSizer* libSizer =
new wxBoxSizer( wxVERTICAL );
159 wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
164 0,
nullptr, wxLB_HSCROLL | wxNO_BORDER );
165 libSizer->Add(
m_libList, 1, wxEXPAND, 5 );
167 libPanel->SetSizer( libSizer );
170 wxPanel* symbolPanel =
new wxPanel(
this );
171 wxSizer* symbolSizer =
new wxBoxSizer( wxVERTICAL );
174 wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
177 _(
"Filter on symbol name, keywords, description and pin count.\n"
178 "Search terms are separated by spaces. All search terms must match.\n"
179 "A term which is a number will also match against the pin count." ) );
185 m_libFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT(
"qb" ) ).y + 10 ) );
186 m_symbolFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT(
"qb" ) ).y + 10 ) );
190 wxDefaultSize, 0,
nullptr, wxLB_HSCROLL | wxNO_BORDER );
193 symbolPanel->SetSizer( symbolSizer );
211 m_auimgr.AddPane( libPanel,
EDA_PANE().Palette().Name(
"Libraries" ).Left().Layer(2)
212 .CaptionVisible(
false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
213 m_auimgr.AddPane( symbolPanel,
EDA_PANE().Palette().Name(
"Symbols" ).Left().Layer(1)
214 .CaptionVisible(
false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
242 bbox.
SetOrigin( -max_size_x / 2, -max_size_y / 2 );
243 bbox.
SetSize( max_size_x, max_size_y );
244 GetCanvas()->GetView()->SetBoundary( bbox );
250 if( !symbName.IsEmpty() )
308#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
309#define CHECK( x ) ACTION_CONDITIONS().Check( x )
313 auto electricalTypesShownCondition =
319 auto pinNumbersShownCondition =
325 auto haveDatasheetCond =
343 m_unit = aUnit > 0 ? aUnit : 1;
385 if( std::shared_ptr<LIB_SYMBOL> parent = symbol->
GetParent().lock() )
386 parentName = parent->GetName();
439 for(
int ii = 0; ii < unit_count; ii++ )
453 int bodyStyle_count = 1;
461 if( bodyStyle_count > 1 )
491 std::vector<wxString> pinnedMatches;
492 std::vector<wxString> otherMatches;
495 [&](
const wxString& aLib )
500 pinnedMatches.push_back( aLib );
504 otherMatches.push_back( aLib );
509 [&](
const wxString& aLib )
524 if( symbolNames.empty() )
536 for(
const auto& [nickname, description] : adapter->
GetSubLibraries( aLib ) )
538 wxString suffix = nickname.IsEmpty()
539 ? wxString( wxT(
"" ) )
540 : wxString::Format( wxT(
" - %s" ), nickname );
541 wxString
name = wxString::Format( wxT(
"%s%s" ), aLib, suffix );
554 for(
const wxString& lib : libNicknames )
559 wxStringTokenizer tokenizer(
m_libFilter->GetValue(),
" \t\r\n", wxTOKEN_STRTOK );
561 while( tokenizer.HasMoreTokens() )
563 const wxString term = tokenizer.GetNextToken().Lower();
566 for(
const wxString& lib : libNicknames )
568 if( matcher.
Find( lib.Lower() ) )
574 if( libNicknames.empty() )
577 for(
const wxString&
name : pinnedMatches )
580 for(
const wxString&
name : otherMatches )
587 if(
index != wxNOT_FOUND )
596 : wxString( wxEmptyString ) );
619 if( libName.IsEmpty() )
623 std::vector<LIB_SYMBOL*> symbols = adapter->
GetSymbols( libName );
625 std::set<wxString> excludes;
629 wxStringTokenizer tokenizer(
m_symbolFilter->GetValue(),
" \t\r\n", wxTOKEN_STRTOK );
631 while( tokenizer.HasMoreTokens() )
633 const wxString filterTerm = tokenizer.GetNextToken().Lower();
638 std::vector<SEARCH_TERM> searchTerms = symbol->GetSearchTerms();
639 int matched = matcher.
ScoreTerms( searchTerms );
641 if( filterTerm.IsNumber() && wxAtoi( filterTerm ) == (
int)symbol->GetPinCount() )
645 excludes.insert( symbol->GetName() );
655 && !subLib.IsSameAs( symbol->GetLibId().GetSubLibraryName() ) )
660 if( !excludes.count( symbol->GetName() ) )
674 bool changed =
false;
676 if(
index == wxNOT_FOUND )
706 if( !adapter->
HasLibrary( selection ) && selection.Find(
'-' ) != wxNOT_FOUND )
710 selection = selection.BeforeLast(
'-', &sublib ).Trim();
711 sublib.Trim(
false );
722 const wxString& aSubLibName )
725 && wxString(
m_currentSymbol.GetSubLibraryName().wx_str() ) == aSubLibName )
812 int maxWidth = cfg->m_LibViewPanel.window.state.size_x - 80;
839 cfg->m_LibViewPanel.show_pin_electrical_type = renderSettings->m_ShowPinsElectricalType;
840 cfg->m_LibViewPanel.show_pin_numbers = renderSettings->m_ShowPinNumbers;
849 return &cfg->m_LibViewPanel.window;
851 wxFAIL_MSG( wxT(
"SYMBOL_VIEWER not running with EESCHEMA_SETTINGS" ) );
874 if( event.GetActive() )
927 if( aEvent.GetKeyCode() == WXK_UP )
931 int prev =
m_libList->GetSelection() - 1;
938 wxCommandEvent
dummy;
944 wxCommandEvent
dummy;
948 else if( aEvent.GetKeyCode() == WXK_DOWN )
959 wxCommandEvent
dummy;
965 wxCommandEvent
dummy;
969 else if( aEvent.GetKeyCode() == WXK_TAB &&
m_libFilter->HasFocus() )
971 if( !aEvent.ShiftDown() )
976 else if( aEvent.GetKeyCode() == WXK_TAB &&
m_symbolFilter->HasFocus() )
978 if( aEvent.ShiftDown() )
983 else if( ( aEvent.GetKeyCode() == WXK_RETURN || aEvent.GetKeyCode() == WXK_NUMPAD_ENTER )
986 wxCommandEvent
dummy;
1002 if( ii != wxNOT_FOUND && ii < (
int) (
m_symbolList->GetCount() - 1 ) )
1016 if( ii != wxNOT_FOUND && ii != 0 )
1059 wxString title = row
1061 :
_(
"[no library selected]" );
1063 title += wxT(
" \u2014 " ) +
_(
"Symbol Library Browser" );
1087 wxCHECK2( symbol,
break );
1099 wxLogTrace(
traceLibWatch,
"Received refresh symbol request for %s, current symbols is %s",
1102 if( lib == libfullname )
constexpr EDA_IU_SCALE schIUScale
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 showDatasheet
static TOOL_ACTION zoomFitScreen
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.
constexpr void SetOrigin(const Vec &pos)
constexpr void SetSize(const SizeVec &size)
Handle actions that are shared between different applications.
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.
TOOLBAR_SETTINGS * m_toolbarSettings
void FinishAUIInitialization()
virtual void RecreateToolbars()
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.
ACTION_TOOLBAR * m_tbTopMain
void ReCreateMenuBar()
Recreate the menu bar.
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.
virtual void ClearMsgPanel()
Clear all messages from the message panel.
COLOR_SETTINGS * m_colorSettings
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
void setupUnits(APP_SETTINGS_BASE *aCfg)
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.
EDA_MSG_PANEL * m_messagePanel
virtual void SetScreen(BASE_SCREEN *aScreen)
void AppendMsgPanel(const wxString &aTextUpper, const wxString &aTextLower, int aPadding=6)
Append a message to the message panel.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
void SetStealsFocus(bool aStealsFocus)
Set whether focus is taken on certain events (mouseover, keys, etc).
Specialization of the wxAuiPaneInfo class for KiCad panels.
Class that groups generic conditions for editor states.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
double m_gridMinSpacing
Whether or not to draw the coordinate system axes.
bool m_axesEnabled
Crosshair drawing mode.
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
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 PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library tables.
std::optional< LIBRARY_TABLE_ROW * > GetRow(const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH) const
Like LIBRARY_MANAGER::GetRow but filtered to the LIBRARY_TABLE_TYPE of this adapter.
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) const
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.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Define a library symbol object.
const LIB_ID & GetLibId() const override
std::weak_ptr< LIB_SYMBOL > & GetParent()
SCH_FIELD & GetDatasheetField()
Return reference to the datasheet field.
wxString GetName() const override
const std::vector< wxString > & GetBodyStyleNames() const
bool HasDeMorganBodyStyles() const override
int GetBodyStyleCount() const override
int GetUnitCount() const override
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
wxString GetUnitDisplayName(int aUnit, bool aLabel) const override
Return the user-defined display name for aUnit for symbols with units.
static const wxString GetPinningSymbol()
virtual COMMON_SETTINGS * GetCommonSettings() const
The backing store for a PROJECT, in JSON format.
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
virtual PROJECT_FILE & GetProjectFile() const
Gather all the actions that are shared by tools.
static TOOL_ACTION showElectricalTypes
static TOOL_ACTION showPinNumbers
static TOOL_ACTION addSymbolToSchematic
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
SCH_BASE_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aWindowType, const wxString &aTitle, const wxPoint &aPosition, const wxSize &aSize, long aStyle, const wxString &aFrameName)
SCH_RENDER_SETTINGS * GetRenderSettings()
void doCloseWindow() override
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
void SyncView()
Mark all items for refresh.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
virtual const wxString & GetText() const override
Return the string associated with the text object.
bool m_ShowPinsElectricalType
Handle actions for the various symbol editor and viewers.
An interface to the global shared library manager that is schematic-specific and linked to one projec...
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
std::vector< wxString > GetSymbolNames(const wxString &aNickname, SYMBOL_TYPE aType=SYMBOL_TYPE::ALL_SYMBOLS)
bool SupportsSubLibraries(const wxString &aNickname) const
std::vector< SUB_LIBRARY > GetSubLibraries(const wxString &aNickname) const
std::vector< LIB_SYMBOL * > GetSymbols(const wxString &aNickname, SYMBOL_TYPE aType=SYMBOL_TYPE::ALL_SYMBOLS)
Symbol library viewer main window.
void OnLibFilter(wxCommandEvent &aEvent)
void updatePreviewSymbol()
std::unique_ptr< LIB_SYMBOL > m_previewItem
void CloseLibraryViewer(wxCommandEvent &event)
wxArrayString m_allowedLibs
void onSelectNextSymbol(wxCommandEvent &aEvent)
wxSearchCtrl * m_libFilter
void SetSelectedLibrary(const wxString &aLibName, const wxString &aSubLibName=wxEmptyString)
Set the selected library in the library window.
void ClickOnLibList(wxCommandEvent &event)
SYMBOL_VIEWER_FRAME(KIWAY *aKiway, wxWindow *aParent)
void DClickOnSymbolList(wxCommandEvent &event)
void OnActivate(wxActivateEvent &event)
Called when the frame is activated to reload the libraries and symbol lists that can be changed by th...
void OnSymFilter(wxCommandEvent &aEvent)
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void doCloseWindow() override
void SetSelectedSymbol(const wxString &aSymbolName)
Set the selected symbol.
WX_LISTBOX * m_symbolList
void KiwayMailIn(KIWAY_EXPRESS &mail) override
Receive KIWAY_EXPRESS messages from other players.
bool ReCreateLibList()
Create o recreates a sorted list of currently loaded libraries.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
void ClickOnSymbolList(wxCommandEvent &event)
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Return bounding box of document with option to not include some items.
void SetUnitAndBodyStyle(int aUnit, int aBodyStyle)
Set unit and convert, and set flag preventing them from automatically resetting to 1.
wxSearchCtrl * m_symbolFilter
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
static LIB_ID m_currentSymbol
WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg) override
Return a pointer to the window settings for this frame.
void OnCharHook(wxKeyEvent &aEvent) override
Capture the key event before it is sent to the GUI.
LIB_SYMBOL * GetSelectedSymbol() const
void onSelectSymbolUnit(wxCommandEvent &aEvent)
wxChoice * m_bodyStyleChoice
void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
void configureToolbars() override
void onSelectPreviousSymbol(wxCommandEvent &aEvent)
void updateBodyStyleChoice()
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void onSelectSymbolBodyStyle(wxCommandEvent &aEvent)
bool m_selection_changed
Updated to true if a list rewrite on GUI activation resulted in the symbol selection changing,...
bool ReCreateSymbolList()
Create or recreate the list of symbols in the currently selected library.
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
This file is part of the common library.
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define LIB_VIEW_FRAME_NAME
Abstract pattern-matching tool and implementations.
@ ID_LIBVIEW_SELECT_UNIT_NUMBER
@ ID_LIBVIEW_SELECT_BODY_STYLE
const wxChar *const traceLibWatch
Flag to enable debug output for library file watch refreshes.
@ LAYER_SCHEMATIC_GRID_AXES
Message panel definition file.
@ ALL
All except INITIAL_ADD.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
static PGM_BASE * process
PGM_BASE & Pgm()
The global program "get" accessor.
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
T * GetToolbarSettings(const wxString &aFilename)
T * GetAppSettings(const char *aFilename)
KIWAY Kiway(KFCTL_STANDALONE)
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
std::vector< wxString > pinned_symbol_libs
Store the common settings that are saved and loaded for each window / frame.
wxLogTrace helper definitions.
VECTOR2< int32_t > VECTOR2I
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.