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