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 OnAllowMicroVias( wxCommandEvent& event ) override;
99 
100  /*
101  * Called on "Move Up" button click
102  * the selected(s) rules are moved up
103  * The default netclass is always the first rule
104  */
105  void OnMoveUpSelectedNetClass( wxCommandEvent& event ) override;
106 
107  /*
108  * Called on the left Choice Box selection
109  */
110  void OnLeftCBSelection( wxCommandEvent& event ) override;
111 
112  /*
113  * Called on the Right Choice Box selection
114  */
115  void OnRightCBSelection( wxCommandEvent& event ) override;
116 
117  void OnRightToLeftCopyButton( wxCommandEvent& event ) override;
118  void OnLeftToRightCopyButton( wxCommandEvent& event ) override;
119 
120  void OnNotebookPageChanged( wxNotebookEvent& event ) override;
121 
122  /*
123  * Called on clicking the left "select all" button:
124  * select all items of the left netname list list box
125  */
126  void OnLeftSelectAllButton( wxCommandEvent& event ) override;
127 
128  /*
129  * Called on clicking the right "select all" button:
130  * select all items of the right netname list list box
131  */
132  void OnRightSelectAllButton( wxCommandEvent& event ) override;
133 
134  /*
135  * Function SetDataValidators
136  * adds numerical validators to relevant text input boxes
137  */
138  void SetDataValidators( void );
139 
140  /*
141  * Function TestDataValidity
142  *
143  * Performs a check of design rule data validity and displays an error message if errors
144  * are found.
145  * @param aErrorMsg is a pointer to a wxString to copy the error message into. Can be NULL.
146  * @return true if Ok, false if error
147  */
148  bool TestDataValidity( wxString* aErrorMsg = NULL );
149 
150  void InitDialogRules();
151  void InitGlobalRules();
152 
157  void InitRulesList();
158 
159  /* Populates the lists of sizes (Tracks width list and Vias diameters & drill list) */
160  void InitDimensionsLists();
161 
163 
164  /* Copy the rules list from grid to board
165  */
166  void CopyRulesListToBoard();
167 
168  void CopyGlobalRulesToBoard();
170  void SetRoutableLayerStatus();
171 
176  void FillListBoxWithNetNames( NETS_LIST_CTRL* aListCtrl, const wxString& aNetClass );
177 
182  void swapNetClass( const wxString& oldClass, const wxString& newClass )
183  {
184  for( NETCUPS::iterator i = m_AllNets.begin(); i!=m_AllNets.end(); ++i )
185  {
186  if( i->clazz == oldClass )
187  i->clazz = newClass;
188  }
189  }
190 
191  void makePointers( PNETCUPS* aList, const wxString& aNetClassName );
192 
193  void setNetClass( const wxString& aNetName, const wxString& aClassName );
194 
195  void moveSelectedItems( NETS_LIST_CTRL* src, const wxString& newClassName );
196 
197 
198 public:
201 
202  virtual bool TransferDataFromWindow() override;
203 };
204 
205 #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.