2019-06-19 07:18:30 -07:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2023-01-09 08:49:20 -05:00
|
|
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-06-19 07:18:30 -07: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
|
|
|
|
*/
|
|
|
|
|
2024-10-09 22:43:40 +01:00
|
|
|
#include <advanced_config.h>
|
2021-09-14 23:45:14 +01:00
|
|
|
#include <kiface_base.h>
|
2019-06-19 07:18:30 -07:00
|
|
|
#include <confirm.h>
|
2024-04-27 22:57:24 +03:00
|
|
|
#include <board.h>
|
2024-10-09 22:43:40 +01:00
|
|
|
#include <footprint.h>
|
2019-06-19 07:18:30 -07:00
|
|
|
#include <pcb_edit_frame.h>
|
2020-01-12 20:44:19 -05:00
|
|
|
#include <pcbnew_settings.h>
|
2019-06-19 07:18:30 -07:00
|
|
|
#include <zone_settings.h>
|
2020-09-21 19:32:07 -04:00
|
|
|
#include <dialog_rule_area_properties_base.h>
|
2024-10-09 22:43:40 +01:00
|
|
|
#include <panel_rule_area_properties_keepout_base.h>
|
|
|
|
#include <panel_rule_area_properties_placement_base.h>
|
2022-02-12 18:56:45 +01:00
|
|
|
#include <widgets/unit_binder.h>
|
2022-07-29 20:56:55 +01:00
|
|
|
#include <wx/statbox.h>
|
2023-01-09 08:49:20 -05:00
|
|
|
#include <wx/statline.h>
|
2022-11-28 20:46:30 +00:00
|
|
|
#include <wx/radiobut.h>
|
2019-06-19 07:18:30 -07:00
|
|
|
|
2019-10-28 10:15:03 +01:00
|
|
|
#define LAYER_LIST_COLUMN_CHECK 0
|
|
|
|
#define LAYER_LIST_COLUMN_ICON 1
|
|
|
|
#define LAYER_LIST_COLUMN_NAME 2
|
|
|
|
#define LAYER_LIST_ROW_ALL_INNER_LAYERS 1
|
2019-06-19 07:18:30 -07:00
|
|
|
|
2021-07-19 19:56:05 -04:00
|
|
|
|
2020-09-21 19:32:07 -04:00
|
|
|
class DIALOG_RULE_AREA_PROPERTIES : public DIALOG_RULE_AREA_PROPERTIES_BASE
|
2019-06-19 07:18:30 -07:00
|
|
|
{
|
|
|
|
public:
|
2022-07-29 20:56:55 +01:00
|
|
|
DIALOG_RULE_AREA_PROPERTIES( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings,
|
2024-10-09 22:43:40 +01:00
|
|
|
CONVERT_SETTINGS* aConvertSettings, BOARD* aBoard );
|
|
|
|
~DIALOG_RULE_AREA_PROPERTIES();
|
2019-06-19 07:18:30 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
bool TransferDataFromWindow() override;
|
|
|
|
|
2024-10-09 22:43:40 +01:00
|
|
|
void PopulatePlacementSourceList( RULE_AREA_PLACEMENT_SOURCE_TYPE placementType );
|
|
|
|
|
2019-06-19 07:18:30 -07:00
|
|
|
void OnLayerSelection( wxDataViewEvent& event ) override;
|
2024-10-09 22:43:40 +01:00
|
|
|
void OnSheetNameRbClicked( wxCommandEvent& event );
|
|
|
|
void OnComponentClassRbClicked( wxCommandEvent& event );
|
2022-07-29 20:56:55 +01:00
|
|
|
|
|
|
|
private:
|
2024-10-09 22:43:40 +01:00
|
|
|
BOARD* m_board;
|
2022-07-29 20:56:55 +01:00
|
|
|
UNIT_BINDER m_outlineHatchPitch;
|
|
|
|
PCB_BASE_FRAME* m_parent;
|
|
|
|
ZONE_SETTINGS m_zonesettings; ///< the working copy of zone settings
|
|
|
|
ZONE_SETTINGS* m_ptr; ///< the pointer to the zone settings of the zone to edit
|
|
|
|
bool m_isFpEditor;
|
|
|
|
|
|
|
|
CONVERT_SETTINGS* m_convertSettings;
|
2022-11-28 20:46:30 +00:00
|
|
|
wxRadioButton* m_rbCenterline;
|
2024-02-14 17:21:02 +00:00
|
|
|
wxRadioButton* m_rbBoundingHull;
|
|
|
|
wxStaticText* m_gapLabel;
|
|
|
|
wxTextCtrl* m_gapCtrl;
|
|
|
|
wxStaticText* m_gapUnits;
|
|
|
|
UNIT_BINDER* m_gap;
|
2022-07-29 20:56:55 +01:00
|
|
|
wxCheckBox* m_cbDeleteOriginals;
|
2024-10-09 22:43:40 +01:00
|
|
|
|
|
|
|
// The name of a rule area source that is not now found on the board (e.g. after a netlist
|
|
|
|
// update). This is used to re-populate the zone settings if the selection is not changed.
|
|
|
|
wxString m_notFoundPlacementSourceName;
|
|
|
|
|
|
|
|
PANEL_RULE_AREA_PROPERTIES_KEEPOUT_BASE* m_keepoutProperties;
|
|
|
|
PANEL_RULE_AREA_PROPERTIES_PLACEMENT_BASE* m_placementProperties;
|
|
|
|
RULE_AREA_PLACEMENT_SOURCE_TYPE m_currentKeepoutSource;
|
|
|
|
|
|
|
|
std::set<wxString> m_sheetNames;
|
|
|
|
std::set<wxString> m_componentClasses;
|
2019-06-19 07:18:30 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2024-10-09 22:43:40 +01:00
|
|
|
int InvokeRuleAreaEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aZoneSettings, BOARD* aBoard,
|
2022-07-29 20:56:55 +01:00
|
|
|
CONVERT_SETTINGS* aConvertSettings )
|
2019-06-19 07:18:30 -07:00
|
|
|
{
|
2024-10-09 22:43:40 +01:00
|
|
|
DIALOG_RULE_AREA_PROPERTIES dlg( aCaller, aZoneSettings, aConvertSettings, aBoard );
|
2019-06-19 07:18:30 -07:00
|
|
|
|
|
|
|
return dlg.ShowModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-10-09 22:43:40 +01:00
|
|
|
DIALOG_RULE_AREA_PROPERTIES::DIALOG_RULE_AREA_PROPERTIES( PCB_BASE_FRAME* aParent,
|
|
|
|
ZONE_SETTINGS* aSettings,
|
|
|
|
CONVERT_SETTINGS* aConvertSettings,
|
|
|
|
BOARD* aBoard ) :
|
2022-02-12 18:56:45 +01:00
|
|
|
DIALOG_RULE_AREA_PROPERTIES_BASE( aParent ),
|
2024-10-09 22:43:40 +01:00
|
|
|
m_board( aBoard ), m_outlineHatchPitch( aParent, m_stBorderHatchPitchText,
|
|
|
|
m_outlineHatchPitchCtrl, m_outlineHatchUnits ),
|
|
|
|
m_convertSettings( aConvertSettings ), m_rbCenterline( nullptr ),
|
|
|
|
m_rbBoundingHull( nullptr ), m_cbDeleteOriginals( nullptr )
|
2019-06-19 07:18:30 -07:00
|
|
|
{
|
|
|
|
m_parent = aParent;
|
|
|
|
|
|
|
|
m_ptr = aSettings;
|
|
|
|
m_zonesettings = *aSettings;
|
2019-10-28 10:15:03 +01:00
|
|
|
|
2024-10-09 22:43:40 +01:00
|
|
|
m_keepoutProperties = new PANEL_RULE_AREA_PROPERTIES_KEEPOUT_BASE( m_areaPropertiesNb );
|
|
|
|
m_areaPropertiesNb->AddPage( m_keepoutProperties, _( "Keepout" ), true );
|
|
|
|
|
|
|
|
if( ADVANCED_CFG::GetCfg().m_EnableMultichannelTool )
|
|
|
|
{
|
|
|
|
m_placementProperties = new PANEL_RULE_AREA_PROPERTIES_PLACEMENT_BASE( m_areaPropertiesNb );
|
|
|
|
m_areaPropertiesNb->AddPage( m_placementProperties, _( "Placement" ) );
|
|
|
|
|
|
|
|
m_placementProperties->m_sourceSheetnameRb->Connect(
|
|
|
|
wxEVT_RADIOBUTTON,
|
|
|
|
wxCommandEventHandler( DIALOG_RULE_AREA_PROPERTIES::OnSheetNameRbClicked ), NULL,
|
|
|
|
this );
|
|
|
|
m_placementProperties->m_sourceComponentClassRb->Connect(
|
|
|
|
wxEVT_RADIOBUTTON,
|
|
|
|
wxCommandEventHandler( DIALOG_RULE_AREA_PROPERTIES::OnComponentClassRbClicked ),
|
|
|
|
NULL, this );
|
|
|
|
}
|
|
|
|
|
2022-07-29 20:56:55 +01:00
|
|
|
if( aConvertSettings )
|
|
|
|
{
|
2023-01-09 08:49:20 -05:00
|
|
|
wxStaticBox* bConvertBox = new wxStaticBox( this, wxID_ANY,
|
|
|
|
_( "Conversion Settings" ) );
|
2022-11-28 20:46:30 +00:00
|
|
|
wxStaticBoxSizer* bConvertSizer = new wxStaticBoxSizer( bConvertBox, wxVERTICAL );
|
2022-07-29 20:56:55 +01:00
|
|
|
|
2022-11-28 20:46:30 +00:00
|
|
|
m_rbCenterline = new wxRadioButton( this, wxID_ANY, _( "Use centerlines" ) );
|
|
|
|
bConvertSizer->Add( m_rbCenterline, 0, wxLEFT|wxRIGHT, 5 );
|
2022-07-29 20:56:55 +01:00
|
|
|
|
2022-11-28 20:46:30 +00:00
|
|
|
bConvertSizer->AddSpacer( 2 );
|
2024-02-14 17:21:02 +00:00
|
|
|
m_rbBoundingHull = new wxRadioButton( this, wxID_ANY, _( "Create bounding hull" ) );
|
|
|
|
bConvertSizer->Add( m_rbBoundingHull, 0, wxLEFT|wxRIGHT, 5 );
|
|
|
|
|
|
|
|
m_gapLabel = new wxStaticText( this, wxID_ANY, _( "Gap:" ) );
|
|
|
|
m_gapCtrl = new wxTextCtrl( this, wxID_ANY );
|
|
|
|
m_gapUnits = new wxStaticText( this, wxID_ANY, _( "mm" ) );
|
|
|
|
m_gap = new UNIT_BINDER( aParent, m_gapLabel, m_gapCtrl, m_gapUnits );
|
|
|
|
|
|
|
|
wxBoxSizer* hullParamsSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
hullParamsSizer->Add( m_gapLabel, 0, wxALIGN_CENTRE_VERTICAL, 5 );
|
|
|
|
hullParamsSizer->Add( m_gapCtrl, 1, wxALIGN_CENTRE_VERTICAL|wxLEFT|wxRIGHT, 3 );
|
|
|
|
hullParamsSizer->Add( m_gapUnits, 0, wxALIGN_CENTRE_VERTICAL, 5 );
|
|
|
|
|
|
|
|
bConvertSizer->AddSpacer( 2 );
|
|
|
|
bConvertSizer->Add( hullParamsSizer, 0, wxLEFT, 26 );
|
2022-07-29 20:56:55 +01:00
|
|
|
|
2022-11-28 20:46:30 +00:00
|
|
|
bConvertSizer->AddSpacer( 6 );
|
2023-01-09 08:49:20 -05:00
|
|
|
m_cbDeleteOriginals = new wxCheckBox( this, wxID_ANY,
|
|
|
|
_( "Delete source objects after conversion" ) );
|
2022-07-29 20:56:55 +01:00
|
|
|
bConvertSizer->Add( m_cbDeleteOriginals, 0, wxALL, 5 );
|
|
|
|
|
|
|
|
GetSizer()->Insert( 0, bConvertSizer, 0, wxALL|wxEXPAND, 10 );
|
|
|
|
|
|
|
|
wxStaticLine* line = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxLI_HORIZONTAL );
|
|
|
|
GetSizer()->Insert( 1, line, 0, wxLEFT|wxRIGHT|wxEXPAND, 10 );
|
|
|
|
|
|
|
|
SetTitle( _( "Convert to Rule Area" ) );
|
|
|
|
}
|
|
|
|
|
2022-02-17 23:54:15 +00:00
|
|
|
m_isFpEditor = m_parent->IsType( FRAME_FOOTPRINT_EDITOR );
|
2019-11-16 13:01:00 +01:00
|
|
|
|
2022-02-17 23:54:15 +00:00
|
|
|
BOARD* board = m_parent->GetBoard();
|
2024-02-20 18:23:51 +00:00
|
|
|
LSET layers = LSET::AllNonCuMask() | LSET::AllCuMask( board->GetCopperLayerCount() );
|
2022-02-17 23:54:15 +00:00
|
|
|
|
|
|
|
m_zonesettings.SetupLayersList( m_layers, m_parent, layers, m_isFpEditor );
|
2019-06-19 07:18:30 -07:00
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons();
|
2019-06-19 07:18:30 -07:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2019-06-19 07:18:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-10-09 22:43:40 +01:00
|
|
|
DIALOG_RULE_AREA_PROPERTIES::~DIALOG_RULE_AREA_PROPERTIES()
|
|
|
|
{
|
|
|
|
if( ADVANCED_CFG::GetCfg().m_EnableMultichannelTool )
|
|
|
|
{
|
|
|
|
m_placementProperties->m_sourceSheetnameRb->Disconnect(
|
|
|
|
wxEVT_RADIOBUTTON,
|
|
|
|
wxCommandEventHandler( DIALOG_RULE_AREA_PROPERTIES::OnSheetNameRbClicked ), NULL,
|
|
|
|
this );
|
|
|
|
m_placementProperties->m_sourceComponentClassRb->Disconnect(
|
|
|
|
wxEVT_RADIOBUTTON,
|
|
|
|
wxCommandEventHandler( DIALOG_RULE_AREA_PROPERTIES::OnComponentClassRbClicked ),
|
|
|
|
NULL, this );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_RULE_AREA_PROPERTIES::OnSheetNameRbClicked( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_currentKeepoutSource == RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_zonesettings.SetRuleAreaPlacementSource( wxEmptyString );
|
|
|
|
m_zonesettings.SetRuleAreaPlacementSourceType( RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME );
|
|
|
|
PopulatePlacementSourceList( RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME );
|
|
|
|
m_currentKeepoutSource = RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_RULE_AREA_PROPERTIES::OnComponentClassRbClicked( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_currentKeepoutSource == RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_zonesettings.SetRuleAreaPlacementSource( wxEmptyString );
|
|
|
|
m_zonesettings.SetRuleAreaPlacementSourceType(
|
|
|
|
RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS );
|
|
|
|
PopulatePlacementSourceList( RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS );
|
|
|
|
m_currentKeepoutSource = RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_RULE_AREA_PROPERTIES::PopulatePlacementSourceList(
|
|
|
|
RULE_AREA_PLACEMENT_SOURCE_TYPE placementType )
|
|
|
|
{
|
|
|
|
m_placementProperties->m_sourceObjectNameCb->Clear();
|
|
|
|
|
|
|
|
std::set<wxString>* sourceStrings;
|
|
|
|
|
|
|
|
switch( placementType )
|
|
|
|
{
|
|
|
|
case RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME:
|
|
|
|
sourceStrings = &m_sheetNames;
|
|
|
|
break;
|
|
|
|
case RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS:
|
|
|
|
sourceStrings = &m_componentClasses;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
int curSourceIdx = -1;
|
|
|
|
const wxString& curSourceName = m_zonesettings.GetRuleAreaPlacementSource();
|
|
|
|
|
|
|
|
for( const wxString& sourceName : *sourceStrings )
|
|
|
|
{
|
|
|
|
if( curSourceName == sourceName )
|
|
|
|
curSourceIdx = m_placementProperties->m_sourceObjectNameCb->GetCount();
|
|
|
|
|
|
|
|
m_placementProperties->m_sourceObjectNameCb->Append( sourceName );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( curSourceIdx != -1 )
|
|
|
|
{
|
|
|
|
m_placementProperties->m_sourceObjectNameCb->Select( curSourceIdx );
|
|
|
|
}
|
|
|
|
else if( curSourceName != wxEmptyString )
|
|
|
|
{
|
|
|
|
m_notFoundPlacementSourceName = curSourceName;
|
|
|
|
wxString notFoundDisplayName = _( "Not found on board: " ) + curSourceName;
|
|
|
|
m_placementProperties->m_sourceObjectNameCb->Insert( notFoundDisplayName, 0 );
|
|
|
|
m_placementProperties->m_sourceObjectNameCb->Select( 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-21 19:32:07 -04:00
|
|
|
bool DIALOG_RULE_AREA_PROPERTIES::TransferDataToWindow()
|
2019-06-19 07:18:30 -07:00
|
|
|
{
|
2022-07-29 20:56:55 +01:00
|
|
|
if( m_convertSettings )
|
|
|
|
{
|
2022-11-28 20:46:30 +00:00
|
|
|
if( m_convertSettings->m_Strategy == BOUNDING_HULL )
|
2024-02-14 17:21:02 +00:00
|
|
|
m_rbBoundingHull->SetValue( true );
|
2022-11-28 20:46:30 +00:00
|
|
|
else
|
|
|
|
m_rbCenterline->SetValue( true );
|
|
|
|
|
2022-07-29 20:56:55 +01:00
|
|
|
m_cbDeleteOriginals->SetValue( m_convertSettings->m_DeleteOriginals );
|
|
|
|
}
|
|
|
|
|
2024-10-09 01:06:11 +01:00
|
|
|
// Init keepout parameters:
|
2024-10-09 22:43:40 +01:00
|
|
|
m_keepoutProperties->m_cbTracksCtrl->SetValue( m_zonesettings.GetDoNotAllowTracks() );
|
|
|
|
m_keepoutProperties->m_cbViasCtrl->SetValue( m_zonesettings.GetDoNotAllowVias() );
|
|
|
|
m_keepoutProperties->m_cbPadsCtrl->SetValue( m_zonesettings.GetDoNotAllowPads() );
|
|
|
|
m_keepoutProperties->m_cbFootprintsCtrl->SetValue( m_zonesettings.GetDoNotAllowFootprints() );
|
|
|
|
m_keepoutProperties->m_cbCopperPourCtrl->SetValue( m_zonesettings.GetDoNotAllowCopperPour() );
|
2024-10-09 01:06:11 +01:00
|
|
|
|
|
|
|
// Init placement parameters:
|
2024-10-09 22:43:40 +01:00
|
|
|
if( ADVANCED_CFG::GetCfg().m_EnableMultichannelTool )
|
2024-01-03 19:47:16 +01:00
|
|
|
{
|
2024-10-09 22:43:40 +01:00
|
|
|
m_placementProperties->m_enabled->SetValue( m_zonesettings.GetRuleAreaPlacementEnabled() );
|
|
|
|
|
|
|
|
// Load schematic sheet and component class lists
|
|
|
|
if( m_board )
|
|
|
|
{
|
|
|
|
// Fetch component classes
|
|
|
|
const std::unordered_map<wxString, std::unique_ptr<COMPONENT_CLASS>>& classes =
|
|
|
|
m_board->GetComponentClassManager().GetClasses();
|
|
|
|
|
|
|
|
for( const auto& [k, v] : classes )
|
|
|
|
m_componentClasses.insert( k );
|
|
|
|
|
|
|
|
// Fetch sheet names
|
|
|
|
for( FOOTPRINT* fp : m_board->Footprints() )
|
|
|
|
m_sheetNames.insert( fp->GetSheetname() );
|
|
|
|
|
|
|
|
if( m_zonesettings.GetRuleAreaPlacementSourceType()
|
|
|
|
== RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME )
|
|
|
|
{
|
|
|
|
m_placementProperties->m_sourceComponentClassRb->SetValue( false );
|
|
|
|
m_placementProperties->m_sourceSheetnameRb->SetValue( true );
|
|
|
|
PopulatePlacementSourceList( RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME );
|
|
|
|
m_currentKeepoutSource = RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_placementProperties->m_sourceSheetnameRb->SetValue( false );
|
|
|
|
m_placementProperties->m_sourceComponentClassRb->SetValue( true );
|
|
|
|
PopulatePlacementSourceList( RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS );
|
|
|
|
m_currentKeepoutSource = RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle most-useful notebook page selection
|
|
|
|
m_areaPropertiesNb->SetSelection( 0 );
|
|
|
|
|
|
|
|
if( !m_zonesettings.HasKeepoutParametersSet()
|
|
|
|
&& m_zonesettings.GetRuleAreaPlacementEnabled() )
|
|
|
|
{
|
|
|
|
m_areaPropertiesNb->SetSelection( 1 );
|
|
|
|
}
|
2024-01-03 19:47:16 +01:00
|
|
|
}
|
2019-06-19 07:18:30 -07:00
|
|
|
|
2021-05-06 22:49:07 +01:00
|
|
|
m_cbLocked->SetValue( m_zonesettings.m_Locked );
|
2020-06-25 22:19:51 -04:00
|
|
|
m_tcName->SetValue( m_zonesettings.m_Name );
|
|
|
|
|
2020-08-07 15:04:34 +01:00
|
|
|
switch( m_zonesettings.m_ZoneBorderDisplayStyle )
|
2019-06-19 07:18:30 -07:00
|
|
|
{
|
2023-10-13 14:25:49 +02:00
|
|
|
case ZONE_BORDER_DISPLAY_STYLE::INVISIBLE_BORDER: // Not used for standard zones. Here use NO_HATCH
|
2020-08-07 15:04:34 +01: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;
|
2019-06-19 07:18:30 -07:00
|
|
|
}
|
|
|
|
|
2022-02-12 18:56:45 +01:00
|
|
|
m_outlineHatchPitch.SetValue( m_zonesettings.m_BorderHatchPitch );
|
|
|
|
|
2020-08-07 15:04:34 +01:00
|
|
|
SetInitialFocus( m_OutlineDisplayCtrl );
|
2024-01-03 19:47:16 +01:00
|
|
|
Layout();
|
2019-06-19 07:18:30 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-21 19:32:07 -04:00
|
|
|
void DIALOG_RULE_AREA_PROPERTIES::OnLayerSelection( wxDataViewEvent& event )
|
2019-06-19 07:18:30 -07:00
|
|
|
{
|
|
|
|
if( event.GetColumn() != 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int row = m_layers->ItemToRow( event.GetItem() );
|
|
|
|
wxVariant layerID;
|
2019-10-28 10:15:03 +01:00
|
|
|
m_layers->GetValue( layerID, row, LAYER_LIST_COLUMN_NAME );
|
|
|
|
bool selected = m_layers->GetToggleValue( row, LAYER_LIST_COLUMN_CHECK );
|
2019-06-19 07:18:30 -07:00
|
|
|
|
2019-11-16 13:01:00 +01:00
|
|
|
// In footprint editor, we have only 3 possible layer selection: C_Cu, inner layers, B_Cu.
|
|
|
|
// So row LAYER_LIST_ROW_ALL_INNER_LAYERS selection is fp editor specific.
|
|
|
|
// in board editor, this row is a normal selection
|
|
|
|
if( m_isFpEditor && row == LAYER_LIST_ROW_ALL_INNER_LAYERS )
|
2019-10-28 10:15:03 +01:00
|
|
|
{
|
|
|
|
if( selected )
|
|
|
|
m_zonesettings.m_Layers |= LSET::InternalCuMask();
|
|
|
|
else
|
|
|
|
m_zonesettings.m_Layers &= ~LSET::InternalCuMask();
|
|
|
|
}
|
|
|
|
else
|
2021-05-06 22:49:07 +01:00
|
|
|
{
|
2019-10-28 10:15:03 +01:00
|
|
|
m_zonesettings.m_Layers.set( ToLAYER_ID( layerID.GetInteger() ), selected );
|
2021-05-06 22:49:07 +01:00
|
|
|
}
|
2019-06-19 07:18:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-21 19:32:07 -04:00
|
|
|
bool DIALOG_RULE_AREA_PROPERTIES::TransferDataFromWindow()
|
2019-06-19 07:18:30 -07:00
|
|
|
{
|
2022-07-29 20:56:55 +01:00
|
|
|
if( m_convertSettings )
|
|
|
|
{
|
2024-02-14 17:21:02 +00:00
|
|
|
if( m_rbBoundingHull->GetValue() )
|
|
|
|
{
|
2022-11-28 20:46:30 +00:00
|
|
|
m_convertSettings->m_Strategy = BOUNDING_HULL;
|
2024-02-14 17:21:02 +00:00
|
|
|
m_convertSettings->m_Gap = m_gap->GetIntValue();
|
|
|
|
}
|
2022-11-28 20:46:30 +00:00
|
|
|
else
|
2024-02-14 17:21:02 +00:00
|
|
|
{
|
2022-11-28 20:46:30 +00:00
|
|
|
m_convertSettings->m_Strategy = CENTERLINE;
|
2024-02-14 17:21:02 +00:00
|
|
|
}
|
2022-11-28 20:46:30 +00:00
|
|
|
|
2022-07-29 20:56:55 +01:00
|
|
|
m_convertSettings->m_DeleteOriginals = m_cbDeleteOriginals->GetValue();
|
|
|
|
}
|
|
|
|
|
2019-06-19 07:18:30 -07:00
|
|
|
// Init keepout parameters:
|
2020-09-21 19:32:07 -04:00
|
|
|
m_zonesettings.SetIsRuleArea( true );
|
2024-10-09 22:43:40 +01:00
|
|
|
m_zonesettings.SetDoNotAllowTracks( m_keepoutProperties->m_cbTracksCtrl->GetValue() );
|
|
|
|
m_zonesettings.SetDoNotAllowVias( m_keepoutProperties->m_cbViasCtrl->GetValue() );
|
|
|
|
m_zonesettings.SetDoNotAllowCopperPour( m_keepoutProperties->m_cbCopperPourCtrl->GetValue() );
|
|
|
|
m_zonesettings.SetDoNotAllowPads( m_keepoutProperties->m_cbPadsCtrl->GetValue() );
|
|
|
|
m_zonesettings.SetDoNotAllowFootprints( m_keepoutProperties->m_cbFootprintsCtrl->GetValue() );
|
|
|
|
|
|
|
|
// Init placement parameters
|
|
|
|
if( ADVANCED_CFG::GetCfg().m_EnableMultichannelTool )
|
|
|
|
{
|
|
|
|
m_zonesettings.SetRuleAreaPlacementEnabled( m_placementProperties->m_enabled->GetValue() );
|
|
|
|
|
|
|
|
if( m_placementProperties->m_sourceSheetnameRb->GetValue() )
|
|
|
|
{
|
|
|
|
m_zonesettings.SetRuleAreaPlacementSourceType(
|
|
|
|
RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_zonesettings.SetRuleAreaPlacementSourceType(
|
|
|
|
RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS );
|
|
|
|
}
|
|
|
|
|
|
|
|
int selectedSourceIdx = m_placementProperties->m_sourceObjectNameCb->GetSelection();
|
|
|
|
|
|
|
|
if( selectedSourceIdx != wxNOT_FOUND )
|
|
|
|
{
|
|
|
|
if( selectedSourceIdx == 0 && m_notFoundPlacementSourceName != wxEmptyString )
|
|
|
|
{
|
|
|
|
m_zonesettings.SetRuleAreaPlacementSource( m_notFoundPlacementSourceName );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_zonesettings.SetRuleAreaPlacementSource(
|
|
|
|
m_placementProperties->m_sourceObjectNameCb->GetString(
|
|
|
|
selectedSourceIdx ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_zonesettings.SetRuleAreaPlacementSource( wxEmptyString );
|
|
|
|
}
|
|
|
|
}
|
2019-06-19 07:18:30 -07:00
|
|
|
|
|
|
|
if( m_zonesettings.m_Layers.count() == 0 )
|
|
|
|
{
|
2021-07-19 19:56:05 -04:00
|
|
|
DisplayError( this, _( "No layers selected." ) );
|
2019-06-19 07:18:30 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-08-07 15:04:34 +01:00
|
|
|
switch( m_OutlineDisplayCtrl->GetSelection() )
|
2019-06-19 07:18:30 -07:00
|
|
|
{
|
2021-07-19 19:56:05 -04:00
|
|
|
case 0:
|
|
|
|
m_zonesettings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::NO_HATCH;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
m_zonesettings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
m_zonesettings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL;
|
|
|
|
break;
|
2019-06-19 07:18:30 -07:00
|
|
|
}
|
|
|
|
|
2022-09-16 07:33:56 -04:00
|
|
|
if( !m_outlineHatchPitch.Validate( pcbIUScale.mmToIU( ZONE_BORDER_HATCH_MINDIST_MM ),
|
|
|
|
pcbIUScale.mmToIU( ZONE_BORDER_HATCH_MAXDIST_MM ) ) )
|
2022-02-12 18:56:45 +01:00
|
|
|
return false;
|
|
|
|
|
2023-05-12 22:03:54 +01:00
|
|
|
m_zonesettings.m_BorderHatchPitch = m_outlineHatchPitch.GetIntValue();
|
2022-02-12 18:56:45 +01:00
|
|
|
|
2021-05-06 22:49:07 +01:00
|
|
|
m_zonesettings.m_Locked = m_cbLocked->GetValue();
|
2019-06-19 07:18:30 -07:00
|
|
|
m_zonesettings.m_ZonePriority = 0; // for a keepout, this param is not used.
|
|
|
|
|
2020-06-25 22:19:51 -04:00
|
|
|
m_zonesettings.m_Name = m_tcName->GetValue();
|
|
|
|
|
2019-06-19 07:18:30 -07:00
|
|
|
*m_ptr = m_zonesettings;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|