KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_setup_constraints.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <algorithm>
25
27#include <board.h>
28#include <math/util.h>
31#include <pcb_edit_frame.h>
33#include <wx/treebook.h>
34#include <bitmaps.h>
35
36
38 PANEL_SETUP_CONSTRAINTS_BASE( aParentWindow ),
39 m_minClearance( aFrame, m_clearanceTitle, m_clearanceCtrl, m_clearanceUnits ),
40 m_minConn( aFrame, m_MinConnTitle, m_MinConnCtrl, m_MinConnUnits ),
41 m_trackMinWidth( aFrame, m_TrackMinWidthTitle, m_TrackMinWidthCtrl, m_TrackMinWidthUnits ),
42 m_viaMinAnnulus( aFrame, m_ViaMinAnnulusTitle, m_ViaMinAnnulusCtrl, m_ViaMinAnnulusUnits ),
43 m_viaMinSize( aFrame, m_ViaMinTitle, m_SetViasMinSizeCtrl, m_ViaMinUnits ),
44 m_throughHoleMin( aFrame, m_MinDrillTitle, m_MinDrillCtrl, m_MinDrillUnits ),
45 m_uviaMinSize( aFrame, m_uviaMinSizeLabel, m_uviaMinSizeCtrl, m_uviaMinSizeUnits ),
46 m_uviaMinDrill( aFrame, m_uviaMinDrillLabel, m_uviaMinDrillCtrl, m_uviaMinDrillUnits ),
47 m_holeToHoleMin( aFrame, m_HoleToHoleTitle, m_SetHoleToHoleCtrl, m_HoleToHoleUnits ),
48 m_holeClearance( aFrame, m_HoleClearanceLabel, m_HoleClearanceCtrl, m_HoleClearanceUnits ),
49 m_edgeClearance( aFrame, m_EdgeClearanceLabel, m_EdgeClearanceCtrl, m_EdgeClearanceUnits ),
50 m_silkClearance( aFrame, m_silkClearanceLabel, m_silkClearanceCtrl, m_silkClearanceUnits ),
51 m_minTextHeight( aFrame, m_textHeightLabel, m_textHeightCtrl, m_textHeightUnits ),
52 m_minTextThickness( aFrame, m_textThicknessLabel, m_textThicknessCtrl, m_textThicknessUnits ),
53 m_maxError( aFrame, m_maxErrorTitle, m_maxErrorCtrl, m_maxErrorUnits )
54{
55 m_Frame = aFrame;
57
58 m_filletBitmap->SetBitmap( KiBitmapBundle( BITMAPS::zone_fillet ) );
59 m_spokeBitmap->SetBitmap( KiBitmapBundle( BITMAPS::thermal_spokes ) );
60 m_bitmapClearance->SetBitmap( KiBitmapBundle( BITMAPS::ps_diff_pair_gap ) );
61 m_bitmapMinTrackWidth->SetBitmap( KiBitmapBundle( BITMAPS::width_track ) );
62 m_bitmapMinConn->SetBitmap( KiBitmapBundle( BITMAPS::width_conn ) );
63 m_bitmapMinViaAnnulus->SetBitmap( KiBitmapBundle( BITMAPS::via_annulus ) );
64 m_bitmapMinViaDiameter->SetBitmap( KiBitmapBundle( BITMAPS::via_diameter ) );
65 m_bitmapMinViaDrill->SetBitmap( KiBitmapBundle( BITMAPS::via_hole_diameter ) );
66 m_bitmapMinuViaDiameter->SetBitmap( KiBitmapBundle( BITMAPS::via_diameter ) );
67 m_bitmapMinuViaDrill->SetBitmap( KiBitmapBundle( BITMAPS::via_hole_diameter ) );
68 m_bitmapHoleClearance->SetBitmap( KiBitmapBundle( BITMAPS::hole_to_copper_clearance ) );
69 m_bitmapMinHoleClearance->SetBitmap( KiBitmapBundle( BITMAPS::hole_to_hole_clearance ) );
70 m_bitmapEdgeClearance->SetBitmap( KiBitmapBundle( BITMAPS::edge_to_copper_clearance ) );
71
73
74 wxSize ctrlSize = m_minResolvedSpokeCountCtrl->GetSize();
75 ctrlSize.x = KIUI::GetTextSize( wxT( "XXX" ), m_minResolvedSpokeCountCtrl ).x;
76 m_minResolvedSpokeCountCtrl->SetSize( ctrlSize );
77}
78
79
81{
82 wxString msg;
83 msg.Printf( m_stCircleToPolyWarning->GetLabel(), m_Frame->StringFromValue( ARC_HIGH_DEF, true ) );
84 m_stCircleToPolyWarning->SetLabel( msg );
85
87
89
92
100
103
106
110
111 return true;
112}
113
114
116{
117 if( !m_minClearance.Validate( 0, 10, EDA_UNITS::INCHES ) )
118 return false;
119
120 if( !m_minConn.Validate( 0, 10, EDA_UNITS::INCHES ) )
121 return false;
122
123 if( !m_trackMinWidth.Validate( 0, 10, EDA_UNITS::INCHES ) )
124 return false;
125
126 if( !m_viaMinAnnulus.Validate( 0, 10, EDA_UNITS::INCHES ) )
127 return false;
128
129 if( !m_viaMinSize.Validate( 0, 10, EDA_UNITS::INCHES ) )
130 return false;
131
132 if( !m_holeClearance.Validate( 0, 10, EDA_UNITS::INCHES ) )
133 return false;
134
135 if( !m_edgeClearance.Validate( 0, 10, EDA_UNITS::INCHES ) )
136 return false;
137
138 if( !m_throughHoleMin.Validate( 2, 1000, EDA_UNITS::MILS ) ) // #107 to 1 inch
139 return false;
140
141 if( !m_holeToHoleMin.Validate( 0, 10, EDA_UNITS::INCHES ) )
142 return false;
143
144 // These are all stored in project file, not board, so no need for OnModify()
145
147
148 m_BrdSettings->m_MaxError = KiROUND( std::clamp( static_cast<double>( m_maxError.GetValue() ),
151
154
162
165
168
172
173 return true;
174}
175
176
178{
179 BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
180
181 m_BrdSettings = &aBoard->GetDesignSettings();
183
184 m_BrdSettings = savedSettings;
185}
constexpr int ARC_HIGH_DEF
Definition: base_units.h:120
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Definition: bitmap.cpp:110
#define MAXIMUM_ERROR_SIZE_MM
#define MINIMUM_ERROR_SIZE_MM
Container for design settings for a BOARD object.
bool m_UseHeightForLengthCalcs
Enable inclusion of stackup height in track length measurements and length tuning.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:289
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:875
Class PANEL_SETUP_CONSTRAINTS_BASE.
PANEL_SETUP_CONSTRAINTS(wxWindow *aParentWindow, PCB_EDIT_FRAME *aFrame)
BOARD_DESIGN_SETTINGS * m_BrdSettings
void ImportSettingsFrom(BOARD *aBoard)
BOARD * GetBoard() const
The main frame for Pcbnew.
wxString StringFromValue(double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
Converts aValue in internal units into a united string.
virtual long long int GetValue()
Return the current value in Internal Units.
virtual bool Validate(double aMin, double aMax, EDA_UNITS aUnits=EDA_UNITS::UNSCALED)
Validate the control against the given range, informing the user of any errors found.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:154
KICOMMON_API wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
Definition: ui_common.cpp:77
const double IU_PER_MM
Definition: base_units.h:76
constexpr ret_type KiROUND(fp_type v, bool aQuiet=false)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:100