From d04641c868631747251e228dd2f8ea48781cbc96 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 11 Oct 2023 11:48:43 +0100 Subject: [PATCH] ADDED: support for editing target length in Meander Properties dialog. Also supports overriding the custom rules. --- pcbnew/dialogs/dialog_meander_properties.cpp | 50 +- pcbnew/dialogs/dialog_meander_properties.h | 14 +- .../dialog_meander_properties_base.cpp | 113 +- .../dialog_meander_properties_base.fbp | 1053 ++++++++++------- .../dialogs/dialog_meander_properties_base.h | 18 +- pcbnew/drc/drc_rule.h | 8 +- pcbnew/generators/pcb_generator_meanders.cpp | 55 +- pcbnew/router/pns_meander.h | 9 +- 8 files changed, 816 insertions(+), 504 deletions(-) diff --git a/pcbnew/dialogs/dialog_meander_properties.cpp b/pcbnew/dialogs/dialog_meander_properties.cpp index df32b65bbc..e492532138 100644 --- a/pcbnew/dialogs/dialog_meander_properties.cpp +++ b/pcbnew/dialogs/dialog_meander_properties.cpp @@ -18,15 +18,20 @@ */ #include "dialog_meander_properties.h" -#include -#include #include -#include +#include +#include +#include -DIALOG_MEANDER_PROPERTIES::DIALOG_MEANDER_PROPERTIES( EDA_DRAW_FRAME* aFrame, + +DIALOG_MEANDER_PROPERTIES::DIALOG_MEANDER_PROPERTIES( PCB_BASE_EDIT_FRAME* aFrame, PNS::MEANDER_SETTINGS& aSettings, - PNS::ROUTER_MODE aMeanderType ) : + PNS::ROUTER_MODE aMeanderType, + const DRC_CONSTRAINT& aConstraint ) : DIALOG_MEANDER_PROPERTIES_BASE( aFrame ), + m_frame( aFrame ), + m_constraint( aConstraint ), + m_targetLength( aFrame, m_targetLengthLabel, m_targetLengthCtrl, m_targetLengthUnits ), m_minA( aFrame, m_track_minALabel, m_minACtrl, m_minAUnits ), m_maxA( aFrame, m_maxALabel, m_maxACtrl, m_maxAUnits ), m_spacing( aFrame, m_spacingLabel, m_spacingCtrl, m_spacingUnits ), @@ -55,16 +60,26 @@ DIALOG_MEANDER_PROPERTIES::DIALOG_MEANDER_PROPERTIES( EDA_DRAW_FRAME* aFrame, } // Bitmap has a new size, so recalculate sizes - GetSizer()->SetSizeHints(this); + GetSizer()->SetSizeHints( this ); SetupStandardButtons(); - GetSizer()->SetSizeHints(this); + GetSizer()->SetSizeHints( this ); Centre(); } bool DIALOG_MEANDER_PROPERTIES::TransferDataToWindow() { + m_targetLength.SetValue( m_settings.m_targetLength ); + m_overrideCustomRules->SetValue( m_settings.m_overrideCustomRules ); + + m_targetLength.Enable( m_constraint.IsNull() || m_settings.m_overrideCustomRules ); + + if( !m_constraint.IsNull() ) + m_sourceInfo->SetLabel( wxString::Format( _( "(from %s)" ), m_constraint.GetName() ) ); + + m_sourceInfo->Show( !m_constraint.IsNull() && !m_settings.m_overrideCustomRules ); + m_minA.SetValue( m_settings.m_minAmplitude ); m_maxA.SetValue( m_settings.m_maxAmplitude ); m_spacing.SetValue( m_settings.m_spacing ); @@ -78,13 +93,32 @@ bool DIALOG_MEANDER_PROPERTIES::TransferDataToWindow() bool DIALOG_MEANDER_PROPERTIES::TransferDataFromWindow() { + m_settings.m_targetLength = m_targetLength.GetValue(); + m_settings.m_overrideCustomRules = m_overrideCustomRules->GetValue(); + m_settings.m_minAmplitude = m_minA.GetIntValue(); m_settings.m_maxAmplitude = m_maxA.GetIntValue(); m_settings.m_spacing = m_spacing.GetIntValue(); m_settings.m_cornerStyle = m_cornerCtrl->GetSelection() ? PNS::MEANDER_STYLE_ROUND : PNS::MEANDER_STYLE_CHAMFER; - m_settings.m_cornerRadiusPercentage = m_r.GetValue(); + m_settings.m_cornerRadiusPercentage = m_r.GetIntValue(); m_settings.m_singleSided = m_singleSided->GetValue(); return true; } + + +void DIALOG_MEANDER_PROPERTIES::onOverrideCustomRules( wxCommandEvent& event ) +{ + m_targetLength.Enable( event.IsChecked() || m_constraint.IsNull() ); + + if( !event.IsChecked() && !m_constraint.IsNull() ) + { + m_targetLength.SetValue( m_constraint.GetValue().Opt() ); + m_sourceInfo->Show( true ); + } + else + { + m_sourceInfo->Show( false ); + } +} \ No newline at end of file diff --git a/pcbnew/dialogs/dialog_meander_properties.h b/pcbnew/dialogs/dialog_meander_properties.h index 2d08237169..1bbb05bf02 100644 --- a/pcbnew/dialogs/dialog_meander_properties.h +++ b/pcbnew/dialogs/dialog_meander_properties.h @@ -32,17 +32,27 @@ class MEANDER_SETTINGS; } +class PCB_BASE_EDIT_FRAME; +class DRC_CONSTRAINT; + + class DIALOG_MEANDER_PROPERTIES : public DIALOG_MEANDER_PROPERTIES_BASE { public: - DIALOG_MEANDER_PROPERTIES( EDA_DRAW_FRAME* aParent, PNS::MEANDER_SETTINGS& aSettings, - PNS::ROUTER_MODE aMeanderType ); + DIALOG_MEANDER_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, PNS::MEANDER_SETTINGS& aSettings, + PNS::ROUTER_MODE aMeanderType, const DRC_CONSTRAINT& aConstraint ); private: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; + void onOverrideCustomRules( wxCommandEvent& event ) override; + private: + PCB_BASE_EDIT_FRAME* m_frame; + const DRC_CONSTRAINT& m_constraint; + + UNIT_BINDER m_targetLength; UNIT_BINDER m_minA; UNIT_BINDER m_maxA; UNIT_BINDER m_spacing; diff --git a/pcbnew/dialogs/dialog_meander_properties_base.cpp b/pcbnew/dialogs/dialog_meander_properties_base.cpp index 32f84b8d0b..c1b7790f47 100644 --- a/pcbnew/dialogs/dialog_meander_properties_base.cpp +++ b/pcbnew/dialogs/dialog_meander_properties_base.cpp @@ -5,8 +5,6 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "widgets/text_ctrl_eval.h" - #include "dialog_meander_properties_base.h" /////////////////////////////////////////////////////////////////////////// @@ -24,115 +22,94 @@ DIALOG_MEANDER_PROPERTIES_BASE::DIALOG_MEANDER_PROPERTIES_BASE( wxWindow* parent m_legend = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); singleTrackSizer->Add( m_legend, 0, wxEXPAND|wxRIGHT|wxLEFT, 15 ); - wxFlexGridSizer* fgSizer31; - fgSizer31 = new wxFlexGridSizer( 0, 5, 5, 5 ); - fgSizer31->AddGrowableCol( 1 ); - fgSizer31->SetFlexibleDirection( wxBOTH ); - fgSizer31->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + wxGridBagSizer* gbSizer1; + gbSizer1 = new wxGridBagSizer( 4, 4 ); + gbSizer1->SetFlexibleDirection( wxBOTH ); + gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + gbSizer1->SetEmptyCellSize( wxSize( 10,8 ) ); + + m_targetLengthLabel = new wxStaticText( this, wxID_ANY, _("Target length:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_targetLengthLabel->Wrap( -1 ); + gbSizer1->Add( m_targetLengthLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_targetLengthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + gbSizer1->Add( m_targetLengthCtrl, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); + + m_targetLengthUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_targetLengthUnits->Wrap( -1 ); + gbSizer1->Add( m_targetLengthUnits, wxGBPosition( 0, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_overrideCustomRules = new wxCheckBox( this, wxID_ANY, _("Override custom rules"), wxDefaultPosition, wxDefaultSize, 0 ); + gbSizer1->Add( m_overrideCustomRules, wxGBPosition( 0, 4 ), wxGBSpan( 1, 3 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_sourceInfo = new wxStaticText( this, wxID_ANY, _("(from 'rule name')"), wxDefaultPosition, wxDefaultSize, 0 ); + m_sourceInfo->Wrap( -1 ); + gbSizer1->Add( m_sourceInfo, wxGBPosition( 1, 1 ), wxGBSpan( 1, 6 ), wxALIGN_CENTER_VERTICAL, 5 ); m_track_minALabel = new wxStaticText( this, wxID_ANY, _("Amplitude (A) min:"), wxDefaultPosition, wxDefaultSize, 0 ); m_track_minALabel->Wrap( -1 ); - fgSizer31->Add( m_track_minALabel, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - wxBoxSizer* bSizer8; - bSizer8 = new wxBoxSizer( wxHORIZONTAL ); + gbSizer1->Add( m_track_minALabel, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); m_minACtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - bSizer8->Add( m_minACtrl, 1, 0, 5 ); + gbSizer1->Add( m_minACtrl, wxGBPosition( 4, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); m_minAUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_minAUnits->Wrap( -1 ); - bSizer8->Add( m_minAUnits, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - - - fgSizer31->Add( bSizer8, 1, wxEXPAND, 5 ); + gbSizer1->Add( m_minAUnits, wxGBPosition( 4, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); m_maxALabel = new wxStaticText( this, wxID_ANY, _("Max:"), wxDefaultPosition, wxDefaultSize, 0 ); m_maxALabel->Wrap( -1 ); - fgSizer31->Add( m_maxALabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 15 ); + gbSizer1->Add( m_maxALabel, wxGBPosition( 4, 4 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); m_maxACtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer31->Add( m_maxACtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + gbSizer1->Add( m_maxACtrl, wxGBPosition( 4, 5 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); m_maxAUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_maxAUnits->Wrap( -1 ); - fgSizer31->Add( m_maxAUnits, 0, wxALIGN_CENTER_VERTICAL, 5 ); + gbSizer1->Add( m_maxAUnits, wxGBPosition( 4, 6 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); m_spacingLabel = new wxStaticText( this, wxID_ANY, _("Spacing (s):"), wxDefaultPosition, wxDefaultSize, 0 ); m_spacingLabel->Wrap( -1 ); - fgSizer31->Add( m_spacingLabel, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - wxBoxSizer* bSizer9; - bSizer9 = new wxBoxSizer( wxHORIZONTAL ); + gbSizer1->Add( m_spacingLabel, wxGBPosition( 5, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); m_spacingCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_spacingCtrl->SetToolTip( _("Minimum spacing between adjacent meander segments. The resulting spacing may be greater based on design rules.") ); - bSizer9->Add( m_spacingCtrl, 1, wxALIGN_CENTER_VERTICAL, 5 ); + gbSizer1->Add( m_spacingCtrl, wxGBPosition( 5, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); m_spacingUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_spacingUnits->Wrap( -1 ); - bSizer9->Add( m_spacingUnits, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); - - - fgSizer31->Add( bSizer9, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); - - - fgSizer31->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer31->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer31->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer31->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer31->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer31->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer31->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer31->Add( 0, 5, 1, wxEXPAND, 5 ); + gbSizer1->Add( m_spacingUnits, wxGBPosition( 5, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); m_cornerLabel = new wxStaticText( this, wxID_ANY, _("Corner style:"), wxDefaultPosition, wxDefaultSize, 0 ); m_cornerLabel->Wrap( -1 ); - fgSizer31->Add( m_cornerLabel, 1, wxALIGN_CENTER_VERTICAL, 5 ); + gbSizer1->Add( m_cornerLabel, wxGBPosition( 7, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); wxString m_cornerCtrlChoices[] = { _("Chamfer"), _("Fillet") }; int m_cornerCtrlNChoices = sizeof( m_cornerCtrlChoices ) / sizeof( wxString ); m_cornerCtrl = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_cornerCtrlNChoices, m_cornerCtrlChoices, 0 ); m_cornerCtrl->SetSelection( 0 ); - fgSizer31->Add( m_cornerCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + gbSizer1->Add( m_cornerCtrl, wxGBPosition( 7, 1 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); m_rLabel = new wxStaticText( this, wxID_ANY, _("Radius (r):"), wxDefaultPosition, wxDefaultSize, 0 ); m_rLabel->Wrap( -1 ); - fgSizer31->Add( m_rLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 15 ); + gbSizer1->Add( m_rLabel, wxGBPosition( 7, 4 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); - m_rCtrl = new TEXT_CTRL_EVAL( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer31->Add( m_rCtrl, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + m_rCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + gbSizer1->Add( m_rCtrl, wxGBPosition( 7, 5 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); m_rUnits = new wxStaticText( this, wxID_ANY, _("%"), wxDefaultPosition, wxDefaultSize, 0 ); m_rUnits->Wrap( -1 ); - fgSizer31->Add( m_rUnits, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - - fgSizer31->Add( 0, 0, 1, wxEXPAND, 5 ); + gbSizer1->Add( m_rUnits, wxGBPosition( 7, 6 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); m_singleSided = new wxCheckBox( this, wxID_ANY, _("Single-sided"), wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer31->Add( m_singleSided, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + gbSizer1->Add( m_singleSided, wxGBPosition( 8, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL, 5 ); - fgSizer31->Add( 0, 0, 1, wxEXPAND, 5 ); + gbSizer1->AddGrowableCol( 1 ); + gbSizer1->AddGrowableCol( 4 ); - - singleTrackSizer->Add( fgSizer31, 0, wxEXPAND|wxLEFT, 5 ); + singleTrackSizer->Add( gbSizer1, 1, wxEXPAND, 5 ); bMainSizer->Add( singleTrackSizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); @@ -150,8 +127,14 @@ DIALOG_MEANDER_PROPERTIES_BASE::DIALOG_MEANDER_PROPERTIES_BASE( wxWindow* parent this->SetSizer( bMainSizer ); this->Layout(); bMainSizer->Fit( this ); + + // Connect Events + m_overrideCustomRules->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_MEANDER_PROPERTIES_BASE::onOverrideCustomRules ), NULL, this ); } DIALOG_MEANDER_PROPERTIES_BASE::~DIALOG_MEANDER_PROPERTIES_BASE() { + // Disconnect Events + m_overrideCustomRules->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_MEANDER_PROPERTIES_BASE::onOverrideCustomRules ), NULL, this ); + } diff --git a/pcbnew/dialogs/dialog_meander_properties_base.fbp b/pcbnew/dialogs/dialog_meander_properties_base.fbp index c22c386cc4..c04d373ef8 100644 --- a/pcbnew/dialogs/dialog_meander_properties_base.fbp +++ b/pcbnew/dialogs/dialog_meander_properties_base.fbp @@ -130,24 +130,353 @@ 5 - wxEXPAND|wxLEFT - 0 - - 5 + wxEXPAND + 1 + + 10,8 wxBOTH - 1 + 1,4 - 5 + 4 - fgSizer31 + gbSizer1 wxFLEX_GROWMODE_SPECIFIED none - 0 - 5 - + 4 + 5 + 1 + 0 wxALIGN_CENTER_VERTICAL - 0 + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Target length: + 0 + + 0 + + + 0 + + 1 + m_targetLengthLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 1 + wxEXPAND + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_targetLengthCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + 1 + 2 + wxALIGN_CENTER_VERTICAL + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + unit + 0 + + 0 + + + 0 + + 1 + m_targetLengthUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 3 + 4 + wxALIGN_CENTER_VERTICAL + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Override custom rules + + 0 + + + 0 + + 1 + m_overrideCustomRules + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onOverrideCustomRules + + + + 5 + 6 + 1 + wxALIGN_CENTER_VERTICAL + 1 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + (from 'rule name') + 0 + + 0 + + + 0 + + 1 + m_sourceInfo + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 0 + wxALIGN_CENTER_VERTICAL + 4 + 1 1 1 @@ -205,146 +534,144 @@ -1 - + 5 + 1 + 1 wxEXPAND - 1 - + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 - bSizer8 - wxHORIZONTAL - none - - 5 - - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - m_minACtrl - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - unit - 0 - - 0 - - - 0 - - 1 - m_minAUnits - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - + 1 + m_minACtrl + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + - - 15 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 + + 5 + 1 + 2 + wxALIGN_CENTER_VERTICAL + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + unit + 0 + + 0 + + + 0 + + 1 + m_minAUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 4 + wxALIGN_CENTER_VERTICAL + 4 + 1 1 1 @@ -402,10 +729,13 @@ -1 - + 5 - wxEXPAND|wxALIGN_CENTER_VERTICAL - 0 + 1 + 5 + wxEXPAND + 4 + 1 1 1 @@ -466,10 +796,13 @@ - + 5 + 1 + 6 wxALIGN_CENTER_VERTICAL - 0 + 4 + 1 1 1 @@ -527,10 +860,13 @@ -1 - + 5 + 1 + 0 wxALIGN_CENTER_VERTICAL - 0 + 5 + 1 1 1 @@ -588,226 +924,144 @@ -1 - + 5 - wxEXPAND|wxALIGN_CENTER_VERTICAL - 1 - + 1 + 1 + wxEXPAND + 5 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 - bSizer9 - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - m_spacingCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - Minimum spacing between adjacent meander segments. The resulting spacing may be greater based on design rules. - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxLEFT|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - unit - 0 - - 0 - - - 0 - - 1 - m_spacingUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - 5 - wxEXPAND - 1 - - 0 + 1 + m_spacingCtrl + 1 + + protected - 0 + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + Minimum spacing between adjacent meander segments. The resulting spacing may be greater based on design rules. + + wxFILTER_NONE + wxDefaultValidator + + + + + - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 5 - protected - 0 - - - + 5 + 1 + 2 wxALIGN_CENTER_VERTICAL - 1 + 5 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + unit + 0 + + 0 + + + 0 + + 1 + m_spacingUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + 1 + 0 + wxALIGN_CENTER_VERTICAL + 7 + 1 1 1 @@ -865,10 +1119,13 @@ -1 - + 5 - wxEXPAND|wxALIGN_CENTER_VERTICAL - 0 + 2 + 1 + wxEXPAND + 7 + 1 1 1 @@ -929,10 +1186,13 @@ - - 15 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 + + 5 + 1 + 4 + wxALIGN_CENTER_VERTICAL + 7 + 1 1 1 @@ -990,10 +1250,13 @@ -1 - + 5 - wxEXPAND|wxALIGN_CENTER_VERTICAL - 0 + 1 + 5 + wxEXPAND + 7 + 1 1 1 @@ -1041,7 +1304,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + 0 @@ -1054,10 +1317,13 @@ - + 5 + 1 + 6 wxALIGN_CENTER_VERTICAL - 0 + 7 + 1 1 1 @@ -1115,20 +1381,13 @@ -1 - + 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND|wxALIGN_CENTER_VERTICAL - 0 + 2 + 1 + wxALIGN_CENTER_VERTICAL + 8 + 1 1 1 @@ -1189,16 +1448,6 @@ - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - diff --git a/pcbnew/dialogs/dialog_meander_properties_base.h b/pcbnew/dialogs/dialog_meander_properties_base.h index 00e17d0bc1..06446280dc 100644 --- a/pcbnew/dialogs/dialog_meander_properties_base.h +++ b/pcbnew/dialogs/dialog_meander_properties_base.h @@ -10,8 +10,6 @@ #include #include #include -class TEXT_CTRL_EVAL; - #include "dialog_shim.h" #include #include @@ -24,9 +22,10 @@ class TEXT_CTRL_EVAL; #include #include #include -#include -#include #include +#include +#include +#include #include #include @@ -42,6 +41,11 @@ class DIALOG_MEANDER_PROPERTIES_BASE : public DIALOG_SHIM protected: wxStaticBitmap* m_legend; + wxStaticText* m_targetLengthLabel; + wxTextCtrl* m_targetLengthCtrl; + wxStaticText* m_targetLengthUnits; + wxCheckBox* m_overrideCustomRules; + wxStaticText* m_sourceInfo; wxStaticText* m_track_minALabel; wxTextCtrl* m_minACtrl; wxStaticText* m_minAUnits; @@ -54,13 +58,17 @@ class DIALOG_MEANDER_PROPERTIES_BASE : public DIALOG_SHIM wxStaticText* m_cornerLabel; wxChoice* m_cornerCtrl; wxStaticText* m_rLabel; - TEXT_CTRL_EVAL* m_rCtrl; + wxTextCtrl* m_rCtrl; wxStaticText* m_rUnits; wxCheckBox* m_singleSided; wxStdDialogButtonSizer* m_stdButtons; wxButton* m_stdButtonsOK; wxButton* m_stdButtonsCancel; + // Virtual event handlers, override them in your derived class + virtual void onOverrideCustomRules( wxCommandEvent& event ) { event.Skip(); } + + public: DIALOG_MEANDER_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Meander Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); diff --git a/pcbnew/drc/drc_rule.h b/pcbnew/drc/drc_rule.h index 1d16f483e8..d2b5847e03 100644 --- a/pcbnew/drc/drc_rule.h +++ b/pcbnew/drc/drc_rule.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2020-2022 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2020-2023 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -21,8 +21,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef DRC_RULE_PROTO_H -#define DRC_RULE_PROTO_H +#ifndef DRC_RULE_H +#define DRC_RULE_H #include #include @@ -153,7 +153,7 @@ class DRC_CONSTRAINT if( m_parentRule->m_Implicit ) return m_parentRule->m_Name; else - return wxString::Format( _( "rule %s" ), m_parentRule->m_Name ); + return wxString::Format( _( "rule '%s'" ), m_parentRule->m_Name ); } return m_name; diff --git a/pcbnew/generators/pcb_generator_meanders.cpp b/pcbnew/generators/pcb_generator_meanders.cpp index f87d6e5c02..f2ef53351e 100644 --- a/pcbnew/generators/pcb_generator_meanders.cpp +++ b/pcbnew/generators/pcb_generator_meanders.cpp @@ -241,10 +241,12 @@ public: return nullptr; meander->m_targetLength = dlg.GetValue(); + meander->m_overrideCustomRules = true; } else { meander->m_targetLength = constraint.GetValue().Opt(); + meander->m_overrideCustomRules = false; } meander->SetFlags( IS_NEW ); @@ -536,6 +538,7 @@ public: settings.m_spacing = m_spacing; settings.m_targetLength = m_targetLength; settings.m_targetSkew = m_targetSkew; + settings.m_overrideCustomRules = m_overrideCustomRules; settings.m_singleSided = m_singleSide; settings.m_segmentSide = m_initialSide; settings.m_cornerRadiusPercentage = m_cornerRadiusPercentage; @@ -551,6 +554,7 @@ public: m_spacing = aSettings.m_spacing; m_targetLength = aSettings.m_targetLength; m_targetSkew = aSettings.m_targetSkew; + m_overrideCustomRules = aSettings.m_overrideCustomRules; m_singleSide = aSettings.m_singleSided; m_initialSide = aSettings.m_segmentSide; m_cornerRadiusPercentage = aSettings.m_cornerRadiusPercentage; @@ -560,13 +564,10 @@ public: { switch( m_tuningMode ) { - case LENGTH_TUNING_MODE::SINGLE: return PNS::PNS_MODE_TUNE_SINGLE; - - case LENGTH_TUNING_MODE::DIFF_PAIR: return PNS::PNS_MODE_TUNE_DIFF_PAIR; - + case LENGTH_TUNING_MODE::SINGLE: return PNS::PNS_MODE_TUNE_SINGLE; + case LENGTH_TUNING_MODE::DIFF_PAIR: return PNS::PNS_MODE_TUNE_DIFF_PAIR; case LENGTH_TUNING_MODE::DIFF_PAIR_SKEW: return PNS::PNS_MODE_TUNE_DIFF_PAIR_SKEW; - - default: return PNS::PNS_MODE_TUNE_SINGLE; + default: return PNS::PNS_MODE_TUNE_SINGLE; } } @@ -965,6 +966,9 @@ public: int GetTargetSkew() const { return m_targetSkew; } void SetTargetSkew( int aValue ) { m_targetSkew = aValue; } + bool GetOverrideCustomRules() const { return m_overrideCustomRules; } + void SetOverrideCustomRules( bool aOverride ) { m_overrideCustomRules = aOverride; } + int GetCornerRadiusPercentage() const { return m_cornerRadiusPercentage; } void SetCornerRadiusPercentage( int aValue ) { m_cornerRadiusPercentage = aValue; } @@ -1002,6 +1006,7 @@ public: props.set( "last_netname", m_lastNetName ); props.set( "last_tuning", m_tuningInfo ); + props.set( "override_custom_rules", m_overrideCustomRules ); if( m_baseLine ) props.set( "base_line", wxAny( *m_baseLine ) ); @@ -1035,6 +1040,7 @@ public: aProps.get_to_iu( "min_spacing", m_spacing ); aProps.get_to_iu( "target_length", m_targetLength ); aProps.get_to_iu( "target_skew", m_targetSkew ); + aProps.get_to( "override_custom_rules", m_overrideCustomRules ); aProps.get_to( "last_netname", m_lastNetName ); aProps.get_to( "last_tuning", m_tuningInfo ); @@ -1046,8 +1052,20 @@ public: void ShowPropertiesDialog( PCB_BASE_EDIT_FRAME* aEditFrame ) override { PNS::MEANDER_SETTINGS settings = ToMeanderSettings(); + DRC_CONSTRAINT constraint; - DIALOG_MEANDER_PROPERTIES dlg( aEditFrame, settings, ToPNSMode() ); + if( !m_items.empty() ) + { + BOARD_ITEM* startItem = *m_items.begin(); + std::shared_ptr& drcEngine = GetBoard()->GetDesignSettings().m_DRCEngine; + + constraint = drcEngine->EvalRules( LENGTH_CONSTRAINT, startItem, nullptr, GetLayer() ); + + if( !constraint.IsNull() && !settings.m_overrideCustomRules ) + settings.m_targetLength = constraint.GetValue().Opt(); + } + + DIALOG_MEANDER_PROPERTIES dlg( aEditFrame, settings, ToPNSMode(), constraint ); if( dlg.ShowModal() == wxID_OK ) { @@ -1107,16 +1125,17 @@ public: } protected: - VECTOR2I m_end; + VECTOR2I m_end; - int m_minAmplitude; - int m_maxAmplitude; - int m_spacing; - int m_targetLength; - int m_targetSkew; - int m_cornerRadiusPercentage; + int m_minAmplitude; + int m_maxAmplitude; + int m_spacing; + int m_targetLength; + int m_targetSkew; + bool m_overrideCustomRules; + int m_cornerRadiusPercentage; - PNS::MEANDER_SIDE m_initialSide; + PNS::MEANDER_SIDE m_initialSide; std::optional m_baseLine; @@ -1371,6 +1390,12 @@ static struct PCB_GENERATOR_MEANDERS_DESC PROPERTY_DISPLAY::PT_SIZE, ORIGIN_TRANSFORMS::ABS_X_COORD ), groupTab ); + propMgr.AddProperty( new PROPERTY( + _HKI( "Override custom rules" ), + &PCB_GENERATOR_MEANDERS::SetOverrideCustomRules, + &PCB_GENERATOR_MEANDERS::GetOverrideCustomRules ), + groupTab ); + propMgr.AddProperty( new PROPERTY( _HKI( "Single-sided" ), &PCB_GENERATOR_MEANDERS::SetSingleSided, diff --git a/pcbnew/router/pns_meander.h b/pcbnew/router/pns_meander.h index 3a03ac85bb..f5d45d2b14 100644 --- a/pcbnew/router/pns_meander.h +++ b/pcbnew/router/pns_meander.h @@ -76,6 +76,7 @@ public: m_spacing = 600000; m_targetLength = 100000000; m_targetSkew = 0; + m_overrideCustomRules = false; m_cornerStyle = MEANDER_STYLE_ROUND; m_cornerRadiusPercentage = 100; m_singleSided = false; @@ -101,6 +102,11 @@ public: ///< Desired length of the tuned line/diff pair (this is in nm, so allow more than board width). long long int m_targetLength; + ///< Target skew value for diff pair de-skewing. + int m_targetSkew; + + bool m_overrideCustomRules; + ///< Type of corners for the meandered line. MEANDER_STYLE m_cornerStyle; @@ -115,9 +121,6 @@ public: ///< Allowable tuning error. int m_lengthTolerance; - - ///< Target skew value for diff pair de-skewing. - int m_targetSkew; }; /**