Code cleanup
This commit is contained in:
parent
5e6c6e7e22
commit
7c61b83df6
|
@ -49,8 +49,12 @@ class FP_THREAD_IFACE
|
|||
using CACHE_ENTRY = FOOTPRINT_PREVIEW_PANEL::CACHE_ENTRY;
|
||||
|
||||
public:
|
||||
FP_THREAD_IFACE() : m_panel( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
/// Retrieve a cache entry by LIB_ID
|
||||
OPT<CACHE_ENTRY> GetFromCache( LIB_ID const & aFPID )
|
||||
OPT<CACHE_ENTRY> GetFromCache( const LIB_ID& aFPID )
|
||||
{
|
||||
std::lock_guard<std::mutex> lock( m_lock );
|
||||
auto it = m_cachedFootprints.find( aFPID );
|
||||
|
@ -65,7 +69,7 @@ class FP_THREAD_IFACE
|
|||
* Push an entry to the loading queue and a placeholder to the cache;
|
||||
* return the placeholder.
|
||||
*/
|
||||
CACHE_ENTRY AddToQueue( LIB_ID const & aEntry )
|
||||
CACHE_ENTRY AddToQueue( const LIB_ID& aEntry )
|
||||
{
|
||||
std::lock_guard<std::mutex> lock( m_lock );
|
||||
|
||||
|
@ -94,7 +98,7 @@ class FP_THREAD_IFACE
|
|||
}
|
||||
|
||||
/// Add an entry to the cache.
|
||||
void AddToCache( CACHE_ENTRY const & aEntry )
|
||||
void AddToCache( const CACHE_ENTRY& aEntry )
|
||||
{
|
||||
std::lock_guard<std::mutex> lock( m_lock );
|
||||
m_cachedFootprints[aEntry.fpid] = aEntry;
|
||||
|
@ -140,7 +144,7 @@ class FP_THREAD_IFACE
|
|||
* Post an event to the panel, if the panel still exists. Return whether
|
||||
* the event was posted.
|
||||
*/
|
||||
bool QueueEvent( wxEvent const& aEvent )
|
||||
bool QueueEvent( const wxEvent& aEvent )
|
||||
{
|
||||
std::lock_guard<std::mutex> lock( m_lock );
|
||||
|
||||
|
@ -160,7 +164,7 @@ class FP_THREAD_IFACE
|
|||
*/
|
||||
FP_LIB_TABLE* GetTable()
|
||||
{
|
||||
std::lock_guard<std::mutex> locK( m_lock );
|
||||
std::lock_guard<std::mutex> lock( m_lock );
|
||||
return m_panel ? m_panel->Prj().PcbFootprintLibs() : nullptr;
|
||||
}
|
||||
|
||||
|
@ -168,7 +172,7 @@ class FP_THREAD_IFACE
|
|||
std::deque<CACHE_ENTRY> m_loaderQueue;
|
||||
std::map<LIB_ID, CACHE_ENTRY> m_cachedFootprints;
|
||||
LIB_ID m_current_fp;
|
||||
FOOTPRINT_PREVIEW_PANEL* m_panel = nullptr;
|
||||
FOOTPRINT_PREVIEW_PANEL* m_panel;
|
||||
std::mutex m_lock;
|
||||
};
|
||||
|
||||
|
@ -184,14 +188,15 @@ class FP_LOADER_THREAD: public wxThread
|
|||
std::shared_ptr<FP_THREAD_IFACE> m_iface;
|
||||
|
||||
public:
|
||||
FP_LOADER_THREAD( std::shared_ptr<FP_THREAD_IFACE> const& aIface ):
|
||||
wxThread( wxTHREAD_DETACHED ),
|
||||
m_iface( aIface )
|
||||
{}
|
||||
FP_LOADER_THREAD( const std::shared_ptr<FP_THREAD_IFACE>& aIface )
|
||||
: wxThread( wxTHREAD_DETACHED ), m_iface( aIface )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
~FP_LOADER_THREAD()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ProcessEntry( CACHE_ENTRY& aEntry )
|
||||
|
@ -201,18 +206,18 @@ public:
|
|||
if( !fptbl )
|
||||
return;
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
aEntry.module.reset( fptbl->FootprintLoadWithOptionalNickname( aEntry.fpid ) );
|
||||
|
||||
if( !aEntry.module )
|
||||
aEntry.status = FPS_NOT_FOUND;
|
||||
|
||||
} catch( const IO_ERROR& )
|
||||
}
|
||||
catch( const IO_ERROR& )
|
||||
{
|
||||
aEntry.status = FPS_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
if( aEntry.status != FPS_NOT_FOUND )
|
||||
aEntry.status = FPS_READY;
|
||||
|
||||
|
@ -247,7 +252,7 @@ FOOTPRINT_PREVIEW_PANEL::FOOTPRINT_PREVIEW_PANEL( KIWAY* aKiway, wxWindow* aPare
|
|||
std::unique_ptr<KIGFX::GAL_DISPLAY_OPTIONS> aOpts, GAL_TYPE aGalType )
|
||||
: PCB_DRAW_PANEL_GAL( aParent, -1, wxPoint( 0, 0 ), wxSize( 200, 200 ), *aOpts, aGalType ),
|
||||
KIWAY_HOLDER( aKiway, KIWAY_HOLDER::PANEL ),
|
||||
m_DisplayOptions( std::move( aOpts ) ),
|
||||
m_displayOptions( std::move( aOpts ) ),
|
||||
m_currentModule( nullptr ),
|
||||
m_footprintDisplayed( true )
|
||||
{
|
||||
|
@ -265,13 +270,14 @@ FOOTPRINT_PREVIEW_PANEL::FOOTPRINT_PREVIEW_PANEL( KIWAY* aKiway, wxWindow* aPare
|
|||
m_colorsSettings->Load( Kiface().KifaceSettings() );
|
||||
|
||||
UseColorScheme( m_colorsSettings.get() );
|
||||
SyncLayersVisibility( &*m_dummyBoard );
|
||||
SyncLayersVisibility( m_dummyBoard.get() );
|
||||
|
||||
Raise();
|
||||
Show( true );
|
||||
StartDrawing();
|
||||
|
||||
Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( FOOTPRINT_PREVIEW_PANEL::OnLoaderThreadUpdate ), NULL, this );
|
||||
Connect( wxEVT_COMMAND_TEXT_UPDATED,
|
||||
wxCommandEventHandler( FOOTPRINT_PREVIEW_PANEL::OnLoaderThreadUpdate ), NULL, this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -300,7 +306,7 @@ FOOTPRINT_PREVIEW_PANEL::CACHE_ENTRY FOOTPRINT_PREVIEW_PANEL::CacheAndReturn( co
|
|||
|
||||
|
||||
// This is separate to avoid having to export CACHE_ENTRY to the global namespace
|
||||
void FOOTPRINT_PREVIEW_PANEL::CacheFootprint( LIB_ID const& aFPID )
|
||||
void FOOTPRINT_PREVIEW_PANEL::CacheFootprint( const LIB_ID& aFPID )
|
||||
{
|
||||
(void) CacheAndReturn( aFPID );
|
||||
}
|
||||
|
@ -365,7 +371,7 @@ void FOOTPRINT_PREVIEW_PANEL::DisplayFootprint ( const LIB_ID& aFPID )
|
|||
}
|
||||
|
||||
|
||||
void FOOTPRINT_PREVIEW_PANEL::OnLoaderThreadUpdate( wxCommandEvent& event )
|
||||
void FOOTPRINT_PREVIEW_PANEL::OnLoaderThreadUpdate( wxCommandEvent& aEvent )
|
||||
{
|
||||
DisplayFootprint( m_currentFPID );
|
||||
}
|
||||
|
@ -385,7 +391,8 @@ wxWindow* FOOTPRINT_PREVIEW_PANEL::GetWindow()
|
|||
|
||||
FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::New( KIWAY* aKiway, wxWindow* aParent )
|
||||
{
|
||||
PCB_EDIT_FRAME* pcbnew = static_cast<PCB_EDIT_FRAME*>( aKiway->Player( FRAME_PCB_EDITOR, false ) );
|
||||
PCB_EDIT_FRAME* pcbnew =
|
||||
static_cast<PCB_EDIT_FRAME*>( aKiway->Player( FRAME_PCB_EDITOR, false ) );
|
||||
wxConfigBase* cfg = Kiface().KifaceSettings();
|
||||
wxConfigBase* commonCfg = Pgm().CommonSettings();
|
||||
bool btemp;
|
||||
|
|
|
@ -59,9 +59,9 @@ public:
|
|||
|
||||
virtual ~FOOTPRINT_PREVIEW_PANEL( );
|
||||
|
||||
virtual void CacheFootprint( LIB_ID const& aFPID ) override;
|
||||
virtual void CacheFootprint( const LIB_ID& aFPID ) override;
|
||||
|
||||
virtual void DisplayFootprint ( LIB_ID const& aFPID ) override;
|
||||
virtual void DisplayFootprint( const LIB_ID& aFPID ) override;
|
||||
|
||||
virtual void SetStatusHandler( FOOTPRINT_STATUS_HANDLER aHandler ) override;
|
||||
|
||||
|
@ -70,8 +70,8 @@ public:
|
|||
static FOOTPRINT_PREVIEW_PANEL* New( KIWAY* aKiway, wxWindow* aParent );
|
||||
|
||||
private:
|
||||
|
||||
struct CACHE_ENTRY {
|
||||
struct CACHE_ENTRY
|
||||
{
|
||||
LIB_ID fpid;
|
||||
std::shared_ptr<MODULE> module;
|
||||
FOOTPRINT_STATUS status;
|
||||
|
@ -89,7 +89,7 @@ private:
|
|||
std::unique_ptr<KIGFX::GAL_DISPLAY_OPTIONS> aOpts, GAL_TYPE aGalType );
|
||||
|
||||
|
||||
virtual CACHE_ENTRY CacheAndReturn ( LIB_ID const& aFPID );
|
||||
virtual CACHE_ENTRY CacheAndReturn( const LIB_ID& aFPID );
|
||||
|
||||
void OnLoaderThreadUpdate( wxCommandEvent& aEvent );
|
||||
|
||||
|
@ -98,8 +98,9 @@ private:
|
|||
FP_LOADER_THREAD* m_loader;
|
||||
std::shared_ptr<FP_THREAD_IFACE> m_iface;
|
||||
FOOTPRINT_STATUS_HANDLER m_handler;
|
||||
|
||||
std::unique_ptr<BOARD> m_dummyBoard;
|
||||
std::unique_ptr<KIGFX::GAL_DISPLAY_OPTIONS> m_DisplayOptions;
|
||||
std::unique_ptr<KIGFX::GAL_DISPLAY_OPTIONS> m_displayOptions;
|
||||
std::unique_ptr<COLORS_DESIGN_SETTINGS> m_colorsSettings;
|
||||
|
||||
std::shared_ptr<MODULE> m_currentModule;
|
||||
|
|
Loading…
Reference in New Issue