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#include <map>
26
28#include <board.h>
29#include <math/util.h>
32#include <pcb_edit_frame.h>
34#include <wx/treebook.h>
35#include <bitmaps.h>
36#include <advanced_config.h>
37
38
40 PANEL_SETUP_CONSTRAINTS_BASE( aParentWindow ),
57{
58 m_Frame = aFrame;
59 m_BrdSettings = &m_Frame->GetBoard()->GetDesignSettings();
60
74
75 m_stCircleToPolyWarning->SetFont( KIUI::GetSmallInfoFont( this ).Italic() );
76
77 wxSize ctrlSize = m_minResolvedSpokeCountCtrl->GetSize();
78 ctrlSize.x = KIUI::GetTextSize( wxT( "XXX" ), m_minResolvedSpokeCountCtrl ).x;
79 m_minResolvedSpokeCountCtrl->SetSize( ctrlSize );
80
81 if( !ADVANCED_CFG::GetCfg().m_EnableCreepageSlot )
82 {
83 m_bitmapMinGrooveWidth->Show( false );
84 m_minGrooveWidthLabel->Show( false );
85 m_minGrooveWidthCtrl->Show( false );
86 m_minGrooveWidthUnits->Show( false );
87 }
88}
89
90
92{
93 wxString msg;
94 msg.Printf( m_stCircleToPolyWarning->GetLabel(), m_Frame->StringFromValue( ARC_HIGH_DEF, true ) );
95 m_stCircleToPolyWarning->SetLabel( msg );
96
97 m_useHeightForLengthCalcs->SetValue( m_BrdSettings->m_UseHeightForLengthCalcs );
98
99 m_maxError.SetValue( m_BrdSettings->m_MaxError );
100
101 m_allowExternalFilletsOpt->SetValue( m_BrdSettings->m_ZoneKeepExternalFillets );
102 m_minResolvedSpokeCountCtrl->SetValue( m_BrdSettings->m_MinResolvedSpokes );
103
104 m_minClearance.SetValue( m_BrdSettings->m_MinClearance );
105 m_minConn.SetValue( m_BrdSettings->m_MinConn );
106 m_trackMinWidth.SetValue( m_BrdSettings->m_TrackMinWidth );
107 m_viaMinAnnulus.SetValue( m_BrdSettings->m_ViasMinAnnularWidth );
108 m_viaMinSize.SetValue(m_BrdSettings->m_ViasMinSize );
109 m_holeClearance.SetValue( m_BrdSettings->m_HoleClearance );
110 m_edgeClearance.SetValue( m_BrdSettings->m_CopperEdgeClearance );
111 m_minGrooveWidth.SetValue( m_BrdSettings->m_MinGrooveWidth );
112
113 m_throughHoleMin.SetValue( m_BrdSettings->m_MinThroughDrill );
114 m_holeToHoleMin.SetValue( m_BrdSettings->m_HoleToHoleMin );
115
116 m_uviaMinSize.SetValue( m_BrdSettings->m_MicroViasMinSize );
117 m_uviaMinDrill.SetValue( m_BrdSettings->m_MicroViasMinDrill );
118
119 m_silkClearance.SetValue( m_BrdSettings->m_SilkClearance );
120 m_minTextHeight.SetValue( m_BrdSettings->m_MinSilkTextHeight );
121 m_minTextThickness.SetValue( m_BrdSettings->m_MinSilkTextThickness );
122
123 return true;
124}
125
126
128{
129 // These are all stored in project file, not board, so no need for OnModify()
130
131 m_BrdSettings->m_UseHeightForLengthCalcs = m_useHeightForLengthCalcs->GetValue();
132
133 m_BrdSettings->m_MaxError = m_maxError.GetValue();
134
135 m_BrdSettings->m_ZoneKeepExternalFillets = m_allowExternalFilletsOpt->GetValue();
136 m_BrdSettings->m_MinResolvedSpokes = m_minResolvedSpokeCountCtrl->GetValue();
137
138 m_BrdSettings->m_MinClearance = m_minClearance.GetValue();
139 m_BrdSettings->m_MinConn = m_minConn.GetValue();
140 m_BrdSettings->m_TrackMinWidth = m_trackMinWidth.GetValue();
141 m_BrdSettings->m_ViasMinAnnularWidth = m_viaMinAnnulus.GetValue();
142 m_BrdSettings->m_ViasMinSize = m_viaMinSize.GetValue();
143 m_BrdSettings->m_HoleClearance = m_holeClearance.GetValue();
144 m_BrdSettings->m_CopperEdgeClearance = m_edgeClearance.GetValue();
145 m_BrdSettings->m_MinGrooveWidth = m_minGrooveWidth.GetValue();
146
147 m_BrdSettings->m_MinThroughDrill = m_throughHoleMin.GetValue();
148 m_BrdSettings->m_HoleToHoleMin = m_holeToHoleMin.GetValue();
149
150 m_BrdSettings->m_MicroViasMinSize = m_uviaMinSize.GetValue();
151 m_BrdSettings->m_MicroViasMinDrill = m_uviaMinDrill.GetValue();
152
153 m_BrdSettings->m_SilkClearance = m_silkClearance.GetValue();
154 m_BrdSettings->m_MinSilkTextHeight = m_minTextHeight.GetValue();
155 m_BrdSettings->m_MinSilkTextThickness = m_minTextThickness.GetValue();
156
157 std::vector<BOARD_DESIGN_SETTINGS::VALIDATION_ERROR> errors =
158 m_BrdSettings->ValidateDesignRules( m_Frame->GetUserUnits() );
159
160 if( !errors.empty() )
161 {
162 const BOARD_DESIGN_SETTINGS::VALIDATION_ERROR& error = errors.front();
163
164 const std::map<wxString, wxWindow*> fieldToControl = {
165 { wxS( "min_clearance" ), m_clearanceCtrl },
166 { wxS( "min_connection" ), m_MinConnCtrl },
167 { wxS( "min_track_width" ), m_TrackMinWidthCtrl },
168 { wxS( "min_via_annular_width" ), m_ViaMinAnnulusCtrl },
169 { wxS( "min_via_diameter" ), m_SetViasMinSizeCtrl },
170 { wxS( "min_through_hole_diameter" ), m_MinDrillCtrl },
171 { wxS( "min_microvia_diameter" ), m_uviaMinSizeCtrl },
172 { wxS( "min_microvia_drill" ), m_uviaMinDrillCtrl },
173 { wxS( "min_hole_to_hole" ), m_SetHoleToHoleCtrl },
174 { wxS( "min_hole_clearance" ), m_HoleClearanceCtrl },
175 { wxS( "min_silk_clearance" ), m_silkClearanceCtrl },
176 { wxS( "min_groove_width" ), m_minGrooveWidthCtrl },
177 { wxS( "min_text_height" ), m_textHeightCtrl },
178 { wxS( "min_text_thickness" ), m_textThicknessCtrl },
179 { wxS( "min_copper_edge_clearance" ), m_EdgeClearanceCtrl },
180 { wxS( "max_error" ), m_maxErrorCtrl },
181 { wxS( "min_resolved_spokes" ), m_minResolvedSpokeCountCtrl }
182 };
183
184 wxWindow* control = nullptr;
185
186 if( auto it = fieldToControl.find( error.setting_name ); it != fieldToControl.end() )
187 control = it->second;
188
189 PAGED_DIALOG::GetDialog( this )->SetError( error.error_message, this, control ? control : this );
190 return false;
191 }
192
193 return true;
194}
195
196
198{
199 BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
200
201 m_BrdSettings = &aBoard->GetDesignSettings();
203
204 m_BrdSettings = savedSettings;
205}
constexpr int ARC_HIGH_DEF
Definition base_units.h:128
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
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:323
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1091
static PAGED_DIALOG * GetDialog(wxWindow *aWindow)
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
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