Fix Cvpcb DISPLAY_FOOTPRINTS_FRAME: some display options not working. Commit 5e4a7041 moved 4 settings used in Cvpcb to a PCBNEW_SETTINGS struct. But in Cvpcb, this config struct does not exist. So these 4 settings are now moved to a section (PCB_VIEWERS_SETTINGS_BASE) common to Cvpcb and Pcbnew config.

This commit is contained in:
jean-pierre charras 2022-07-23 10:34:31 +02:00
parent f48755cc67
commit 8eee766791
9 changed files with 123 additions and 50 deletions

View File

@ -30,7 +30,7 @@
const int cvpcbSchemaVersion = 0; const int cvpcbSchemaVersion = 0;
CVPCB_SETTINGS::CVPCB_SETTINGS() : CVPCB_SETTINGS::CVPCB_SETTINGS() :
APP_SETTINGS_BASE( "cvpcb", cvpcbSchemaVersion ), PCB_VIEWERS_SETTINGS_BASE( "cvpcb", cvpcbSchemaVersion ),
m_FootprintViewerZoom( 1.0 ), m_FootprintViewerZoom( 1.0 ),
m_FootprintViewerAutoZoomOnSelect( true ), m_FootprintViewerAutoZoomOnSelect( true ),
m_FilterFlags( 0 ), m_FilterFlags( 0 ),
@ -54,6 +54,18 @@ CVPCB_SETTINGS::CVPCB_SETTINGS() :
m_params.emplace_back( new PARAM<double>( "footprint_viewer.zoom", &m_FootprintViewerZoom, 1.0 ) ); m_params.emplace_back( new PARAM<double>( "footprint_viewer.zoom", &m_FootprintViewerZoom, 1.0 ) );
m_params.emplace_back( new PARAM<bool>( "footprint_viewer.autozoom", m_params.emplace_back( new PARAM<bool>( "footprint_viewer.autozoom",
&m_FootprintViewerAutoZoomOnSelect, true ) ); &m_FootprintViewerAutoZoomOnSelect, true ) );
m_params.emplace_back( new PARAM<bool>( "footprint_viewer.show_pad_fill",
&m_ViewersDisplay.m_DisplayPadFill, true ) );
m_params.emplace_back( new PARAM<bool>( "footprint_viewer.show_pad_number",
&m_ViewersDisplay.m_DisplayPadNumbers, true ) );
m_params.emplace_back( new PARAM<bool>( "footprint_viewer.show_text_fill",
&m_ViewersDisplay.m_DisplayTextFill, true ) );
m_params.emplace_back( new PARAM<bool>( "footprint_viewer.show_graphic_fill",
&m_ViewersDisplay.m_DisplayGraphicsFill, true ) );
} }

View File

@ -28,7 +28,7 @@
#include <pcbnew_settings.h> #include <pcbnew_settings.h>
#include <settings/app_settings.h> #include <settings/app_settings.h>
class CVPCB_SETTINGS : public APP_SETTINGS_BASE class CVPCB_SETTINGS : public PCB_VIEWERS_SETTINGS_BASE
{ {
public: public:
CVPCB_SETTINGS(); CVPCB_SETTINGS();

View File

@ -346,7 +346,7 @@ void DISPLAY_FOOTPRINTS_FRAME::UpdateToolbarControlSizes()
void DISPLAY_FOOTPRINTS_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) void DISPLAY_FOOTPRINTS_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
{ {
auto cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg ); CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg );
wxCHECK( cfg, /* void */ ); wxCHECK( cfg, /* void */ );
// We don't allow people to change this right now, so make sure it's on // We don't allow people to change this right now, so make sure it's on

View File

@ -53,7 +53,7 @@ void PANEL_DISPLAY_OPTIONS::loadPCBSettings( PCBNEW_SETTINGS* aCfg )
m_OptDisplayTracksClearance->SetSelection( i ); m_OptDisplayTracksClearance->SetSelection( i );
m_OptDisplayPadClearence->SetValue( aCfg->m_Display.m_PadClearance ); m_OptDisplayPadClearence->SetValue( aCfg->m_Display.m_PadClearance );
m_OptDisplayPadNumber->SetValue( aCfg->m_Display.m_PadNumbers ); m_OptDisplayPadNumber->SetValue( aCfg->m_ViewersDisplay.m_DisplayPadNumbers );
m_OptDisplayPadNoConn->SetValue( aCfg->m_Display.m_PadNoConnects ); m_OptDisplayPadNoConn->SetValue( aCfg->m_Display.m_PadNoConnects );
m_ShowNetNamesOption->SetSelection( aCfg->m_Display.m_NetNames ); m_ShowNetNamesOption->SetSelection( aCfg->m_Display.m_NetNames );
m_live3Drefresh->SetValue( aCfg->m_Display.m_Live3DRefresh ); m_live3Drefresh->SetValue( aCfg->m_Display.m_Live3DRefresh );
@ -96,7 +96,7 @@ bool PANEL_DISPLAY_OPTIONS::TransferDataFromWindow()
cfg->m_Display.m_TrackClearance = UTIL::GetValFromConfig( clearanceModeMap, i ); cfg->m_Display.m_TrackClearance = UTIL::GetValFromConfig( clearanceModeMap, i );
cfg->m_Display.m_PadClearance = m_OptDisplayPadClearence->GetValue(); cfg->m_Display.m_PadClearance = m_OptDisplayPadClearence->GetValue();
cfg->m_Display.m_PadNumbers = m_OptDisplayPadNumber->GetValue(); cfg->m_ViewersDisplay.m_DisplayPadNumbers = m_OptDisplayPadNumber->GetValue();
cfg->m_Display.m_PadNoConnects = m_OptDisplayPadNoConn->GetValue(); cfg->m_Display.m_PadNoConnects = m_OptDisplayPadNoConn->GetValue();
cfg->m_Display.m_NetNames = m_ShowNetNamesOption->GetSelection(); cfg->m_Display.m_NetNames = m_ShowNetNamesOption->GetSelection();
cfg->m_Display.m_Live3DRefresh = m_live3Drefresh->GetValue(); cfg->m_Display.m_Live3DRefresh = m_live3Drefresh->GetValue();

View File

@ -66,6 +66,43 @@
using namespace KIGFX; using namespace KIGFX;
PCBNEW_SETTINGS* pcbconfig()
{
return dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
}
// Helpers for display options existing in Cvpcb and Pcbnew
// Note, when running Cvpcb, pcbconfig() returns nullptr and viewer_settings()
// returns the viewer options existing to Cvpcb and Pcbnew
static PCB_VIEWERS_SETTINGS_BASE* viewer_settings()
{
return static_cast<PCB_VIEWERS_SETTINGS_BASE*>( Kiface().KifaceSettings() );
}
static bool displayPadFill()
{
return viewer_settings()->m_ViewersDisplay.m_DisplayPadFill;
}
static bool displayGraphicsFill()
{
return viewer_settings()->m_ViewersDisplay.m_DisplayGraphicsFill;
}
static bool displayTextFill()
{
return viewer_settings()->m_ViewersDisplay.m_DisplayTextFill;
}
static bool displayPadNumbers()
{
return viewer_settings()->m_ViewersDisplay.m_DisplayPadNumbers;
}
PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS() PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS()
{ {
m_backgroundColor = COLOR4D( 0.0, 0.0, 0.0, 1.0 ); m_backgroundColor = COLOR4D( 0.0, 0.0, 0.0, 1.0 );
@ -359,12 +396,6 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons
} }
PCBNEW_SETTINGS* pcbconfig()
{
return dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
}
bool PCB_RENDER_SETTINGS::GetShowPageLimits() const bool PCB_RENDER_SETTINGS::GetShowPageLimits() const
{ {
return pcbconfig() && pcbconfig()->m_ShowPageLimits; return pcbconfig() && pcbconfig()->m_ShowPageLimits;
@ -957,20 +988,19 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
if( IsNetnameLayer( aLayer ) ) if( IsNetnameLayer( aLayer ) )
{ {
if( !pcbconfig() ) PCBNEW_SETTINGS::DISPLAY_OPTIONS* displayOpts = pcbconfig() ? &pcbconfig()->m_Display : nullptr;
return;
PCBNEW_SETTINGS::DISPLAY_OPTIONS& displayOpts = pcbconfig()->m_Display;
wxString netname; wxString netname;
wxString padNumber; wxString padNumber;
if( displayOpts.m_PadNumbers ) if( displayPadNumbers() )
padNumber = UnescapeString( aPad->GetNumber() ); padNumber = UnescapeString( aPad->GetNumber() );
if( displayOpts.m_NetNames == 1 || displayOpts.m_NetNames == 3 ) if( displayOpts )
{
if( displayOpts->m_NetNames == 1 || displayOpts->m_NetNames == 3 )
netname = UnescapeString( aPad->GetShortNetname() ); netname = UnescapeString( aPad->GetShortNetname() );
if( displayOpts.m_PadNoConnects if( displayOpts->m_PadNoConnects
&& aPad->GetShortNetname().StartsWith( wxT( "unconnected-(" ) ) ) && aPad->GetShortNetname().StartsWith( wxT( "unconnected-(" ) ) )
{ {
wxString pinType = aPad->GetPinType(); wxString pinType = aPad->GetPinType();
@ -980,6 +1010,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
else if( pinType == wxT( "free" ) ) else if( pinType == wxT( "free" ) )
netname = wxT( "*" ); netname = wxT( "*" );
} }
}
if( netname.IsEmpty() && padNumber.IsEmpty() ) if( netname.IsEmpty() && padNumber.IsEmpty() )
return; return;
@ -1097,7 +1128,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
return; return;
} }
bool outline_mode = pcbconfig() && !pcbconfig()->m_Display.m_DisplayPadFill; bool outline_mode = !displayPadFill();
if( m_pcbSettings.m_ForcePadSketchModeOff ) if( m_pcbSettings.m_ForcePadSketchModeOff )
outline_mode = false; outline_mode = false;
@ -1412,7 +1443,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer ) void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
{ {
COLOR4D color = m_pcbSettings.GetColor( aShape, aShape->GetLayer() ); COLOR4D color = m_pcbSettings.GetColor( aShape, aShape->GetLayer() );
bool outline_mode = pcbconfig() && !pcbconfig()->m_Display.m_DisplayGraphicsFill; bool outline_mode = !displayGraphicsFill();
int thickness = getLineThickness( aShape->GetWidth() ); int thickness = getLineThickness( aShape->GetWidth() );
PLOT_DASH_TYPE lineStyle = aShape->GetStroke().GetPlotStyle(); PLOT_DASH_TYPE lineStyle = aShape->GetStroke().GetPlotStyle();
@ -1733,7 +1764,7 @@ void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer )
TEXT_ATTRIBUTES attrs = aText->GetAttributes(); TEXT_ATTRIBUTES attrs = aText->GetAttributes();
const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() ); const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
bool outline_mode = pcbconfig() && !pcbconfig()->m_Display.m_DisplayTextFill; bool outline_mode = !displayTextFill();
m_gal->SetStrokeColor( color ); m_gal->SetStrokeColor( color );
m_gal->SetFillColor( color ); m_gal->SetFillColor( color );
@ -1886,7 +1917,7 @@ void PCB_PAINTER::draw( const FP_TEXT* aText, int aLayer )
return; return;
const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer ); const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
bool outline_mode = pcbconfig() && !pcbconfig()->m_Display.m_DisplayTextFill; bool outline_mode = !displayTextFill();
TEXT_ATTRIBUTES attrs = aText->GetAttributes(); TEXT_ATTRIBUTES attrs = aText->GetAttributes();
m_gal->SetStrokeColor( color ); m_gal->SetStrokeColor( color );
@ -2226,7 +2257,7 @@ void PCB_PAINTER::draw( const PCB_DIMENSION_BASE* aDimension, int aLayer )
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
bool outline_mode = pcbconfig() && !pcbconfig()->m_Display.m_DisplayGraphicsFill; bool outline_mode = !displayGraphicsFill();
if( outline_mode ) if( outline_mode )
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth ); m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );

View File

@ -47,7 +47,7 @@ const int pcbnewSchemaVersion = 2;
PCBNEW_SETTINGS::PCBNEW_SETTINGS() PCBNEW_SETTINGS::PCBNEW_SETTINGS()
: APP_SETTINGS_BASE( "pcbnew", pcbnewSchemaVersion ), : PCB_VIEWERS_SETTINGS_BASE( "pcbnew", pcbnewSchemaVersion ),
m_AuiPanels(), m_AuiPanels(),
m_Cleanup(), m_Cleanup(),
m_DrcDialog(), m_DrcDialog(),
@ -162,16 +162,16 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
900 ) ); 900 ) );
m_params.emplace_back( new PARAM<bool>( "pcb_display.graphic_items_fill", m_params.emplace_back( new PARAM<bool>( "pcb_display.graphic_items_fill",
&m_Display.m_DisplayGraphicsFill, true ) ); &m_ViewersDisplay.m_DisplayGraphicsFill, true ) );
m_params.emplace_back( new PARAM<int>( "pcb_display.max_links_shown", m_params.emplace_back( new PARAM<int>( "pcb_display.max_links_shown",
&m_Display.m_MaxLinksShowed, 3, 0, 15 ) ); &m_Display.m_MaxLinksShowed, 3, 0, 15 ) );
m_params.emplace_back( new PARAM<bool>( "pcb_display.graphics_fill", m_params.emplace_back( new PARAM<bool>( "pcb_display.graphics_fill",
&m_Display.m_DisplayGraphicsFill, true ) ); &m_ViewersDisplay.m_DisplayGraphicsFill, true ) );
m_params.emplace_back( new PARAM<bool>( "pcb_display.text_fill", m_params.emplace_back( new PARAM<bool>( "pcb_display.text_fill",
&m_Display.m_DisplayTextFill, true ) ); &m_ViewersDisplay.m_DisplayTextFill, true ) );
m_params.emplace_back( new PARAM<int>( "pcb_display.net_names_mode", m_params.emplace_back( new PARAM<int>( "pcb_display.net_names_mode",
&m_Display.m_NetNames, 3, 0, 3 ) ); &m_Display.m_NetNames, 3, 0, 3 ) );
@ -183,10 +183,10 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
&m_Display.m_PadNoConnects, true ) ); &m_Display.m_PadNoConnects, true ) );
m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_fill", m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_fill",
&m_Display.m_DisplayPadFill, true ) ); &m_ViewersDisplay.m_DisplayPadFill, true ) );
m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_numbers", m_params.emplace_back( new PARAM<bool>( "pcb_display.pad_numbers",
&m_Display.m_PadNumbers, true ) ); &m_ViewersDisplay.m_DisplayPadNumbers, true ) );
m_params.emplace_back( new PARAM<bool>( "pcb_display.ratsnest_global", m_params.emplace_back( new PARAM<bool>( "pcb_display.ratsnest_global",
&m_Display.m_ShowGlobalRatsnest, true ) ); &m_Display.m_ShowGlobalRatsnest, true ) );

View File

@ -82,7 +82,34 @@ enum PCB_DISPLAY_ORIGIN
typedef std::vector<std::pair<wxString, bool>> ACTION_PLUGIN_SETTINGS_LIST; typedef std::vector<std::pair<wxString, bool>> ACTION_PLUGIN_SETTINGS_LIST;
class PCBNEW_SETTINGS : public APP_SETTINGS_BASE // base class to handle Pcbnew SETTINGS also used in Cvpcb
class PCB_VIEWERS_SETTINGS_BASE : public APP_SETTINGS_BASE
{
public:
struct VIEWERS_DISPLAY_OPTIONS
{
bool m_DisplayGraphicsFill;
bool m_DisplayTextFill;
bool m_DisplayPadNumbers;
bool m_DisplayPadFill;
};
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay;
PCB_VIEWERS_SETTINGS_BASE( const std::string& aFilename, int aSchemaVersion ):
APP_SETTINGS_BASE( aFilename, aSchemaVersion )
{
m_ViewersDisplay.m_DisplayGraphicsFill = true;
m_ViewersDisplay.m_DisplayTextFill = true;
m_ViewersDisplay.m_DisplayPadNumbers = true;
m_ViewersDisplay.m_DisplayPadFill = true;
}
virtual ~PCB_VIEWERS_SETTINGS_BASE() {};
};
class PCBNEW_SETTINGS : public PCB_VIEWERS_SETTINGS_BASE
{ {
public: public:
struct AUI_PANELS struct AUI_PANELS
@ -251,17 +278,16 @@ public:
struct DISPLAY_OPTIONS struct DISPLAY_OPTIONS
{ {
bool m_DisplayPadFill; // Note: Display options common to Cvpcb and Pcbnew are stored in
// VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay, because the section DISPLAY_OPTIONS
// exists only for Pcbnew
bool m_DisplayViaFill; bool m_DisplayViaFill;
bool m_DisplayGraphicsFill;
bool m_DisplayTextFill;
bool m_DisplayPcbTrackFill; bool m_DisplayPcbTrackFill;
TRACK_CLEARANCE_MODE m_TrackClearance; TRACK_CLEARANCE_MODE m_TrackClearance;
bool m_PadClearance; bool m_PadClearance;
int m_NetNames; int m_NetNames;
bool m_PadNumbers;
bool m_PadNoConnects; bool m_PadNoConnects;
RATSNEST_MODE m_RatsnestMode; RATSNEST_MODE m_RatsnestMode;

View File

@ -146,25 +146,25 @@ bool PCB_EDITOR_CONDITIONS::hasItemsFunc( const SELECTION& aSelection, PCB_BASE_
bool PCB_EDITOR_CONDITIONS::padNumberDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame ) bool PCB_EDITOR_CONDITIONS::padNumberDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
{ {
return aFrame->Settings().m_Display.m_PadNumbers; return aFrame->Settings().m_ViewersDisplay.m_DisplayPadNumbers;
} }
bool PCB_EDITOR_CONDITIONS::padFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame ) bool PCB_EDITOR_CONDITIONS::padFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
{ {
return aFrame->Settings().m_Display.m_DisplayPadFill; return aFrame->GetPcbNewSettings()->m_ViewersDisplay.m_DisplayPadFill;
} }
bool PCB_EDITOR_CONDITIONS::textFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame ) bool PCB_EDITOR_CONDITIONS::textFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
{ {
return aFrame->Settings().m_Display.m_DisplayTextFill; return aFrame->Settings().m_ViewersDisplay.m_DisplayTextFill;
} }
bool PCB_EDITOR_CONDITIONS::graphicsFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame ) bool PCB_EDITOR_CONDITIONS::graphicsFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
{ {
return aFrame->Settings().m_Display.m_DisplayGraphicsFill; return aFrame->Settings().m_ViewersDisplay.m_DisplayGraphicsFill;
} }

View File

@ -90,7 +90,8 @@ template<class T> void Flip( T& aValue )
int PCB_VIEWER_TOOLS::ShowPadNumbers( const TOOL_EVENT& aEvent ) int PCB_VIEWER_TOOLS::ShowPadNumbers( const TOOL_EVENT& aEvent )
{ {
Flip( displayOptions().m_PadNumbers ); PCB_VIEWERS_SETTINGS_BASE& cfg = frame()->Settings();
Flip( cfg.m_ViewersDisplay.m_DisplayPadNumbers );
for( FOOTPRINT* fp : board()->Footprints() ) for( FOOTPRINT* fp : board()->Footprints() )
{ {
@ -106,7 +107,8 @@ int PCB_VIEWER_TOOLS::ShowPadNumbers( const TOOL_EVENT& aEvent )
int PCB_VIEWER_TOOLS::PadDisplayMode( const TOOL_EVENT& aEvent ) int PCB_VIEWER_TOOLS::PadDisplayMode( const TOOL_EVENT& aEvent )
{ {
Flip( displayOptions().m_DisplayPadFill ); PCB_VIEWERS_SETTINGS_BASE& cfg = frame()->Settings();
Flip( cfg.m_ViewersDisplay.m_DisplayPadFill );
for( FOOTPRINT* fp : board()->Footprints() ) for( FOOTPRINT* fp : board()->Footprints() )
{ {
@ -122,7 +124,8 @@ int PCB_VIEWER_TOOLS::PadDisplayMode( const TOOL_EVENT& aEvent )
int PCB_VIEWER_TOOLS::GraphicOutlines( const TOOL_EVENT& aEvent ) int PCB_VIEWER_TOOLS::GraphicOutlines( const TOOL_EVENT& aEvent )
{ {
Flip( displayOptions().m_DisplayGraphicsFill ); PCB_VIEWERS_SETTINGS_BASE& cfg = frame()->Settings();
Flip( cfg.m_ViewersDisplay.m_DisplayGraphicsFill );
for( FOOTPRINT* fp : board()->Footprints() ) for( FOOTPRINT* fp : board()->Footprints() )
{ {
@ -151,7 +154,8 @@ int PCB_VIEWER_TOOLS::GraphicOutlines( const TOOL_EVENT& aEvent )
int PCB_VIEWER_TOOLS::TextOutlines( const TOOL_EVENT& aEvent ) int PCB_VIEWER_TOOLS::TextOutlines( const TOOL_EVENT& aEvent )
{ {
Flip( displayOptions().m_DisplayTextFill ); PCB_VIEWERS_SETTINGS_BASE& cfg = frame()->Settings();
Flip( cfg.m_ViewersDisplay.m_DisplayTextFill );
for( FOOTPRINT* fp : board()->Footprints() ) for( FOOTPRINT* fp : board()->Footprints() )
{ {