2018-04-28 15:22:25 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2020-05-04 14:01:25 +00:00
|
|
|
* Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2018-04-28 15:22:25 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <board_design_settings.h>
|
2021-01-26 11:41:47 +00:00
|
|
|
#include <board.h>
|
|
|
|
#include <convert_to_biu.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <math/util.h>
|
2021-01-26 11:41:47 +00:00
|
|
|
#include <panel_setup_constraints.h>
|
|
|
|
#include <panel_setup_constraints_base.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2021-01-26 11:41:47 +00:00
|
|
|
#include <widgets/paged_dialog.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <wx/treebook.h>
|
2020-04-25 13:20:54 +00:00
|
|
|
#include <bitmaps.h>
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2021-01-26 11:41:47 +00:00
|
|
|
PANEL_SETUP_CONSTRAINTS::PANEL_SETUP_CONSTRAINTS( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ) :
|
|
|
|
PANEL_SETUP_CONSTRAINTS_BASE( aParent->GetTreebook() ),
|
2021-03-12 15:12:49 +00:00
|
|
|
m_minClearance( aFrame, m_clearanceTitle, m_clearanceCtrl, m_clearanceUnits ),
|
|
|
|
m_trackMinWidth( aFrame, m_TrackMinWidthTitle, m_TrackMinWidthCtrl, m_TrackMinWidthUnits ),
|
|
|
|
m_viaMinAnnulus( aFrame, m_ViaMinAnnulusTitle, m_ViaMinAnnulusCtrl, m_ViaMinAnnulusUnits ),
|
|
|
|
m_viaMinSize( aFrame, m_ViaMinTitle, m_SetViasMinSizeCtrl, m_ViaMinUnits ),
|
|
|
|
m_throughHoleMin( aFrame, m_MinDrillTitle, m_MinDrillCtrl, m_MinDrillUnits ),
|
|
|
|
m_uviaMinSize( aFrame, m_uviaMinSizeLabel, m_uviaMinSizeCtrl, m_uviaMinSizeUnits ),
|
|
|
|
m_uviaMinDrill( aFrame, m_uviaMinDrillLabel, m_uviaMinDrillCtrl, m_uviaMinDrillUnits ),
|
|
|
|
m_holeToHoleMin( aFrame, m_HoleToHoleTitle, m_SetHoleToHoleCtrl, m_HoleToHoleUnits ),
|
|
|
|
m_holeClearance( aFrame, m_HoleClearanceLabel, m_HoleClearanceCtrl, m_HoleClearanceUnits ),
|
|
|
|
m_edgeClearance( aFrame, m_EdgeClearanceLabel, m_EdgeClearanceCtrl, m_EdgeClearanceUnits ),
|
|
|
|
m_silkClearance( aFrame, m_silkClearanceLabel, m_silkClearanceCtrl, m_silkClearanceUnits ),
|
2021-07-11 15:12:28 +00:00
|
|
|
m_minTextHeight( aFrame, m_textHeightLabel, m_textHeightCtrl, m_textHeightUnits ),
|
|
|
|
m_minTextThickness( aFrame, m_textThicknessLabel, m_textThicknessCtrl, m_textThicknessUnits ),
|
2021-03-12 15:12:49 +00:00
|
|
|
m_maxError( aFrame, m_maxErrorTitle, m_maxErrorCtrl, m_maxErrorUnits )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
|
|
|
m_Frame = aFrame;
|
|
|
|
m_BrdSettings = &m_Frame->GetBoard()->GetDesignSettings();
|
2021-01-26 11:23:23 +00:00
|
|
|
|
2021-09-11 19:07:33 +00:00
|
|
|
m_stCircleToPolyWarning->SetFont( KIUI::GetInfoFont( this ) );
|
2021-08-09 10:10:09 +00:00
|
|
|
|
|
|
|
wxSize ctrlSize = m_minResolvedSpokeCountCtrl->GetSize();
|
|
|
|
ctrlSize.x = KIUI::GetTextSize( wxT( "XXX" ), m_minResolvedSpokeCountCtrl ).x;
|
|
|
|
m_minResolvedSpokeCountCtrl->SetSize( ctrlSize );
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-26 11:41:47 +00:00
|
|
|
bool PANEL_SETUP_CONSTRAINTS::TransferDataToWindow()
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
2021-01-26 11:23:23 +00:00
|
|
|
wxString msg;
|
|
|
|
msg.Printf( m_stCircleToPolyWarning->GetLabel(),
|
|
|
|
StringFromValue( m_Frame->GetUserUnits(), ARC_HIGH_DEF, true ) );
|
|
|
|
m_stCircleToPolyWarning->SetLabel( msg );
|
2020-08-13 08:01:23 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
m_OptAllowBlindBuriedVias->SetValue( m_BrdSettings->m_BlindBuriedViaAllowed );
|
|
|
|
m_OptAllowMicroVias->SetValue( m_BrdSettings->m_MicroViasAllowed );
|
2021-05-11 02:11:58 +00:00
|
|
|
m_useHeightForLengthCalcs->SetValue( m_BrdSettings->m_UseHeightForLengthCalcs );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2020-05-04 21:05:30 +00:00
|
|
|
m_maxError.SetValue( m_BrdSettings->m_MaxError );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2020-08-30 14:18:35 +00:00
|
|
|
m_allowExternalFilletsOpt->SetValue( m_BrdSettings->m_ZoneKeepExternalFillets );
|
2021-08-09 10:10:09 +00:00
|
|
|
m_minResolvedSpokeCountCtrl->SetValue( m_BrdSettings->m_MinResolvedSpokes );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2020-05-04 21:05:30 +00:00
|
|
|
m_minClearance.SetValue( m_BrdSettings->m_MinClearance );
|
|
|
|
m_trackMinWidth.SetValue( m_BrdSettings->m_TrackMinWidth );
|
2021-06-26 09:11:22 +00:00
|
|
|
m_viaMinAnnulus.SetValue( m_BrdSettings->m_ViasMinAnnularWidth );
|
2020-05-04 21:05:30 +00:00
|
|
|
m_viaMinSize.SetValue(m_BrdSettings->m_ViasMinSize );
|
2020-11-29 22:01:40 +00:00
|
|
|
m_holeClearance.SetValue( m_BrdSettings->m_HoleClearance );
|
2019-04-05 16:10:59 +00:00
|
|
|
m_edgeClearance.SetValue( m_BrdSettings->m_CopperEdgeClearance );
|
|
|
|
|
2020-05-04 21:05:30 +00:00
|
|
|
m_throughHoleMin.SetValue( m_BrdSettings->m_MinThroughDrill );
|
|
|
|
m_holeToHoleMin.SetValue( m_BrdSettings->m_HoleToHoleMin );
|
2019-05-22 14:47:38 +00:00
|
|
|
|
2020-05-04 21:05:30 +00:00
|
|
|
m_uviaMinSize.SetValue( m_BrdSettings->m_MicroViasMinSize );
|
|
|
|
m_uviaMinDrill.SetValue( m_BrdSettings->m_MicroViasMinDrill );
|
2019-06-04 07:23:12 +00:00
|
|
|
|
2020-10-12 13:10:50 +00:00
|
|
|
m_silkClearance.SetValue( m_BrdSettings->m_SilkClearance );
|
2021-07-11 15:12:28 +00:00
|
|
|
m_minTextHeight.SetValue( m_BrdSettings->m_MinSilkTextHeight );
|
|
|
|
m_minTextThickness.SetValue( m_BrdSettings->m_MinSilkTextThickness );
|
2020-10-12 13:10:50 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-26 11:41:47 +00:00
|
|
|
bool PANEL_SETUP_CONSTRAINTS::TransferDataFromWindow()
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
2020-06-14 15:08:47 +00:00
|
|
|
if( !m_minClearance.Validate( 0, 10, EDA_UNITS::INCHES ) )
|
2020-05-04 21:05:30 +00:00
|
|
|
return false;
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2020-06-14 15:08:47 +00:00
|
|
|
if( !m_trackMinWidth.Validate( 0, 10, EDA_UNITS::INCHES ) )
|
2020-05-04 21:05:30 +00:00
|
|
|
return false;
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2020-06-14 15:08:47 +00:00
|
|
|
if( !m_viaMinAnnulus.Validate( 0, 10, EDA_UNITS::INCHES ) )
|
2020-05-11 19:39:30 +00:00
|
|
|
return false;
|
|
|
|
|
2020-06-14 15:08:47 +00:00
|
|
|
if( !m_viaMinSize.Validate( 0, 10, EDA_UNITS::INCHES ) )
|
2020-05-04 21:05:30 +00:00
|
|
|
return false;
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2020-11-29 22:01:40 +00:00
|
|
|
if( !m_holeClearance.Validate( 0, 10, EDA_UNITS::INCHES ) )
|
|
|
|
return false;
|
|
|
|
|
2020-06-14 15:08:47 +00:00
|
|
|
if( !m_edgeClearance.Validate( 0, 10, EDA_UNITS::INCHES ) )
|
2020-05-04 21:05:30 +00:00
|
|
|
return false;
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2020-10-02 22:04:16 +00:00
|
|
|
if( !m_throughHoleMin.Validate( 2, 1000, EDA_UNITS::MILS ) ) // #107 to 1 inch
|
2020-05-04 21:05:30 +00:00
|
|
|
return false;
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2020-06-14 15:08:47 +00:00
|
|
|
if( !m_holeToHoleMin.Validate( 0, 10, EDA_UNITS::INCHES ) )
|
2020-05-04 21:05:30 +00:00
|
|
|
return false;
|
|
|
|
|
2020-10-13 22:05:15 +00:00
|
|
|
// These are all stored in project file, not board, so no need for OnModify()
|
|
|
|
|
2021-05-11 02:11:58 +00:00
|
|
|
m_BrdSettings->m_BlindBuriedViaAllowed = m_OptAllowBlindBuriedVias->GetValue();
|
|
|
|
m_BrdSettings->m_MicroViasAllowed = m_OptAllowMicroVias->GetValue();
|
|
|
|
m_BrdSettings->m_UseHeightForLengthCalcs = m_useHeightForLengthCalcs->GetValue();
|
2019-04-05 16:10:59 +00:00
|
|
|
|
2019-05-22 14:47:38 +00:00
|
|
|
m_BrdSettings->m_MaxError = Clamp<int>( IU_PER_MM * MINIMUM_ERROR_SIZE_MM,
|
2020-10-13 22:05:15 +00:00
|
|
|
m_maxError.GetValue(),
|
|
|
|
IU_PER_MM * MAXIMUM_ERROR_SIZE_MM );
|
2019-05-22 14:47:38 +00:00
|
|
|
|
2020-08-30 14:18:35 +00:00
|
|
|
m_BrdSettings->m_ZoneKeepExternalFillets = m_allowExternalFilletsOpt->GetValue();
|
2021-08-09 10:10:09 +00:00
|
|
|
m_BrdSettings->m_MinResolvedSpokes = m_minResolvedSpokeCountCtrl->GetValue();
|
2019-06-04 07:23:12 +00:00
|
|
|
|
2020-05-04 21:05:30 +00:00
|
|
|
m_BrdSettings->m_MinClearance = m_minClearance.GetValue();
|
|
|
|
m_BrdSettings->m_TrackMinWidth = m_trackMinWidth.GetValue();
|
2021-06-26 09:11:22 +00:00
|
|
|
m_BrdSettings->m_ViasMinAnnularWidth = m_viaMinAnnulus.GetValue();
|
2020-05-04 21:05:30 +00:00
|
|
|
m_BrdSettings->m_ViasMinSize = m_viaMinSize.GetValue();
|
2020-11-29 22:01:40 +00:00
|
|
|
m_BrdSettings->m_HoleClearance = m_holeClearance.GetValue();
|
2021-07-11 15:12:28 +00:00
|
|
|
m_BrdSettings->m_CopperEdgeClearance = m_edgeClearance.GetValue();
|
2020-05-04 21:05:30 +00:00
|
|
|
|
|
|
|
m_BrdSettings->m_MinThroughDrill = m_throughHoleMin.GetValue();
|
2021-07-11 15:12:28 +00:00
|
|
|
m_BrdSettings->m_HoleToHoleMin = m_holeToHoleMin.GetValue();
|
2020-05-04 21:05:30 +00:00
|
|
|
|
|
|
|
m_BrdSettings->m_MicroViasMinSize = m_uviaMinSize.GetValue();
|
|
|
|
m_BrdSettings->m_MicroViasMinDrill = m_uviaMinDrill.GetValue();
|
|
|
|
|
2020-10-12 13:10:50 +00:00
|
|
|
m_BrdSettings->m_SilkClearance = m_silkClearance.GetValue();
|
2021-07-11 15:12:28 +00:00
|
|
|
m_BrdSettings->m_MinSilkTextHeight = m_minTextHeight.GetValue();
|
|
|
|
m_BrdSettings->m_MinSilkTextThickness = m_minTextThickness.GetValue();
|
2020-10-12 13:10:50 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-26 11:41:47 +00:00
|
|
|
bool PANEL_SETUP_CONSTRAINTS::Show( bool aShow )
|
2020-05-04 14:01:25 +00:00
|
|
|
{
|
|
|
|
bool retVal = wxPanel::Show( aShow );
|
|
|
|
|
2020-05-08 18:10:47 +00:00
|
|
|
if( aShow )
|
|
|
|
{
|
|
|
|
// These *should* work in the constructor, and indeed they do if this panel is the
|
|
|
|
// first displayed. However, on OSX 3.0.5 (at least), if another panel is displayed
|
|
|
|
// first then the icons will be blank unless they're set here.
|
2021-03-08 02:59:07 +00:00
|
|
|
m_filletBitmap->SetBitmap( KiBitmap( BITMAPS::zone_fillet ) );
|
2021-08-09 10:10:09 +00:00
|
|
|
m_spokeBitmap->SetBitmap( KiBitmap( BITMAPS::thermal_spokes ) );
|
2021-03-08 02:59:07 +00:00
|
|
|
m_bitmapClearance->SetBitmap( KiBitmap( BITMAPS::ps_diff_pair_gap ) );
|
|
|
|
m_bitmapMinTrackWidth->SetBitmap( KiBitmap( BITMAPS::width_track ) );
|
|
|
|
m_bitmapMinViaAnnulus->SetBitmap( KiBitmap( BITMAPS::via_annulus ) );
|
|
|
|
m_bitmapMinViaDiameter->SetBitmap( KiBitmap( BITMAPS::via_diameter ) );
|
|
|
|
m_bitmapMinViaDrill->SetBitmap( KiBitmap( BITMAPS::via_hole_diameter ) );
|
|
|
|
m_bitmapMinuViaDiameter->SetBitmap( KiBitmap( BITMAPS::via_diameter ) );
|
|
|
|
m_bitmapMinuViaDrill->SetBitmap( KiBitmap( BITMAPS::via_hole_diameter ) );
|
|
|
|
m_bitmapHoleClearance->SetBitmap( KiBitmap( BITMAPS::hole_to_copper_clearance ) );
|
|
|
|
m_bitmapMinHoleClearance->SetBitmap( KiBitmap( BITMAPS::hole_to_hole_clearance ) );
|
|
|
|
m_bitmapEdgeClearance->SetBitmap( KiBitmap( BITMAPS::edge_to_copper_clearance ) );
|
|
|
|
m_bitmapBlindBuried->SetBitmap( KiBitmap( BITMAPS::via_buried ) );
|
|
|
|
m_bitmap_uVia->SetBitmap( KiBitmap( BITMAPS::via_microvia ) );
|
2020-05-23 07:48:05 +00:00
|
|
|
|
|
|
|
Layout();
|
2020-05-08 18:10:47 +00:00
|
|
|
}
|
2020-05-04 14:01:25 +00:00
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-26 11:41:47 +00:00
|
|
|
void PANEL_SETUP_CONSTRAINTS::ImportSettingsFrom( BOARD* aBoard )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
|
|
|
BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
|
|
|
|
|
|
|
|
m_BrdSettings = &aBoard->GetDesignSettings();
|
|
|
|
TransferDataToWindow();
|
|
|
|
|
|
|
|
m_BrdSettings = savedSettings;
|
2019-05-22 14:47:38 +00:00
|
|
|
}
|