2017-02-19 02:39:55 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
* Copyright (C) 2017 Chris Pavlina <pavlina.chris@gmail.com>
|
|
|
|
* Copyright (C) 2016 Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
#include <footprint_preview_panel.h>
|
2017-02-19 02:39:55 +00:00
|
|
|
#include <pcb_draw_panel_gal.h>
|
2018-09-18 18:13:01 +00:00
|
|
|
#include <kiface_i.h>
|
2017-02-19 02:39:55 +00:00
|
|
|
#include <kiway.h>
|
|
|
|
#include <io_mgr.h>
|
|
|
|
#include <fp_lib_table.h>
|
|
|
|
#include <view/view.h>
|
|
|
|
#include <math/box2.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_board.h>
|
2017-03-11 13:22:08 +00:00
|
|
|
#include <ki_mutex.h>
|
2018-11-03 12:35:17 +00:00
|
|
|
#include <draw_frame.h>
|
2017-02-19 02:39:55 +00:00
|
|
|
#include <boost/bind.hpp>
|
2017-09-23 09:20:10 +00:00
|
|
|
#include <utility>
|
2017-02-19 02:39:55 +00:00
|
|
|
#include <make_unique.h>
|
2018-01-31 08:23:20 +00:00
|
|
|
#include <colors_design_settings.h>
|
2018-11-03 12:35:17 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2017-02-19 02:39:55 +00:00
|
|
|
#include <wx/stattext.h>
|
2018-11-03 12:35:17 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <painter.h>
|
2017-02-19 02:39:55 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
/**
|
|
|
|
* Threadsafe interface class between loader thread and panel class.
|
|
|
|
*/
|
|
|
|
class FP_THREAD_IFACE
|
|
|
|
{
|
|
|
|
using CACHE_ENTRY = FOOTPRINT_PREVIEW_PANEL::CACHE_ENTRY;
|
2017-02-19 02:39:55 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
public:
|
|
|
|
/// Retrieve a cache entry by LIB_ID
|
2017-11-01 11:14:16 +00:00
|
|
|
OPT<CACHE_ENTRY> GetFromCache( LIB_ID const & aFPID )
|
2017-03-06 03:22:25 +00:00
|
|
|
{
|
2017-03-11 13:22:08 +00:00
|
|
|
MUTLOCK lock( m_lock );
|
2017-03-10 19:11:41 +00:00
|
|
|
auto it = m_cachedFootprints.find( aFPID );
|
2017-02-19 02:39:55 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
if( it != m_cachedFootprints.end() )
|
|
|
|
return it->second;
|
|
|
|
else
|
2017-11-01 11:14:16 +00:00
|
|
|
return NULLOPT;
|
2017-03-10 19:11:41 +00:00
|
|
|
}
|
2017-03-06 03:22:25 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
/**
|
|
|
|
* Push an entry to the loading queue and a placeholder to the cache;
|
|
|
|
* return the placeholder.
|
|
|
|
*/
|
|
|
|
CACHE_ENTRY AddToQueue( LIB_ID const & aEntry )
|
|
|
|
{
|
2017-03-11 13:22:08 +00:00
|
|
|
MUTLOCK lock( m_lock );
|
2017-03-06 03:22:25 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
CACHE_ENTRY ent = { aEntry, NULL, FPS_LOADING };
|
|
|
|
m_cachedFootprints[aEntry] = ent;
|
|
|
|
m_loaderQueue.push_back( ent );
|
2017-03-06 03:22:25 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
return ent;
|
|
|
|
}
|
2017-03-06 03:22:25 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
/// Pop an entry from the queue, or empty option if none is available.
|
2017-11-01 11:14:16 +00:00
|
|
|
OPT<CACHE_ENTRY> PopFromQueue()
|
2017-03-10 19:11:41 +00:00
|
|
|
{
|
2017-03-11 13:22:08 +00:00
|
|
|
MUTLOCK lock( m_lock );
|
2017-03-06 03:22:25 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
if( m_loaderQueue.empty() )
|
|
|
|
{
|
2017-11-01 11:14:16 +00:00
|
|
|
return NULLOPT;
|
2017-03-10 19:11:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auto ent = m_loaderQueue.front();
|
|
|
|
m_loaderQueue.pop_front();
|
|
|
|
return ent;
|
|
|
|
}
|
|
|
|
}
|
2017-03-06 03:22:25 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
/// Add an entry to the cache.
|
|
|
|
void AddToCache( CACHE_ENTRY const & aEntry )
|
|
|
|
{
|
2017-03-11 13:22:08 +00:00
|
|
|
MUTLOCK lock( m_lock );
|
2017-03-10 19:11:41 +00:00
|
|
|
m_cachedFootprints[aEntry.fpid] = aEntry;
|
|
|
|
}
|
2017-03-08 22:02:10 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
/**
|
|
|
|
* Threadsafe accessor to set the current footprint.
|
|
|
|
*/
|
|
|
|
void SetCurrentFootprint( LIB_ID aFp )
|
|
|
|
{
|
2017-03-11 13:22:08 +00:00
|
|
|
MUTLOCK lock( m_lock );
|
2017-09-23 09:20:10 +00:00
|
|
|
m_current_fp = std::move( aFp );
|
2017-03-10 19:11:41 +00:00
|
|
|
}
|
2017-03-06 03:22:25 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
/**
|
|
|
|
* Threadsafe accessor to get the current footprint.
|
|
|
|
*/
|
|
|
|
LIB_ID GetCurrentFootprint()
|
|
|
|
{
|
2017-03-11 13:22:08 +00:00
|
|
|
MUTLOCK lock( m_lock );
|
2017-03-10 19:11:41 +00:00
|
|
|
return m_current_fp;
|
2017-03-06 03:22:25 +00:00
|
|
|
}
|
|
|
|
|
2017-03-26 23:43:41 +00:00
|
|
|
/**
|
|
|
|
* Set the associated panel, for QueueEvent() and GetTable().
|
|
|
|
*/
|
|
|
|
void SetPanel( FOOTPRINT_PREVIEW_PANEL* aPanel )
|
|
|
|
{
|
|
|
|
MUTLOCK lock( m_lock );
|
|
|
|
m_panel = aPanel;
|
|
|
|
}
|
|
|
|
|
2017-03-27 18:23:03 +00:00
|
|
|
/**
|
|
|
|
* Get the associated panel.
|
|
|
|
*/
|
|
|
|
FOOTPRINT_PREVIEW_PANEL* GetPanel()
|
|
|
|
{
|
|
|
|
MUTLOCK lock( m_lock );
|
|
|
|
return m_panel;
|
|
|
|
}
|
|
|
|
|
2017-03-26 23:43:41 +00:00
|
|
|
/**
|
|
|
|
* Post an event to the panel, if the panel still exists. Return whether
|
|
|
|
* the event was posted.
|
|
|
|
*/
|
|
|
|
bool QueueEvent( wxEvent const& aEvent )
|
|
|
|
{
|
|
|
|
MUTLOCK lock( m_lock );
|
|
|
|
|
|
|
|
if( m_panel )
|
|
|
|
{
|
|
|
|
m_panel->GetEventHandler()->QueueEvent( aEvent.Clone() );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get an FP_LIB_TABLE, or null if the panel is dead.
|
|
|
|
*/
|
|
|
|
FP_LIB_TABLE* GetTable()
|
|
|
|
{
|
|
|
|
MUTLOCK locK( m_lock );
|
|
|
|
return m_panel ? m_panel->Prj().PcbFootprintLibs() : nullptr;
|
|
|
|
}
|
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
private:
|
|
|
|
std::deque<CACHE_ENTRY> m_loaderQueue;
|
|
|
|
std::map<LIB_ID, CACHE_ENTRY> m_cachedFootprints;
|
|
|
|
LIB_ID m_current_fp;
|
2017-11-09 17:51:06 +00:00
|
|
|
FOOTPRINT_PREVIEW_PANEL* m_panel = nullptr;
|
2017-03-11 13:22:08 +00:00
|
|
|
MUTEX m_lock;
|
2017-03-06 03:22:25 +00:00
|
|
|
};
|
2017-02-19 02:39:55 +00:00
|
|
|
|
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
/**
|
|
|
|
* Footprint loader thread to prevent footprint loading from locking the UI.
|
|
|
|
* Interface is via a FP_THREAD_IFACE.
|
|
|
|
*/
|
|
|
|
class FP_LOADER_THREAD: public wxThread
|
2017-02-19 02:39:55 +00:00
|
|
|
{
|
2017-03-10 19:11:41 +00:00
|
|
|
using CACHE_ENTRY = FOOTPRINT_PREVIEW_PANEL::CACHE_ENTRY;
|
2017-02-19 02:39:55 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
std::shared_ptr<FP_THREAD_IFACE> m_iface;
|
|
|
|
|
|
|
|
public:
|
2017-03-26 23:43:41 +00:00
|
|
|
FP_LOADER_THREAD( std::shared_ptr<FP_THREAD_IFACE> const& aIface ):
|
2017-03-10 19:11:41 +00:00
|
|
|
wxThread( wxTHREAD_DETACHED ),
|
|
|
|
m_iface( aIface )
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
~FP_LOADER_THREAD()
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
void ProcessEntry( CACHE_ENTRY& aEntry )
|
2017-02-19 02:39:55 +00:00
|
|
|
{
|
2017-03-26 23:43:41 +00:00
|
|
|
FP_LIB_TABLE* fptbl = m_iface->GetTable();
|
2017-02-19 02:39:55 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
if( !fptbl )
|
|
|
|
return;
|
2017-02-19 02:39:55 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
aEntry.module = NULL;
|
2017-02-19 02:39:55 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
try {
|
|
|
|
aEntry.module = fptbl->FootprintLoadWithOptionalNickname( aEntry.fpid );
|
2017-02-19 02:39:55 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
if( !aEntry.module )
|
|
|
|
aEntry.status = FPS_NOT_FOUND;
|
2017-02-19 02:39:55 +00:00
|
|
|
|
2017-06-11 01:54:25 +00:00
|
|
|
} catch( const IO_ERROR& )
|
2017-03-10 19:11:41 +00:00
|
|
|
{
|
|
|
|
aEntry.status = FPS_NOT_FOUND;
|
|
|
|
}
|
2017-02-19 02:39:55 +00:00
|
|
|
|
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
if( aEntry.status != FPS_NOT_FOUND )
|
|
|
|
aEntry.status = FPS_READY;
|
2017-02-19 02:39:55 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
m_iface->AddToCache( aEntry );
|
2017-02-19 02:39:55 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
if( aEntry.fpid == m_iface->GetCurrentFootprint() )
|
|
|
|
{
|
2017-03-26 23:43:41 +00:00
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_TEXT_UPDATED, 1 );
|
|
|
|
m_iface->QueueEvent( evt );
|
2017-03-10 19:11:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual void* Entry() override
|
|
|
|
{
|
2017-03-27 18:23:03 +00:00
|
|
|
while( m_iface->GetPanel() )
|
2017-03-10 19:11:41 +00:00
|
|
|
{
|
|
|
|
auto ent = m_iface->PopFromQueue();
|
|
|
|
|
|
|
|
if( ent )
|
|
|
|
ProcessEntry( *ent );
|
|
|
|
else
|
|
|
|
wxMilliSleep( 100 );
|
|
|
|
}
|
|
|
|
|
2017-03-27 18:23:03 +00:00
|
|
|
return nullptr;
|
2017-03-10 19:11:41 +00:00
|
|
|
}
|
|
|
|
};
|
2017-02-19 02:39:55 +00:00
|
|
|
|
|
|
|
|
2018-09-11 15:28:57 +00:00
|
|
|
FOOTPRINT_PREVIEW_PANEL::FOOTPRINT_PREVIEW_PANEL( KIWAY* aKiway, wxWindow* aParent,
|
|
|
|
KIGFX::GAL_DISPLAY_OPTIONS& aOpts,
|
|
|
|
GAL_TYPE aGalType )
|
2017-02-19 02:39:55 +00:00
|
|
|
: PCB_DRAW_PANEL_GAL ( aParent, -1, wxPoint( 0, 0 ), wxSize(200, 200), aOpts, aGalType ),
|
|
|
|
KIWAY_HOLDER( aKiway ),
|
2017-03-10 19:11:41 +00:00
|
|
|
m_footprintDisplayed( true )
|
2017-02-19 02:39:55 +00:00
|
|
|
{
|
2017-03-10 19:11:41 +00:00
|
|
|
m_iface = std::make_shared<FP_THREAD_IFACE>();
|
2017-03-26 23:43:41 +00:00
|
|
|
m_iface->SetPanel( this );
|
|
|
|
m_loader = new FP_LOADER_THREAD( m_iface );
|
2017-02-19 02:39:55 +00:00
|
|
|
m_loader->Run();
|
|
|
|
|
2017-03-03 21:05:13 +00:00
|
|
|
SetStealsFocus( false );
|
2017-02-19 02:39:55 +00:00
|
|
|
ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER );
|
|
|
|
EnableScrolling( false, false ); // otherwise Zoom Auto disables GAL canvas
|
|
|
|
|
|
|
|
m_dummyBoard = std::make_unique<BOARD>();
|
2017-09-10 14:21:56 +00:00
|
|
|
m_colorsSettings = std::make_unique<COLORS_DESIGN_SETTINGS>( FRAME_PCB_FOOTPRINT_PREVIEW );
|
2018-09-18 18:13:01 +00:00
|
|
|
m_colorsSettings->Load( Kiface().KifaceSettings() );
|
2017-02-19 02:39:55 +00:00
|
|
|
|
2017-08-04 12:43:02 +00:00
|
|
|
UseColorScheme( m_colorsSettings.get() );
|
2017-02-19 02:39:55 +00:00
|
|
|
SyncLayersVisibility( &*m_dummyBoard );
|
|
|
|
|
|
|
|
Raise();
|
2018-09-11 15:28:57 +00:00
|
|
|
Show( true );
|
2017-02-19 02:39:55 +00:00
|
|
|
StartDrawing();
|
|
|
|
|
|
|
|
Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( FOOTPRINT_PREVIEW_PANEL::OnLoaderThreadUpdate ), NULL, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FOOTPRINT_PREVIEW_PANEL::~FOOTPRINT_PREVIEW_PANEL( )
|
|
|
|
{
|
2017-03-26 23:43:41 +00:00
|
|
|
m_iface->SetPanel( nullptr );
|
2017-02-19 02:39:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
FOOTPRINT_PREVIEW_PANEL::CACHE_ENTRY FOOTPRINT_PREVIEW_PANEL::CacheAndReturn( const LIB_ID& aFPID )
|
2017-02-19 02:39:55 +00:00
|
|
|
{
|
2017-03-06 03:22:25 +00:00
|
|
|
auto opt_ent = m_iface->GetFromCache( aFPID );
|
2017-02-19 02:39:55 +00:00
|
|
|
|
|
|
|
if( opt_ent )
|
|
|
|
return *opt_ent;
|
|
|
|
else
|
2017-03-06 03:22:25 +00:00
|
|
|
return m_iface->AddToQueue( aFPID );
|
2017-02-19 02:39:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
// This is separate to avoid having to export CACHE_ENTRY to the global namespace
|
|
|
|
void FOOTPRINT_PREVIEW_PANEL::CacheFootprint( LIB_ID const& aFPID )
|
|
|
|
{
|
|
|
|
(void) CacheAndReturn( aFPID );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-19 02:39:55 +00:00
|
|
|
void FOOTPRINT_PREVIEW_PANEL::renderFootprint( MODULE *module )
|
|
|
|
{
|
|
|
|
GetView()->Clear();
|
2018-09-11 15:28:57 +00:00
|
|
|
module->SetParent( &*m_dummyBoard );
|
2017-02-19 02:39:55 +00:00
|
|
|
|
2018-09-11 15:28:57 +00:00
|
|
|
GetView()->Add( module );
|
2017-02-19 02:39:55 +00:00
|
|
|
GetView()->SetVisible( module, true );
|
|
|
|
GetView()->Update( module, KIGFX::ALL );
|
|
|
|
|
|
|
|
BOX2I bbox = module->ViewBBox();
|
|
|
|
bbox.Merge ( module->Value().ViewBBox() );
|
|
|
|
bbox.Merge ( module->Reference().ViewBBox() );
|
|
|
|
|
|
|
|
if( bbox.GetSize().x > 0 && bbox.GetSize().y > 0 )
|
|
|
|
{
|
|
|
|
// Autozoom
|
|
|
|
GetView()->SetViewport( BOX2D( bbox.GetOrigin(), bbox.GetSize() ) );
|
|
|
|
|
|
|
|
// Add a margin
|
|
|
|
GetView()->SetScale( GetView()->GetScale() * 0.7 );
|
|
|
|
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_PREVIEW_PANEL::DisplayFootprint ( const LIB_ID& aFPID )
|
|
|
|
{
|
|
|
|
m_currentFPID = aFPID;
|
2017-03-10 19:11:41 +00:00
|
|
|
m_iface->SetCurrentFootprint( aFPID );
|
2017-02-19 02:39:55 +00:00
|
|
|
m_footprintDisplayed = false;
|
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
CACHE_ENTRY fpe = CacheAndReturn ( m_currentFPID );
|
2017-02-19 02:39:55 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
if( m_handler )
|
|
|
|
m_handler( fpe.status );
|
2017-02-19 02:39:55 +00:00
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
if( fpe.status == FPS_READY )
|
|
|
|
{
|
2017-02-19 02:39:55 +00:00
|
|
|
if ( !m_footprintDisplayed )
|
|
|
|
{
|
|
|
|
renderFootprint( fpe.module );
|
|
|
|
m_footprintDisplayed = true;
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_PREVIEW_PANEL::OnLoaderThreadUpdate( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
DisplayFootprint( m_currentFPID );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
void FOOTPRINT_PREVIEW_PANEL::SetStatusHandler( FOOTPRINT_STATUS_HANDLER aHandler )
|
2017-02-19 02:39:55 +00:00
|
|
|
{
|
2017-03-10 19:11:41 +00:00
|
|
|
m_handler = aHandler;
|
2017-02-19 02:39:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-10 19:11:41 +00:00
|
|
|
wxWindow* FOOTPRINT_PREVIEW_PANEL::GetWindow()
|
2017-02-19 02:39:55 +00:00
|
|
|
{
|
2017-03-10 19:11:41 +00:00
|
|
|
return static_cast<wxWindow*>( this );
|
2017-02-19 02:39:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::New( KIWAY* aKiway, wxWindow* aParent )
|
|
|
|
{
|
2018-11-03 12:35:17 +00:00
|
|
|
PCB_EDIT_FRAME* pcbnew = static_cast<PCB_EDIT_FRAME*>( aKiway->Player( FRAME_PCB, false ) );
|
2017-02-19 02:39:55 +00:00
|
|
|
KIGFX::GAL_DISPLAY_OPTIONS gal_opts;
|
2018-11-03 12:35:17 +00:00
|
|
|
wxConfigBase* cfg = Kiface().KifaceSettings();
|
|
|
|
wxConfigBase* commonCfg = Pgm().CommonSettings();
|
|
|
|
bool btemp;
|
|
|
|
int itemp;
|
|
|
|
wxString msg;
|
|
|
|
COLOR4D ctemp;
|
|
|
|
|
|
|
|
// Fetch grid & display settings from PCBNew if it's running; otherwise fetch them
|
|
|
|
// from PCBNew's config settings.
|
|
|
|
|
|
|
|
if( pcbnew )
|
|
|
|
{
|
|
|
|
gal_opts = pcbnew->GetGalDisplayOptions();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gal_opts.ReadConfig( cfg, wxString( PCB_EDIT_FRAME_NAME ) + GAL_DISPLAY_OPTIONS_KEY );
|
|
|
|
|
|
|
|
commonCfg->Read( GAL_ANTIALIASING_MODE_KEY, &itemp, (int) KIGFX::OPENGL_ANTIALIASING_MODE::NONE );
|
|
|
|
gal_opts.gl_antialiasing_mode = (KIGFX::OPENGL_ANTIALIASING_MODE) itemp;
|
2018-01-04 12:13:00 +00:00
|
|
|
|
|
|
|
commonCfg->Read( CAIRO_ANTIALIASING_MODE_KEY, &itemp, (int) KIGFX::CAIRO_ANTIALIASING_MODE::NONE );
|
|
|
|
gal_opts.cairo_antialiasing_mode = (KIGFX::CAIRO_ANTIALIASING_MODE) itemp;
|
2018-11-03 12:35:17 +00:00
|
|
|
}
|
2017-02-19 02:39:55 +00:00
|
|
|
|
2018-09-11 15:28:57 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
// Cairo renderer doesn't handle Retina displays
|
|
|
|
EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
|
|
|
|
#else
|
|
|
|
EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
|
|
|
|
#endif
|
2018-11-03 12:35:17 +00:00
|
|
|
|
|
|
|
auto panel = new FOOTPRINT_PREVIEW_PANEL( aKiway, aParent, gal_opts, backend );
|
|
|
|
|
|
|
|
if( pcbnew )
|
|
|
|
{
|
|
|
|
panel->GetGAL()->SetGridVisibility( pcbnew->IsGridVisible() );
|
|
|
|
panel->GetGAL()->SetGridSize( VECTOR2D( pcbnew->GetScreen()->GetGridSize() ) );
|
|
|
|
|
|
|
|
// Grid color (among other things):
|
|
|
|
KIGFX::PAINTER* pcbnew_painter = pcbnew->GetGalCanvas()->GetView()->GetPainter();
|
|
|
|
panel->GetView()->GetPainter()->ApplySettings( pcbnew_painter->GetSettings() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
btemp = cfg->ReadBool( wxString( PCB_EDIT_FRAME_NAME ) + ShowGridEntryKeyword, true );
|
|
|
|
panel->GetGAL()->SetGridVisibility( btemp );
|
|
|
|
|
|
|
|
// Read grid size:
|
|
|
|
std::unique_ptr<PCB_SCREEN> temp_screen = std::make_unique<PCB_SCREEN>( wxSize() );
|
|
|
|
cfg->Read( wxString( PCB_EDIT_FRAME_NAME ) + LastGridSizeIdKeyword, &itemp, 0L );
|
|
|
|
temp_screen->SetGrid( itemp + ID_POPUP_GRID_LEVEL_1000 );
|
|
|
|
panel->GetGAL()->SetGridSize( VECTOR2D( temp_screen->GetGridSize() ) );
|
|
|
|
|
|
|
|
// Read grid color:
|
|
|
|
msg = cfg->Read( wxString( PCB_EDIT_FRAME_NAME ) + GridColorEntryKeyword, wxT( "NONE" ) );
|
|
|
|
ctemp.SetFromWxString( msg );
|
|
|
|
panel->GetGAL()->SetGridColor( ctemp );
|
|
|
|
}
|
|
|
|
|
|
|
|
return panel;
|
2017-02-19 02:39:55 +00:00
|
|
|
}
|