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 The 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#include <advanced_config.h>
36
37
39 PANEL_SETUP_CONSTRAINTS_BASE( aParentWindow ),
56{
57 m_Frame = aFrame;
58 m_BrdSettings = &m_Frame->GetBoard()->GetDesignSettings();
59
73
74 m_stCircleToPolyWarning->SetFont( KIUI::GetSmallInfoFont( this ).Italic() );
75
76 wxSize ctrlSize = m_minResolvedSpokeCountCtrl->GetSize();
77 ctrlSize.x = KIUI::GetTextSize( wxT( "XXX" ), m_minResolvedSpokeCountCtrl ).x;
78 m_minResolvedSpokeCountCtrl->SetSize( ctrlSize );
79
80 if( !ADVANCED_CFG::GetCfg().m_EnableCreepageSlot )
81 {
82 m_bitmapMinGrooveWidth->Show( false );
83 m_minGrooveWidthLabel->Show( false );
84 m_minGrooveWidthCtrl->Show( false );
85 m_minGrooveWidthUnits->Show( false );
86 }
87}
88
89
91{
92 wxString msg;
93 msg.Printf( m_stCircleToPolyWarning->GetLabel(), m_Frame->StringFromValue( ARC_HIGH_DEF, true ) );
94 m_stCircleToPolyWarning->SetLabel( msg );
95
96 m_useHeightForLengthCalcs->SetValue( m_BrdSettings->m_UseHeightForLengthCalcs );
97
98 m_maxError.SetValue( m_BrdSettings->m_MaxError );
99
100 m_allowExternalFilletsOpt->SetValue( m_BrdSettings->m_ZoneKeepExternalFillets );
101 m_minResolvedSpokeCountCtrl->SetValue( m_BrdSettings->m_MinResolvedSpokes );
102
103 m_minClearance.SetValue( m_BrdSettings->m_MinClearance );
104 m_minConn.SetValue( m_BrdSettings->m_MinConn );
105 m_trackMinWidth.SetValue( m_BrdSettings->m_TrackMinWidth );
106 m_viaMinAnnulus.SetValue( m_BrdSettings->m_ViasMinAnnularWidth );
107 m_viaMinSize.SetValue(m_BrdSettings->m_ViasMinSize );
108 m_holeClearance.SetValue( m_BrdSettings->m_HoleClearance );
109 m_edgeClearance.SetValue( m_BrdSettings->m_CopperEdgeClearance );
110 m_minGrooveWidth.SetValue( m_BrdSettings->m_MinGrooveWidth );
111
112 m_throughHoleMin.SetValue( m_BrdSettings->m_MinThroughDrill );
113 m_holeToHoleMin.SetValue( m_BrdSettings->m_HoleToHoleMin );
114
115 m_uviaMinSize.SetValue( m_BrdSettings->m_MicroViasMinSize );
116 m_uviaMinDrill.SetValue( m_BrdSettings->m_MicroViasMinDrill );
117
118 m_silkClearance.SetValue( m_BrdSettings->m_SilkClearance );
119 m_minTextHeight.SetValue( m_BrdSettings->m_MinSilkTextHeight );
120 m_minTextThickness.SetValue( m_BrdSettings->m_MinSilkTextThickness );
121
122 return true;
123}
124
125
127{
128 if( !m_minClearance.Validate( 0, 10, EDA_UNITS::INCH ) )
129 return false;
130
131 if( !m_minConn.Validate( 0, 10, EDA_UNITS::INCH ) )
132 return false;
133
134 if( !m_trackMinWidth.Validate( 0, 10, EDA_UNITS::INCH ) )
135 return false;
136
137 if( !m_viaMinAnnulus.Validate( 0, 10, EDA_UNITS::INCH ) )
138 return false;
139
140 if( !m_viaMinSize.Validate( 0, 10, EDA_UNITS::INCH ) )
141 return false;
142
143 if( !m_holeClearance.Validate( 0, 10, EDA_UNITS::INCH ) )
144 return false;
145
146 if( !m_edgeClearance.Validate( 0, 10, EDA_UNITS::INCH ) )
147 return false;
148
149 if( !m_minGrooveWidth.Validate( 0, 10, EDA_UNITS::INCH ) )
150 return false;
151
152 if( !m_throughHoleMin.Validate( 2, 1000, EDA_UNITS::MILS ) ) // #107 to 1 inch
153 return false;
154
155 if( !m_holeToHoleMin.Validate( 0, 10, EDA_UNITS::INCH ) )
156 return false;
157
158 // These are all stored in project file, not board, so no need for OnModify()
159
160 m_BrdSettings->m_UseHeightForLengthCalcs = m_useHeightForLengthCalcs->GetValue();
161
162 m_BrdSettings->m_MaxError = KiROUND( std::clamp( static_cast<double>( m_maxError.GetValue() ),
164 pcbIUScale.IU_PER_MM * MAXIMUM_ERROR_SIZE_MM ) );
165
166 m_BrdSettings->m_ZoneKeepExternalFillets = m_allowExternalFilletsOpt->GetValue();
167 m_BrdSettings->m_MinResolvedSpokes = m_minResolvedSpokeCountCtrl->GetValue();
168
169 m_BrdSettings->m_MinClearance = m_minClearance.GetValue();
170 m_BrdSettings->m_MinConn = m_minConn.GetValue();
171 m_BrdSettings->m_TrackMinWidth = m_trackMinWidth.GetValue();
172 m_BrdSettings->m_ViasMinAnnularWidth = m_viaMinAnnulus.GetValue();
173 m_BrdSettings->m_ViasMinSize = m_viaMinSize.GetValue();
174 m_BrdSettings->m_HoleClearance = m_holeClearance.GetValue();
175 m_BrdSettings->m_CopperEdgeClearance = m_edgeClearance.GetValue();
176 m_BrdSettings->m_MinGrooveWidth = m_minGrooveWidth.GetValue();
177
178 m_BrdSettings->m_MinThroughDrill = m_throughHoleMin.GetValue();
179 m_BrdSettings->m_HoleToHoleMin = m_holeToHoleMin.GetValue();
180
181 m_BrdSettings->m_MicroViasMinSize = m_uviaMinSize.GetValue();
182 m_BrdSettings->m_MicroViasMinDrill = m_uviaMinDrill.GetValue();
183
184 m_BrdSettings->m_SilkClearance = m_silkClearance.GetValue();
185 m_BrdSettings->m_MinSilkTextHeight = m_minTextHeight.GetValue();
186 m_BrdSettings->m_MinSilkTextThickness = m_minTextThickness.GetValue();
187
188 return true;
189}
190
191
193{
194 BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
195
196 m_BrdSettings = &aBoard->GetDesignSettings();
198
199 m_BrdSettings = savedSettings;
200}
constexpr int ARC_HIGH_DEF
Definition base_units.h:129
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:110
@ via_hole_diameter
@ hole_to_hole_clearance
@ edge_to_copper_clearance
@ hole_to_copper_clearance
@ ps_diff_pair_gap
#define MAXIMUM_ERROR_SIZE_MM
#define MINIMUM_ERROR_SIZE_MM
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:990
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
Container for design settings for a BOARD object.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:317
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1040
PANEL_SETUP_CONSTRAINTS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
PANEL_SETUP_CONSTRAINTS(wxWindow *aParentWindow, PCB_EDIT_FRAME *aFrame)
BOARD_DESIGN_SETTINGS * m_BrdSettings
The main frame for Pcbnew.
KICOMMON_API wxFont GetSmallInfoFont(wxWindow *aWindow)
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:78