54 #include <wx/listbox.h> 92 #define LIB_VIEW_NAME "ViewlibFrame" 93 #define LIB_VIEW_NAME_MODAL "ViewlibFrameModal" 95 #define LIB_VIEW_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE ) 96 #define LIB_VIEW_STYLE_MODAL ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT ) 100 const wxString& aLibraryName ) :
101 SCH_BASE_FRAME( aKiway, aParent, aFrameType,
_(
"Symbol Library Browser" ),
102 wxDefaultPosition, wxDefaultSize,
105 m_unitChoice( nullptr ),
106 m_libList( nullptr ),
107 m_symbolList( nullptr ),
108 m_previewItem( nullptr )
156 0,
nullptr, wxLB_HSCROLL | wxNO_BORDER );
159 0,
nullptr, wxLB_HSCROLL | wxNO_BORDER );
161 if( aLibraryName.empty() )
182 .Bottom().Layer( 6 ) );
185 .CaptionVisible(
false ).MinSize( 80, -1 ).BestSize(
m_libListWidth, -1 ) );
187 .CaptionVisible(
false ).MinSize( 80, -1 )
212 bbox.
SetOrigin( -max_size_x / 2, -max_size_y / 2 );
213 bbox.
SetSize( max_size_x, max_size_y );
266 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x ) 267 #define CHECK( x ) ACTION_CONDITIONS().Check( x ) 271 auto electricalTypesShownCondition =
285 auto demorganStandardCond =
288 return m_convert == LIB_ITEM::LIB_CONVERT::BASE;
291 auto demorganAlternateCond =
294 return m_convert == LIB_ITEM::LIB_CONVERT::DEMORGAN;
297 auto haveDatasheetCond =
320 m_unit = aUnit > 0 ? aUnit : 1;
321 m_convert = aConvert > 0 ? aConvert : LIB_ITEM::LIB_CONVERT::BASE;
364 parentName = parent->GetName();
379 if( aSymbol && !aSymbol->IsEmpty() )
385 libid.
Parse( *aSymbol,
true );
393 msg.Printf(
_(
"The current configuration does not include the library '%s'.\n" 394 "Use Manage Symbol Libraries to edit the configuration." ),
400 msg.Printf(
_(
"The library '%s' is not enabled in the current configuration.\n" 401 "Use Manage Symbol Libraries to edit the configuration." ),
462 for(
int ii = 0; ii < unit_count; ii++ )
484 std::vector<wxString> libs =
Prj().SchSymbolLibTable()->GetLogicalLibs();
489 for(
unsigned ii = 0; ii < libs.size(); )
492 libs.erase( libs.begin() + ii );
501 for(
unsigned ii = 0; ii < libs.size(); )
503 wxArrayString aliasNames;
505 Prj().SchSymbolLibTable()->EnumerateSymbolLib( libs[ii], aliasNames,
true );
507 if( aliasNames.IsEmpty() )
508 libs.erase( libs.begin() + ii );
517 wxArrayString libNames;
519 for(
const auto&
name : libs )
527 if( index != wxNOT_FOUND )
554 wxArrayString aliasNames;
565 if( aliasNames.IsEmpty() )
574 wxArrayString unescapedNames;
576 for(
const wxString&
name : aliasNames )
582 bool changed =
false;
584 if( index == wxNOT_FOUND )
733 auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
735 return &cfg->m_LibViewPanel.window;
746 if( aEnvVarsChanged )
753 if( event.GetActive() )
800 std::shared_ptr< LIB_SYMBOL > tmp;
833 if( !dialogLock.try_lock() )
838 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> dataPtr
841 = static_cast<SYMBOL_TREE_MODEL_ADAPTER*>( dataPtr.get() );
859 wxString dialogTitle;
860 dialogTitle.Printf(
_(
"Choose Symbol (%d items loaded)" ), modelAdapter->
GetItemCount() );
884 if( ii != wxNOT_FOUND || ii != (
int)
m_symbolList->GetCount() - 1 )
898 if( ii != wxNOT_FOUND && ii != 0 )
925 wxString title = row ? row->
GetFullURI(
true ) :
_(
"[no library selected]" );
927 title += wxT(
" \u2014 " ) +
_(
"Symbol Library Browser" );
void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
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...
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void ReCreateMenuBar() override
Recreates the menu bar.
LIB_SYMBOL_REF & GetParent()
static TOOL_ACTION showDatasheet
Inspection and Editing.
LIB_SYMBOL_SPTR SharedPtr() const
const UTF8 & GetLibItemName() const
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
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.
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)
wxString GetName() const override
virtual void SetScreen(BASE_SCREEN *aScreen)
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
void ClickOnCmpList(wxCommandEvent &event)
void SetPreselectNode(const LIB_ID &aLibId, int aUnit)
Set the symbol name to be selected if there are no search results.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(EDA_BASE_FRAME *aParent, LIB_TABLE *aLibs)
Factory function: create a model adapter in a reference-counting container.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
wxArrayString m_allowedLibs
static TOOL_ACTION zoomFitScreen
void SetSize(const Vec &size)
Symbol library viewer main window.
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
static wxString m_entryName
ACTION_TOOLBAR * m_mainToolBar
Manage TOOL_ACTION objects.
A logical library item identifier and consists of various portions much like a URI.
The base class for create windows for drawing purpose.
double m_gridMinSpacing
Whether or not to draw the coordinate system axes.
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
bool IsValid() const
Check if this LID_ID is valid.
void onUpdateUnitChoice(wxUpdateUIEvent &aEvent)
Define a library symbol object.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
static TOOL_ACTION showDeMorganAlternate
Class that groups generic conditions for editor states.
static std::mutex g_Mutex
Dialog class to select a symbol from the libraries.
void OnSelectSymbol(wxCommandEvent &aEvent)
bool m_axesEnabled
Fullscreen crosshair or small cross.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
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...
LIB_SYMBOL * m_previewItem
void CloseLibraryViewer(wxCommandEvent &event)
void onSelectNextSymbol(wxCommandEvent &aEvent)
void onSelectPreviousSymbol(wxCommandEvent &aEvent)
bool HasConversion() const
Test if symbol has more than one body conversion type (DeMorgan).
void onSelectSymbolUnit(wxCommandEvent &aEvent)
Stores the common settings that are saved and loaded for each window / frame.
void ReCreateHToolbar() override
int GetItemCount() const
Return the number of symbols loaded in the tree.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg) override
Return a pointer to the window settings for this frame.
wxString GetKeyWords() const
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.
static TOOL_ACTION toggleGrid
bool m_Center
Center on screen.
LIB_ID GetLibId() const override
void SyncView()
Mark all items for refresh.
EDA_MSG_PANEL * m_messagePanel
const wxPoint GetOrigin() const
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
int GetUnitCount() const override
For items with units, return the number of units.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
void SetStealsFocus(bool aStealsFocus)
Set whether focus is taken on certain events (mouseover, keys, etc).
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void SetSelectedSymbol(const wxString &aSymbolName)
Set the selected symbol.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition for symbol library class.
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
void SetUnitAndConvert(int aUnit, int aConvert)
Set unit and convert, and set flag preventing them from automatically resetting to 1.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
bool ReCreateLibList()
Create o recreates a sorted list of currently loaded libraries.
static TOOL_ACTION addSymbolToSchematic
void ReCreateVToolbar() override
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.
virtual void ClearMsgPanel()
Clear all messages from the message panel.
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
COLOR_SETTINGS * GetColorSettings() const override
Returns a pointer to the active color theme settings.
Specialization of the wxAuiPaneInfo class for KiCad panels.
static TOOL_ACTION showDeMorganStandard
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 showElectricalTypes
wxString UnescapeString(const wxString &aSource)
Gather all the actions that are shared by tools.
void updatePreviewSymbol()
COLOR_SETTINGS * m_colorSettings
The current canvas type.
void SetModal(bool aIsModal)
PANEL_LIB_VIEW m_LibViewPanel
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
bool m_selection_changed
Updated to true if a list rewrite on GUI activation resulted in the symbol selection changing,...
void LoadColors(const COLOR_SETTINGS *aSettings) override
COLOR4D GetColor(int aLayer) const
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
void SetFilter(const SCHLIB_FILTER *aFilter)
Set a filter to display only libraries and/or symbols which match the filter.
void OnActivate(wxActivateEvent &event)
Called when the frame is activated to reload the libraries and symbol lists that can be changed by th...
void SetSelectedLibrary(const wxString &aLibName)
Set the selected library in the library window.
void DismissModal(bool aRetVal, const wxString &aResult=wxEmptyString)
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
void DClickOnCmpList(wxCommandEvent &event)
void setupUnits(APP_SETTINGS_BASE *aCfg)
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
LIB_SYMBOL * GetSelectedSymbol() const
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
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...
void SetOrigin(const Vec &pos)
LIB_FIELD & GetDatasheetField()
Return reference to the datasheet field.
Handle the component boundary box.
const wxArrayString & GetAllowedLibList() const
bool show_pin_electrical_type
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void ClickOnLibList(wxCommandEvent &event)
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
void OnGridSettings(wxCommandEvent &event)
#define LIB_VIEW_NAME_MODAL
bool ShowModal(wxString *aSymbol, wxWindow *aParent) override
Runs the symbol viewer as a modal dialog.
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
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
void doCloseWindow() override
void SetBoundary(const BOX2D &aBoundary)
Set limits for view area.
void SetDefaultPenWidth(int aWidth)
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
wxString GetDescription() override
Message panel definition file.
Handle actions for the various symbol editor and viewers.
static wxString m_libraryName
static constexpr int Millimeter2iu(double mm)
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
SYMBOL_VIEWER_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aLibraryName=wxEmptyString)
bool m_ShowPinsElectricalType
void FinishModal()
Send the selected symbol back to the caller.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString & GetText() const
Return the string associated with the text object.
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
bool AddLibraries(const std::vector< wxString > &aNicknames, wxWindow *aParent)
Add all the libraries in a SYMBOL_LIB_TABLE to the model.
bool ReCreateSymbolList()
Create or recreate the list of symbols in the currently selected library.
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
bool GetFilterPowerSymbols() const
void AppendMsgPanel(const wxString &aTextUpper, const wxString &aTextLower, int aPadding=6)
Append a message to the message panel.
#define LIB_VIEW_STYLE_MODAL
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.