pcbnew: Allow user-setting rounded rectangle radius
When designing pads, it can be helpful to not only see the resulting rounded rectangle radius from a given percentage but also to set it, constraining the related percentage. This adjusts the dialog to allow editing the rounded rectangle corner radius. It does not change the file format as the resulting ratio is saved. Further updates of the pad size or ratio will modify the radius. Fixes: lp:1668020 * https://bugs.launchpad.net/kicad/+bug/1668020
This commit is contained in:
parent
9e33d38cd5
commit
9cafe65e84
|
@ -204,6 +204,15 @@ int D_PAD::GetRoundRectCornerRadius( const wxSize& aSize ) const
|
|||
}
|
||||
|
||||
|
||||
void D_PAD::SetRoundRectCornerRadius( double aRadius )
|
||||
{
|
||||
int min_r = std::min( m_Size.x, m_Size.y );
|
||||
|
||||
if( min_r > 0 )
|
||||
SetRoundRectRadiusRatio( aRadius / min_r );
|
||||
}
|
||||
|
||||
|
||||
const EDA_RECT D_PAD::GetBoundingBox() const
|
||||
{
|
||||
EDA_RECT area;
|
||||
|
|
|
@ -541,6 +541,12 @@ public:
|
|||
*/
|
||||
int GetRoundRectCornerRadius( const wxSize& aSize ) const;
|
||||
|
||||
/**
|
||||
* Set the rounded rectangle radius ratio based on a given radius
|
||||
* @param aRadius = desired radius of curvature
|
||||
*/
|
||||
void SetRoundRectCornerRadius( double aRadius );
|
||||
|
||||
/**
|
||||
* Function BuildPadShapePolygon
|
||||
* Build the Corner list of the polygonal shape,
|
||||
|
|
|
@ -112,7 +112,7 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aP
|
|||
m_offsetY( aParent, m_offsetYLabel, m_offsetYCtrl, m_offsetYUnits, true ),
|
||||
m_padToDie( aParent, m_padToDieLabel, m_padToDieCtrl, m_padToDieUnits, true ),
|
||||
m_trapDelta( aParent, m_trapDeltaLabel, m_trapDeltaCtrl, m_trapDeltaUnits, true ),
|
||||
m_cornerRadius( aParent, m_cornerRadiusLabel, m_cornerRadiusValue, m_cornerRadiusUnits, true ),
|
||||
m_cornerRadius( aParent, m_cornerRadiusLabel, m_tcCornerRadius, m_cornerRadiusUnits, true ),
|
||||
m_holeX( aParent, m_holeXLabel, m_holeXCtrl, m_holeXUnits, true, 0 ),
|
||||
m_holeY( aParent, m_holeYLabel, m_holeYCtrl, m_holeYUnits, true, 0 ),
|
||||
m_OrientValidator( 1, &m_OrientValue ),
|
||||
|
@ -467,6 +467,32 @@ void DIALOG_PAD_PROPERTIES::updateRoundRectCornerValues()
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_PAD_PROPERTIES::onCornerRadiusChange( wxCommandEvent& event )
|
||||
{
|
||||
if( m_dummyPad->GetShape() != PAD_SHAPE_ROUNDRECT )
|
||||
return;
|
||||
|
||||
wxString value = m_tcCornerRadius->GetValue();
|
||||
double rrRadius;
|
||||
|
||||
if( value.ToDouble( &rrRadius ) )
|
||||
{
|
||||
if( rrRadius < 0.0 )
|
||||
{
|
||||
rrRadius = 0.0;
|
||||
m_tcCornerRadius->ChangeValue( "0.0" );
|
||||
}
|
||||
|
||||
transferDataToPad( m_dummyPad );
|
||||
m_dummyPad->SetRoundRectCornerRadius( Millimeter2iu( rrRadius ) );
|
||||
|
||||
auto ratio = wxString::Format( "%.1f", m_dummyPad->GetRoundRectRadiusRatio() * 100 );
|
||||
m_tcCornerSizeRatio->ChangeValue( ratio );
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_PAD_PROPERTIES::onCornerSizePercentChange( wxCommandEvent& event )
|
||||
{
|
||||
if( m_dummyPad->GetShape() != PAD_SHAPE_ROUNDRECT )
|
||||
|
@ -491,7 +517,7 @@ void DIALOG_PAD_PROPERTIES::onCornerSizePercentChange( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
transferDataToPad( m_dummyPad );
|
||||
m_cornerRadius.SetValue( m_dummyPad->GetRoundRectCornerRadius() );
|
||||
m_cornerRadius.ChangeValue( m_dummyPad->GetRoundRectCornerRadius() );
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,6 +138,7 @@ private:
|
|||
|
||||
// Called when corner setup value is changed for rounded rect pads
|
||||
void onCornerSizePercentChange( wxCommandEvent& event ) override;
|
||||
void onCornerRadiusChange( wxCommandEvent& event ) override;
|
||||
|
||||
/// Called when a dimension has changed.
|
||||
/// Update the graphical pad shown in the panel.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Dec 30 2017)
|
||||
// C++ code generated with wxFormBuilder (version Apr 19 2018)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -219,13 +219,12 @@ DIALOG_PAD_PROPERTIES_BASE::DIALOG_PAD_PROPERTIES_BASE( wxWindow* parent, wxWind
|
|||
m_cornerRadiusLabel->Wrap( -1 );
|
||||
m_cornerRadiusLabel->SetToolTip( _("Corner radius.\nCan be no more than half pad width.\nThe width is the smaller value between size X and size Y.\nNote: IPC norm gives a max value = 0.25mm.") );
|
||||
|
||||
fgSizerShapeType->Add( m_cornerRadiusLabel, 0, wxRIGHT|wxLEFT, 3 );
|
||||
fgSizerShapeType->Add( m_cornerRadiusLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 3 );
|
||||
|
||||
m_cornerRadiusValue = new wxStaticText( m_panelGeneral, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_cornerRadiusValue->Wrap( -1 );
|
||||
m_cornerRadiusValue->SetToolTip( _("Corner radius.\nCan be no more than half pad width.\nThe width is the smaller value between size X and size Y\nNote: IPC norm gives a max value = 0.25mm") );
|
||||
m_tcCornerRadius = new TEXT_CTRL_EVAL( m_panelGeneral, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_tcCornerRadius->SetToolTip( _("Corner radius.\nCan be no more than half pad width.\nThe width is the smaller value between size X and size Y\nNote: IPC norm gives a max value = 0.25mm") );
|
||||
|
||||
fgSizerShapeType->Add( m_cornerRadiusValue, 0, wxRIGHT|wxLEFT, 3 );
|
||||
fgSizerShapeType->Add( m_tcCornerRadius, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
|
||||
|
||||
m_cornerRadiusUnits = new wxStaticText( m_panelGeneral, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_cornerRadiusUnits->Wrap( -1 );
|
||||
|
@ -725,6 +724,7 @@ DIALOG_PAD_PROPERTIES_BASE::DIALOG_PAD_PROPERTIES_BASE( wxWindow* parent, wxWind
|
|||
m_trapDeltaCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this );
|
||||
m_trapAxisCtrl->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnSetLayers ), NULL, this );
|
||||
m_tcCornerSizeRatio->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::onCornerSizePercentChange ), NULL, this );
|
||||
m_tcCornerRadius->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::onCornerRadiusChange ), NULL, this );
|
||||
m_holeShapeCtrl->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnDrillShapeSelected ), NULL, this );
|
||||
m_holeXCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this );
|
||||
m_holeYCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this );
|
||||
|
@ -772,6 +772,7 @@ DIALOG_PAD_PROPERTIES_BASE::~DIALOG_PAD_PROPERTIES_BASE()
|
|||
m_trapDeltaCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this );
|
||||
m_trapAxisCtrl->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnSetLayers ), NULL, this );
|
||||
m_tcCornerSizeRatio->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::onCornerSizePercentChange ), NULL, this );
|
||||
m_tcCornerRadius->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::onCornerRadiusChange ), NULL, this );
|
||||
m_holeShapeCtrl->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnDrillShapeSelected ), NULL, this );
|
||||
m_holeXCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this );
|
||||
m_holeYCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAD_PROPERTIES_BASE::OnValuesChanged ), NULL, this );
|
||||
|
@ -1114,7 +1115,7 @@ DIALOG_PAD_PRIMITIVE_POLY_PROPS_BASE::DIALOG_PAD_PRIMITIVE_POLY_PROPS_BASE( wxWi
|
|||
wxBoxSizer* bSizerRightButts;
|
||||
bSizerRightButts = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_addButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_addButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
|
||||
m_addButton->SetMinSize( wxSize( 30,30 ) );
|
||||
|
||||
bSizerRightButts->Add( m_addButton, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
@ -1122,7 +1123,7 @@ DIALOG_PAD_PRIMITIVE_POLY_PROPS_BASE::DIALOG_PAD_PRIMITIVE_POLY_PROPS_BASE( wxWi
|
|||
|
||||
bSizerRightButts->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_deleteButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_deleteButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
|
||||
m_deleteButton->SetMinSize( wxSize( 30,30 ) );
|
||||
|
||||
bSizerRightButts->Add( m_deleteButton, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Dec 30 2017)
|
||||
// C++ code generated with wxFormBuilder (version Apr 19 2018)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -104,7 +104,7 @@ class DIALOG_PAD_PROPERTIES_BASE : public DIALOG_SHIM
|
|||
TEXT_CTRL_EVAL* m_tcCornerSizeRatio;
|
||||
wxStaticText* m_staticTextCornerSizeRatioUnit;
|
||||
wxStaticText* m_cornerRadiusLabel;
|
||||
wxStaticText* m_cornerRadiusValue;
|
||||
TEXT_CTRL_EVAL* m_tcCornerRadius;
|
||||
wxStaticText* m_cornerRadiusUnits;
|
||||
wxStaticText* m_holeShapeLabel;
|
||||
wxChoice* m_holeShapeCtrl;
|
||||
|
@ -195,6 +195,7 @@ class DIALOG_PAD_PROPERTIES_BASE : public DIALOG_SHIM
|
|||
virtual void PadOrientEvent( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnSetLayers( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onCornerSizePercentChange( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onCornerRadiusChange( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnDrillShapeSelected( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnUpdateUINonCopperWarning( wxUpdateUIEvent& event ) { event.Skip(); }
|
||||
virtual void onPrimitiveDClick( wxMouseEvent& event ) { event.Skip(); }
|
||||
|
|
Loading…
Reference in New Issue