2014-09-19 23:58:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004-2009 Jean-Pierre Charras, jean-pierre.charras@gpisa-lab.inpg.fr
|
|
|
|
* Copyright (C) 2009 Dick Hollenbeck, dick@softplc.com
|
2015-10-02 19:11:33 +00:00
|
|
|
* Copyright (C) 2009-2015 KiCad Developers, see change_log.txt for contributors.
|
2014-09-19 23:58:32 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file dialog_design_rules.h
|
|
|
|
*/
|
2009-07-18 11:44:19 +00:00
|
|
|
|
|
|
|
#ifndef __dialog_design_rules_h_
|
|
|
|
#define __dialog_design_rules_h_
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <../class_board.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_design_rules_base.h>
|
2009-07-18 11:44:19 +00:00
|
|
|
|
2016-11-30 07:47:25 +00:00
|
|
|
#include <float.h>
|
|
|
|
#include <wx/valnum.h>
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
|
|
|
|
class PCB_EDIT_FRAME;
|
|
|
|
class BOARD_DESIGN_SETTINGS;
|
|
|
|
|
|
|
|
|
2009-09-28 16:14:45 +00:00
|
|
|
// helper struct to handle a net and its netclass in dialog design rule editor
|
2009-09-10 15:22:26 +00:00
|
|
|
struct NETCUP
|
|
|
|
{
|
|
|
|
NETCUP( const wxString& aNet, const wxString& aClass )
|
|
|
|
{
|
|
|
|
net = aNet;
|
|
|
|
clazz = aClass;
|
|
|
|
}
|
|
|
|
|
2009-09-10 17:28:38 +00:00
|
|
|
wxString net; ///< a net name
|
|
|
|
wxString clazz; ///< a class name
|
2009-09-10 15:22:26 +00:00
|
|
|
};
|
|
|
|
|
2009-09-10 17:28:38 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
typedef std::vector<NETCUP> NETCUPS;
|
|
|
|
typedef std::vector<NETCUP*> PNETCUPS;
|
2009-07-18 11:44:19 +00:00
|
|
|
|
|
|
|
class DIALOG_DESIGN_RULES : public DIALOG_DESIGN_RULES_BASE
|
|
|
|
{
|
2009-09-10 17:28:38 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2014-09-19 23:58:32 +00:00
|
|
|
static const wxString wildCard; ///< the name of a fictitious netclass which includes all NETs
|
2009-09-10 17:28:38 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_EDIT_FRAME* m_Parent;
|
2009-09-10 17:28:38 +00:00
|
|
|
BOARD* m_Pcb;
|
2014-05-13 09:22:51 +00:00
|
|
|
BOARD_DESIGN_SETTINGS* m_BrdSettings;
|
2009-09-10 17:28:38 +00:00
|
|
|
|
2016-11-30 07:47:25 +00:00
|
|
|
NETCLASSPTR m_SelectedNetClass;
|
|
|
|
|
2009-11-02 05:20:58 +00:00
|
|
|
static int s_LastTabSelection; ///< which tab user had open last
|
2016-08-25 07:35:35 +00:00
|
|
|
int m_initialRowLabelsSize; ///< the initial width given by wxFormBuilder
|
2009-11-02 05:20:58 +00:00
|
|
|
|
2016-11-30 07:47:25 +00:00
|
|
|
wxFloatingPointValidator< double > m_validator; // Floating point validator
|
|
|
|
|
2009-09-10 19:42:34 +00:00
|
|
|
/**
|
|
|
|
* A two column table which gets filled once and never loses any elements, so it is
|
|
|
|
* basically constant, except that the NETCUP::clazz member can change for any
|
2015-10-02 19:11:33 +00:00
|
|
|
* given row a NET is moved in and out of a class. class reflects the respective
|
2009-09-10 19:42:34 +00:00
|
|
|
* NET's current net class.
|
|
|
|
*/
|
2009-09-10 17:28:38 +00:00
|
|
|
NETCUPS m_AllNets;
|
|
|
|
|
2009-10-26 19:00:46 +00:00
|
|
|
// List of values to "customize" some tracks and vias
|
2009-10-30 17:58:15 +00:00
|
|
|
std::vector <VIA_DIMENSION> m_ViasDimensionsList;
|
2011-11-24 17:32:51 +00:00
|
|
|
std::vector <int> m_TracksWidthList;
|
2009-10-26 19:00:46 +00:00
|
|
|
|
2009-09-10 17:28:38 +00:00
|
|
|
private:
|
2016-09-25 17:06:49 +00:00
|
|
|
void OnNetClassesNameLeftClick( wxGridEvent& event ) override { event.Skip(); }
|
|
|
|
void OnNetClassesNameRightClick( wxGridEvent& event ) override { event.Skip(); }
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnAddNetclassClick( wxCommandEvent& event ) override;
|
|
|
|
void OnRemoveNetclassClick( wxCommandEvent& event ) override;
|
2017-08-28 19:45:50 +00:00
|
|
|
void CheckAllowMicroVias();
|
2016-11-30 07:47:25 +00:00
|
|
|
void OnAllowMicroVias( wxCommandEvent& event ) override;
|
2014-09-19 23:58:32 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Called on "Move Up" button click
|
|
|
|
* the selected(s) rules are moved up
|
|
|
|
* The default netclass is always the first rule
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnMoveUpSelectedNetClass( wxCommandEvent& event ) override;
|
2014-09-19 23:58:32 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Called on the left Choice Box selection
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnLeftCBSelection( wxCommandEvent& event ) override;
|
2014-09-19 23:58:32 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Called on the Right Choice Box selection
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnRightCBSelection( wxCommandEvent& event ) override;
|
2014-09-19 23:58:32 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnRightToLeftCopyButton( wxCommandEvent& event ) override;
|
|
|
|
void OnLeftToRightCopyButton( wxCommandEvent& event ) override;
|
2014-09-19 23:58:32 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnNotebookPageChanged( wxNotebookEvent& event ) override;
|
2015-10-02 19:11:33 +00:00
|
|
|
|
2014-09-19 23:58:32 +00:00
|
|
|
/*
|
|
|
|
* Called on clicking the left "select all" button:
|
|
|
|
* select all items of the left netname list list box
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnLeftSelectAllButton( wxCommandEvent& event ) override;
|
2014-09-19 23:58:32 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Called on clicking the right "select all" button:
|
|
|
|
* select all items of the right netname list list box
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnRightSelectAllButton( wxCommandEvent& event ) override;
|
2014-09-19 23:58:32 +00:00
|
|
|
|
2016-11-30 07:47:25 +00:00
|
|
|
/*
|
|
|
|
* Function SetDataValidators
|
|
|
|
* adds numerical validators to relevant text input boxes
|
|
|
|
*/
|
|
|
|
void SetDataValidators( void );
|
|
|
|
|
2014-09-19 23:58:32 +00:00
|
|
|
/*
|
|
|
|
* Function TestDataValidity
|
|
|
|
*
|
2015-10-02 19:11:33 +00:00
|
|
|
* Performs a check of design rule data validity and displays an error message if errors
|
|
|
|
* are found.
|
|
|
|
* @param aErrorMsg is a pointer to a wxString to copy the error message into. Can be NULL.
|
2014-09-19 23:58:32 +00:00
|
|
|
* @return true if Ok, false if error
|
|
|
|
*/
|
2015-10-02 19:11:33 +00:00
|
|
|
bool TestDataValidity( wxString* aErrorMsg = NULL );
|
2014-09-19 23:58:32 +00:00
|
|
|
|
2009-10-06 18:58:51 +00:00
|
|
|
void InitDialogRules();
|
2009-10-21 19:16:25 +00:00
|
|
|
void InitGlobalRules();
|
2014-09-19 23:58:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function InitRulesList
|
|
|
|
* Fill the grid showing current rules with values
|
|
|
|
*/
|
2009-09-10 17:28:38 +00:00
|
|
|
void InitRulesList();
|
2014-09-19 23:58:32 +00:00
|
|
|
|
|
|
|
/* Populates the lists of sizes (Tracks width list and Vias diameters & drill list) */
|
2009-10-26 19:00:46 +00:00
|
|
|
void InitDimensionsLists();
|
2014-09-19 23:58:32 +00:00
|
|
|
|
2009-09-10 17:28:38 +00:00
|
|
|
void InitializeRulesSelectionBoxes();
|
2014-09-19 23:58:32 +00:00
|
|
|
|
|
|
|
/* Copy the rules list from grid to board
|
|
|
|
*/
|
2009-09-10 17:28:38 +00:00
|
|
|
void CopyRulesListToBoard();
|
2014-09-19 23:58:32 +00:00
|
|
|
|
2009-10-26 19:00:46 +00:00
|
|
|
void CopyGlobalRulesToBoard();
|
|
|
|
void CopyDimensionsListsToBoard( );
|
2009-09-10 17:28:38 +00:00
|
|
|
void SetRoutableLayerStatus();
|
2014-09-19 23:58:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function FillListBoxWithNetNames
|
|
|
|
* populates aListCtrl with net names and class names from m_AllNets in a two column display.
|
|
|
|
*/
|
2010-09-02 13:10:48 +00:00
|
|
|
void FillListBoxWithNetNames( NETS_LIST_CTRL* aListCtrl, const wxString& aNetClass );
|
2014-09-19 23:58:32 +00:00
|
|
|
|
2009-09-10 17:28:38 +00:00
|
|
|
/**
|
|
|
|
* Function swapNetClass
|
|
|
|
* replaces one net class name with another in the master list, m_AllNets.
|
|
|
|
*/
|
|
|
|
void swapNetClass( const wxString& oldClass, const wxString& newClass )
|
|
|
|
{
|
|
|
|
for( NETCUPS::iterator i = m_AllNets.begin(); i!=m_AllNets.end(); ++i )
|
2009-09-10 15:22:26 +00:00
|
|
|
{
|
2009-09-10 17:28:38 +00:00
|
|
|
if( i->clazz == oldClass )
|
|
|
|
i->clazz = newClass;
|
2009-09-10 15:22:26 +00:00
|
|
|
}
|
2009-09-10 17:28:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void makePointers( PNETCUPS* aList, const wxString& aNetClassName );
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2009-09-10 17:28:38 +00:00
|
|
|
void setNetClass( const wxString& aNetName, const wxString& aClassName );
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2010-09-02 13:10:48 +00:00
|
|
|
void moveSelectedItems( NETS_LIST_CTRL* src, const wxString& newClassName );
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2009-07-18 11:44:19 +00:00
|
|
|
|
2009-09-10 17:28:38 +00:00
|
|
|
public:
|
2011-03-01 19:26:17 +00:00
|
|
|
DIALOG_DESIGN_RULES( PCB_EDIT_FRAME* parent );
|
2015-10-02 19:11:33 +00:00
|
|
|
~DIALOG_DESIGN_RULES( ) { }
|
2009-07-18 11:44:19 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual bool TransferDataFromWindow() override;
|
2009-07-18 11:44:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //__dialog_design_rules_h_
|