Cleanup.
This commit is contained in:
parent
806b5fab0e
commit
efa14e501c
|
@ -170,12 +170,9 @@ enum
|
||||||
|
|
||||||
|
|
||||||
PANEL_FP_EDITOR_DEFAULTS::PANEL_FP_EDITOR_DEFAULTS( wxWindow* aParent,
|
PANEL_FP_EDITOR_DEFAULTS::PANEL_FP_EDITOR_DEFAULTS( wxWindow* aParent,
|
||||||
EDA_BASE_FRAME* aUnitsProvider ) :
|
UNITS_PROVIDER* aUnitsProvider ) :
|
||||||
PANEL_FP_EDITOR_DEFAULTS_BASE( aParent )
|
PANEL_FP_EDITOR_DEFAULTS_BASE( aParent )
|
||||||
{
|
{
|
||||||
if( aUnitsProvider )
|
|
||||||
m_units = aUnitsProvider->GetUserUnits();
|
|
||||||
|
|
||||||
m_parent = static_cast<PAGED_DIALOG*>( aParent->GetParent() );
|
m_parent = static_cast<PAGED_DIALOG*>( aParent->GetParent() );
|
||||||
|
|
||||||
m_textItemsGrid->SetDefaultRowSize( m_textItemsGrid->GetDefaultRowSize() + 4 );
|
m_textItemsGrid->SetDefaultRowSize( m_textItemsGrid->GetDefaultRowSize() + 4 );
|
||||||
|
@ -226,29 +223,29 @@ void PANEL_FP_EDITOR_DEFAULTS::loadFPSettings( FOOTPRINT_EDITOR_SETTINGS* aCfg )
|
||||||
{
|
{
|
||||||
wxColour disabledColour = wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND );
|
wxColour disabledColour = wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND );
|
||||||
|
|
||||||
#define SET_MILS_CELL( row, col, val ) \
|
auto disableCell =
|
||||||
m_graphicsGrid->SetCellValue( row, col, EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_units, val, true ) )
|
[&]( int row, int col )
|
||||||
|
{
|
||||||
#define DISABLE_CELL( row, col ) \
|
m_graphicsGrid->SetReadOnly( row, col );
|
||||||
m_graphicsGrid->SetReadOnly( row, col ); \
|
m_graphicsGrid->SetCellBackgroundColour( row, col, disabledColour );
|
||||||
m_graphicsGrid->SetCellBackgroundColour( row, col, disabledColour );
|
};
|
||||||
|
|
||||||
for( int i = 0; i < ROW_COUNT; ++i )
|
for( int i = 0; i < ROW_COUNT; ++i )
|
||||||
{
|
{
|
||||||
SET_MILS_CELL( i, COL_LINE_THICKNESS, aCfg->m_DesignSettings.m_LineThickness[ i ] );
|
m_graphicsGrid->SetUnitValue( i, COL_LINE_THICKNESS, aCfg->m_DesignSettings.m_LineThickness[ i ] );
|
||||||
|
|
||||||
if( i == ROW_EDGES || i == ROW_COURTYARD )
|
if( i == ROW_EDGES || i == ROW_COURTYARD )
|
||||||
{
|
{
|
||||||
DISABLE_CELL( i, COL_TEXT_WIDTH );
|
disableCell( i, COL_TEXT_WIDTH );
|
||||||
DISABLE_CELL( i, COL_TEXT_HEIGHT );
|
disableCell( i, COL_TEXT_HEIGHT );
|
||||||
DISABLE_CELL( i, COL_TEXT_THICKNESS );
|
disableCell( i, COL_TEXT_THICKNESS );
|
||||||
DISABLE_CELL( i, COL_TEXT_ITALIC );
|
disableCell( i, COL_TEXT_ITALIC );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SET_MILS_CELL( i, COL_TEXT_WIDTH, aCfg->m_DesignSettings.m_TextSize[ i ].x );
|
m_graphicsGrid->SetUnitValue( i, COL_TEXT_WIDTH, aCfg->m_DesignSettings.m_TextSize[ i ].x );
|
||||||
SET_MILS_CELL( i, COL_TEXT_HEIGHT, aCfg->m_DesignSettings.m_TextSize[ i ].y );
|
m_graphicsGrid->SetUnitValue( i, COL_TEXT_HEIGHT, aCfg->m_DesignSettings.m_TextSize[ i ].y );
|
||||||
SET_MILS_CELL( i, COL_TEXT_THICKNESS, aCfg->m_DesignSettings.m_TextThickness[ i ] );
|
m_graphicsGrid->SetUnitValue( i, COL_TEXT_THICKNESS, aCfg->m_DesignSettings.m_TextThickness[ i ] );
|
||||||
m_graphicsGrid->SetCellValue( i, COL_TEXT_ITALIC, aCfg->m_DesignSettings.m_TextItalic[ i ] ? wxT( "1" ) : wxT( "" ) );
|
m_graphicsGrid->SetCellValue( i, COL_TEXT_ITALIC, aCfg->m_DesignSettings.m_TextItalic[ i ] ? wxT( "1" ) : wxT( "" ) );
|
||||||
|
|
||||||
auto attr = new wxGridCellAttr;
|
auto attr = new wxGridCellAttr;
|
||||||
|
@ -322,15 +319,6 @@ bool PANEL_FP_EDITOR_DEFAULTS::Show( bool aShow )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PANEL_FP_EDITOR_DEFAULTS::getGridValue( int aRow, int aCol )
|
|
||||||
{
|
|
||||||
wxString msg = m_graphicsGrid->GetCellValue( aRow, aCol );
|
|
||||||
double value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_units, msg );
|
|
||||||
|
|
||||||
return KiROUND<double, int>( value );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool PANEL_FP_EDITOR_DEFAULTS::validateData()
|
bool PANEL_FP_EDITOR_DEFAULTS::validateData()
|
||||||
{
|
{
|
||||||
if( !m_textItemsGrid->CommitPendingChanges() || !m_graphicsGrid->CommitPendingChanges() )
|
if( !m_textItemsGrid->CommitPendingChanges() || !m_graphicsGrid->CommitPendingChanges() )
|
||||||
|
@ -339,10 +327,10 @@ bool PANEL_FP_EDITOR_DEFAULTS::validateData()
|
||||||
// Test text parameters.
|
// Test text parameters.
|
||||||
for( int row : { ROW_SILK, ROW_COPPER, ROW_FAB, ROW_OTHERS } )
|
for( int row : { ROW_SILK, ROW_COPPER, ROW_FAB, ROW_OTHERS } )
|
||||||
{
|
{
|
||||||
int textSize = std::min( getGridValue( row, COL_TEXT_WIDTH ),
|
int textSize = std::min( m_graphicsGrid->GetUnitValue( row, COL_TEXT_WIDTH ),
|
||||||
getGridValue( row, COL_TEXT_HEIGHT ) );
|
m_graphicsGrid->GetUnitValue( row, COL_TEXT_HEIGHT ) );
|
||||||
|
|
||||||
if( getGridValue( row, COL_TEXT_THICKNESS ) > textSize / 4 )
|
if( m_graphicsGrid->GetUnitValue( row, COL_TEXT_THICKNESS ) > textSize / 4 )
|
||||||
{
|
{
|
||||||
wxString msg = _( "Text will not be readable with a thickness greater than\n"
|
wxString msg = _( "Text will not be readable with a thickness greater than\n"
|
||||||
"1/4 its width or height." );
|
"1/4 its width or height." );
|
||||||
|
@ -360,27 +348,27 @@ bool PANEL_FP_EDITOR_DEFAULTS::TransferDataFromWindow()
|
||||||
if( !validateData() )
|
if( !validateData() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
||||||
FOOTPRINT_EDITOR_SETTINGS* cfg = mgr.GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
|
BOARD_DESIGN_SETTINGS& cfg = mgr.GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>()->m_DesignSettings;
|
||||||
|
|
||||||
for( int i = 0; i < ROW_COUNT; ++i )
|
for( int i = 0; i < ROW_COUNT; ++i )
|
||||||
{
|
{
|
||||||
cfg->m_DesignSettings.m_LineThickness[ i ] = getGridValue( i, COL_LINE_THICKNESS );
|
cfg.m_LineThickness[ i ] = m_graphicsGrid->GetUnitValue( i, COL_LINE_THICKNESS );
|
||||||
|
|
||||||
if( i == ROW_EDGES || i == ROW_COURTYARD )
|
if( i == ROW_EDGES || i == ROW_COURTYARD )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
cfg->m_DesignSettings.m_TextSize[ i ] = wxSize( getGridValue( i, COL_TEXT_WIDTH ),
|
cfg.m_TextSize[ i ] = wxSize( m_graphicsGrid->GetUnitValue( i, COL_TEXT_WIDTH ),
|
||||||
getGridValue( i, COL_TEXT_HEIGHT ) );
|
m_graphicsGrid->GetUnitValue( i, COL_TEXT_HEIGHT ) );
|
||||||
cfg->m_DesignSettings.m_TextThickness[ i ] = getGridValue( i, COL_TEXT_THICKNESS );
|
cfg.m_TextThickness[ i ] = m_graphicsGrid->GetUnitValue( i, COL_TEXT_THICKNESS );
|
||||||
|
|
||||||
wxString msg = m_graphicsGrid->GetCellValue( i, COL_TEXT_ITALIC );
|
wxString msg = m_graphicsGrid->GetCellValue( i, COL_TEXT_ITALIC );
|
||||||
cfg->m_DesignSettings.m_TextItalic[ i ] = wxGridCellBoolEditor::IsTrueValue( msg );
|
cfg.m_TextItalic[ i ] = wxGridCellBoolEditor::IsTrueValue( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Footprint defaults
|
// Footprint defaults
|
||||||
wxGridTableBase* table = m_textItemsGrid->GetTable();
|
wxGridTableBase* table = m_textItemsGrid->GetTable();
|
||||||
cfg->m_DesignSettings.m_DefaultFPTextItems.clear();
|
cfg.m_DefaultFPTextItems.clear();
|
||||||
|
|
||||||
for( int i = 0; i < m_textItemsGrid->GetNumberRows(); ++i )
|
for( int i = 0; i < m_textItemsGrid->GetNumberRows(); ++i )
|
||||||
{
|
{
|
||||||
|
@ -388,7 +376,7 @@ bool PANEL_FP_EDITOR_DEFAULTS::TransferDataFromWindow()
|
||||||
bool visible = table->GetValueAsBool( i, 1 );
|
bool visible = table->GetValueAsBool( i, 1 );
|
||||||
int layer = (int) table->GetValueAsLong( i, 2 );
|
int layer = (int) table->GetValueAsLong( i, 2 );
|
||||||
|
|
||||||
cfg->m_DesignSettings.m_DefaultFPTextItems.emplace_back( text, visible, layer );
|
cfg.m_DefaultFPTextItems.emplace_back( text, visible, layer );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -29,7 +29,7 @@ class FOOTPRINT_EDITOR_SETTINGS;
|
||||||
class PANEL_FP_EDITOR_DEFAULTS : public PANEL_FP_EDITOR_DEFAULTS_BASE
|
class PANEL_FP_EDITOR_DEFAULTS : public PANEL_FP_EDITOR_DEFAULTS_BASE
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PANEL_FP_EDITOR_DEFAULTS( wxWindow* aParent, EDA_BASE_FRAME* aUnitsProvider );
|
PANEL_FP_EDITOR_DEFAULTS( wxWindow* aParent, UNITS_PROVIDER* aUnitsProvider );
|
||||||
~PANEL_FP_EDITOR_DEFAULTS() override;
|
~PANEL_FP_EDITOR_DEFAULTS() override;
|
||||||
|
|
||||||
bool TransferDataToWindow() override;
|
bool TransferDataToWindow() override;
|
||||||
|
@ -43,14 +43,11 @@ private:
|
||||||
|
|
||||||
bool Show( bool aShow ) override;
|
bool Show( bool aShow ) override;
|
||||||
|
|
||||||
int getGridValue( int aRow, int aCol );
|
|
||||||
|
|
||||||
bool validateData();
|
bool validateData();
|
||||||
|
|
||||||
void loadFPSettings( FOOTPRINT_EDITOR_SETTINGS* aCfg );
|
void loadFPSettings( FOOTPRINT_EDITOR_SETTINGS* aCfg );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EDA_UNITS m_units = EDA_UNITS::MILLIMETRES;
|
|
||||||
PAGED_DIALOG* m_parent;
|
PAGED_DIALOG* m_parent;
|
||||||
bool m_firstShow = true;
|
bool m_firstShow = true;
|
||||||
};
|
};
|
||||||
|
|
|
@ -158,8 +158,8 @@ static struct IFACE : public KIFACE_BASE
|
||||||
|
|
||||||
if( !unitsProvider )
|
if( !unitsProvider )
|
||||||
{
|
{
|
||||||
// If we can't find an eeschema frame we'll have to make do with the units
|
// If we can't find a pcb-type frame we'll have to make do with whatever FRAME
|
||||||
// defined in whatever FRAME we _can_ find.
|
// we _can_ find.
|
||||||
for( unsigned i = 0; !unitsProvider && i < KIWAY_PLAYER_COUNT; ++i )
|
for( unsigned i = 0; !unitsProvider && i < KIWAY_PLAYER_COUNT; ++i )
|
||||||
unitsProvider = aKiway->Player( (FRAME_T) i, false );
|
unitsProvider = aKiway->Player( (FRAME_T) i, false );
|
||||||
}
|
}
|
||||||
|
@ -168,6 +168,7 @@ static struct IFACE : public KIFACE_BASE
|
||||||
{
|
{
|
||||||
wxWindow* manager = wxFindWindowByName( KICAD_MANAGER_FRAME_NAME );
|
wxWindow* manager = wxFindWindowByName( KICAD_MANAGER_FRAME_NAME );
|
||||||
unitsProvider = static_cast<EDA_BASE_FRAME*>( manager );
|
unitsProvider = static_cast<EDA_BASE_FRAME*>( manager );
|
||||||
|
wxASSERT( unitsProvider );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( aClassId == PANEL_FP_EDIT_OPTIONS )
|
if( aClassId == PANEL_FP_EDIT_OPTIONS )
|
||||||
|
|
Loading…
Reference in New Issue