2012-06-25 20:59:19 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-02-18 09:09:13 +00:00
|
|
|
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2012-06-25 20:59:19 +00:00
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2021-07-12 21:55:46 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-06-25 20:59:19 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pcbnew_settings.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <zones.h>
|
2018-02-20 14:58:01 +00:00
|
|
|
#include <bitmaps.h>
|
2018-05-25 14:56:04 +00:00
|
|
|
#include <widgets/unit_binder.h>
|
2020-11-11 23:05:59 +00:00
|
|
|
#include <zone.h>
|
2021-06-27 10:18:53 +00:00
|
|
|
#include <pad.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2020-10-14 03:37:48 +00:00
|
|
|
#include <trigo.h>
|
2021-07-12 21:55:46 +00:00
|
|
|
#include <eda_pattern_match.h>
|
2018-05-25 14:56:04 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
#include <dialog_copper_zones_base.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
class DIALOG_COPPER_ZONE : public DIALOG_COPPER_ZONE_BASE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DIALOG_COPPER_ZONE( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings );
|
|
|
|
|
|
|
|
private:
|
2021-07-12 21:55:46 +00:00
|
|
|
using NET_FILTER = std::unique_ptr<EDA_PATTERN_MATCH>;
|
|
|
|
using NET_FILTER_LIST = std::vector<NET_FILTER>;
|
|
|
|
|
|
|
|
static constexpr int INVALID_NET_CODE{ 0 };
|
|
|
|
|
|
|
|
static constexpr int DEFAULT_SORT_CONFIG{ -1 };
|
|
|
|
static constexpr int NO_PERSISTENT_SORT_MODE{ 0 };
|
|
|
|
static constexpr int HIDE_ANONYMOUS_NETS{ 1 << 0 };
|
|
|
|
static constexpr int SORT_BY_PAD_COUNT{ 1 << 1 };
|
|
|
|
|
2021-06-27 10:18:53 +00:00
|
|
|
PCB_BASE_FRAME* m_Parent;
|
|
|
|
|
|
|
|
bool m_settingsExported; // settings will be written to all other zones
|
2012-02-06 05:44:19 +00:00
|
|
|
|
2021-06-27 10:18:53 +00:00
|
|
|
ZONE_SETTINGS m_settings;
|
|
|
|
ZONE_SETTINGS* m_ptr;
|
|
|
|
bool m_netSortingByPadCount;
|
2021-07-12 21:55:46 +00:00
|
|
|
NET_FILTER_LIST m_showNetsFilter;
|
|
|
|
|
2021-06-27 10:18:53 +00:00
|
|
|
int m_cornerSmoothingType;
|
2021-07-12 21:55:46 +00:00
|
|
|
int m_maxNetCode;
|
|
|
|
int m_currentlySelectedNetcode;
|
2022-02-12 16:37:27 +00:00
|
|
|
UNIT_BINDER m_outlineHatchPitch;
|
2018-07-19 20:08:31 +00:00
|
|
|
|
2021-06-27 10:18:53 +00:00
|
|
|
UNIT_BINDER m_cornerRadius;
|
|
|
|
UNIT_BINDER m_clearance;
|
|
|
|
UNIT_BINDER m_minWidth;
|
2021-07-12 21:55:46 +00:00
|
|
|
UNIT_BINDER m_antipadClearance;
|
2021-06-27 10:18:53 +00:00
|
|
|
UNIT_BINDER m_spokeWidth;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2021-06-27 10:18:53 +00:00
|
|
|
UNIT_BINDER m_gridStyleRotation;
|
|
|
|
UNIT_BINDER m_gridStyleThickness;
|
|
|
|
UNIT_BINDER m_gridStyleGap;
|
|
|
|
UNIT_BINDER m_islandThreshold;
|
2021-07-12 21:55:46 +00:00
|
|
|
bool m_hideAutoGeneratedNets;
|
2022-03-05 16:18:42 +00:00
|
|
|
bool m_isTeardrop;
|
2021-07-12 21:55:46 +00:00
|
|
|
|
|
|
|
std::map<wxString, int> m_netNameToNetCode;
|
|
|
|
std::vector<NETINFO_ITEM*> m_netInfoItemList;
|
2018-02-18 09:09:13 +00:00
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
bool TransferDataFromWindow() override;
|
2012-02-06 05:44:19 +00:00
|
|
|
|
|
|
|
/**
|
2019-03-04 16:34:04 +00:00
|
|
|
* @param aUseExportableSetupOnly is true to use exportable parameters only (used to
|
|
|
|
* export this setup to other zones).
|
2012-02-06 05:44:19 +00:00
|
|
|
* @return bool - false if incorrect options, true if ok.
|
|
|
|
*/
|
2018-05-25 14:56:04 +00:00
|
|
|
bool AcceptOptions( bool aUseExportableSetupOnly = false );
|
2012-02-06 05:44:19 +00:00
|
|
|
|
2018-02-18 09:09:13 +00:00
|
|
|
void OnStyleSelection( wxCommandEvent& event ) override;
|
2018-05-25 14:56:04 +00:00
|
|
|
void OnLayerSelection( wxDataViewEvent& event ) override;
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnNetSortingOptionSelected( wxCommandEvent& event ) override;
|
|
|
|
void ExportSetupToOtherCopperZones( wxCommandEvent& event ) override;
|
2021-07-12 21:55:46 +00:00
|
|
|
void OnShowNetNameFilterChange( wxCommandEvent& event ) override;
|
2018-05-25 14:56:04 +00:00
|
|
|
void OnUpdateUI( wxUpdateUIEvent& ) override;
|
|
|
|
void OnButtonCancelClick( wxCommandEvent& event ) override;
|
|
|
|
void OnClose( wxCloseEvent& event ) override;
|
2021-07-12 21:55:46 +00:00
|
|
|
void OnNetSelectionUpdated( wxCommandEvent& event ) override;
|
|
|
|
void OnRemoveIslandsSelection( wxCommandEvent& event ) override;
|
|
|
|
|
|
|
|
void readNetInformation();
|
|
|
|
void readFilteringAndSortingCriteria();
|
|
|
|
void buildListOfNets( const NETINFO_LIST& nets );
|
|
|
|
wxArrayString buildListOfNetsToDisplay();
|
|
|
|
void sortNetsByPadCount( std::vector<NETINFO_ITEM*>& nets, const int maxNetCode );
|
|
|
|
void updateDisplayedListOfNets();
|
|
|
|
int ensureSelectedNetIsVisible( int selectedNetCode, wxArrayString& netsList );
|
|
|
|
void displayNetsList( const wxArrayString& netNamesList, int selectIndex );
|
|
|
|
void updateShowNetsFilter();
|
|
|
|
wxString getUnescapedNetName( const NETINFO_ITEM* net );
|
|
|
|
void sortNetsIfRequired();
|
|
|
|
wxArrayString getSortedNetNamesList();
|
|
|
|
wxArrayString applyShowFilter( const wxArrayString& sortedNetNames );
|
|
|
|
wxArrayString applyHideFilterIfRequired( const wxArrayString& netNames );
|
|
|
|
bool isAutoGenerated( const wxString& netName );
|
|
|
|
void updateCurrentNetSelection();
|
|
|
|
void updateInfoBar();
|
|
|
|
void handleRemoveIslandsSelection();
|
|
|
|
void storePersistentNetSortConfigurations();
|
|
|
|
void loadPersistentNetSortConfigurations();
|
2012-02-06 05:44:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
int InvokeCopperZonesEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSettings )
|
2012-02-06 05:44:19 +00:00
|
|
|
{
|
|
|
|
DIALOG_COPPER_ZONE dlg( aCaller, aSettings );
|
|
|
|
|
2021-02-20 13:06:12 +00:00
|
|
|
return dlg.ShowQuasiModal();
|
2012-02-06 05:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
// The pad count for each netcode, stored in a buffer for a fast access.
|
|
|
|
// This is needed by the sort function sortNetsByNodes()
|
|
|
|
static std::vector<int> padCountListByNet;
|
|
|
|
|
|
|
|
|
|
|
|
// Sort nets by decreasing pad count.
|
|
|
|
// For same pad count, sort by alphabetic names
|
|
|
|
static bool sortNetsByNodes( const NETINFO_ITEM* a, const NETINFO_ITEM* b )
|
|
|
|
{
|
|
|
|
int countA = padCountListByNet[a->GetNetCode()];
|
|
|
|
int countB = padCountListByNet[b->GetNetCode()];
|
|
|
|
|
|
|
|
if( countA == countB )
|
|
|
|
return a->GetNetname() < b->GetNetname();
|
|
|
|
else
|
|
|
|
return countB < countA;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Sort nets by alphabetic names
|
|
|
|
static bool sortNetsByNames( const NETINFO_ITEM* a, const NETINFO_ITEM* b )
|
|
|
|
{
|
|
|
|
return a->GetNetname() < b->GetNetname();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings ) :
|
2021-07-12 21:55:46 +00:00
|
|
|
DIALOG_COPPER_ZONE_BASE( aParent ),
|
|
|
|
m_cornerSmoothingType( ZONE_SETTINGS::SMOOTHING_UNDEFINED ),
|
2022-02-12 16:37:27 +00:00
|
|
|
m_outlineHatchPitch( aParent, m_stBorderHatchPitchText,
|
|
|
|
m_outlineHatchPitchCtrl, m_outlineHatchUnits ),
|
2021-07-12 21:55:46 +00:00
|
|
|
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 ),
|
|
|
|
m_antipadClearance( aParent, m_antipadLabel, m_antipadCtrl, m_antipadUnits ),
|
|
|
|
m_spokeWidth( aParent, m_spokeWidthLabel, m_spokeWidthCtrl, m_spokeWidthUnits ),
|
|
|
|
m_gridStyleRotation( aParent, m_staticTextGrindOrient, m_tcGridStyleOrientation,
|
|
|
|
m_staticTextRotUnits ),
|
|
|
|
m_gridStyleThickness( aParent, m_staticTextStyleThickness, m_tcGridStyleThickness,
|
|
|
|
m_GridStyleThicknessUnits ),
|
|
|
|
m_gridStyleGap( aParent, m_staticTextGridGap, m_tcGridStyleGap, m_GridStyleGapUnits ),
|
|
|
|
m_islandThreshold( aParent, m_islandThresholdLabel, m_tcIslandThreshold,
|
|
|
|
m_islandThresholdUnits ),
|
|
|
|
m_hideAutoGeneratedNets{ false }
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2012-02-06 05:44:19 +00:00
|
|
|
m_Parent = aParent;
|
|
|
|
|
|
|
|
m_ptr = aSettings;
|
|
|
|
m_settings = *aSettings;
|
2022-02-17 23:54:15 +00:00
|
|
|
m_settings.SetupLayersList( m_layers, m_Parent,
|
|
|
|
LSET::AllCuMask( aParent->GetBoard()->GetCopperLayerCount() ),
|
|
|
|
false );
|
2022-03-05 16:18:42 +00:00
|
|
|
m_isTeardrop = m_settings.m_TeardropType != TEARDROP_TYPE::TD_NONE;
|
|
|
|
|
|
|
|
switch( m_settings.m_TeardropType )
|
|
|
|
{
|
|
|
|
case TEARDROP_TYPE::TD_NONE:
|
|
|
|
// standard copper zone
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TEARDROP_TYPE::TD_VIAPAD:
|
|
|
|
SetTitle( _( "Teardrop on Vias/Pads Properties" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TEARDROP_TYPE::TD_TRACKEND:
|
|
|
|
SetTitle( _( "Teardrop on Tracks Properties" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
SetTitle( _( "Teardrop Properties" ) );
|
|
|
|
break;
|
|
|
|
}
|
2012-02-06 05:44:19 +00:00
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
m_settingsExported = false;
|
2021-07-13 16:53:13 +00:00
|
|
|
m_currentlySelectedNetcode = INVALID_NET_CODE;
|
|
|
|
m_maxNetCode = INVALID_NET_CODE;
|
2009-08-23 15:22:44 +00:00
|
|
|
|
2021-06-27 10:18:53 +00:00
|
|
|
m_netSortingByPadCount = true; // false = alphabetic sort, true = pad count sort
|
2010-01-20 12:43:05 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
m_ShowNetNameFilter->SetHint( _( "Filter" ) );
|
2016-07-02 09:35:52 +00:00
|
|
|
|
2020-06-26 02:19:51 +00:00
|
|
|
m_cbRemoveIslands->Bind( wxEVT_CHOICE,
|
|
|
|
[&]( wxCommandEvent& )
|
|
|
|
{
|
|
|
|
// Area mode is index 2
|
|
|
|
bool val = m_cbRemoveIslands->GetSelection() == 2;
|
|
|
|
|
|
|
|
m_tcIslandThreshold->Enable( val );
|
|
|
|
m_islandThresholdLabel->Enable( val );
|
|
|
|
m_islandThresholdUnits->Enable( val );
|
|
|
|
} );
|
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons();
|
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
bool DIALOG_COPPER_ZONE::TransferDataToWindow()
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2018-05-25 14:56:04 +00:00
|
|
|
m_constrainOutline->SetValue( m_settings.m_Zone_45_Only );
|
2021-05-06 21:49:07 +00:00
|
|
|
m_cbLocked->SetValue( m_settings.m_Locked );
|
2012-02-06 05:44:19 +00:00
|
|
|
m_cornerSmoothingChoice->SetSelection( m_settings.GetCornerSmoothingType() );
|
2018-05-25 14:56:04 +00:00
|
|
|
m_cornerRadius.SetValue( m_settings.GetCornerRadius() );
|
|
|
|
m_PriorityLevelCtrl->SetValue( m_settings.m_ZonePriority );
|
2011-02-21 19:43:59 +00:00
|
|
|
|
2022-03-05 16:18:42 +00:00
|
|
|
if( m_isTeardrop ) // outlines are never smoothed: they have alreay the right shape
|
|
|
|
{
|
|
|
|
m_cornerSmoothingChoice->SetSelection( 0 );
|
|
|
|
m_cornerSmoothingChoice->Enable( false );
|
|
|
|
m_cornerRadius.SetValue( 0 );
|
|
|
|
m_cornerRadius.Enable( false );
|
|
|
|
}
|
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
switch( m_settings.m_ZoneBorderDisplayStyle )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2020-08-07 14:04:34 +00:00
|
|
|
case ZONE_BORDER_DISPLAY_STYLE::NO_HATCH: m_OutlineDisplayCtrl->SetSelection( 0 ); break;
|
|
|
|
case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE: m_OutlineDisplayCtrl->SetSelection( 1 ); break;
|
|
|
|
case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL: m_OutlineDisplayCtrl->SetSelection( 2 ); break;
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
2022-02-12 16:37:27 +00:00
|
|
|
m_outlineHatchPitch.SetValue( m_settings.m_BorderHatchPitch );
|
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
m_clearance.SetValue( m_settings.m_ZoneClearance );
|
|
|
|
m_minWidth.SetValue( m_settings.m_ZoneMinThickness );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
switch( m_settings.GetPadConnection() )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2018-05-25 14:56:04 +00:00
|
|
|
default:
|
2020-08-07 14:04:34 +00:00
|
|
|
case ZONE_CONNECTION::THERMAL: m_PadInZoneOpt->SetSelection( 1 ); break;
|
|
|
|
case ZONE_CONNECTION::THT_THERMAL: m_PadInZoneOpt->SetSelection( 2 ); break;
|
|
|
|
case ZONE_CONNECTION::NONE: m_PadInZoneOpt->SetSelection( 3 ); break;
|
|
|
|
case ZONE_CONNECTION::FULL: m_PadInZoneOpt->SetSelection( 0 ); break;
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
2022-03-05 16:18:42 +00:00
|
|
|
if( m_isTeardrop )
|
|
|
|
{
|
|
|
|
m_PadInZoneOpt->SetSelection( 0 );
|
|
|
|
m_PadInZoneOpt->Enable( false );
|
|
|
|
}
|
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
// Do not enable/disable antipad clearance and spoke width. They might be needed if
|
2020-11-13 11:17:15 +00:00
|
|
|
// a footprint or pad overrides the zone to specify a thermal connection.
|
2018-05-25 14:56:04 +00:00
|
|
|
m_antipadClearance.SetValue( m_settings.m_ThermalReliefGap );
|
2020-09-17 13:14:45 +00:00
|
|
|
m_spokeWidth.SetValue( m_settings.m_ThermalReliefSpokeWidth );
|
2013-03-25 17:02:29 +00:00
|
|
|
|
2020-06-26 02:19:51 +00:00
|
|
|
m_islandThreshold.SetDataType( EDA_DATA_TYPE::AREA );
|
|
|
|
m_islandThreshold.SetDoubleValue( static_cast<double>( m_settings.GetMinIslandArea() ) );
|
|
|
|
|
|
|
|
m_cbRemoveIslands->SetSelection( static_cast<int>( m_settings.GetIslandRemovalMode() ) );
|
|
|
|
|
|
|
|
bool val = m_settings.GetIslandRemovalMode() == ISLAND_REMOVAL_MODE::AREA;
|
|
|
|
|
|
|
|
m_tcIslandThreshold->Enable( val );
|
|
|
|
m_islandThresholdLabel->Enable( val );
|
|
|
|
m_islandThresholdUnits->Enable( val );
|
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
loadPersistentNetSortConfigurations();
|
2018-05-25 14:56:04 +00:00
|
|
|
|
2021-06-27 10:18:53 +00:00
|
|
|
m_sortByPadsOpt->SetValue( m_netSortingByPadCount );
|
2021-07-12 21:55:46 +00:00
|
|
|
m_hideAutoGenNetNamesOpt->SetValue( m_hideAutoGeneratedNets );
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
m_currentlySelectedNetcode = m_settings.m_NetcodeSelection;
|
2011-02-21 19:43:59 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
// Initialize information required to display nets list
|
|
|
|
readNetInformation();
|
2019-03-04 16:34:04 +00:00
|
|
|
|
2022-03-05 16:18:42 +00:00
|
|
|
if( !m_isTeardrop && m_settings.m_FillMode == ZONE_FILL_MODE::HATCH_PATTERN )
|
|
|
|
m_GridStyleCtrl->SetSelection( 1 );
|
|
|
|
else
|
|
|
|
m_GridStyleCtrl->SetSelection( 0 );
|
|
|
|
|
|
|
|
m_GridStyleCtrl->Enable( !m_isTeardrop );
|
2018-02-18 09:09:13 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
m_gridStyleRotation.SetUnits( EDA_UNITS::DEGREES );
|
2022-01-19 00:22:40 +00:00
|
|
|
m_gridStyleRotation.SetAngleValue( m_settings.m_HatchOrientation );
|
2018-02-18 09:09:13 +00:00
|
|
|
|
|
|
|
// Gives a reasonable value to grid style parameters, if currently there are no defined
|
|
|
|
// parameters for grid pattern thickness and gap (if the value is 0)
|
|
|
|
// the grid pattern thickness default value is (arbitrary) m_ZoneMinThickness * 4
|
|
|
|
// or 1mm
|
|
|
|
// the grid pattern gap default value is (arbitrary) m_ZoneMinThickness * 6
|
|
|
|
// or 1.5 mm
|
2020-08-07 14:04:34 +00:00
|
|
|
int bestvalue = m_settings.m_HatchThickness;
|
2018-02-18 09:09:13 +00:00
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
if( bestvalue <= 0 ) // No defined value for m_HatchThickness
|
2018-02-18 09:09:13 +00:00
|
|
|
bestvalue = std::max( m_settings.m_ZoneMinThickness * 4, Millimeter2iu( 1.0 ) );
|
|
|
|
|
|
|
|
m_gridStyleThickness.SetValue( std::max( bestvalue, m_settings.m_ZoneMinThickness ) );
|
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
bestvalue = m_settings.m_HatchGap;
|
2018-02-18 09:09:13 +00:00
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
if( bestvalue <= 0 ) // No defined value for m_HatchGap
|
2018-02-18 09:09:13 +00:00
|
|
|
bestvalue = std::max( m_settings.m_ZoneMinThickness * 6, Millimeter2iu( 1.5 ) );
|
|
|
|
|
|
|
|
m_gridStyleGap.SetValue( std::max( bestvalue, m_settings.m_ZoneMinThickness ) );
|
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
m_spinCtrlSmoothLevel->SetValue( m_settings.m_HatchSmoothingLevel );
|
|
|
|
m_spinCtrlSmoothValue->SetValue( m_settings.m_HatchSmoothingValue );
|
2018-02-18 09:09:13 +00:00
|
|
|
|
2020-06-26 02:19:51 +00:00
|
|
|
m_tcZoneName->SetValue( m_settings.m_Name );
|
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
updateInfoBar();
|
|
|
|
handleRemoveIslandsSelection();
|
|
|
|
|
|
|
|
updateDisplayedListOfNets();
|
|
|
|
|
|
|
|
SetInitialFocus( m_ShowNetNameFilter );
|
|
|
|
|
2018-02-18 09:09:13 +00:00
|
|
|
// Enable/Disable some widgets
|
|
|
|
wxCommandEvent event;
|
|
|
|
OnStyleSelection( event );
|
|
|
|
|
2020-06-26 02:19:51 +00:00
|
|
|
Fit();
|
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
return true;
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
void DIALOG_COPPER_ZONE::readNetInformation()
|
2018-02-20 14:58:01 +00:00
|
|
|
{
|
2021-07-12 21:55:46 +00:00
|
|
|
NETINFO_LIST& netInfoList = m_Parent->GetBoard()->GetNetInfo();
|
2018-05-25 14:56:04 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
if( netInfoList.GetNetCount() > 0 )
|
|
|
|
{
|
|
|
|
buildListOfNets( netInfoList );
|
|
|
|
}
|
|
|
|
}
|
2020-06-26 02:19:51 +00:00
|
|
|
|
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
void DIALOG_COPPER_ZONE::buildListOfNets( const NETINFO_LIST& nets )
|
|
|
|
{
|
|
|
|
m_netInfoItemList.clear();
|
|
|
|
m_netInfoItemList.reserve( nets.GetNetCount() );
|
|
|
|
|
|
|
|
m_netNameToNetCode.clear();
|
|
|
|
m_netNameToNetCode[wxT( "<no net>" )] = INVALID_NET_CODE;
|
|
|
|
|
|
|
|
m_maxNetCode = INVALID_NET_CODE;
|
|
|
|
|
|
|
|
for( NETINFO_ITEM* net : nets )
|
|
|
|
{
|
|
|
|
const int& netCode = net->GetNetCode();
|
|
|
|
const wxString& netName = getUnescapedNetName( net );
|
|
|
|
|
|
|
|
m_netNameToNetCode[netName] = netCode;
|
|
|
|
|
|
|
|
if( netCode > INVALID_NET_CODE && net->IsCurrent() )
|
|
|
|
{
|
|
|
|
m_netInfoItemList.push_back( net );
|
|
|
|
m_maxNetCode = std::max( netCode, m_maxNetCode );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-25 14:56:04 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
|
|
|
|
void DIALOG_COPPER_ZONE::OnUpdateUI( wxUpdateUIEvent& )
|
|
|
|
{
|
2018-07-19 20:08:31 +00:00
|
|
|
if( m_cornerSmoothingType != m_cornerSmoothingChoice->GetSelection() )
|
|
|
|
{
|
|
|
|
m_cornerSmoothingType = m_cornerSmoothingChoice->GetSelection();
|
|
|
|
|
|
|
|
if( m_cornerSmoothingChoice->GetSelection() == ZONE_SETTINGS::SMOOTHING_CHAMFER )
|
|
|
|
m_cornerRadiusLabel->SetLabel( _( "Chamfer distance:" ) );
|
|
|
|
else
|
|
|
|
m_cornerRadiusLabel->SetLabel( _( "Fillet radius:" ) );
|
|
|
|
}
|
2019-04-30 11:16:29 +00:00
|
|
|
|
|
|
|
m_cornerRadiusCtrl->Enable(m_cornerSmoothingType > ZONE_SETTINGS::SMOOTHING_NONE );
|
2018-02-20 14:58:01 +00:00
|
|
|
}
|
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
void DIALOG_COPPER_ZONE::OnButtonCancelClick( wxCommandEvent& event )
|
2011-02-19 10:13:09 +00:00
|
|
|
{
|
2018-05-25 14:56:04 +00:00
|
|
|
// After an "Export Settings to Other Zones" cancel and close must return
|
|
|
|
// ZONE_EXPORT_VALUES instead of wxID_CANCEL.
|
2011-02-19 10:13:09 +00:00
|
|
|
Close( true );
|
|
|
|
}
|
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
void DIALOG_COPPER_ZONE::OnNetSelectionUpdated( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
updateCurrentNetSelection();
|
|
|
|
|
|
|
|
updateInfoBar();
|
|
|
|
|
|
|
|
// When info bar is updated, the nets-list shrinks.
|
|
|
|
// Therefore, we need to reestablish the list and maintain the
|
|
|
|
// correct selection
|
|
|
|
updateDisplayedListOfNets();
|
|
|
|
|
|
|
|
handleRemoveIslandsSelection();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_COPPER_ZONE::OnRemoveIslandsSelection( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
handleRemoveIslandsSelection();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_COPPER_ZONE::handleRemoveIslandsSelection()
|
2012-02-06 05:44:19 +00:00
|
|
|
{
|
2021-07-12 21:55:46 +00:00
|
|
|
bool noNetSelected = m_currentlySelectedNetcode == INVALID_NET_CODE;
|
|
|
|
bool enableSize = !noNetSelected && ( m_cbRemoveIslands->GetSelection() == 2 );
|
2012-02-06 05:44:19 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
// Zones with no net never have islands removed
|
|
|
|
m_cbRemoveIslands->Enable( !noNetSelected );
|
|
|
|
m_islandThresholdLabel->Enable( enableSize );
|
|
|
|
m_islandThresholdUnits->Enable( enableSize );
|
|
|
|
m_tcIslandThreshold->Enable( enableSize );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_COPPER_ZONE::TransferDataFromWindow()
|
|
|
|
{
|
2018-02-18 09:09:13 +00:00
|
|
|
if( m_GridStyleCtrl->GetSelection() > 0 )
|
2019-12-20 14:11:39 +00:00
|
|
|
m_settings.m_FillMode = ZONE_FILL_MODE::HATCH_PATTERN;
|
2018-02-18 09:09:13 +00:00
|
|
|
else
|
2019-12-20 14:11:39 +00:00
|
|
|
m_settings.m_FillMode = ZONE_FILL_MODE::POLYGONS;
|
2018-02-18 09:09:13 +00:00
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
if( !AcceptOptions() )
|
|
|
|
return false;
|
2012-02-06 05:44:19 +00:00
|
|
|
|
2022-01-19 00:22:40 +00:00
|
|
|
m_settings.m_HatchOrientation = m_gridStyleRotation.GetAngleValue();
|
2020-08-07 14:04:34 +00:00
|
|
|
m_settings.m_HatchThickness = m_gridStyleThickness.GetValue();
|
|
|
|
m_settings.m_HatchGap = m_gridStyleGap.GetValue();
|
|
|
|
m_settings.m_HatchSmoothingLevel = m_spinCtrlSmoothLevel->GetValue();
|
|
|
|
m_settings.m_HatchSmoothingValue = m_spinCtrlSmoothValue->GetValue();
|
2018-02-18 09:09:13 +00:00
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
*m_ptr = m_settings;
|
|
|
|
return true;
|
|
|
|
}
|
2011-02-19 10:13:09 +00:00
|
|
|
|
2019-03-04 16:34:04 +00:00
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
void DIALOG_COPPER_ZONE::OnClose( wxCloseEvent& event )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2021-02-20 13:06:12 +00:00
|
|
|
SetReturnCode( m_settingsExported ? ZONE_EXPORT_VALUES : wxID_CANCEL );
|
|
|
|
event.Skip();
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
bool DIALOG_COPPER_ZONE::AcceptOptions( bool aUseExportableSetupOnly )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2018-11-29 18:59:38 +00:00
|
|
|
if( !m_clearance.Validate( 0, Mils2iu( ZONE_CLEARANCE_MAX_VALUE_MIL ) ) )
|
|
|
|
return false;
|
2018-02-18 09:09:13 +00:00
|
|
|
|
2018-11-29 18:59:38 +00:00
|
|
|
if( !m_minWidth.Validate( Mils2iu( ZONE_THICKNESS_MIN_VALUE_MIL ), INT_MAX ) )
|
|
|
|
return false;
|
2018-02-18 09:09:13 +00:00
|
|
|
|
2018-11-29 18:59:38 +00:00
|
|
|
if( !m_cornerRadius.Validate( 0, INT_MAX ) )
|
|
|
|
return false;
|
2018-02-18 09:09:13 +00:00
|
|
|
|
2018-11-29 18:59:38 +00:00
|
|
|
if( !m_spokeWidth.Validate( 0, INT_MAX ) )
|
|
|
|
return false;
|
|
|
|
|
2019-09-05 14:36:23 +00:00
|
|
|
m_gridStyleRotation.SetValue( NormalizeAngle180( m_gridStyleRotation.GetValue() ) );
|
2018-02-18 09:09:13 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
if( m_settings.m_FillMode == ZONE_FILL_MODE::HATCH_PATTERN )
|
2018-05-25 14:56:04 +00:00
|
|
|
{
|
2018-02-18 09:09:13 +00:00
|
|
|
int minThickness = m_minWidth.GetValue();
|
2018-05-25 14:56:04 +00:00
|
|
|
|
2018-02-18 09:09:13 +00:00
|
|
|
if( !m_gridStyleThickness.Validate( minThickness, INT_MAX ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( !m_gridStyleGap.Validate( minThickness, INT_MAX ) )
|
|
|
|
return false;
|
2018-05-25 14:56:04 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 22:40:31 +00:00
|
|
|
switch( m_PadInZoneOpt->GetSelection() )
|
|
|
|
{
|
2021-03-04 19:15:52 +00:00
|
|
|
case 3: m_settings.SetPadConnection( ZONE_CONNECTION::NONE ); break;
|
|
|
|
case 2: m_settings.SetPadConnection( ZONE_CONNECTION::THT_THERMAL ); break;
|
|
|
|
case 1: m_settings.SetPadConnection( ZONE_CONNECTION::THERMAL ); break;
|
|
|
|
case 0: m_settings.SetPadConnection( ZONE_CONNECTION::FULL ); break;
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
switch( m_OutlineDisplayCtrl->GetSelection() )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2020-08-07 14:04:34 +00:00
|
|
|
case 0: m_settings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::NO_HATCH; break;
|
|
|
|
case 1: m_settings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE; break;
|
|
|
|
case 2: m_settings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL; break;
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
2022-02-12 16:37:27 +00:00
|
|
|
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();
|
|
|
|
|
2021-03-04 19:15:52 +00:00
|
|
|
PCBNEW_SETTINGS* cfg = m_Parent->GetPcbNewSettings();
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
cfg->m_Zones.hatching_style = static_cast<int>( m_settings.m_ZoneBorderDisplayStyle );
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
m_settings.m_ZoneClearance = m_clearance.GetValue();
|
|
|
|
m_settings.m_ZoneMinThickness = m_minWidth.GetValue();
|
2008-11-22 20:50:30 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
m_settings.SetCornerSmoothingType( m_cornerSmoothingChoice->GetSelection() );
|
2019-04-30 11:16:29 +00:00
|
|
|
|
|
|
|
m_settings.SetCornerRadius( m_settings.GetCornerSmoothingType() == ZONE_SETTINGS::SMOOTHING_NONE
|
|
|
|
? 0 : m_cornerRadius.GetValue() );
|
2011-02-21 19:43:59 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
m_settings.m_ZonePriority = m_PriorityLevelCtrl->GetValue();
|
2012-01-29 19:29:19 +00:00
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
m_settings.m_Zone_45_Only = m_constrainOutline->GetValue();
|
2021-05-06 21:49:07 +00:00
|
|
|
m_settings.m_Locked = m_cbLocked->GetValue();
|
2012-02-06 05:44:19 +00:00
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
m_settings.m_ThermalReliefGap = m_antipadClearance.GetValue();
|
2020-09-17 13:14:45 +00:00
|
|
|
m_settings.m_ThermalReliefSpokeWidth = m_spokeWidth.GetValue();
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2020-09-17 13:14:45 +00:00
|
|
|
if( m_settings.m_ThermalReliefSpokeWidth < m_settings.m_ZoneMinThickness )
|
2018-09-03 11:57:11 +00:00
|
|
|
{
|
2019-07-12 12:56:02 +00:00
|
|
|
DisplayError( this, _( "Thermal spoke width cannot be smaller than the minimum width." ) );
|
2018-09-03 11:57:11 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
storePersistentNetSortConfigurations();
|
2020-01-13 01:44:19 +00:00
|
|
|
cfg->m_Zones.clearance = Iu2Mils( m_settings.m_ZoneClearance );
|
|
|
|
cfg->m_Zones.min_thickness = Iu2Mils( m_settings.m_ZoneMinThickness );
|
|
|
|
cfg->m_Zones.thermal_relief_gap = Iu2Mils( m_settings.m_ThermalReliefGap );
|
2020-09-17 13:14:45 +00:00
|
|
|
cfg->m_Zones.thermal_relief_copper_width = Iu2Mils( m_settings.m_ThermalReliefSpokeWidth );
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2020-06-26 02:19:51 +00:00
|
|
|
m_settings.SetIslandRemovalMode(
|
|
|
|
static_cast<ISLAND_REMOVAL_MODE>( m_cbRemoveIslands->GetSelection() ) );
|
|
|
|
m_settings.SetMinIslandArea( m_islandThreshold.GetValue() );
|
|
|
|
|
2008-11-14 22:40:31 +00:00
|
|
|
// If we use only exportable to others zones parameters, exit here:
|
|
|
|
if( aUseExportableSetupOnly )
|
|
|
|
return true;
|
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
// Get the layer selection for this zone
|
2020-08-09 11:22:09 +00:00
|
|
|
int layers = 0;
|
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
for( int ii = 0; ii < m_layers->GetItemCount(); ++ii )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2018-05-25 14:56:04 +00:00
|
|
|
if( m_layers->GetToggleValue( (unsigned) ii, 0 ) )
|
2020-08-09 11:22:09 +00:00
|
|
|
layers++;
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
2020-08-09 11:22:09 +00:00
|
|
|
if( layers == 0 )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2018-05-25 14:56:04 +00:00
|
|
|
DisplayError( this, _( "No layer selected." ) );
|
2008-11-14 22:40:31 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
m_settings.m_NetcodeSelection = m_currentlySelectedNetcode;
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2020-06-26 02:19:51 +00:00
|
|
|
m_settings.m_Name = m_tcZoneName->GetValue();
|
|
|
|
|
2008-11-14 22:40:31 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-09-17 20:43:14 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
void DIALOG_COPPER_ZONE::updateCurrentNetSelection()
|
|
|
|
{
|
|
|
|
const int netSelection{ m_ListNetNameSelection->GetSelection() };
|
|
|
|
|
|
|
|
if( netSelection )
|
|
|
|
{
|
|
|
|
const wxString& selectedNetName = m_ListNetNameSelection->GetString( netSelection );
|
|
|
|
m_currentlySelectedNetcode = m_netNameToNetCode[selectedNetName];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_currentlySelectedNetcode = INVALID_NET_CODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-18 09:09:13 +00:00
|
|
|
void DIALOG_COPPER_ZONE::OnStyleSelection( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
bool enable = m_GridStyleCtrl->GetSelection() >= 1;
|
|
|
|
m_tcGridStyleThickness->Enable( enable );
|
|
|
|
m_tcGridStyleGap->Enable( enable );
|
|
|
|
m_tcGridStyleOrientation->Enable( enable );
|
|
|
|
m_spinCtrlSmoothLevel->Enable( enable );
|
|
|
|
m_spinCtrlSmoothValue->Enable( enable );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
void DIALOG_COPPER_ZONE::OnLayerSelection( wxDataViewEvent& event )
|
2012-02-06 05:44:19 +00:00
|
|
|
{
|
2018-05-25 14:56:04 +00:00
|
|
|
if( event.GetColumn() != 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int row = m_layers->ItemToRow( event.GetItem() );
|
2012-02-06 05:44:19 +00:00
|
|
|
|
2020-08-09 11:22:09 +00:00
|
|
|
bool checked = m_layers->GetToggleValue( row, 0 );
|
|
|
|
|
2020-06-24 02:19:08 +00:00
|
|
|
wxVariant layerID;
|
|
|
|
m_layers->GetValue( layerID, row, 2 );
|
2020-08-09 11:22:09 +00:00
|
|
|
|
|
|
|
m_settings.m_Layers.set( ToLAYER_ID( layerID.GetInteger() ), checked );
|
2012-02-06 05:44:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 22:40:31 +00:00
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
void DIALOG_COPPER_ZONE::OnNetSortingOptionSelected( wxCommandEvent& event )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2021-07-12 21:55:46 +00:00
|
|
|
updateDisplayedListOfNets();
|
|
|
|
}
|
2015-09-17 20:43:14 +00:00
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
void DIALOG_COPPER_ZONE::storePersistentNetSortConfigurations()
|
|
|
|
{
|
|
|
|
// These configurations are persistent across multiple invokations of
|
|
|
|
// this dialog
|
|
|
|
int newConfig{ NO_PERSISTENT_SORT_MODE };
|
2018-05-25 14:56:04 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
if( m_hideAutoGeneratedNets )
|
|
|
|
{
|
|
|
|
newConfig |= HIDE_ANONYMOUS_NETS;
|
|
|
|
}
|
2018-05-25 14:56:04 +00:00
|
|
|
|
2021-06-27 10:18:53 +00:00
|
|
|
if( m_netSortingByPadCount )
|
2021-07-12 21:55:46 +00:00
|
|
|
{
|
|
|
|
newConfig |= SORT_BY_PAD_COUNT;
|
|
|
|
}
|
|
|
|
|
|
|
|
PCBNEW_SETTINGS* cfg = m_Parent->GetPcbNewSettings();
|
|
|
|
cfg->m_Zones.net_sort_mode = newConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_COPPER_ZONE::loadPersistentNetSortConfigurations()
|
|
|
|
{
|
|
|
|
PCBNEW_SETTINGS* cfg{ m_Parent->GetPcbNewSettings() };
|
|
|
|
int savedConfig{ cfg->m_Zones.net_sort_mode };
|
|
|
|
|
|
|
|
if( savedConfig == DEFAULT_SORT_CONFIG )
|
|
|
|
{
|
|
|
|
savedConfig = HIDE_ANONYMOUS_NETS;
|
|
|
|
}
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
m_hideAutoGeneratedNets = ( savedConfig & HIDE_ANONYMOUS_NETS );
|
|
|
|
m_netSortingByPadCount = ( savedConfig & SORT_BY_PAD_COUNT );
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 22:36:38 +00:00
|
|
|
void DIALOG_COPPER_ZONE::ExportSetupToOtherCopperZones( wxCommandEvent& event )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2018-05-25 14:56:04 +00:00
|
|
|
if( !AcceptOptions( true ) )
|
2008-11-14 22:40:31 +00:00
|
|
|
return;
|
|
|
|
|
2012-11-23 09:10:37 +00:00
|
|
|
// Export settings ( but layer and netcode ) to others copper zones
|
2009-01-05 05:21:35 +00:00
|
|
|
BOARD* pcb = m_Parent->GetBoard();
|
2015-09-17 20:43:14 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
for( ZONE* zone : pcb->Zones() )
|
2008-11-14 22:40:31 +00:00
|
|
|
{
|
2012-11-23 09:10:37 +00:00
|
|
|
// Cannot export settings from a copper zone
|
|
|
|
// to a zone keepout:
|
2020-09-21 23:32:07 +00:00
|
|
|
if( zone->GetIsRuleArea() )
|
2012-11-23 09:10:37 +00:00
|
|
|
continue;
|
2015-09-17 20:43:14 +00:00
|
|
|
|
2022-03-05 16:18:42 +00:00
|
|
|
// Export only to similar zones:
|
|
|
|
// Teardrop area -> teardrop area of same type
|
|
|
|
// copper zone -> copper zone
|
|
|
|
// Exporting current settings to a different zone type make no sense
|
|
|
|
if( m_settings.m_TeardropType != zone->GetTeardropAreaType() )
|
|
|
|
continue;
|
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
m_settings.ExportSetting( *zone, false ); // false = partial export
|
2018-05-25 14:56:04 +00:00
|
|
|
m_settingsExported = true;
|
2010-02-19 13:23:58 +00:00
|
|
|
m_Parent->OnModify();
|
2008-11-14 22:40:31 +00:00
|
|
|
}
|
2010-08-23 12:13:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
void DIALOG_COPPER_ZONE::OnShowNetNameFilterChange( wxCommandEvent& event )
|
2010-08-23 12:13:48 +00:00
|
|
|
{
|
2021-07-12 21:55:46 +00:00
|
|
|
updateDisplayedListOfNets();
|
|
|
|
}
|
2015-09-17 20:43:14 +00:00
|
|
|
|
2021-07-03 19:26:09 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
void DIALOG_COPPER_ZONE::updateDisplayedListOfNets()
|
|
|
|
{
|
|
|
|
readFilteringAndSortingCriteria();
|
2021-07-03 19:26:09 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
wxArrayString listOfNets = buildListOfNetsToDisplay();
|
2021-07-03 19:26:09 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
const int selectedNet = ensureSelectedNetIsVisible( m_currentlySelectedNetcode, listOfNets );
|
2021-07-03 19:26:09 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
displayNetsList( listOfNets, selectedNet );
|
2010-08-23 12:13:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
void DIALOG_COPPER_ZONE::readFilteringAndSortingCriteria()
|
|
|
|
{
|
|
|
|
updateShowNetsFilter();
|
2021-06-27 10:18:53 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
// Hide nets filter criteria
|
|
|
|
m_hideAutoGeneratedNets = m_hideAutoGenNetNamesOpt->GetValue();
|
2021-06-27 10:18:53 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
// Nets sort criteria
|
|
|
|
m_netSortingByPadCount = m_sortByPadsOpt->GetValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_COPPER_ZONE::updateShowNetsFilter()
|
2021-06-27 10:18:53 +00:00
|
|
|
{
|
2021-07-12 21:55:46 +00:00
|
|
|
wxString netNameShowFilter = m_ShowNetNameFilter->GetValue();
|
2021-06-27 10:18:53 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
if( netNameShowFilter.Len() == 0 )
|
|
|
|
{
|
|
|
|
netNameShowFilter = wxT( "*" );
|
|
|
|
}
|
|
|
|
|
2022-02-04 22:44:59 +00:00
|
|
|
wxStringTokenizer showFilters( netNameShowFilter.Lower(), wxT( "," ) );
|
2021-07-12 21:55:46 +00:00
|
|
|
|
|
|
|
m_showNetsFilter.clear();
|
|
|
|
|
|
|
|
while( showFilters.HasMoreTokens() )
|
|
|
|
{
|
|
|
|
wxString filter = showFilters.GetNextToken();
|
|
|
|
filter.Trim( false );
|
|
|
|
filter.Trim( true );
|
|
|
|
|
|
|
|
if( !filter.IsEmpty() )
|
|
|
|
{
|
|
|
|
m_showNetsFilter.emplace_back( std::make_unique<EDA_PATTERN_MATCH_WILDCARD>() );
|
|
|
|
m_showNetsFilter.back()->SetPattern( filter );
|
|
|
|
}
|
|
|
|
}
|
2021-06-27 10:18:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
wxArrayString DIALOG_COPPER_ZONE::buildListOfNetsToDisplay()
|
2021-06-27 10:18:53 +00:00
|
|
|
{
|
2021-07-12 21:55:46 +00:00
|
|
|
sortNetsIfRequired();
|
|
|
|
|
|
|
|
const wxArrayString sortedNetNames = getSortedNetNamesList();
|
|
|
|
|
|
|
|
const wxArrayString netsAfterShowFilter = applyShowFilter( sortedNetNames );
|
|
|
|
|
|
|
|
wxArrayString filteredNetNames = applyHideFilterIfRequired( netsAfterShowFilter );
|
|
|
|
|
|
|
|
return filteredNetNames;
|
2021-06-27 10:18:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
void DIALOG_COPPER_ZONE::sortNetsIfRequired()
|
2010-08-23 12:13:48 +00:00
|
|
|
{
|
2021-07-12 21:55:46 +00:00
|
|
|
if( m_netSortingByPadCount )
|
|
|
|
{
|
|
|
|
sortNetsByPadCount( m_netInfoItemList, m_maxNetCode );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sort( m_netInfoItemList.begin(), m_netInfoItemList.end(), sortNetsByNames );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_COPPER_ZONE::sortNetsByPadCount( std::vector<NETINFO_ITEM*>& nets,
|
|
|
|
const int maxNetCode )
|
|
|
|
{
|
|
|
|
const std::vector<PAD*> pads = m_Parent->GetBoard()->GetPads();
|
|
|
|
|
|
|
|
padCountListByNet.clear();
|
2021-07-03 19:12:30 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
// +1 is required for <no-net> item
|
|
|
|
padCountListByNet.assign( maxNetCode + 1, 0 );
|
2010-08-23 12:13:48 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
for( PAD* pad : pads )
|
2021-06-27 10:18:53 +00:00
|
|
|
{
|
2021-07-12 21:55:46 +00:00
|
|
|
const int netCode = pad->GetNetCode();
|
2021-06-27 10:18:53 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
if( netCode > INVALID_NET_CODE )
|
|
|
|
padCountListByNet[netCode]++;
|
|
|
|
}
|
2010-08-23 12:13:48 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
sort( nets.begin(), nets.end(), sortNetsByNodes );
|
|
|
|
}
|
2021-06-27 10:18:53 +00:00
|
|
|
|
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
wxArrayString DIALOG_COPPER_ZONE::getSortedNetNamesList()
|
|
|
|
{
|
|
|
|
wxArrayString sortedNetNames;
|
2021-06-27 10:18:53 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
for( NETINFO_ITEM* net : m_netInfoItemList )
|
|
|
|
{
|
|
|
|
const wxString& netName = getUnescapedNetName( net );
|
|
|
|
sortedNetNames.Add( netName );
|
|
|
|
}
|
2021-06-27 10:18:53 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
return sortedNetNames;
|
|
|
|
}
|
2021-06-27 10:18:53 +00:00
|
|
|
|
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
wxArrayString DIALOG_COPPER_ZONE::applyShowFilter( const wxArrayString& netNames )
|
|
|
|
{
|
|
|
|
wxArrayString netsAfterShowFilter;
|
2021-06-27 10:18:53 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
for( const wxString& netName : netNames )
|
|
|
|
{
|
|
|
|
for( const NET_FILTER& filter : m_showNetsFilter )
|
2021-06-27 10:18:53 +00:00
|
|
|
{
|
2021-07-12 21:55:46 +00:00
|
|
|
if( filter->Find( netName.Lower() ) )
|
|
|
|
{
|
|
|
|
netsAfterShowFilter.Add( netName );
|
|
|
|
}
|
2021-06-27 10:18:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
return netsAfterShowFilter;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxArrayString DIALOG_COPPER_ZONE::applyHideFilterIfRequired( const wxArrayString& netNames )
|
|
|
|
{
|
|
|
|
wxArrayString filteredNetNames;
|
2011-08-27 23:31:56 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
if( m_hideAutoGeneratedNets )
|
|
|
|
{
|
|
|
|
for( const wxString& netName : netNames )
|
2010-08-23 12:13:48 +00:00
|
|
|
{
|
2021-07-12 21:55:46 +00:00
|
|
|
if( !isAutoGenerated( netName ) )
|
2010-08-23 12:13:48 +00:00
|
|
|
{
|
2021-07-12 21:55:46 +00:00
|
|
|
filteredNetNames.Add( netName );
|
2010-08-23 12:13:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-12 21:55:46 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
filteredNetNames = netNames;
|
|
|
|
}
|
|
|
|
|
|
|
|
filteredNetNames.Insert( wxT( "<no net>" ), INVALID_NET_CODE );
|
|
|
|
|
|
|
|
return filteredNetNames;
|
|
|
|
}
|
|
|
|
|
2011-08-27 23:31:56 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
bool DIALOG_COPPER_ZONE::isAutoGenerated( const wxString& netName )
|
|
|
|
{
|
2022-02-04 22:44:59 +00:00
|
|
|
return netName.StartsWith( wxT( "Net-(" ) ) || netName.StartsWith( wxT( "unconnected-(" ) );
|
2021-07-12 21:55:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_COPPER_ZONE::displayNetsList( const wxArrayString& netNamesList, int selectIndex )
|
|
|
|
{
|
|
|
|
m_ListNetNameSelection->Clear();
|
|
|
|
m_ListNetNameSelection->InsertItems( netNamesList, 0 );
|
|
|
|
m_ListNetNameSelection->SetSelection( selectIndex );
|
|
|
|
m_ListNetNameSelection->EnsureVisible( selectIndex );
|
|
|
|
}
|
2010-08-23 12:13:48 +00:00
|
|
|
|
2011-08-27 23:31:56 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
int DIALOG_COPPER_ZONE::ensureSelectedNetIsVisible( int selectedNetCode, wxArrayString& netsList )
|
|
|
|
{
|
|
|
|
int selectedIndex = 0;
|
|
|
|
if( selectedNetCode > INVALID_NET_CODE )
|
2010-08-23 12:13:48 +00:00
|
|
|
{
|
2021-07-12 21:55:46 +00:00
|
|
|
NETINFO_ITEM* selectedNet = m_Parent->GetBoard()->FindNet( selectedNetCode );
|
2021-06-27 10:18:53 +00:00
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
if( selectedNet )
|
2010-08-23 12:13:48 +00:00
|
|
|
{
|
2021-07-12 21:55:46 +00:00
|
|
|
const wxString& netName = getUnescapedNetName( selectedNet );
|
|
|
|
selectedIndex = netsList.Index( netName );
|
2011-08-27 23:31:56 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
if( wxNOT_FOUND == selectedIndex )
|
2010-08-23 12:13:48 +00:00
|
|
|
{
|
2011-08-27 23:31:56 +00:00
|
|
|
// the currently selected net must *always* be visible.
|
2018-05-25 14:56:04 +00:00
|
|
|
// <no net> is the zero'th index, so pick next lowest
|
2021-07-12 21:55:46 +00:00
|
|
|
netsList.Insert( netName, 1 );
|
|
|
|
selectedIndex = 1;
|
2010-08-23 12:13:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-08-27 23:31:56 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
return selectedIndex;
|
2010-08-23 12:13:48 +00:00
|
|
|
}
|
2011-02-19 10:13:09 +00:00
|
|
|
|
2021-07-12 21:55:46 +00:00
|
|
|
|
|
|
|
wxString DIALOG_COPPER_ZONE::getUnescapedNetName( const NETINFO_ITEM* net )
|
|
|
|
{
|
|
|
|
return UnescapeString( net->GetNetname() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_COPPER_ZONE::updateInfoBar()
|
|
|
|
{
|
|
|
|
if( m_currentlySelectedNetcode <= INVALID_NET_CODE && !m_copperZoneInfo->IsShown() )
|
|
|
|
{
|
|
|
|
m_copperZoneInfo->ShowMessage(
|
|
|
|
_( "Selecting <no net> will create an isolated copper island." ), wxICON_WARNING );
|
|
|
|
}
|
|
|
|
else if( m_currentlySelectedNetcode > INVALID_NET_CODE && m_copperZoneInfo->IsShown() )
|
|
|
|
{
|
|
|
|
m_copperZoneInfo->Dismiss();
|
|
|
|
}
|
|
|
|
}
|