KiCad PCB EDA Suite
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-2020 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 <board_design_settings.h>
25 #include <board.h>
26 #include <convert_to_biu.h>
27 #include <math/util.h>
30 #include <pcb_edit_frame.h>
31 #include <widgets/paged_dialog.h>
32 #include <wx/treebook.h>
33 #include <bitmaps.h>
34 
35 
37  PANEL_SETUP_CONSTRAINTS_BASE( aParent->GetTreebook() ),
38  m_minClearance( aFrame, m_clearanceTitle, m_clearanceCtrl, m_clearanceUnits ),
39  m_trackMinWidth( aFrame, m_TrackMinWidthTitle, m_TrackMinWidthCtrl, m_TrackMinWidthUnits ),
40  m_viaMinAnnulus( aFrame, m_ViaMinAnnulusTitle, m_ViaMinAnnulusCtrl, m_ViaMinAnnulusUnits ),
41  m_viaMinSize( aFrame, m_ViaMinTitle, m_SetViasMinSizeCtrl, m_ViaMinUnits ),
42  m_throughHoleMin( aFrame, m_MinDrillTitle, m_MinDrillCtrl, m_MinDrillUnits ),
43  m_uviaMinSize( aFrame, m_uviaMinSizeLabel, m_uviaMinSizeCtrl, m_uviaMinSizeUnits ),
44  m_uviaMinDrill( aFrame, m_uviaMinDrillLabel, m_uviaMinDrillCtrl, m_uviaMinDrillUnits ),
45  m_holeToHoleMin( aFrame, m_HoleToHoleTitle, m_SetHoleToHoleCtrl, m_HoleToHoleUnits ),
46  m_holeClearance( aFrame, m_HoleClearanceLabel, m_HoleClearanceCtrl, m_HoleClearanceUnits ),
47  m_edgeClearance( aFrame, m_EdgeClearanceLabel, m_EdgeClearanceCtrl, m_EdgeClearanceUnits ),
48  m_silkClearance( aFrame, m_silkClearanceLabel, m_silkClearanceCtrl, m_silkClearanceUnits ),
49  m_maxError( aFrame, m_maxErrorTitle, m_maxErrorCtrl, m_maxErrorUnits )
50 {
51  m_Frame = aFrame;
53 
54  wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
55  infoFont.SetSymbolicSize( wxFONTSIZE_SMALL );
56  m_stCircleToPolyWarning->SetFont( infoFont );
57 }
58 
59 
61 {
62  wxString msg;
63  msg.Printf( m_stCircleToPolyWarning->GetLabel(),
64  StringFromValue( m_Frame->GetUserUnits(), ARC_HIGH_DEF, true ) );
65  m_stCircleToPolyWarning->SetLabel( msg );
66 
69 
71 
75 
82 
85 
88 
90 
91  return true;
92 }
93 
94 
96 {
98  return false;
99 
101  return false;
102 
104  return false;
105 
106  if( !m_viaMinSize.Validate( 0, 10, EDA_UNITS::INCHES ) )
107  return false;
108 
110  return false;
111 
113  return false;
114 
115  if( !m_throughHoleMin.Validate( 2, 1000, EDA_UNITS::MILS ) ) // #107 to 1 inch
116  return false;
117 
119  return false;
120 
121  // These are all stored in project file, not board, so no need for OnModify()
122 
125 
129 
132 
139 
142 
145 
147 
148  return true;
149 }
150 
151 
153 {
154  bool retVal = wxPanel::Show( aShow );
155 
156  if( aShow )
157  {
158  // These *should* work in the constructor, and indeed they do if this panel is the
159  // first displayed. However, on OSX 3.0.5 (at least), if another panel is displayed
160  // first then the icons will be blank unless they're set here.
175 
176  Layout();
177  }
178 
179  return retVal;
180 }
181 
182 
184 {
185  BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
186 
187  m_BrdSettings = &aBoard->GetDesignSettings();
189 
190  m_BrdSettings = savedSettings;
191 }
192 
193 
194 void PANEL_SETUP_CONSTRAINTS::onChangeOutlineOpt( wxCommandEvent& event )
195 {
196  wxObject* item =event.GetEventObject();
197 
198  if( item == m_rbOutlinePolygonBestQ )
199  m_rbOutlinePolygonFastest->SetValue( not m_rbOutlinePolygonBestQ->GetValue() );
200  else
201  m_rbOutlinePolygonBestQ->SetValue( not m_rbOutlinePolygonFastest->GetValue() );
202 }
int m_ZoneFillVersion
Option to select different fill algorithms.
void SetCopperEdgeClearance(int aDistance)
static constexpr double IU_PER_MM
Mock up a conversion function.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
#define MINIMUM_ERROR_SIZE_MM
bool Show(bool aShow) override
BOARD_DESIGN_SETTINGS * m_BrdSettings
void SetMinHoleSeparation(int aDistance)
void onChangeOutlineOpt(wxCommandEvent &event) override
bool m_BlindBuriedViaAllowed
true to allow blind/buried vias
PANEL_SETUP_CONSTRAINTS(PAGED_DIALOG *aParent, PCB_EDIT_FRAME *aFrame)
Class PANEL_SETUP_CONSTRAINTS_BASE.
void ImportSettingsFrom(BOARD *aBoard)
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.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
#define MAXIMUM_ERROR_SIZE_MM
virtual void SetValue(int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
The main frame for Pcbnew.
virtual long long int GetValue()
Return the current value in Internal Units.
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:225
bool m_MicroViasAllowed
true to allow micro vias
BOARD * GetBoard() const
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
Container for design settings for a BOARD object.
wxBitmap KiBitmap(BITMAPS aBitmap)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:104