From 699082459791d811ec77423ebbf5d3135816d012 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 18 Jun 2018 21:41:10 -0700 Subject: [PATCH] pcbnew: Hide routing options that are not available Options that do not have code implementing them are now hidden from the user so that they are not searching for ways to enable the greyed out options. Similarly, when selecting a routing option that disables free-mode, we show the effect of disabling the mode in the dialog. --- pcbnew/dialogs/dialog_pns_settings.cpp | 19 ++++++++++++++++--- pcbnew/dialogs/dialog_pns_settings.h | 1 + pcbnew/dialogs/dialog_pns_settings_base.cpp | 4 +++- pcbnew/dialogs/dialog_pns_settings_base.fbp | 4 ++-- pcbnew/dialogs/dialog_pns_settings_base.h | 1 + 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/pcbnew/dialogs/dialog_pns_settings.cpp b/pcbnew/dialogs/dialog_pns_settings.cpp index 2cfa1d60e0..5d79c1a62e 100644 --- a/pcbnew/dialogs/dialog_pns_settings.cpp +++ b/pcbnew/dialogs/dialog_pns_settings.cpp @@ -29,9 +29,6 @@ DIALOG_PNS_SETTINGS::DIALOG_PNS_SETTINGS( wxWindow* aParent, PNS::ROUTING_SETTINGS& aSettings ) : DIALOG_PNS_SETTINGS_BASE( aParent ), m_settings( aSettings ) { - // "Figure out what's best" is not available yet - m_mode->Enable( PNS::RM_Smart, false ); - // Add tool tip to the mode radio box, one by option // (cannot be made with wxFormBuilder for each item ) m_mode->SetItemToolTip( 0, _( "DRC violation: highlight obstacles" ) ); @@ -51,6 +48,10 @@ DIALOG_PNS_SETTINGS::DIALOG_PNS_SETTINGS( wxWindow* aParent, PNS::ROUTING_SETTIN m_freeAngleMode->SetValue( m_settings.GetFreeAngleMode() ); m_dragToolMode->SetSelection ( m_settings.InlineDragEnabled() ? 1 : 0 ); + // Don't show options that are not implemented + m_suggestEnding->Hide(); + m_shoveVias->Hide(); + SetDefaultItem( m_stdButtonsOK ); GetSizer()->Fit( this ); GetSizer()->SetSizeHints( this ); @@ -74,3 +75,15 @@ void DIALOG_PNS_SETTINGS::OnOkClick( wxCommandEvent& aEvent ) aEvent.Skip(); // ends returning wxID_OK (default behavior) } + + +void DIALOG_PNS_SETTINGS::onModeChange( wxCommandEvent& aEvent ) +{ + if( m_mode->GetSelection() == PNS::RM_MarkObstacles ) + m_freeAngleMode->Enable(); + else + { + m_freeAngleMode->SetValue( false ); + m_freeAngleMode->Enable( false ); + } +} diff --git a/pcbnew/dialogs/dialog_pns_settings.h b/pcbnew/dialogs/dialog_pns_settings.h index d9fca5b314..7b686b4a59 100644 --- a/pcbnew/dialogs/dialog_pns_settings.h +++ b/pcbnew/dialogs/dialog_pns_settings.h @@ -41,6 +41,7 @@ class DIALOG_PNS_SETTINGS : public DIALOG_PNS_SETTINGS_BASE private: virtual void OnOkClick( wxCommandEvent& aEvent ) override; + virtual void onModeChange( wxCommandEvent& aEvent ) override; PNS::ROUTING_SETTINGS& m_settings; }; diff --git a/pcbnew/dialogs/dialog_pns_settings_base.cpp b/pcbnew/dialogs/dialog_pns_settings_base.cpp index c350db266e..01e51a6ac1 100644 --- a/pcbnew/dialogs/dialog_pns_settings_base.cpp +++ b/pcbnew/dialogs/dialog_pns_settings_base.cpp @@ -16,7 +16,7 @@ DIALOG_PNS_SETTINGS_BASE::DIALOG_PNS_SETTINGS_BASE( wxWindow* parent, wxWindowID wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxVERTICAL ); - wxString m_modeChoices[] = { _("Highlight collisions"), _("Shove"), _("Walk around"), _("Figure out what's best") }; + wxString m_modeChoices[] = { _("Highlight collisions"), _("Shove"), _("Walk around") }; int m_modeNChoices = sizeof( m_modeChoices ) / sizeof( wxString ); m_mode = new wxRadioBox( this, wxID_ANY, _("Mode:"), wxDefaultPosition, wxDefaultSize, m_modeNChoices, m_modeChoices, 1, wxRA_SPECIFY_COLS ); m_mode->SetSelection( 0 ); @@ -149,6 +149,7 @@ DIALOG_PNS_SETTINGS_BASE::DIALOG_PNS_SETTINGS_BASE( wxWindow* parent, wxWindowID bMainSizer->Fit( this ); // Connect Events + m_mode->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PNS_SETTINGS_BASE::onModeChange ), NULL, this ); m_freeAngleMode->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PNS_SETTINGS_BASE::onFreeAngleModeChange ), NULL, this ); m_stdButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PNS_SETTINGS_BASE::OnOkClick ), NULL, this ); } @@ -156,6 +157,7 @@ DIALOG_PNS_SETTINGS_BASE::DIALOG_PNS_SETTINGS_BASE( wxWindow* parent, wxWindowID DIALOG_PNS_SETTINGS_BASE::~DIALOG_PNS_SETTINGS_BASE() { // Disconnect Events + m_mode->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PNS_SETTINGS_BASE::onModeChange ), NULL, this ); m_freeAngleMode->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PNS_SETTINGS_BASE::onFreeAngleModeChange ), NULL, this ); m_stdButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PNS_SETTINGS_BASE::OnOkClick ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_pns_settings_base.fbp b/pcbnew/dialogs/dialog_pns_settings_base.fbp index 49f4c43108..1d72be0081 100644 --- a/pcbnew/dialogs/dialog_pns_settings_base.fbp +++ b/pcbnew/dialogs/dialog_pns_settings_base.fbp @@ -112,7 +112,7 @@ 1 0 - "Highlight collisions" "Shove" "Walk around" "Figure out what's best" + "Highlight collisions" "Shove" "Walk around" 1 1 @@ -175,7 +175,7 @@ - + onModeChange diff --git a/pcbnew/dialogs/dialog_pns_settings_base.h b/pcbnew/dialogs/dialog_pns_settings_base.h index cfe9ee1fff..4f05ccadc7 100644 --- a/pcbnew/dialogs/dialog_pns_settings_base.h +++ b/pcbnew/dialogs/dialog_pns_settings_base.h @@ -60,6 +60,7 @@ class DIALOG_PNS_SETTINGS_BASE : public DIALOG_SHIM wxButton* m_stdButtonsCancel; // Virtual event handlers, overide them in your derived class + virtual void onModeChange( wxCommandEvent& event ) { event.Skip(); } virtual void onFreeAngleModeChange( wxCommandEvent& event ) { event.Skip(); } virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }