KiCad PCB EDA Suite
dialog_design_rules.h
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) 2004-2009 Jean-Pierre Charras, jean-pierre.charras@gpisa-lab.inpg.fr
5  * Copyright (C) 2009 Dick Hollenbeck, dick@softplc.com
6  * Copyright (C) 2009-2015 KiCad Developers, see change_log.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 
31 #ifndef __dialog_design_rules_h_
32 #define __dialog_design_rules_h_
33 
34 #include <../class_board.h>
35 
37 
38 #include <float.h>
39 #include <wx/valnum.h>
40 
41 
42 class PCB_EDIT_FRAME;
44 
45 
46 // helper struct to handle a net and its netclass in dialog design rule editor
47 struct NETCUP
48 {
49  NETCUP( const wxString& aNet, const wxString& aClass )
50  {
51  net = aNet;
52  clazz = aClass;
53  }
54 
55  wxString net;
56  wxString clazz;
57 };
58 
59 
60 typedef std::vector<NETCUP> NETCUPS;
61 typedef std::vector<NETCUP*> PNETCUPS;
62 
64 {
65 
66 private:
67 
68  static const wxString wildCard;
69 
73 
74  NETCLASSPTR m_SelectedNetClass;
75 
76  static int s_LastTabSelection;
78 
79  wxFloatingPointValidator< double > m_validator; // Floating point validator
80 
88 
89  // List of values to "customize" some tracks and vias
90  std::vector <VIA_DIMENSION> m_ViasDimensionsList;
91  std::vector <int> m_TracksWidthList;
92 
93 private:
94  void OnNetClassesNameLeftClick( wxGridEvent& event ) override { event.Skip(); }
95  void OnNetClassesNameRightClick( wxGridEvent& event ) override { event.Skip(); }
96  void OnAddNetclassClick( wxCommandEvent& event ) override;
97  void OnRemoveNetclassClick( wxCommandEvent& event ) override;
98  void CheckAllowMicroVias();
99  void OnAllowMicroVias( wxCommandEvent& event ) override;
100 
101  /*
102  * Called on "Move Up" button click
103  * the selected(s) rules are moved up
104  * The default netclass is always the first rule
105  */
106  void OnMoveUpSelectedNetClass( wxCommandEvent& event ) override;
107 
108  /*
109  * Called on the left Choice Box selection
110  */
111  void OnLeftCBSelection( wxCommandEvent& event ) override;
112 
113  /*
114  * Called on the Right Choice Box selection
115  */
116  void OnRightCBSelection( wxCommandEvent& event ) override;
117 
118  void OnRightToLeftCopyButton( wxCommandEvent& event ) override;
119  void OnLeftToRightCopyButton( wxCommandEvent& event ) override;
120 
121  void OnNotebookPageChanged( wxNotebookEvent& event ) override;
122 
123  /*
124  * Called on clicking the left "select all" button:
125  * select all items of the left netname list list box
126  */
127  void OnLeftSelectAllButton( wxCommandEvent& event ) override;
128 
129  /*
130  * Called on clicking the right "select all" button:
131  * select all items of the right netname list list box
132  */
133  void OnRightSelectAllButton( wxCommandEvent& event ) override;
134 
135  /*
136  * Function SetDataValidators
137  * adds numerical validators to relevant text input boxes
138  */
139  void SetDataValidators( void );
140 
141  /*
142  * Function TestDataValidity
143  *
144  * Performs a check of design rule data validity and displays an error message if errors
145  * are found.
146  * @param aErrorMsg is a pointer to a wxString to copy the error message into. Can be NULL.
147  * @return true if Ok, false if error
148  */
149  bool TestDataValidity( wxString* aErrorMsg = NULL );
150 
151  void InitDialogRules();
152  void InitGlobalRules();
153 
158  void InitRulesList();
159 
160  /* Populates the lists of sizes (Tracks width list and Vias diameters & drill list) */
161  void InitDimensionsLists();
162 
164 
165  /* Copy the rules list from grid to board
166  */
167  void CopyRulesListToBoard();
168 
169  void CopyGlobalRulesToBoard();
171  void SetRoutableLayerStatus();
172 
177  void FillListBoxWithNetNames( NETS_LIST_CTRL* aListCtrl, const wxString& aNetClass );
178 
183  void swapNetClass( const wxString& oldClass, const wxString& newClass )
184  {
185  for( NETCUPS::iterator i = m_AllNets.begin(); i!=m_AllNets.end(); ++i )
186  {
187  if( i->clazz == oldClass )
188  i->clazz = newClass;
189  }
190  }
191 
192  void makePointers( PNETCUPS* aList, const wxString& aNetClassName );
193 
194  void setNetClass( const wxString& aNetName, const wxString& aClassName );
195 
196  void moveSelectedItems( NETS_LIST_CTRL* src, const wxString& newClassName );
197 
198 
199 public:
202 
203  virtual bool TransferDataFromWindow() override;
204 };
205 
206 #endif //__dialog_design_rules_h_
void OnNotebookPageChanged(wxNotebookEvent &event) override
std::vector< int > m_TracksWidthList
virtual bool TransferDataFromWindow() override
void OnLeftToRightCopyButton(wxCommandEvent &event) override
NETCUP(const wxString &aNet, const wxString &aClass)
wxString clazz
a class name
void InitRulesList()
Function InitRulesList Fill the grid showing current rules with values.
void swapNetClass(const wxString &oldClass, const wxString &newClass)
Function swapNetClass replaces one net class name with another in the master list, m_AllNets.
void moveSelectedItems(NETS_LIST_CTRL *src, const wxString &newClassName)
std::vector< NETCUP * > PNETCUPS
void OnMoveUpSelectedNetClass(wxCommandEvent &event) override
std::vector< VIA_DIMENSION > m_ViasDimensionsList
std::vector< NETCUP > NETCUPS
void OnRemoveNetclassClick(wxCommandEvent &event) override
void OnRightSelectAllButton(wxCommandEvent &event) override
wxFloatingPointValidator< double > m_validator
PCB_EDIT_FRAME * m_Parent
void OnRightCBSelection(wxCommandEvent &event) override
Class DIALOG_DESIGN_RULES_BASE.
bool TestDataValidity(wxString *aErrorMsg=NULL)
Class NETS_LIST_CTRL is a helper to display lists of nets and associated netclasses used in dialog de...
NETCLASSPTR m_SelectedNetClass
void SetRoutableLayerStatus()
int m_initialRowLabelsSize
the initial width given by wxFormBuilder
void OnAddNetclassClick(wxCommandEvent &event) override
void makePointers(PNETCUPS *aList, const wxString &aNetClassName)
wxString net
a net name
void OnAllowMicroVias(wxCommandEvent &event) override
Function OnAllowMicroVias is called whenever the AllowMicroVias checkbox is toggled.
void OnLeftCBSelection(wxCommandEvent &event) override
static const wxString wildCard
the name of a fictitious netclass which includes all NETs
void OnRightToLeftCopyButton(wxCommandEvent &event) override
BOARD_DESIGN_SETTINGS * m_BrdSettings
void setNetClass(const wxString &aNetName, const wxString &aClassName)
void OnLeftSelectAllButton(wxCommandEvent &event) override
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
static int s_LastTabSelection
which tab user had open last
void FillListBoxWithNetNames(NETS_LIST_CTRL *aListCtrl, const wxString &aNetClass)
Function FillListBoxWithNetNames populates aListCtrl with net names and class names from m_AllNets in...
void OnNetClassesNameLeftClick(wxGridEvent &event) override
NETCUPS m_AllNets
A two column table which gets filled once and never loses any elements, so it is basically constant...
DIALOG_DESIGN_RULES(PCB_EDIT_FRAME *parent)
void OnNetClassesNameRightClick(wxGridEvent &event) override
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.