2019-06-19 14:18:30 +00: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>
|
|
|
|
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <fctsys.h>
|
|
|
|
#include <kiface_i.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <pcb_edit_frame.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pcbnew_settings.h>
|
2019-11-16 12:01:00 +00:00
|
|
|
#include <footprint_edit_frame.h>
|
2019-06-19 14:18:30 +00:00
|
|
|
#include <class_zone.h>
|
|
|
|
#include <zones.h>
|
|
|
|
#include <zone_settings.h>
|
|
|
|
#include <dialog_keepout_area_properties_base.h>
|
|
|
|
|
2019-10-28 09:15:03 +00: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 14:18:30 +00:00
|
|
|
|
|
|
|
class DIALOG_KEEPOUT_AREA_PROPERTIES : public DIALOG_KEEPOUT_AREA_PROPERTIES_BASE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DIALOG_KEEPOUT_AREA_PROPERTIES( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings );
|
|
|
|
|
|
|
|
private:
|
|
|
|
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
|
2019-11-16 12:01:00 +00:00
|
|
|
bool m_isFpEditor;
|
2019-06-19 14:18:30 +00:00
|
|
|
|
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
bool TransferDataFromWindow() override;
|
|
|
|
|
|
|
|
void OnLayerSelection( wxDataViewEvent& event ) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int InvokeKeepoutAreaEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSettings )
|
|
|
|
{
|
|
|
|
DIALOG_KEEPOUT_AREA_PROPERTIES dlg( aCaller, aSettings );
|
|
|
|
|
|
|
|
return dlg.ShowModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_KEEPOUT_AREA_PROPERTIES::DIALOG_KEEPOUT_AREA_PROPERTIES( PCB_BASE_FRAME* aParent,
|
|
|
|
ZONE_SETTINGS* aSettings ) :
|
|
|
|
DIALOG_KEEPOUT_AREA_PROPERTIES_BASE( aParent )
|
|
|
|
{
|
|
|
|
m_parent = aParent;
|
|
|
|
|
|
|
|
m_ptr = aSettings;
|
|
|
|
m_zonesettings = *aSettings;
|
2019-10-28 09:15:03 +00:00
|
|
|
|
2019-11-16 12:01:00 +00:00
|
|
|
m_isFpEditor = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( aParent ) != nullptr;
|
|
|
|
|
2019-10-28 09:15:03 +00:00
|
|
|
bool fpEditorMode = m_parent->IsType( FRAME_FOOTPRINT_EDITOR );
|
|
|
|
m_zonesettings.SetupLayersList( m_layers, m_parent, true, fpEditorMode );
|
2019-06-19 14:18:30 +00:00
|
|
|
|
|
|
|
m_sdbSizerButtonsOK->SetDefault();
|
|
|
|
|
|
|
|
FinishDialogSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_KEEPOUT_AREA_PROPERTIES::TransferDataToWindow()
|
|
|
|
{
|
|
|
|
// Init keepout parameters:
|
|
|
|
m_cbTracksCtrl->SetValue( m_zonesettings.GetDoNotAllowTracks() );
|
|
|
|
m_cbViasCtrl->SetValue( m_zonesettings.GetDoNotAllowVias() );
|
2020-05-07 00:30:46 +00:00
|
|
|
m_cbPadsCtrl->SetValue( m_zonesettings.GetDoNotAllowPads() );
|
|
|
|
m_cbFootprintsCtrl->SetValue( m_zonesettings.GetDoNotAllowFootprints() );
|
2019-06-19 14:18:30 +00:00
|
|
|
m_cbCopperPourCtrl->SetValue( m_zonesettings.GetDoNotAllowCopperPour() );
|
|
|
|
|
|
|
|
m_cbConstrainCtrl->SetValue( m_zonesettings.m_Zone_45_Only );
|
|
|
|
|
2020-06-26 02:19:51 +00:00
|
|
|
m_tcName->SetValue( m_zonesettings.m_Name );
|
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
switch( m_zonesettings.m_ZoneBorderDisplayStyle )
|
2019-06-19 14:18:30 +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;
|
2019-06-19 14:18:30 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
SetInitialFocus( m_OutlineDisplayCtrl );
|
2019-06-19 14:18:30 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_KEEPOUT_AREA_PROPERTIES::OnLayerSelection( wxDataViewEvent& event )
|
|
|
|
{
|
|
|
|
if( event.GetColumn() != 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int row = m_layers->ItemToRow( event.GetItem() );
|
|
|
|
wxVariant layerID;
|
2019-10-28 09:15:03 +00:00
|
|
|
m_layers->GetValue( layerID, row, LAYER_LIST_COLUMN_NAME );
|
|
|
|
bool selected = m_layers->GetToggleValue( row, LAYER_LIST_COLUMN_CHECK );
|
2019-06-19 14:18:30 +00:00
|
|
|
|
2019-11-16 12:01:00 +00: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 09:15:03 +00:00
|
|
|
{
|
|
|
|
if( selected )
|
|
|
|
m_zonesettings.m_Layers |= LSET::InternalCuMask();
|
|
|
|
else
|
|
|
|
m_zonesettings.m_Layers &= ~LSET::InternalCuMask();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_zonesettings.m_Layers.set( ToLAYER_ID( layerID.GetInteger() ), selected );
|
2019-06-19 14:18:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_KEEPOUT_AREA_PROPERTIES::TransferDataFromWindow()
|
|
|
|
{
|
|
|
|
// Init keepout parameters:
|
|
|
|
m_zonesettings.SetIsKeepout( true );
|
|
|
|
m_zonesettings.SetDoNotAllowTracks( m_cbTracksCtrl->GetValue() );
|
|
|
|
m_zonesettings.SetDoNotAllowVias( m_cbViasCtrl->GetValue() );
|
|
|
|
m_zonesettings.SetDoNotAllowCopperPour( m_cbCopperPourCtrl->GetValue() );
|
2020-05-07 00:30:46 +00:00
|
|
|
m_zonesettings.SetDoNotAllowPads( m_cbPadsCtrl->GetValue() );
|
|
|
|
m_zonesettings.SetDoNotAllowFootprints( m_cbFootprintsCtrl->GetValue() );
|
2019-06-19 14:18:30 +00:00
|
|
|
|
|
|
|
// Test for not allowed items: should have at least one item not allowed:
|
|
|
|
if( ! m_zonesettings.GetDoNotAllowTracks() &&
|
|
|
|
! m_zonesettings.GetDoNotAllowVias() &&
|
2020-05-07 00:30:46 +00:00
|
|
|
! m_zonesettings.GetDoNotAllowPads() &&
|
|
|
|
! m_zonesettings.GetDoNotAllowFootprints() &&
|
2019-06-19 14:18:30 +00:00
|
|
|
! m_zonesettings.GetDoNotAllowCopperPour() )
|
|
|
|
{
|
2020-08-31 13:19:57 +00:00
|
|
|
DisplayError( NULL, _("No items are disallowed. The keepout will have no effect." ) );
|
2019-06-19 14:18:30 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_zonesettings.m_Layers.count() == 0 )
|
|
|
|
{
|
|
|
|
DisplayError( NULL, _( "No layers selected." ) );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
switch( m_OutlineDisplayCtrl->GetSelection() )
|
2019-06-19 14:18:30 +00:00
|
|
|
{
|
2020-08-07 14:04:34 +00: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 14:18:30 +00:00
|
|
|
}
|
|
|
|
|
2020-05-06 01:43:37 +00:00
|
|
|
auto cfg = m_parent->GetPcbNewSettings();
|
2020-08-07 14:04:34 +00:00
|
|
|
cfg->m_Zones.hatching_style = static_cast<int>( m_zonesettings.m_ZoneBorderDisplayStyle );
|
2019-06-19 14:18:30 +00:00
|
|
|
|
|
|
|
m_zonesettings.m_Zone_45_Only = m_cbConstrainCtrl->GetValue();
|
|
|
|
m_zonesettings.m_ZonePriority = 0; // for a keepout, this param is not used.
|
|
|
|
|
2020-06-26 02:19:51 +00:00
|
|
|
m_zonesettings.m_Name = m_tcName->GetValue();
|
|
|
|
|
2019-06-19 14:18:30 +00:00
|
|
|
*m_ptr = m_zonesettings;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|