From 32836da14bc72ea05cbacebf34823a3e5daceffe Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 24 Nov 2022 18:05:37 +0000 Subject: [PATCH] Don't show annular rings controls for vias that span only a single layer. --- pcbnew/board.cpp | 12 +++++++++ pcbnew/board.h | 2 ++ .../dialogs/dialog_track_via_properties.cpp | 27 ++++++++++++++++++- pcbnew/dialogs/dialog_track_via_properties.h | 3 +++ .../dialog_track_via_properties_base.cpp | 6 ++++- .../dialog_track_via_properties_base.fbp | 2 ++ .../dialog_track_via_properties_base.h | 2 +- 7 files changed, 51 insertions(+), 3 deletions(-) diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 2254f6486d..782eaf6496 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -508,6 +508,18 @@ void BOARD::SetCopperLayerCount( int aCount ) } +int BOARD::LayerDepth( PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer ) const +{ + if( aStartLayer > aEndLayer ) + std::swap( aStartLayer, aEndLayer ); + + if( aEndLayer == B_Cu ) + aEndLayer = ToLAYER_ID( F_Cu + GetCopperLayerCount() - 1 ); + + return aEndLayer - aStartLayer; +} + + LSET BOARD::GetEnabledLayers() const { return GetDesignSettings().GetEnabledLayers(); diff --git a/pcbnew/board.h b/pcbnew/board.h index f449ae22fc..e32adfbbec 100644 --- a/pcbnew/board.h +++ b/pcbnew/board.h @@ -510,6 +510,8 @@ public: int GetCopperLayerCount() const; void SetCopperLayerCount( int aCount ); + int LayerDepth( PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer ) const; + /** * A proxy function that calls the corresponding function in m_BoardSettings. * diff --git a/pcbnew/dialogs/dialog_track_via_properties.cpp b/pcbnew/dialogs/dialog_track_via_properties.cpp index 245e41e120..73b87184d5 100644 --- a/pcbnew/dialogs/dialog_track_via_properties.cpp +++ b/pcbnew/dialogs/dialog_track_via_properties.cpp @@ -265,6 +265,7 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen m_ViaStartLayer->SetUndefinedLayerName( INDETERMINATE_STATE ); m_ViaStartLayer->Resync(); } + m_ViaStartLayer->SetLayerSelection( selection_first_layer ); if( selection_last_layer == UNDEFINED_LAYER ) @@ -272,6 +273,7 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen m_ViaEndLayer->SetUndefinedLayerName( INDETERMINATE_STATE ); m_ViaEndLayer->Resync(); } + m_ViaEndLayer->SetLayerSelection( selection_last_layer ); } @@ -336,6 +338,9 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen m_ViaStartLayer->Enable( viaType != VIATYPE::THROUGH ); m_ViaEndLayer->Enable( viaType != VIATYPE::THROUGH ); + + m_annularRingsLabel->Show( getLayerDepth() > 1 ); + m_annularRingsCtrl->Show( getLayerDepth() > 1 ); } else { @@ -481,7 +486,7 @@ bool DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange( const std::vector& cha bool DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow() { - // Run validations: + // Check for malformed data ONLY; design rules and constraints are the business of DRC. if( m_vias ) { @@ -797,6 +802,23 @@ void DIALOG_TRACK_VIA_PROPERTIES::onViaSelect( wxCommandEvent& aEvent ) } +int DIALOG_TRACK_VIA_PROPERTIES::getLayerDepth() +{ + int viaType = m_ViaTypeChoice->GetSelection(); + + if( viaType <= 0 ) + return m_frame->GetBoard()->GetCopperLayerCount() - 1; + + int startLayer = m_ViaStartLayer->GetLayerSelection(); + int endLayer = m_ViaEndLayer->GetLayerSelection(); + + if( startLayer < 0 || endLayer < 0 ) + return m_frame->GetBoard()->GetCopperLayerCount() - 1; + else + return m_frame->GetBoard()->LayerDepth( ToLAYER_ID( startLayer ), ToLAYER_ID( endLayer ) ); +} + + void DIALOG_TRACK_VIA_PROPERTIES::onViaEdit( wxCommandEvent& aEvent ) { m_DesignRuleViasCtrl->SetSelection( wxNOT_FOUND ); @@ -816,5 +838,8 @@ void DIALOG_TRACK_VIA_PROPERTIES::onViaEdit( wxCommandEvent& aEvent ) m_ViaStartLayer->Enable( false ); m_ViaEndLayer->Enable( false ); } + + m_annularRingsLabel->Show( getLayerDepth() > 1 ); + m_annularRingsCtrl->Show( getLayerDepth() > 1 ); } } diff --git a/pcbnew/dialogs/dialog_track_via_properties.h b/pcbnew/dialogs/dialog_track_via_properties.h index 6a2d38daea..82a9388d68 100644 --- a/pcbnew/dialogs/dialog_track_via_properties.h +++ b/pcbnew/dialogs/dialog_track_via_properties.h @@ -56,6 +56,9 @@ private: bool confirmPadChange( const std::vector& connectedPads ); + int getLayerDepth(); + +private: PCB_BASE_FRAME* m_frame; const PCB_SELECTION& m_items; // List of items to be modified. COMMIT& m_commit; // An undo record to add any changes to. diff --git a/pcbnew/dialogs/dialog_track_via_properties_base.cpp b/pcbnew/dialogs/dialog_track_via_properties_base.cpp index 6d589942e1..4c14861395 100644 --- a/pcbnew/dialogs/dialog_track_via_properties_base.cpp +++ b/pcbnew/dialogs/dialog_track_via_properties_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5) +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -319,6 +319,8 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa m_ViaDrillCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onViaEdit ), NULL, this ); m_viaNetclass->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onViaNetclassCheck ), NULL, this ); m_ViaTypeChoice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onViaEdit ), NULL, this ); + m_ViaStartLayer->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onViaEdit ), NULL, this ); + m_ViaEndLayer->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onViaEdit ), NULL, this ); } DIALOG_TRACK_VIA_PROPERTIES_BASE::~DIALOG_TRACK_VIA_PROPERTIES_BASE() @@ -333,5 +335,7 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::~DIALOG_TRACK_VIA_PROPERTIES_BASE() m_ViaDrillCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onViaEdit ), NULL, this ); m_viaNetclass->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onViaNetclassCheck ), NULL, this ); m_ViaTypeChoice->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onViaEdit ), NULL, this ); + m_ViaStartLayer->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onViaEdit ), NULL, this ); + m_ViaEndLayer->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onViaEdit ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_track_via_properties_base.fbp b/pcbnew/dialogs/dialog_track_via_properties_base.fbp index 37c07f1667..b8f267b089 100644 --- a/pcbnew/dialogs/dialog_track_via_properties_base.fbp +++ b/pcbnew/dialogs/dialog_track_via_properties_base.fbp @@ -3128,6 +3128,7 @@ + onViaEdit @@ -3254,6 +3255,7 @@ + onViaEdit diff --git a/pcbnew/dialogs/dialog_track_via_properties_base.h b/pcbnew/dialogs/dialog_track_via_properties_base.h index 78615f6c00..fad8f0723a 100644 --- a/pcbnew/dialogs/dialog_track_via_properties_base.h +++ b/pcbnew/dialogs/dialog_track_via_properties_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5) +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE!