Tidy renderSettings / jobsHandler APIs.

This commit is contained in:
Jeff Young 2024-04-08 12:26:56 +01:00
parent 5abc7145da
commit 9c94967b52
20 changed files with 65 additions and 78 deletions

View File

@ -402,7 +402,7 @@ void DIALOG_PIN_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
SCH_RENDER_SETTINGS renderSettings( *symbolEditor->GetRenderSettings() );
renderSettings.m_ShowPinNumbers = true;
renderSettings.m_ShowPinNames = true;
renderSettings.m_ShowHiddenLibFields = true;
renderSettings.m_ShowHiddenFields = true;
renderSettings.m_ShowConnectionPoints = true;
renderSettings.m_Transform = DefaultTransform;
renderSettings.SetPrintDC( &dc );

View File

@ -684,19 +684,6 @@ int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob,
}
}
if( aSvgJob->m_includeHiddenPins )
{
// horrible hack, TODO overhaul the Plot method to handle this
for( SCH_ITEM& item : symbolToPlot->GetDrawItems() )
{
if( item.Type() != LIB_PIN_T )
continue;
LIB_PIN& pin = static_cast<LIB_PIN&>( item );
pin.SetVisible( true );
}
}
// iterate from unit 1, unit 0 would be "all units" which we don't want
for( int unit = 1; unit < symbol->GetUnitCount() + 1; unit++ )
{
@ -783,12 +770,10 @@ int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob,
// note, we want the fields from the original symbol pointer (in case of non-alias)
symbolToPlot->Plot( plotter, background, plotOpts, unit, bodyStyle, offset, false );
symbol->PlotFields( plotter, background, plotOpts, unit, bodyStyle, offset, false,
aSvgJob->m_includeHiddenFields );
symbol->PlotFields( plotter, background, plotOpts, unit, bodyStyle, offset, false );
symbolToPlot->Plot( plotter, !background, plotOpts, unit, bodyStyle, offset, false );
symbol->PlotFields( plotter, !background, plotOpts, unit, bodyStyle, offset, false,
aSvgJob->m_includeHiddenFields );
symbol->PlotFields( plotter, !background, plotOpts, unit, bodyStyle, offset, false );
plotter->EndPlot();
delete plotter;
@ -845,6 +830,8 @@ int EESCHEMA_JOBS_HANDLER::JobSymExportSvg( JOB* aJob )
COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings( svgJob->m_colorTheme );
renderSettings.LoadColors( cs );
renderSettings.SetDefaultPenWidth( DEFAULT_LINE_WIDTH_MILS * schIUScale.IU_PER_MILS );
renderSettings.m_ShowHiddenPins = svgJob->m_includeHiddenPins;
renderSettings.m_ShowHiddenFields = svgJob->m_includeHiddenFields;
int exitCode = CLI::EXIT_CODES::OK;

View File

@ -206,7 +206,7 @@ void LIB_PIN::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyS
/* Calculate the pin position */
VECTOR2I pos1 = aSettings->TransformCoordinate( m_position ) + aOffset;
if( IsVisible() || aSettings->m_ShowHiddenLibFields )
if( IsVisible() || aSettings->m_ShowHiddenFields )
{
printPinSymbol( aSettings, pos1, orient, aDimmed );

View File

@ -752,10 +752,10 @@ void LIB_SYMBOL::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBo
{
LIB_FIELD& field = static_cast<LIB_FIELD&>( item );
if( field.IsVisible() && !aSettings->m_ShowVisibleLibFields )
if( field.IsVisible() && !aSettings->m_ShowVisibleFields )
continue;
if( !field.IsVisible() && !aSettings->m_ShowHiddenLibFields )
if( !field.IsVisible() && !aSettings->m_ShowHiddenFields )
continue;
}
@ -861,8 +861,7 @@ void LIB_SYMBOL::Plot( PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS&
void LIB_SYMBOL::PlotFields( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed,
bool aPlotHidden )
int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
{
wxASSERT( aPlotter != nullptr );
@ -888,7 +887,7 @@ void LIB_SYMBOL::PlotFields( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT
LIB_FIELD& field = static_cast<LIB_FIELD&>( item );
if( !aPlotHidden && !field.IsVisible() )
if( !renderSettings->m_ShowHiddenFields && !field.IsVisible() )
continue;
// The reference is a special case: we should change the basic text

View File

@ -364,8 +364,7 @@ public:
* Plot symbol fields.
*/
void PlotFields( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed,
bool aPlotHidden );
int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed );
/**
* Add a new draw \a aItem to the draw object list and sort according to \a aSort.

View File

@ -1029,7 +1029,7 @@ void SCH_PAINTER::draw( const LIB_FIELD* aField, int aLayer, bool aDimmed )
if( !( aField->IsVisible() || aField->IsForceVisible() ) )
{
bool force_show = m_schematic ? eeconfig()->m_Appearance.show_hidden_fields
: m_schSettings.m_ShowHiddenLibFields;
: m_schSettings.m_ShowHiddenFields;
if( force_show )
color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows, aDimmed );
@ -1362,7 +1362,8 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed )
return;
bool force_show = m_schematic ? eeconfig()->m_Appearance.show_hidden_pins
: m_schSettings.m_ShowHiddenLibPins;
: m_schSettings.m_ShowHiddenPins;
if( force_show )
{
color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows, aDimmed );

View File

@ -35,9 +35,9 @@ SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() :
m_ShowUnit( 0 ),
m_ShowBodyStyle( 0 ),
m_ShowPinsElectricalType( true ),
m_ShowHiddenLibPins( true ), // Force showing of hidden pin ( symbol editor specific)
m_ShowHiddenLibFields( true ), // Force showing of hidden fields ( symbol editor specific)
m_ShowVisibleLibFields( true ),
m_ShowHiddenPins( true ),
m_ShowHiddenFields( true ),
m_ShowVisibleFields( true ),
m_ShowPinNumbers( false ),
m_ShowPinNames( false ),
m_ShowPinElectricalTypes( false ),

View File

@ -81,9 +81,9 @@ public:
int m_ShowBodyStyle; // Show all body styles if 0
bool m_ShowPinsElectricalType;
bool m_ShowHiddenLibPins; // Force showing of hidden pin ( symbol editor specific)
bool m_ShowHiddenLibFields; // Force showing of hidden fields ( symbol editor specific)
bool m_ShowVisibleLibFields;
bool m_ShowHiddenPins;
bool m_ShowHiddenFields;
bool m_ShowVisibleFields;
bool m_ShowPinNumbers; // Force showing of pin numbers (normally symbol-specific)
bool m_ShowPinNames; // Force showing of pin names (normally symbol-specific)
bool m_ShowPinElectricalTypes;

View File

@ -492,8 +492,8 @@ void SCH_SYMBOL::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUni
{
SCH_RENDER_SETTINGS cfg( *aSettings );
cfg.m_Transform = m_transform;
cfg.m_ShowVisibleLibFields = false;
cfg.m_ShowHiddenLibFields = false;
cfg.m_ShowVisibleFields = false;
cfg.m_ShowHiddenFields = false;
if( GetDNP() )
aDimmed = true;
@ -508,8 +508,8 @@ void SCH_SYMBOL::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBo
{
SCH_RENDER_SETTINGS cfg( *aSettings );
cfg.m_Transform = m_transform;
cfg.m_ShowVisibleLibFields = false;
cfg.m_ShowHiddenLibFields = false;
cfg.m_ShowVisibleFields = false;
cfg.m_ShowHiddenFields = false;
if( m_DNP )
aDimmed = true;

View File

@ -125,9 +125,9 @@ void SYMBOL_EDIT_FRAME::doReCreateMenuBar()
viewMenu->Add( ACTIONS::zoomRedraw );
viewMenu->AppendSeparator();
viewMenu->Add( EE_ACTIONS::showSymbolTree, ACTION_MENU::CHECK );
viewMenu->Add( EE_ACTIONS::showHiddenLibPins, ACTION_MENU::CHECK );
viewMenu->Add( EE_ACTIONS::showHiddenLibFields, ACTION_MENU::CHECK );
viewMenu->Add( EE_ACTIONS::showSymbolTree, ACTION_MENU::CHECK );
viewMenu->Add( EE_ACTIONS::showHiddenPins, ACTION_MENU::CHECK );
viewMenu->Add( EE_ACTIONS::showHiddenFields, ACTION_MENU::CHECK );
//-- Place menu -----------------------------------------------

View File

@ -323,8 +323,8 @@ void SYMBOL_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
SCH_BASE_FRAME::LoadSettings( GetSettings() );
GetRenderSettings()->m_ShowPinsElectricalType = m_settings->m_ShowPinElectricalType;
GetRenderSettings()->m_ShowHiddenLibPins = m_settings->m_ShowHiddenLibPins;
GetRenderSettings()->m_ShowHiddenLibFields = m_settings->m_ShowHiddenLibFields;
GetRenderSettings()->m_ShowHiddenPins = m_settings->m_ShowHiddenPins;
GetRenderSettings()->m_ShowHiddenFields = m_settings->m_ShowHiddenFields;
GetRenderSettings()->SetDefaultFont( wxEmptyString );
}
@ -338,10 +338,10 @@ void SYMBOL_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
SCH_BASE_FRAME::SaveSettings( GetSettings() );
m_settings->m_ShowPinElectricalType = GetRenderSettings()->m_ShowPinsElectricalType;
m_settings->m_ShowHiddenLibPins = GetRenderSettings()->m_ShowHiddenLibPins;
m_settings->m_ShowHiddenLibFields = GetRenderSettings()->m_ShowHiddenLibFields;
m_settings->m_ShowHiddenPins = GetRenderSettings()->m_ShowHiddenPins;
m_settings->m_ShowHiddenFields = GetRenderSettings()->m_ShowHiddenFields;
m_settings->m_LibWidth = m_treePane->GetSize().x;
m_settings->m_LibWidth = m_treePane->GetSize().x;
m_settings->m_LibrarySortMode = m_treePane->GetLibTree()->GetSortMode();
@ -497,13 +497,13 @@ void SYMBOL_EDIT_FRAME::setupUIConditions()
auto hiddenPinCond =
[this]( const SELECTION& )
{
return GetRenderSettings() && GetRenderSettings()->m_ShowHiddenLibPins;
return GetRenderSettings() && GetRenderSettings()->m_ShowHiddenPins;
};
auto hiddenFieldCond =
[this]( const SELECTION& )
{
return GetRenderSettings() && GetRenderSettings()->m_ShowHiddenLibFields;
return GetRenderSettings() && GetRenderSettings()->m_ShowHiddenFields;
};
auto showCompTreeCond =
@ -522,8 +522,8 @@ void SYMBOL_EDIT_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) );
mgr->SetConditions( EE_ACTIONS::showSymbolTree, CHECK( showCompTreeCond ) );
mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) );
mgr->SetConditions( EE_ACTIONS::showHiddenLibPins, CHECK( hiddenPinCond ) );
mgr->SetConditions( EE_ACTIONS::showHiddenLibFields, CHECK( hiddenFieldCond ) );
mgr->SetConditions( EE_ACTIONS::showHiddenPins, CHECK( hiddenPinCond ) );
mgr->SetConditions( EE_ACTIONS::showHiddenFields, CHECK( hiddenFieldCond ) );
auto demorganCond =
[this]( const SELECTION& )
@ -1253,8 +1253,8 @@ void SYMBOL_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextV
SYMBOL_EDITOR_SETTINGS* cfg = mgr->GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
GetRenderSettings()->m_ShowPinsElectricalType = cfg->m_ShowPinElectricalType;
GetRenderSettings()->m_ShowHiddenLibPins = cfg->m_ShowHiddenLibPins;
GetRenderSettings()->m_ShowHiddenLibFields = cfg->m_ShowHiddenLibFields;
GetRenderSettings()->m_ShowHiddenPins = cfg->m_ShowHiddenPins;
GetRenderSettings()->m_ShowHiddenFields = cfg->m_ShowHiddenFields;
GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
@ -1883,12 +1883,12 @@ void SYMBOL_EDIT_FRAME::updateSelectionFilterVisbility()
bool SYMBOL_EDIT_FRAME::GetShowInvisibleFields()
{
// Returns the current render option for invisible fields
return GetRenderSettings()->m_ShowHiddenLibFields;
return GetRenderSettings()->m_ShowHiddenFields;
}
bool SYMBOL_EDIT_FRAME::GetShowInvisiblePins()
{
// Returns the current render option for invisible pins
return GetRenderSettings()->m_ShowHiddenLibPins;
return GetRenderSettings()->m_ShowHiddenPins;
}

View File

@ -68,7 +68,7 @@ void SYMBOL_EDIT_FRAME::SVGPlotSymbol( const wxString& aFullFileName, const VECT
m_symbol->Plot( plotter, background, plotOpts, GetUnit(), GetBodyStyle(), aOffset, false );
m_symbol->Plot( plotter, !background, plotOpts, GetUnit(), GetBodyStyle(), aOffset, false );
m_symbol->PlotFields( plotter, !background, plotOpts, GetUnit(), GetBodyStyle(), aOffset,
false, GetShowInvisibleFields() );
false );
}
plotter->EndPlot();

View File

@ -104,10 +104,10 @@ SYMBOL_EDITOR_SETTINGS::SYMBOL_EDITOR_SETTINGS() :
&m_ShowPinElectricalType, true ) );
m_params.emplace_back( new PARAM<bool>( "show_hidden_lib_fields",
&m_ShowHiddenLibFields, true ) );
&m_ShowHiddenFields, true ) );
m_params.emplace_back( new PARAM<bool>( "show_hidden_lib_pins",
&m_ShowHiddenLibPins, true ) );
&m_ShowHiddenPins, true ) );
m_params.emplace_back( new PARAM<int>( "lib_table_width",
&m_LibWidth, 250 ) );

View File

@ -81,8 +81,8 @@ public:
DIALOG_IMPORT_GRAPHICS m_ImportGraphics;
bool m_ShowPinElectricalType;
bool m_ShowHiddenLibPins;
bool m_ShowHiddenLibFields;
bool m_ShowHiddenPins;
bool m_ShowHiddenFields;
int m_LibWidth;

View File

@ -168,8 +168,8 @@ void SYMBOL_EDIT_FRAME::ReCreateOptToolbar()
m_optionsToolBar->AddScaledSeparator( this );
m_optionsToolBar->Add( EE_ACTIONS::showElectricalTypes, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( EE_ACTIONS::showHiddenLibPins, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( EE_ACTIONS::showHiddenLibFields, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( EE_ACTIONS::showHiddenPins, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( EE_ACTIONS::showHiddenFields, ACTION_TOOLBAR::TOGGLE );
if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes )
m_optionsToolBar->Add( ACTIONS::toggleBoundingBoxes, ACTION_TOOLBAR::TOGGLE );

View File

@ -319,15 +319,15 @@ TOOL_ACTION EE_ACTIONS::toggleSyncedPinsMode( TOOL_ACTION_ARGS()
"Enabled by default for multiunit parts with interchangeable units." ) )
.Icon( BITMAPS::pin2pin ) );
TOOL_ACTION EE_ACTIONS::showHiddenLibPins( TOOL_ACTION_ARGS()
.Name( "eeschema.SymbolLibraryControl.showHiddenLibPins" )
TOOL_ACTION EE_ACTIONS::showHiddenPins( TOOL_ACTION_ARGS()
.Name( "eeschema.SymbolLibraryControl.showHiddenPins" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Show Hidden Pins" ) )
.Tooltip( _( "Toggle display of hidden pins" ) )
.Icon( BITMAPS::hidden_pin ) );
TOOL_ACTION EE_ACTIONS::showHiddenLibFields( TOOL_ACTION_ARGS()
.Name( "eeschema.SymbolLibraryControl.showHiddenLibFields" )
TOOL_ACTION EE_ACTIONS::showHiddenFields( TOOL_ACTION_ARGS()
.Name( "eeschema.SymbolLibraryControl.showHiddenFields" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Show Hidden Fields" ) )
.Tooltip( _( "Toggle display of hidden text fields" ) )

View File

@ -230,8 +230,8 @@ public:
// Miscellaneous
static TOOL_ACTION toggleHiddenPins;
static TOOL_ACTION toggleHiddenFields;
static TOOL_ACTION showHiddenLibPins;
static TOOL_ACTION showHiddenLibFields;
static TOOL_ACTION showHiddenPins;
static TOOL_ACTION showHiddenFields;
static TOOL_ACTION toggleDirectiveLabels;
static TOOL_ACTION toggleERCWarnings;
static TOOL_ACTION toggleERCErrors;

View File

@ -606,11 +606,11 @@ int SYMBOL_EDITOR_CONTROL::ToggleSyncedPinsMode( const TOOL_EVENT& aEvent )
}
int SYMBOL_EDITOR_CONTROL::ToggleHiddenLibPins( const TOOL_EVENT& aEvent )
int SYMBOL_EDITOR_CONTROL::ToggleHiddenPins( const TOOL_EVENT& aEvent )
{
SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
editFrame->GetRenderSettings()->m_ShowHiddenLibPins =
!editFrame->GetRenderSettings()->m_ShowHiddenLibPins;
editFrame->GetRenderSettings()->m_ShowHiddenPins =
!editFrame->GetRenderSettings()->m_ShowHiddenPins;
getView()->UpdateAllItems( KIGFX::REPAINT );
editFrame->GetCanvas()->Refresh();
@ -619,11 +619,11 @@ int SYMBOL_EDITOR_CONTROL::ToggleHiddenLibPins( const TOOL_EVENT& aEvent )
}
int SYMBOL_EDITOR_CONTROL::ToggleHiddenLibFields( const TOOL_EVENT& aEvent )
int SYMBOL_EDITOR_CONTROL::ToggleHiddenFields( const TOOL_EVENT& aEvent )
{
SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
editFrame->GetRenderSettings()->m_ShowHiddenLibFields =
!editFrame->GetRenderSettings()->m_ShowHiddenLibFields;
editFrame->GetRenderSettings()->m_ShowHiddenFields =
!editFrame->GetRenderSettings()->m_ShowHiddenFields;
getView()->UpdateAllItems( KIGFX::REPAINT );
editFrame->GetCanvas()->Refresh();
@ -827,6 +827,6 @@ void SYMBOL_EDITOR_CONTROL::setTransitions()
Go( &SYMBOL_EDITOR_CONTROL::ToggleSyncedPinsMode, EE_ACTIONS::toggleSyncedPinsMode.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ToggleProperties, ACTIONS::showProperties.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ToggleHiddenLibPins, EE_ACTIONS::showHiddenLibPins.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ToggleHiddenLibFields, EE_ACTIONS::showHiddenLibFields.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ToggleHiddenPins, EE_ACTIONS::showHiddenPins.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ToggleHiddenFields, EE_ACTIONS::showHiddenFields.MakeEvent() );
}

View File

@ -72,8 +72,8 @@ public:
int ToggleProperties( const TOOL_EVENT& aEvent );
int ToggleSyncedPinsMode( const TOOL_EVENT& aEvent );
int ToggleHiddenLibPins( const TOOL_EVENT& aEvent );
int ToggleHiddenLibFields( const TOOL_EVENT& aEvent );
int ToggleHiddenPins( const TOOL_EVENT& aEvent );
int ToggleHiddenFields( const TOOL_EVENT& aEvent );
int DdAddLibrary( const TOOL_EVENT& aEvent );

View File

@ -86,7 +86,8 @@ SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY* aKiway,
settings->m_ShowPinsElectricalType = app_settings->m_LibViewPanel.show_pin_electrical_type;
settings->m_ShowPinNumbers = app_settings->m_LibViewPanel.show_pin_numbers;
settings->m_ShowHiddenLibFields = false;
settings->m_ShowHiddenPins = false;
settings->m_ShowHiddenFields = false;
m_outerSizer = new wxBoxSizer( wxVERTICAL );