From 77448f032b5ec62fe60e2e137a6da2d09fafa891 Mon Sep 17 00:00:00 2001 From: JamesJCode <13408010-JamesJCode@users.noreply.gitlab.com> Date: Mon, 6 Jan 2025 22:24:38 +0000 Subject: [PATCH] Improve placement rule areas UI --- .../dialogs/dialog_rule_area_properties.cpp | 27 ++-- ...el_rule_area_properties_placement_base.cpp | 14 +- ...el_rule_area_properties_placement_base.fbp | 121 ++++++++++++++---- ...anel_rule_area_properties_placement_base.h | 10 +- 4 files changed, 123 insertions(+), 49 deletions(-) diff --git a/pcbnew/dialogs/dialog_rule_area_properties.cpp b/pcbnew/dialogs/dialog_rule_area_properties.cpp index 8663f6d244..a48ca4c44f 100644 --- a/pcbnew/dialogs/dialog_rule_area_properties.cpp +++ b/pcbnew/dialogs/dialog_rule_area_properties.cpp @@ -128,11 +128,11 @@ DIALOG_RULE_AREA_PROPERTIES::DIALOG_RULE_AREA_PROPERTIES( PCB_BASE_FRAME* aPar m_placementProperties = new PANEL_RULE_AREA_PROPERTIES_PLACEMENT_BASE( m_areaPropertiesNb ); m_areaPropertiesNb->AddPage( m_placementProperties, _( "Placement" ) ); - m_placementProperties->m_SheetCb->Connect( + m_placementProperties->m_SheetRb->Connect( wxEVT_CHECKBOX, wxCommandEventHandler( DIALOG_RULE_AREA_PROPERTIES::OnSheetNameClicked ), nullptr, this ); - m_placementProperties->m_ComponentsCb->Connect( + m_placementProperties->m_ComponentsRb->Connect( wxEVT_CHECKBOX, wxCommandEventHandler( DIALOG_RULE_AREA_PROPERTIES::OnComponentClassClicked ), nullptr, this ); @@ -192,11 +192,11 @@ DIALOG_RULE_AREA_PROPERTIES::DIALOG_RULE_AREA_PROPERTIES( PCB_BASE_FRAME* aPar DIALOG_RULE_AREA_PROPERTIES::~DIALOG_RULE_AREA_PROPERTIES() { - m_placementProperties->m_SheetCb->Disconnect( + m_placementProperties->m_SheetRb->Disconnect( wxEVT_CHECKBOX, wxCommandEventHandler( DIALOG_RULE_AREA_PROPERTIES::OnSheetNameClicked ), nullptr, this ); - m_placementProperties->m_ComponentsCb->Disconnect( + m_placementProperties->m_ComponentsRb->Disconnect( wxEVT_CHECKBOX, wxCommandEventHandler( DIALOG_RULE_AREA_PROPERTIES::OnComponentClassClicked ), nullptr, this ); @@ -205,14 +205,12 @@ DIALOG_RULE_AREA_PROPERTIES::~DIALOG_RULE_AREA_PROPERTIES() void DIALOG_RULE_AREA_PROPERTIES::OnSheetNameClicked( wxCommandEvent& event ) { - m_placementProperties->m_ComponentsCb->SetValue( false ); m_lastPlacementSourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME; } void DIALOG_RULE_AREA_PROPERTIES::OnComponentClassClicked( wxCommandEvent& event ) { - m_placementProperties->m_SheetCb->SetValue( false ); m_lastPlacementSourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS; } @@ -237,10 +235,11 @@ bool DIALOG_RULE_AREA_PROPERTIES::TransferDataToWindow() m_keepoutProperties->m_cbCopperPourCtrl->SetValue( m_zonesettings.GetDoNotAllowCopperPour() ); // Init placement parameters: - m_placementProperties->m_SheetCb->SetValue( false ); + m_placementProperties->m_DisabedlRb->SetValue( true ); + m_placementProperties->m_SheetRb->SetValue( false ); m_placementProperties->m_sheetCombo->Clear(); - m_placementProperties->m_ComponentsCb->SetValue( false ); + m_placementProperties->m_ComponentsRb->SetValue( false ); m_placementProperties->m_componentClassCombo->Clear(); wxString curSourceName = m_zonesettings.GetRuleAreaPlacementSource(); @@ -257,6 +256,8 @@ bool DIALOG_RULE_AREA_PROPERTIES::TransferDataToWindow() for( const wxString& sourceName : classNames ) m_placementProperties->m_componentClassCombo->Append( sourceName ); + m_placementProperties->m_componentClassCombo->Select( 0 ); + // Fetch sheet names std::set sheetNames; @@ -265,6 +266,8 @@ bool DIALOG_RULE_AREA_PROPERTIES::TransferDataToWindow() for( const wxString& sourceName : sheetNames ) m_placementProperties->m_sheetCombo->Append( sourceName ); + + m_placementProperties->m_sheetCombo->Select( 0 ); } auto setupCurrentSourceSelection = [&]( wxComboBox* cb ) @@ -286,7 +289,7 @@ bool DIALOG_RULE_AREA_PROPERTIES::TransferDataToWindow() == RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME ) { if( m_zonesettings.GetRuleAreaPlacementEnabled() ) - m_placementProperties->m_SheetCb->SetValue( true ); + m_placementProperties->m_SheetRb->SetValue( true ); setupCurrentSourceSelection( m_placementProperties->m_sheetCombo ); m_originalPlacementSourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME; @@ -295,7 +298,7 @@ bool DIALOG_RULE_AREA_PROPERTIES::TransferDataToWindow() else { if( m_zonesettings.GetRuleAreaPlacementEnabled() ) - m_placementProperties->m_ComponentsCb->SetValue( true ); + m_placementProperties->m_ComponentsRb->SetValue( true ); setupCurrentSourceSelection( m_placementProperties->m_componentClassCombo ); m_originalPlacementSourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS; @@ -414,12 +417,12 @@ bool DIALOG_RULE_AREA_PROPERTIES::TransferDataFromWindow() } }; - if( m_placementProperties->m_SheetCb->GetValue() ) + if( m_placementProperties->m_SheetRb->GetValue() ) { m_zonesettings.SetRuleAreaPlacementEnabled( true ); setPlacementSource( RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME ); } - else if( m_placementProperties->m_ComponentsCb->GetValue() ) + else if( m_placementProperties->m_ComponentsRb->GetValue() ) { m_zonesettings.SetRuleAreaPlacementEnabled( true ); setPlacementSource( RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS ); diff --git a/pcbnew/dialogs/panel_rule_area_properties_placement_base.cpp b/pcbnew/dialogs/panel_rule_area_properties_placement_base.cpp index 9ef78c4255..a949b10d9e 100644 --- a/pcbnew/dialogs/panel_rule_area_properties_placement_base.cpp +++ b/pcbnew/dialogs/panel_rule_area_properties_placement_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) +// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -17,8 +17,12 @@ PANEL_RULE_AREA_PROPERTIES_PLACEMENT_BASE::PANEL_RULE_AREA_PROPERTIES_PLACEMENT_ wxBoxSizer* bMarginsSizer; bMarginsSizer = new wxBoxSizer( wxVERTICAL ); - m_SheetCb = new wxCheckBox( this, wxID_ANY, _("Place items from sheet:"), wxDefaultPosition, wxDefaultSize, 0 ); - bMarginsSizer->Add( m_SheetCb, 0, wxALL, 5 ); + m_DisabedlRb = new wxRadioButton( this, wxID_ANY, _("No placement"), wxDefaultPosition, wxDefaultSize, 0 ); + m_DisabedlRb->SetValue( true ); + bMarginsSizer->Add( m_DisabedlRb, 0, wxALL, 5 ); + + m_SheetRb = new wxRadioButton( this, wxID_ANY, _("Place items from sheet:"), wxDefaultPosition, wxDefaultSize, 0 ); + bMarginsSizer->Add( m_SheetRb, 0, wxALL, 5 ); m_sheetCombo = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); bMarginsSizer->Add( m_sheetCombo, 0, wxLEFT|wxEXPAND, 25 ); @@ -26,8 +30,8 @@ PANEL_RULE_AREA_PROPERTIES_PLACEMENT_BASE::PANEL_RULE_AREA_PROPERTIES_PLACEMENT_ bMarginsSizer->Add( 0, 15, 0, wxEXPAND, 5 ); - m_ComponentsCb = new wxCheckBox( this, wxID_ANY, _("Place items matching component class:"), wxDefaultPosition, wxDefaultSize, 0 ); - bMarginsSizer->Add( m_ComponentsCb, 0, wxALL, 5 ); + m_ComponentsRb = new wxRadioButton( this, wxID_ANY, _("Place items matching component class:"), wxDefaultPosition, wxDefaultSize, 0 ); + bMarginsSizer->Add( m_ComponentsRb, 0, wxALL, 5 ); m_componentClassCombo = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); bMarginsSizer->Add( m_componentClassCombo, 0, wxLEFT|wxEXPAND, 25 ); diff --git a/pcbnew/dialogs/panel_rule_area_properties_placement_base.fbp b/pcbnew/dialogs/panel_rule_area_properties_placement_base.fbp index ba8c547b64..f8f08d47f8 100644 --- a/pcbnew/dialogs/panel_rule_area_properties_placement_base.fbp +++ b/pcbnew/dialogs/panel_rule_area_properties_placement_base.fbp @@ -1,34 +1,36 @@ - + - ; C++ - 1 - source_name - 0 - 0 + ; + 1 + connect + none + + + 0 + 0 res UTF-8 - connect panel_rule_area_properties_placement_base 6000 - none - - 1 + 1 + UI PANEL_RULE_AREA_PROPERTIES_PLACEMENT_BASE - . - + 0 + source_name + 1 + 0 + source_name + + + 1 1 - 1 - 1 - 1 - UI - 0 - 0 0 + 0 0 wxAUI_MGR_DEFAULT @@ -71,7 +73,72 @@ 5 wxALL 0 - + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + No placement + + 0 + + + 0 + + 1 + m_DisabedlRb + 1 + + + public + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 1 + + + + + + + 5 + wxALL + 0 + 1 1 1 @@ -85,7 +152,6 @@ 1 0 - 0 1 1 @@ -109,7 +175,7 @@ 0 1 - m_SheetCb + m_SheetRb 1 @@ -127,6 +193,7 @@ wxFILTER_NONE wxDefaultValidator + 0 @@ -212,21 +279,20 @@ 5 wxALL 0 - + 1 1 1 1 - + 0 - - + 0 + 0 1 0 - 0 1 1 @@ -250,7 +316,7 @@ 0 1 - m_ComponentsCb + m_ComponentsRb 1 @@ -268,6 +334,7 @@ wxFILTER_NONE wxDefaultValidator + 0 diff --git a/pcbnew/dialogs/panel_rule_area_properties_placement_base.h b/pcbnew/dialogs/panel_rule_area_properties_placement_base.h index fa2ad651e2..bcbc2dcb6c 100644 --- a/pcbnew/dialogs/panel_rule_area_properties_placement_base.h +++ b/pcbnew/dialogs/panel_rule_area_properties_placement_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) +// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -22,7 +22,6 @@ /////////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_RULE_AREA_PROPERTIES_PLACEMENT_BASE /////////////////////////////////////////////////////////////////////////////// @@ -33,9 +32,10 @@ class PANEL_RULE_AREA_PROPERTIES_PLACEMENT_BASE : public wxPanel protected: public: - wxCheckBox* m_SheetCb; + wxRadioButton* m_DisabedlRb; + wxRadioButton* m_SheetRb; wxComboBox* m_sheetCombo; - wxCheckBox* m_ComponentsCb; + wxRadioButton* m_ComponentsRb; wxComboBox* m_componentClassCombo; PANEL_RULE_AREA_PROPERTIES_PLACEMENT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );