Hook up Import Settings to tuning patterns and custom rules.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15980
This commit is contained in:
Jeff Young 2023-10-30 18:12:26 +00:00
parent 87571ed8b8
commit 42d9bc4a98
10 changed files with 221 additions and 3 deletions

View File

@ -69,6 +69,7 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
m_teardropsPage( 0 ),
m_tuningPatternsPage( 0 ),
m_netclassesPage( 0 ),
m_customRulesPage( 0 ),
m_severitiesPage( 0 )
{
@ -183,6 +184,7 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
false );
}, _( "Net Classes" ) );
m_customRulesPage = m_treebook->GetPageCount();
m_treebook->AddLazySubPage(
[this]( wxWindow* aParent ) -> wxWindow*
{
@ -378,12 +380,24 @@ void DIALOG_BOARD_SETUP::onAuxiliaryAction( wxCommandEvent& aEvent )
m_teardropsPage )->ImportSettingsFrom( otherBoard );
}
if( importDlg.m_TuningPatternsOpt->GetValue() )
{
RESOLVE_PAGE( PANEL_SETUP_TUNING_PATTERNS,
m_tuningPatternsPage )->ImportSettingsFrom( otherBoard );
}
if( importDlg.m_MaskAndPasteOpt->GetValue() )
{
RESOLVE_PAGE( PANEL_SETUP_MASK_AND_PASTE,
m_maskAndPagePage )->ImportSettingsFrom( otherBoard );
}
if( importDlg.m_CustomRulesOpt->GetValue() )
{
RESOLVE_PAGE( PANEL_SETUP_RULES,
m_customRulesPage )->ImportSettingsFrom( otherBoard );
}
if( importDlg.m_SeveritiesOpt->GetValue() )
{
BOARD_DESIGN_SETTINGS& otherSettings = otherBoard->GetDesignSettings();

View File

@ -70,6 +70,7 @@ private:
size_t m_teardropsPage;
size_t m_tuningPatternsPage;
size_t m_netclassesPage;
size_t m_customRulesPage;
size_t m_severitiesPage;
};

View File

@ -82,7 +82,8 @@ bool DIALOG_IMPORT_SETTINGS::UpdateImportSettingsButton()
bool buttonEnableState = ( m_LayersOpt->IsChecked() || m_MaskAndPasteOpt->IsChecked()
|| m_ConstraintsOpt->IsChecked() || m_NetclassesOpt->IsChecked()
|| m_SeveritiesOpt->IsChecked() || m_TextAndGraphicsOpt->IsChecked()
|| m_FormattingOpt->IsChecked() || m_TracksAndViasOpt->IsChecked() );
|| m_FormattingOpt->IsChecked() || m_TracksAndViasOpt->IsChecked()
|| m_TuningPatternsOpt->IsChecked() || m_CustomRulesOpt->IsChecked() );
m_sdbSizer1OK->Enable( buttonEnableState );
@ -144,6 +145,8 @@ void DIALOG_IMPORT_SETTINGS::OnSelectAll( wxCommandEvent& event )
m_TracksAndViasOpt->SetValue( m_showSelectAllOnBtn );
m_MaskAndPasteOpt->SetValue( m_showSelectAllOnBtn );
m_SeveritiesOpt->SetValue( m_showSelectAllOnBtn );
m_TuningPatternsOpt->SetValue( m_showSelectAllOnBtn );
m_CustomRulesOpt->SetValue( m_showSelectAllOnBtn );
// Ensure "Import Settings" button state is enabled as appropriate
UpdateImportSettingsButton();

View File

@ -69,9 +69,15 @@ DIALOG_IMPORT_SETTINGS_BASE::DIALOG_IMPORT_SETTINGS_BASE( wxWindow* parent, wxWi
m_TeardropsOpt = new wxCheckBox( this, wxID_ANY, _("Teardrop defaults"), wxDefaultPosition, wxDefaultSize, 0 );
bLeftCol->Add( m_TeardropsOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_TuningPatternsOpt = new wxCheckBox( this, wxID_ANY, _("Length-tuning pattern defaults"), wxDefaultPosition, wxDefaultSize, 0 );
bLeftCol->Add( m_TuningPatternsOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_NetclassesOpt = new wxCheckBox( this, wxID_ANY, _("Net classes"), wxDefaultPosition, wxDefaultSize, 0 );
bLeftCol->Add( m_NetclassesOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_CustomRulesOpt = new wxCheckBox( this, wxID_ANY, _("Custom rules"), wxDefaultPosition, wxDefaultSize, 0 );
bLeftCol->Add( m_CustomRulesOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_SeveritiesOpt = new wxCheckBox( this, wxID_ANY, _("Violation severities"), wxDefaultPosition, wxDefaultSize, 0 );
bLeftCol->Add( m_SeveritiesOpt, 0, wxRIGHT|wxLEFT, 5 );
@ -112,7 +118,9 @@ DIALOG_IMPORT_SETTINGS_BASE::DIALOG_IMPORT_SETTINGS_BASE( wxWindow* parent, wxWi
m_TextAndGraphicsOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_SETTINGS_BASE::OnCheckboxClicked ), NULL, this );
m_ConstraintsOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_SETTINGS_BASE::OnCheckboxClicked ), NULL, this );
m_TracksAndViasOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_SETTINGS_BASE::OnCheckboxClicked ), NULL, this );
m_TuningPatternsOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_SETTINGS_BASE::OnCheckboxClicked ), NULL, this );
m_NetclassesOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_SETTINGS_BASE::OnCheckboxClicked ), NULL, this );
m_CustomRulesOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_SETTINGS_BASE::OnCheckboxClicked ), NULL, this );
m_SeveritiesOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_SETTINGS_BASE::OnCheckboxClicked ), NULL, this );
m_selectAllButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_SETTINGS_BASE::OnSelectAll ), NULL, this );
}
@ -126,7 +134,9 @@ DIALOG_IMPORT_SETTINGS_BASE::~DIALOG_IMPORT_SETTINGS_BASE()
m_TextAndGraphicsOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_SETTINGS_BASE::OnCheckboxClicked ), NULL, this );
m_ConstraintsOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_SETTINGS_BASE::OnCheckboxClicked ), NULL, this );
m_TracksAndViasOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_SETTINGS_BASE::OnCheckboxClicked ), NULL, this );
m_TuningPatternsOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_SETTINGS_BASE::OnCheckboxClicked ), NULL, this );
m_NetclassesOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_SETTINGS_BASE::OnCheckboxClicked ), NULL, this );
m_CustomRulesOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_SETTINGS_BASE::OnCheckboxClicked ), NULL, this );
m_SeveritiesOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_SETTINGS_BASE::OnCheckboxClicked ), NULL, this );
m_selectAllButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_IMPORT_SETTINGS_BASE::OnSelectAll ), NULL, this );

View File

@ -803,6 +803,71 @@
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Length-tuning pattern defaults</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_TuningPatternsOpt</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">public</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnCheckBox">OnCheckboxClicked</event>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>
@ -868,6 +933,71 @@
<event name="OnCheckBox">OnCheckboxClicked</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Custom rules</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_CustomRulesOpt</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">public</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnCheckBox">OnCheckboxClicked</event>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxRIGHT|wxLEFT</property>

View File

@ -62,7 +62,9 @@ class DIALOG_IMPORT_SETTINGS_BASE : public DIALOG_SHIM
wxCheckBox* m_ConstraintsOpt;
wxCheckBox* m_TracksAndViasOpt;
wxCheckBox* m_TeardropsOpt;
wxCheckBox* m_TuningPatternsOpt;
wxCheckBox* m_NetclassesOpt;
wxCheckBox* m_CustomRulesOpt;
wxCheckBox* m_SeveritiesOpt;
DIALOG_IMPORT_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Import Settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );

View File

