diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index 914504e50c..16e90924f9 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -68,6 +68,7 @@ private: int m_cornerSmoothingType; int m_maxNetCode; int m_currentlySelectedNetcode; + UNIT_BINDER m_outlineHatchPitch; UNIT_BINDER m_cornerRadius; UNIT_BINDER m_clearance; @@ -165,6 +166,8 @@ static bool sortNetsByNames( const NETINFO_ITEM* a, const NETINFO_ITEM* b ) DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings ) : DIALOG_COPPER_ZONE_BASE( aParent ), m_cornerSmoothingType( ZONE_SETTINGS::SMOOTHING_UNDEFINED ), + m_outlineHatchPitch( aParent, m_stBorderHatchPitchText, + m_outlineHatchPitchCtrl, m_outlineHatchUnits ), m_cornerRadius( aParent, m_cornerRadiusLabel, m_cornerRadiusCtrl, m_cornerRadiusUnits ), m_clearance( aParent, m_clearanceLabel, m_clearanceCtrl, m_clearanceUnits ), m_minWidth( aParent, m_minWidthLabel, m_minWidthCtrl, m_minWidthUnits ), @@ -225,6 +228,8 @@ bool DIALOG_COPPER_ZONE::TransferDataToWindow() case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL: m_OutlineDisplayCtrl->SetSelection( 2 ); break; } + m_outlineHatchPitch.SetValue( m_settings.m_BorderHatchPitch ); + m_clearance.SetValue( m_settings.m_ZoneClearance ); m_minWidth.SetValue( m_settings.m_ZoneMinThickness ); @@ -479,6 +484,12 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aUseExportableSetupOnly ) case 2: m_settings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL; break; } + if( !m_outlineHatchPitch.Validate( Millimeter2iu( ZONE_BORDER_HATCH_MINDIST_MM ), + Millimeter2iu( ZONE_BORDER_HATCH_MAXDIST_MM ) ) ) + return false; + + m_settings.m_BorderHatchPitch = m_outlineHatchPitch.GetValue(); + PCBNEW_SETTINGS* cfg = m_Parent->GetPcbNewSettings(); cfg->m_Zones.hatching_style = static_cast( m_settings.m_ZoneBorderDisplayStyle ); diff --git a/pcbnew/dialogs/dialog_copper_zones_base.cpp b/pcbnew/dialogs/dialog_copper_zones_base.cpp index 9bb7a9be00..738ebac082 100644 --- a/pcbnew/dialogs/dialog_copper_zones_base.cpp +++ b/pcbnew/dialogs/dialog_copper_zones_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -140,6 +140,17 @@ DIALOG_COPPER_ZONE_BASE::DIALOG_COPPER_ZONE_BASE( wxWindow* parent, wxWindowID i m_OutlineDisplayCtrl->SetSelection( 0 ); gbSizer1->Add( m_OutlineDisplayCtrl, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_stBorderHatchPitchText = new wxStaticText( m_ExportableSetupSizer->GetStaticBox(), wxID_ANY, _("Outline hatch dist:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_stBorderHatchPitchText->Wrap( -1 ); + gbSizer1->Add( m_stBorderHatchPitchText, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_outlineHatchPitchCtrl = new wxTextCtrl( m_ExportableSetupSizer->GetStaticBox(), ID_M_CORNERSMOOTHINGCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + gbSizer1->Add( m_outlineHatchPitchCtrl, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + m_outlineHatchUnits = new wxStaticText( m_ExportableSetupSizer->GetStaticBox(), wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); + m_outlineHatchUnits->Wrap( -1 ); + gbSizer1->Add( m_outlineHatchUnits, wxGBPosition( 3, 2 ), wxGBSpan( 1, 1 ), wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + m_staticline1 = new wxStaticLine( m_ExportableSetupSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); gbSizer1->Add( m_staticline1, wxGBPosition( 3, 0 ), wxGBSpan( 1, 3 ), wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); diff --git a/pcbnew/dialogs/dialog_copper_zones_base.fbp b/pcbnew/dialogs/dialog_copper_zones_base.fbp index 4efcadfeea..3eae333d1e 100644 --- a/pcbnew/dialogs/dialog_copper_zones_base.fbp +++ b/pcbnew/dialogs/dialog_copper_zones_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,6 +14,7 @@ dialog_copper_zones_base 1000 none + 1 dialog_copper_zones_base @@ -25,6 +26,7 @@ 1 1 UI + 0 1 0 @@ -50,6 +52,7 @@ DIALOG_SHIM; dialog_shim.h Copper Zone Properties + 0 @@ -1079,6 +1082,201 @@ + + 5 + 1 + 0 + wxALL|wxALIGN_CENTER_VERTICAL + 3 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Outline hatch dist: + 0 + + 0 + + + 0 + + 1 + m_stBorderHatchPitchText + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + 1 + 1 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 3 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_M_CORNERSMOOTHINGCTRL + + 0 + + 0 + + 0 + -1,-1 + 1 + m_outlineHatchPitchCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + 1 + 2 + wxALL|wxALIGN_CENTER_VERTICAL + 3 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + + 1 + m_outlineHatchUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + 5 3 @@ -3895,6 +4093,7 @@ + 0 diff --git a/pcbnew/dialogs/dialog_copper_zones_base.h b/pcbnew/dialogs/dialog_copper_zones_base.h index 0848d6ce80..0e2c4de4fb 100644 --- a/pcbnew/dialogs/dialog_copper_zones_base.h +++ b/pcbnew/dialogs/dialog_copper_zones_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -28,10 +28,10 @@ #include #include #include +#include #include #include #include -#include #include /////////////////////////////////////////////////////////////////////////// @@ -51,8 +51,8 @@ class DIALOG_COPPER_ZONE_BASE : public DIALOG_SHIM ID_NETNAME_SELECTION, ID_M_PRIORITYLEVELCTRL, ID_M_OUTLINEAPPEARANCECTRL, - ID_CORNER_SMOOTHING, ID_M_CORNERSMOOTHINGCTRL, + ID_CORNER_SMOOTHING, ID_M_PADINZONEOPT, wxID_ANTIPAD_SIZE, wxID_COPPER_BRIDGE_VALUE, @@ -74,6 +74,9 @@ class DIALOG_COPPER_ZONE_BASE : public DIALOG_SHIM wxCheckBox* m_cbLocked; wxStaticText* m_staticTextStyle; wxChoice* m_OutlineDisplayCtrl; + wxStaticText* m_stBorderHatchPitchText; + wxTextCtrl* m_outlineHatchPitchCtrl; + wxStaticText* m_outlineHatchUnits; wxStaticLine* m_staticline1; wxStaticText* m_staticTextSmoothing; wxChoice* m_cornerSmoothingChoice; @@ -121,7 +124,7 @@ class DIALOG_COPPER_ZONE_BASE : public DIALOG_SHIM wxButton* m_sdbSizerOK; wxButton* m_sdbSizerCancel; - // Virtual event handlers, overide them in your derived class + // Virtual event handlers, override them in your derived class virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } virtual void OnLayerSelection( wxDataViewEvent& event ) { event.Skip(); } @@ -137,6 +140,7 @@ class DIALOG_COPPER_ZONE_BASE : public DIALOG_SHIM public: DIALOG_COPPER_ZONE_BASE( wxWindow* parent, wxWindowID id = ID_DIALOG_COPPER_ZONE_BASE, const wxString& title = _("Copper Zone Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_COPPER_ZONE_BASE(); }; diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index 5f7b368cf0..c1c231a477 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -797,18 +797,23 @@ int ZONE::GetBorderHatchPitch() const } -void ZONE::SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aHatchStyle, int aHatchPitch, - bool aRebuildHatch ) -{ - SetHatchPitch( aHatchPitch ); - m_borderStyle = aHatchStyle; - - if( aRebuildHatch ) +void ZONE::SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, + int aBorderHatchPitch, + bool aRebuildBorderHatch ) +{ + aBorderHatchPitch = std::max( aBorderHatchPitch, + Millimeter2iu( ZONE_BORDER_HATCH_MINDIST_MM ) ); + aBorderHatchPitch = std::min( aBorderHatchPitch, + Millimeter2iu( ZONE_BORDER_HATCH_MAXDIST_MM ) ); + SetBorderHatchPitch( aBorderHatchPitch ); + m_borderStyle = aBorderHatchStyle; + + if( aRebuildBorderHatch ) HatchBorder(); } -void ZONE::SetHatchPitch( int aPitch ) +void ZONE::SetBorderHatchPitch( int aPitch ) { m_borderHatchPitch = aPitch; } @@ -991,7 +996,7 @@ void ZONE::HatchBorder() int ZONE::GetDefaultHatchPitch() { - return Mils2iu( 20 ); + return Mils2iu( ZONE_BORDER_HATCH_DIST_MIL ); } diff --git a/pcbnew/zone.h b/pcbnew/zone.h index 8ebb864bbb..c6f1d504ab 100644 --- a/pcbnew/zone.h +++ b/pcbnew/zone.h @@ -787,21 +787,21 @@ public: /** * Set all hatch parameters for the zone. * - * @param aHatchStyle is the style of the hatch, specified as one of HATCH_STYLE possible - * values. - * @param aHatchPitch is the hatch pitch in iu. - * @param aRebuildHatch is a flag to indicate whether to re-hatch after having set the + * @param aBorderHatchStyle is the style of the hatch, specified as one of HATCH_STYLE + possible values. + * @param aBorderHatchPitch is the hatch pitch in iu. + * @param aRebuildBorderHatch is a flag to indicate whether to re-hatch after having set the * previous parameters. */ - void SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aHatchStyle, int aHatchPitch, - bool aRebuildHatch ); + void SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch, + bool aRebuilBorderdHatch ); /** * Set the hatch pitch parameter for the zone. * * @param aPitch is the hatch pitch in iu. */ - void SetHatchPitch( int aPitch ); + void SetBorderHatchPitch( int aPitch ); /** * Clear the zone's hatch. diff --git a/pcbnew/zone_settings.cpp b/pcbnew/zone_settings.cpp index 1202b4de81..d211f67c7d 100644 --- a/pcbnew/zone_settings.cpp +++ b/pcbnew/zone_settings.cpp @@ -59,6 +59,7 @@ ZONE_SETTINGS::ZONE_SETTINGS() m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE; // Option to show the zone // outlines only, short // hatches or full hatches + m_BorderHatchPitch = Mils2iu( ZONE_BORDER_HATCH_DIST_MIL ); m_Layers.reset().set( F_Cu ); m_Name = wxEmptyString; @@ -104,6 +105,7 @@ ZONE_SETTINGS& ZONE_SETTINGS::operator << ( const ZONE& aSource ) m_NetcodeSelection = aSource.GetNetCode(); m_Name = aSource.GetZoneName(); m_ZoneBorderDisplayStyle = aSource.GetHatchStyle(); + m_BorderHatchPitch = aSource.GetBorderHatchPitch(); m_ThermalReliefGap = aSource.GetThermalReliefGap(); m_ThermalReliefSpokeWidth = aSource.GetThermalReliefSpokeWidth(); m_padConnection = aSource.GetPadConnection(); @@ -166,8 +168,8 @@ void ZONE_SETTINGS::ExportSetting( ZONE& aTarget, bool aFullExport ) const // call SetBorderDisplayStyle last, because hatch lines will be rebuilt, // using new parameters values - aTarget.SetBorderDisplayStyle( m_ZoneBorderDisplayStyle, aTarget.GetDefaultHatchPitch(), - true ); + aTarget.SetBorderDisplayStyle( m_ZoneBorderDisplayStyle, + m_BorderHatchPitch, true ); } diff --git a/pcbnew/zone_settings.h b/pcbnew/zone_settings.h index 90f07780cb..69d3b4f386 100644 --- a/pcbnew/zone_settings.h +++ b/pcbnew/zone_settings.h @@ -99,6 +99,7 @@ public: /// Option to show the zone area (outlines only, short hatches or full hatches ZONE_BORDER_DISPLAY_STYLE m_ZoneBorderDisplayStyle; + int m_BorderHatchPitch; // for hatched outlines: dist between 2 hatches long m_ThermalReliefGap; // thickness of the gap in thermal reliefs long m_ThermalReliefSpokeWidth; // thickness of the copper bridge in thermal reliefs diff --git a/pcbnew/zones.h b/pcbnew/zones.h index d071fac012..8023eca8d3 100644 --- a/pcbnew/zones.h +++ b/pcbnew/zones.h @@ -34,6 +34,9 @@ #define ZONE_THICKNESS_MIN_VALUE_MIL 1 // minimum acceptable value for ZONE_SETTINGS::m_ZoneMinThickness #define ZONE_CLEARANCE_MIL 20 // default value for ZONE_SETTINGS::m_ZoneClearance #define ZONE_CLEARANCE_MAX_VALUE_MIL 500 // maximum acceptable value for ZONE_SETTINGS::m_ZoneClearance +#define ZONE_BORDER_HATCH_DIST_MIL 20 // default distance between hatches to draw hatched outlines +#define ZONE_BORDER_HATCH_MINDIST_MM 0.1 // min distance between hatches to draw hatched outlines +#define ZONE_BORDER_HATCH_MAXDIST_MM 2.0 // min distance between hatches to draw hatched outlines #define ZONE_EXPORT_VALUES 1004 // Copper zone dialog reports wxID_OK, wxID_CANCEL or