@ -38,6 +38,7 @@
#include <drc/drc_rule_parser.h>
#include <tools/drc_tool.h>
#include <pgm_base.h>
#include "wildcards_and_files_ext.h"
PANEL_SETUP_RULES::PANEL_SETUP_RULES( wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame ) :
PANEL_SETUP_RULES_BASE( aParentWindow ),
@ -706,3 +707,34 @@ void PANEL_SETUP_RULES::OnSyntaxHelp( wxHyperlinkEvent& aEvent )
m_helpWindow->ShowModeless();
}
void PANEL_SETUP_RULES::ImportSettingsFrom( BOARD* aBoard )
{
if( !m_frame->Prj().IsNullProject() )
{
wxFileName relFile = aBoard->GetFileName();
relFile.SetExt( DesignRulesFileExtension );
wxFileName absFile( aBoard->GetProject()->AbsolutePath( relFile.GetFullName() ) );
if( absFile.FileExists() )
{
wxTextFile file( absFile.GetFullPath() );
if( file.Open() )
{
for ( wxString str = file.GetFirstLine(); !file.Eof(); str = file.GetNextLine() )
{
ConvertSmartQuotesAndDashes( &str );
m_textEditor->AddText( str << '\n' );
}
m_textEditor->EmptyUndoBuffer();
wxCommandEvent dummy;
OnCompile( dummy );
}
}
}
}

View File

@ -41,6 +41,8 @@ public:
PANEL_SETUP_RULES( wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame );
~PANEL_SETUP_RULES( ) override;
void ImportSettingsFrom( BOARD* aBoard );
private:
void onScintillaCharAdded( wxStyledTextEvent &aEvent );

View File

@ -22,6 +22,8 @@
#include <widgets/text_ctrl_eval.h>
#include <bitmaps.h>
#include <eda_draw_frame.h>
#include <board.h>
#include <board_design_settings.h>
PANEL_SETUP_TUNING_PATTERNS::PANEL_SETUP_TUNING_PATTERNS( wxWindow* aParent, EDA_DRAW_FRAME* aFrame,
PNS::MEANDER_SETTINGS& aTrackSettings,
@ -87,7 +89,7 @@ bool PANEL_SETUP_TUNING_PATTERNS::TransferDataFromWindow()
m_trackSettings.m_spacing = m_track_spacing.GetIntValue();
m_trackSettings.m_cornerStyle = m_track_cornerCtrl->GetSelection() ? PNS::MEANDER_STYLE_ROUND
: PNS::MEANDER_STYLE_CHAMFER;
m_trackSettings.m_cornerRadiusPercentage = m_track_r.GetValue();
m_trackSettings.m_cornerRadiusPercentage = m_track_r.GetIntValue();
m_trackSettings.m_singleSided = m_track_singleSided->GetValue();
m_dpSettings.m_minAmplitude = m_dp_minA.GetIntValue();
@ -104,7 +106,24 @@ bool PANEL_SETUP_TUNING_PATTERNS::TransferDataFromWindow()
m_skewSettings.m_spacing = m_skew_spacing.GetIntValue();
m_skewSettings.m_cornerStyle = m_skew_cornerCtrl->GetSelection() ? PNS::MEANDER_STYLE_ROUND
: PNS::MEANDER_STYLE_CHAMFER;
m_skewSettings.m_cornerRadiusPercentage = m_skew_r.GetValue();
m_skewSettings.m_cornerRadiusPercentage = m_skew_r.GetIntValue();
return true;
}
void PANEL_SETUP_TUNING_PATTERNS::ImportSettingsFrom( BOARD* aBoard )
{
PNS::MEANDER_SETTINGS savedTrackSettings = m_trackSettings;
PNS::MEANDER_SETTINGS savedDPSettings = m_dpSettings;
PNS::MEANDER_SETTINGS savedSkewSettings = m_skewSettings;
m_trackSettings = aBoard->GetDesignSettings().m_singleTrackMeanderSettings;
m_dpSettings = aBoard->GetDesignSettings().m_diffPairMeanderSettings;
m_skewSettings = aBoard->GetDesignSettings().m_skewMeanderSettings;
TransferDataToWindow();
m_trackSettings = savedTrackSettings;
m_dpSettings = savedDPSettings;
m_skewSettings = savedSkewSettings;
}

View File

@ -30,6 +30,9 @@ class MEANDER_SETTINGS;
}
class BOARD;
class PANEL_SETUP_TUNING_PATTERNS : public PANEL_SETUP_TUNING_PATTERNS_BASE
{
public:
@ -38,6 +41,8 @@ public:
PNS::MEANDER_SETTINGS& aDiffPairSettings,
PNS::MEANDER_SETTINGS& aSkewSettings );
void ImportSettingsFrom( BOARD* aBoard );
private:
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;