diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 98ff68f633..52f7cfdd80 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -8,7 +8,7 @@ email address. ================================================================================ ++pcbnew First work about net classes. This is a work in progress and a moving target. - Manual routing and DRC do not used yet this feature + Manual routing and DRC do not use yet this feature 2009-Jul-13 UPDATE Dick Hollenbeck diff --git a/pcbnew/dialog_design_rules.cpp b/pcbnew/dialog_design_rules.cpp index e943d3b1aa..6fad29fc36 100644 --- a/pcbnew/dialog_design_rules.cpp +++ b/pcbnew/dialog_design_rules.cpp @@ -23,11 +23,11 @@ #define LAYERS_GRID_NAME_POSITION 2 // Fields Positions on rules grid -#define RULE_GRID_TRACKSIZE_POSITION 0 -#define RULE_GRID_VIASIZE_POSITION 1 -#define RULE_GRID_CLEARANCE_POSITION 2 +#define RULE_GRID_TRACKSIZE_POSITION 0 +#define RULE_GRID_VIASIZE_POSITION 1 +#define RULE_GRID_CLEARANCE_POSITION 2 #define RULE_GRID_MINTRACKSIZE_POSITION 3 -#define RULE_GRID_MINVIASIZE_POSITION 4 +#define RULE_GRID_MINVIASIZE_POSITION 4 /***********************************************************************************/ DIALOG_DESIGN_RULES::DIALOG_DESIGN_RULES( WinEDA_PcbFrame* parent ) : @@ -48,11 +48,11 @@ void DIALOG_DESIGN_RULES::Init() /********************************************************************/ { SetFocus(); + SetReturnCode( 0 ); // Initialize the layers grid: m_ActivesLayersCount = g_DesignSettings.m_CopperLayerCount; - m_Pcb = m_Parent->GetBoard(); - m_Changes = 0; + m_Pcb = m_Parent->GetBoard(); m_LayersCountSelection->SetSelection( m_ActivesLayersCount / 2 ); @@ -100,67 +100,74 @@ void DIALOG_DESIGN_RULES::Init() InitRulesList(); /* Initialize the list of nets buffers - (note the netcode 0 is not a real net, so it is not loaded) - */ - for ( unsigned ii = 1; ; ii ++ ) + * (note the netcode 0 is not a real net, so it is not loaded) + */ + for( unsigned ii = 1; ; ii++ ) { NETINFO_ITEM* net = m_Pcb->FindNet( ii ); if( net == NULL ) break; - m_StockNets.push_back(net); + m_StockNets.push_back( net ); + // search the index in rules list for this net int rules_idx = 0; - for (int jj = 0; jj < m_gridNetClassesProperties->GetNumberRows(); jj++ ) + for( int jj = 0; jj < m_gridNetClassesProperties->GetNumberRows(); jj++ ) { - if( m_gridNetClassesProperties->GetRowLabelValue(jj).CmpNoCase(net->GetClassName()) == 0 ) + if( m_gridNetClassesProperties->GetRowLabelValue( jj ).CmpNoCase( net->GetClassName() ) + == 0 ) { rules_idx = jj; break; } } - m_NetsLinkToClasses.push_back(rules_idx); // All nets are set to default net class + + m_NetsLinkToClasses.push_back( rules_idx ); // All nets are set to default net class } InitializeRulesSelectionBoxes(); } + /** Function FillListBoxWithNetsNames * populates the aListBox with net names members of the aNetclassIndex net class * the "Client Data pointer" is used to store the index of nets in ne nets lists */ -void DIALOG_DESIGN_RULES::FillListBoxWithNetsNames(wxListBox* aListBox, int aNetclassIndex) +void DIALOG_DESIGN_RULES::FillListBoxWithNetsNames( wxListBox* aListBox, int aNetclassIndex ) { aListBox->Clear(); unsigned idx = 0; - for(unsigned ii = 0; ii < m_StockNets.size(); ii++ ) + for( unsigned ii = 0; ii < m_StockNets.size(); ii++ ) { - if (aNetclassIndex == m_NetsLinkToClasses[ii] ) + if( aNetclassIndex == m_NetsLinkToClasses[ii] ) { aListBox->Append( m_StockNets[ii]->GetNetname() ); + // Store the index of this net - aListBox->SetClientData(idx, (void *) ii); + aListBox->SetClientData( idx, (void*) ii ); idx++; } } } + /* Initialize the combno boxes by the list of existing net classes */ void DIALOG_DESIGN_RULES::InitializeRulesSelectionBoxes() { m_CBoxRightSelection->Clear(); m_CBoxLeftSelection->Clear(); - for (int ii = 0; ii < m_gridNetClassesProperties->GetNumberRows(); ii++ ) + for( int ii = 0; ii < m_gridNetClassesProperties->GetNumberRows(); ii++ ) { - m_CBoxRightSelection->Append(m_gridNetClassesProperties->GetRowLabelValue(ii)); - m_CBoxLeftSelection->Append(m_gridNetClassesProperties->GetRowLabelValue(ii)); + m_CBoxRightSelection->Append( m_gridNetClassesProperties->GetRowLabelValue( ii ) ); + m_CBoxLeftSelection->Append( m_gridNetClassesProperties->GetRowLabelValue( ii ) ); } - m_CBoxRightSelection->Select(0); - m_CBoxLeftSelection->Select(0); - m_buttonRightToLeft->Enable(false); - m_buttonLeftToRight->Enable(false);; - FillListBoxWithNetsNames(m_listBoxLeftNetSelect, m_CBoxLeftSelection->GetCurrentSelection() ); - FillListBoxWithNetsNames(m_listBoxRightNetSelect, m_CBoxRightSelection->GetCurrentSelection() ); + + m_CBoxRightSelection->Select( 0 ); + m_CBoxLeftSelection->Select( 0 ); + m_buttonRightToLeft->Enable( false ); + m_buttonLeftToRight->Enable( false );; + FillListBoxWithNetsNames( m_listBoxLeftNetSelect, m_CBoxLeftSelection->GetCurrentSelection() ); + FillListBoxWithNetsNames( m_listBoxRightNetSelect, m_CBoxRightSelection->GetCurrentSelection() ); } @@ -179,97 +186,111 @@ void DIALOG_DESIGN_RULES::SetRoutableLayerStatus() value = wxT( "1" ); m_gridLayersProperties->SetCellValue( ii, LAYERS_GRID_ROUTABLE_POSITION, value ); m_gridLayersProperties->SetReadOnly( ii, LAYERS_GRID_ROUTABLE_POSITION ); + // Set to Read Only cell for non existing copper layers: m_gridLayersProperties->SetReadOnly( ii, LAYERS_GRID_STATUS_POSITION, value != wxT( "1" ) ); m_gridLayersProperties->SetReadOnly( ii, LAYERS_GRID_NAME_POSITION, value != wxT( "1" ) ); } } + /* Initialize the rules list from board -*/ + */ void DIALOG_DESIGN_RULES::InitRulesList() { for( int ii = 0; ; ii++ ) { - const NETCLASS * netclass = m_Pcb->m_NetClassesList.GetNetClass(ii); - if ( netclass == NULL ) + const NETCLASS* netclass = m_Pcb->m_NetClassesList.GetNetClass( ii ); + if( netclass == NULL ) break; + // Creates one entry if needed - if (ii >= m_gridNetClassesProperties->GetNumberRows() ) - m_gridNetClassesProperties->AppendRows( ); + if( ii >= m_gridNetClassesProperties->GetNumberRows() ) + m_gridNetClassesProperties->AppendRows(); + // Init name - m_gridNetClassesProperties->SetRowLabelValue(ii, netclass->m_Name); + m_gridNetClassesProperties->SetRowLabelValue( ii, netclass->m_Name ); + // Init data wxString msg; - msg = ReturnStringFromValue( g_UnitMetric, - netclass->m_NetParams.m_TracksWidth, - m_Parent->m_InternalUnits, false ); - m_gridNetClassesProperties->SetCellValue(ii, RULE_GRID_TRACKSIZE_POSITION, msg); - msg = ReturnStringFromValue( g_UnitMetric, - netclass->m_NetParams.m_ViasSize, - m_Parent->m_InternalUnits, false ); - m_gridNetClassesProperties->SetCellValue(ii, RULE_GRID_VIASIZE_POSITION, msg); - msg = ReturnStringFromValue( g_UnitMetric, - netclass->m_NetParams.m_Clearance, - m_Parent->m_InternalUnits, false ); - m_gridNetClassesProperties->SetCellValue(ii, RULE_GRID_CLEARANCE_POSITION, msg); - msg = ReturnStringFromValue( g_UnitMetric, - netclass->m_NetParams.m_TracksMinWidth, - m_Parent->m_InternalUnits, false ); - m_gridNetClassesProperties->SetCellValue(ii, RULE_GRID_MINTRACKSIZE_POSITION, msg); - msg = ReturnStringFromValue( g_UnitMetric, - netclass->m_NetParams.m_ViasMinSize, - m_Parent->m_InternalUnits, false ); - m_gridNetClassesProperties->SetCellValue(ii, RULE_GRID_MINVIASIZE_POSITION, msg); + msg = ReturnStringFromValue( g_UnitMetric, + netclass->m_NetParams.m_TracksWidth, + m_Parent->m_InternalUnits, false ); + m_gridNetClassesProperties->SetCellValue( ii, RULE_GRID_TRACKSIZE_POSITION, msg ); + msg = ReturnStringFromValue( g_UnitMetric, + netclass->m_NetParams.m_ViasSize, + m_Parent->m_InternalUnits, false ); + m_gridNetClassesProperties->SetCellValue( ii, RULE_GRID_VIASIZE_POSITION, msg ); + msg = ReturnStringFromValue( g_UnitMetric, + netclass->m_NetParams.m_Clearance, + m_Parent->m_InternalUnits, false ); + m_gridNetClassesProperties->SetCellValue( ii, RULE_GRID_CLEARANCE_POSITION, msg ); + msg = ReturnStringFromValue( g_UnitMetric, + netclass->m_NetParams.m_TracksMinWidth, + m_Parent->m_InternalUnits, false ); + m_gridNetClassesProperties->SetCellValue( ii, RULE_GRID_MINTRACKSIZE_POSITION, msg ); + msg = ReturnStringFromValue( g_UnitMetric, + netclass->m_NetParams.m_ViasMinSize, + m_Parent->m_InternalUnits, false ); + m_gridNetClassesProperties->SetCellValue( ii, RULE_GRID_MINVIASIZE_POSITION, msg ); } } + /* Copy the rules list to board -*/ + */ void DIALOG_DESIGN_RULES::CopyRulesListToBoard() { m_Pcb->m_NetClassesList.ClearList(); for( int ii = 0; ii < m_gridNetClassesProperties->GetNumberRows(); ii++ ) { - NETCLASS * netclass = new NETCLASS(m_Pcb, - m_gridNetClassesProperties->GetRowLabelValue(ii) ); - m_Pcb->m_NetClassesList.AddNetclass(netclass); + NETCLASS* netclass = new NETCLASS( m_Pcb, + m_gridNetClassesProperties->GetRowLabelValue( ii ) ); + m_Pcb->m_NetClassesList.AddNetclass( netclass ); + // Init data netclass->m_NetParams.m_TracksWidth = ReturnValueFromString( g_UnitMetric, - m_gridNetClassesProperties->GetCellValue(ii, RULE_GRID_TRACKSIZE_POSITION), - m_Parent->m_InternalUnits ); + m_gridNetClassesProperties->GetCellValue( ii, + RULE_GRID_TRACKSIZE_POSITION ), + m_Parent->m_InternalUnits ); netclass->m_NetParams.m_ViasSize = ReturnValueFromString( g_UnitMetric, - m_gridNetClassesProperties->GetCellValue(ii, RULE_GRID_VIASIZE_POSITION), - m_Parent->m_InternalUnits ); + m_gridNetClassesProperties->GetCellValue( ii, + RULE_GRID_VIASIZE_POSITION ), + m_Parent->m_InternalUnits ); netclass->m_NetParams.m_Clearance = ReturnValueFromString( g_UnitMetric, - m_gridNetClassesProperties->GetCellValue(ii, RULE_GRID_CLEARANCE_POSITION), - m_Parent->m_InternalUnits ); + m_gridNetClassesProperties->GetCellValue( ii, + RULE_GRID_CLEARANCE_POSITION ), + m_Parent->m_InternalUnits ); netclass->m_NetParams.m_TracksMinWidth = ReturnValueFromString( g_UnitMetric, - m_gridNetClassesProperties->GetCellValue(ii, RULE_GRID_MINTRACKSIZE_POSITION), - m_Parent->m_InternalUnits ); + m_gridNetClassesProperties->GetCellValue( ii, + RULE_GRID_MINTRACKSIZE_POSITION ), + m_Parent->m_InternalUnits ); netclass->m_NetParams.m_ViasMinSize = ReturnValueFromString( g_UnitMetric, - m_gridNetClassesProperties->GetCellValue(ii, RULE_GRID_MINVIASIZE_POSITION), - m_Parent->m_InternalUnits ); + m_gridNetClassesProperties->GetCellValue( ii, + RULE_GRID_MINVIASIZE_POSITION ), + m_Parent->m_InternalUnits ); + // Copy the list of nets associated to this netclass: - for(unsigned idx = 0; idx < m_StockNets.size(); idx++ ) + for( unsigned idx = 0; idx < m_StockNets.size(); idx++ ) { if( m_NetsLinkToClasses[idx] == ii ) - netclass->AddMember(m_StockNets[idx]->GetNetname()); + netclass->AddMember( m_StockNets[idx]->GetNetname() ); } } - m_Pcb->TransfertDesignRulesToNets( ); + m_Pcb->TransfertDesignRulesToNets(); } + /*****************************************************************/ void DIALOG_DESIGN_RULES::OnCancelButtonClick( wxCommandEvent& event ) /*****************************************************************/ @@ -282,6 +303,12 @@ void DIALOG_DESIGN_RULES::OnCancelButtonClick( wxCommandEvent& event ) void DIALOG_DESIGN_RULES::OnOkButtonClick( wxCommandEvent& event ) /**************************************************************************/ { + if( !TestDataValidity() ) + { + DisplayError( this, _( "Errors detected, Abort" ) ); + return; + } + g_DesignSettings.m_CopperLayerCount = m_ActivesLayersCount; // Initialize the new layer name @@ -311,7 +338,7 @@ void DIALOG_DESIGN_RULES::OnOkButtonClick( wxCommandEvent& event ) CopyRulesListToBoard(); - EndModal( 1 ); + EndModal( wxID_OK ); } @@ -333,7 +360,8 @@ void DIALOG_DESIGN_RULES::OnAddNetclassClick( wxCommandEvent& event ) /**************************************************************************/ { wxString class_name; - if( Get_Message( _("New Net Class Name:"), + + if( Get_Message( _( "New Net Class Name:" ), wxEmptyString, class_name, this ) ) @@ -343,26 +371,28 @@ void DIALOG_DESIGN_RULES::OnAddNetclassClick( wxCommandEvent& event ) for( int ii = 0; ii < m_gridNetClassesProperties->GetNumberRows(); ii++ ) { wxString value; - value = m_gridNetClassesProperties->GetRowLabelValue(ii); - if( class_name.CmpNoCase( value) == 0 ) // Already exists! + value = m_gridNetClassesProperties->GetRowLabelValue( ii ); + if( class_name.CmpNoCase( value ) == 0 ) // Already exists! { - DisplayError(this, _("This NetClass is alerady existing, cannot add it") ); + DisplayError( this, _( "This NetClass is already existing, cannot add it; Aborted" ) ); return; } } - m_gridNetClassesProperties->AppendRows( ); + m_gridNetClassesProperties->AppendRows(); m_gridNetClassesProperties->SetRowLabelValue( - m_gridNetClassesProperties->GetNumberRows()-1, - class_name); + m_gridNetClassesProperties->GetNumberRows() - 1, + class_name ); + // Copy values of the previous class: - int irow = m_gridNetClassesProperties->GetNumberRows()-1; + int irow = m_gridNetClassesProperties->GetNumberRows() - 1; for( int icol = 0; icol < m_gridNetClassesProperties->GetNumberCols(); icol++ ) { wxString value; - value = m_gridNetClassesProperties->GetCellValue(irow-1, icol); - m_gridNetClassesProperties->SetCellValue(irow, icol, value); + value = m_gridNetClassesProperties->GetCellValue( irow - 1, icol ); + m_gridNetClassesProperties->SetCellValue( irow, icol, value ); } + InitializeRulesSelectionBoxes(); } @@ -372,116 +402,194 @@ void DIALOG_DESIGN_RULES::OnRemoveNetclassClick( wxCommandEvent& event ) /**************************************************************************/ { wxArrayInt select = m_gridNetClassesProperties->GetSelectedRows(); - for( int ii = select.GetCount()-1; ii >= 0; ii-- ) + + for( int ii = select.GetCount() - 1; ii >= 0; ii-- ) { if( select[ii] != 0 ) // Do not remove the default class { - m_gridNetClassesProperties->DeleteRows(select[ii]); + m_gridNetClassesProperties->DeleteRows( select[ii] ); + // reset the net class to default for nets member of the removed net class - for ( unsigned jj = 0; jj< m_NetsLinkToClasses.size(); jj++ ) + for( unsigned jj = 0; jj< m_NetsLinkToClasses.size(); jj++ ) if( m_NetsLinkToClasses[jj] == ii ) m_NetsLinkToClasses[jj] = 0; // Reset to default net class } } + InitializeRulesSelectionBoxes(); } + /* * Called on the left Choice Box selection -*/ + */ void DIALOG_DESIGN_RULES::OnLeftCBSelection( wxCommandEvent& event ) { - FillListBoxWithNetsNames(m_listBoxLeftNetSelect, m_CBoxLeftSelection->GetCurrentSelection() ); - if ( m_CBoxLeftSelection->GetCurrentSelection() == m_CBoxRightSelection->GetCurrentSelection() ) + FillListBoxWithNetsNames( m_listBoxLeftNetSelect, m_CBoxLeftSelection->GetCurrentSelection() ); + if( m_CBoxLeftSelection->GetCurrentSelection() == m_CBoxRightSelection->GetCurrentSelection() ) { - m_buttonRightToLeft->Enable(false); - m_buttonLeftToRight->Enable(false); + m_buttonRightToLeft->Enable( false ); + m_buttonLeftToRight->Enable( false ); } else { - m_buttonRightToLeft->Enable(true); - m_buttonLeftToRight->Enable(true); + m_buttonRightToLeft->Enable( true ); + m_buttonLeftToRight->Enable( true ); } } + /* * Called on the Right Choice Box selection -*/ + */ void DIALOG_DESIGN_RULES::OnRightCBSelection( wxCommandEvent& event ) { - FillListBoxWithNetsNames(m_listBoxRightNetSelect, m_CBoxRightSelection->GetCurrentSelection() ); - if ( m_CBoxLeftSelection->GetCurrentSelection() == m_CBoxRightSelection->GetCurrentSelection() ) + FillListBoxWithNetsNames( m_listBoxRightNetSelect, m_CBoxRightSelection->GetCurrentSelection() ); + if( m_CBoxLeftSelection->GetCurrentSelection() == m_CBoxRightSelection->GetCurrentSelection() ) { - m_buttonRightToLeft->Enable(false); - m_buttonLeftToRight->Enable(false);; + m_buttonRightToLeft->Enable( false ); + m_buttonLeftToRight->Enable( false );; } else { - m_buttonRightToLeft->Enable(true); - m_buttonLeftToRight->Enable(true); + m_buttonRightToLeft->Enable( true ); + m_buttonLeftToRight->Enable( true ); } } /* Called on clicking the "<<<" or Copy Right to Left button: * Selected items are moved from the right list to the left list -*/ + */ void DIALOG_DESIGN_RULES::OnRightToLeftCopyButton( wxCommandEvent& event ) { int idx_class = m_CBoxLeftSelection->GetCurrentSelection(); - if ( idx_class == wxNOT_FOUND ) + + if( idx_class == wxNOT_FOUND ) return; for( unsigned ii = 0; ii < m_listBoxRightNetSelect->GetCount(); ii++ ) { - if( ! m_listBoxRightNetSelect->IsSelected(ii) ) + if( !m_listBoxRightNetSelect->IsSelected( ii ) ) continue; - unsigned idx = (unsigned) m_listBoxRightNetSelect->GetClientData( ii); + unsigned idx = (unsigned) m_listBoxRightNetSelect->GetClientData( ii ); m_NetsLinkToClasses[idx] = idx_class; } - FillListBoxWithNetsNames(m_listBoxLeftNetSelect, m_CBoxLeftSelection->GetCurrentSelection()); - FillListBoxWithNetsNames(m_listBoxRightNetSelect, m_CBoxRightSelection->GetCurrentSelection()); + FillListBoxWithNetsNames( m_listBoxLeftNetSelect, m_CBoxLeftSelection->GetCurrentSelection() ); + FillListBoxWithNetsNames( m_listBoxRightNetSelect, m_CBoxRightSelection->GetCurrentSelection() ); } + /* Called on clicking the ">>>" or Copy Left to Right button: * Selected items are moved from the left list to the right list -*/ + */ void DIALOG_DESIGN_RULES::OnLeftToRightCopyButton( wxCommandEvent& event ) { int idx_class = m_CBoxRightSelection->GetCurrentSelection(); - if ( idx_class == wxNOT_FOUND ) + + if( idx_class == wxNOT_FOUND ) return; for( unsigned ii = 0; ii < m_listBoxLeftNetSelect->GetCount(); ii++ ) { - if( ! m_listBoxLeftNetSelect->IsSelected(ii) ) + if( !m_listBoxLeftNetSelect->IsSelected( ii ) ) continue; - unsigned idx = (unsigned) m_listBoxLeftNetSelect->GetClientData(ii); + unsigned idx = (unsigned) m_listBoxLeftNetSelect->GetClientData( ii ); m_NetsLinkToClasses[idx] = idx_class; } - FillListBoxWithNetsNames(m_listBoxLeftNetSelect, m_CBoxLeftSelection->GetCurrentSelection()); - FillListBoxWithNetsNames(m_listBoxRightNetSelect, m_CBoxRightSelection->GetCurrentSelection()); + FillListBoxWithNetsNames( m_listBoxLeftNetSelect, m_CBoxLeftSelection->GetCurrentSelection() ); + FillListBoxWithNetsNames( m_listBoxRightNetSelect, m_CBoxRightSelection->GetCurrentSelection() ); } + /* Called on clicking the left "select all" button: * select alls items of the left netname list lisxt box -*/ + */ void DIALOG_DESIGN_RULES::OnLeftSelectAllButton( wxCommandEvent& event ) { for( unsigned ii = 0; ii < m_listBoxLeftNetSelect->GetCount(); ii++ ) - m_listBoxLeftNetSelect->SetSelection(ii); + m_listBoxLeftNetSelect->SetSelection( ii ); } + /* Called on clicking the right "select all" button: * select alls items of the right netname list lisxt box -*/ + */ void DIALOG_DESIGN_RULES::OnRightSelectAllButton( wxCommandEvent& event ) { for( unsigned ii = 0; ii < m_listBoxRightNetSelect->GetCount(); ii++ ) - m_listBoxRightNetSelect->SetSelection(ii); + m_listBoxRightNetSelect->SetSelection( ii ); } + +/* TestDataValidity + * Performs a control of data validity + * set the background of a bad cell in RED and display an info message + * @return true if Ok, false if error + */ +bool DIALOG_DESIGN_RULES::TestDataValidity() +{ + bool success = true; + m_MessagesList->SetPage(wxEmptyString); // Clear message list + + // Test duplicate layers names + for( int ii = 0; ii < m_gridLayersProperties->GetNumberRows() - 1; ii++ ) + { + wxString value = m_gridLayersProperties->GetCellValue( ii, LAYERS_GRID_NAME_POSITION ); + for( int jj = ii+1; jj < m_gridLayersProperties->GetNumberRows(); jj++ ) + { + wxString othervalue = m_gridLayersProperties->GetCellValue( ii, + LAYERS_GRID_NAME_POSITION ); + othervalue = m_gridLayersProperties->GetCellValue( jj, LAYERS_GRID_NAME_POSITION ); + if( value.CmpNoCase( othervalue ) == 0 ) // Already exists! + { + wxString text; + text.Printf( _( + "This layer name %s is already existing
" ), + value.GetData() ); + m_MessagesList->AppendToPage( text ); + success = false; + } + } + } + + int value; + int minvalue; + + for( int ii = 0; ii < m_gridNetClassesProperties->GetNumberRows(); ii++ ) + { + value = ReturnValueFromString( g_UnitMetric, + m_gridNetClassesProperties->GetCellValue( + ii, RULE_GRID_TRACKSIZE_POSITION ), + m_Parent->m_InternalUnits ); + minvalue = ReturnValueFromString( g_UnitMetric, + m_gridNetClassesProperties->GetCellValue( ii, + RULE_GRID_MINTRACKSIZE_POSITION ), + m_Parent->m_InternalUnits ); + if( value < minvalue ) + { + success = false; + m_MessagesList->AppendToPage( _( "The track minimum size is bigger than the size
" ) ); + } + + value = ReturnValueFromString( g_UnitMetric, + m_gridNetClassesProperties->GetCellValue( + ii, RULE_GRID_VIASIZE_POSITION ), + m_Parent->m_InternalUnits ); + minvalue = ReturnValueFromString( g_UnitMetric, + m_gridNetClassesProperties->GetCellValue( ii, + RULE_GRID_MINVIASIZE_POSITION ), + m_Parent->m_InternalUnits ); + if( value < minvalue ) + { + success = false; + m_MessagesList->AppendToPage( _( "The via minimum size is bigger than the size
" ) ); + } + } + + return success; +} diff --git a/pcbnew/dialog_design_rules.h b/pcbnew/dialog_design_rules.h index 5a8ad290f7..1869a48955 100644 --- a/pcbnew/dialog_design_rules.h +++ b/pcbnew/dialog_design_rules.h @@ -14,7 +14,6 @@ class DIALOG_DESIGN_RULES : public DIALOG_DESIGN_RULES_BASE WinEDA_PcbFrame * m_Parent; int m_ActivesLayersCount; BOARD * m_Pcb; - int m_Changes; LAYER_T m_LayersType[4]; wxString m_LayersTypeName[4]; std::vector m_StockNets; // full list of nets on board @@ -36,6 +35,7 @@ class DIALOG_DESIGN_RULES : public DIALOG_DESIGN_RULES_BASE void OnLeftToRightCopyButton( wxCommandEvent& event ); void OnLeftSelectAllButton( wxCommandEvent& event ); void OnRightSelectAllButton( wxCommandEvent& event ); + bool TestDataValidity( ); void Init(); void InitRulesList(); void InitializeRulesSelectionBoxes(); diff --git a/pcbnew/dialog_design_rules_base.cpp b/pcbnew/dialog_design_rules_base.cpp index 082990b88d..621ffb685f 100644 --- a/pcbnew/dialog_design_rules_base.cpp +++ b/pcbnew/dialog_design_rules_base.cpp @@ -11,7 +11,7 @@ DIALOG_DESIGN_RULES_BASE::DIALOG_DESIGN_RULES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) { - this->SetSizeHints( wxSize( 600,450 ), wxDefaultSize ); + this->SetSizeHints( wxSize( 600,520 ), wxDefaultSize ); wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxVERTICAL ); @@ -124,7 +124,7 @@ DIALOG_DESIGN_RULES_BASE::DIALOG_DESIGN_RULES_BASE( wxWindow* parent, wxWindowID // Cell Defaults m_gridNetClassesProperties->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - m_gridNetClassesProperties->SetMinSize( wxSize( -1,100 ) ); + m_gridNetClassesProperties->SetMinSize( wxSize( -1,150 ) ); sbSizer1->Add( m_gridNetClassesProperties, 1, wxALL|wxEXPAND, 5 ); @@ -139,7 +139,7 @@ DIALOG_DESIGN_RULES_BASE::DIALOG_DESIGN_RULES_BASE( wxWindow* parent, wxWindowID sbSizer1->Add( bSizerButtons, 0, wxALIGN_CENTER_VERTICAL, 5 ); - bmainSizerNclasses->Add( sbSizer1, 1, wxEXPAND, 5 ); + bmainSizerNclasses->Add( sbSizer1, 0, wxEXPAND, 5 ); wxBoxSizer* bSizerNetSelect; bSizerNetSelect = new wxBoxSizer( wxHORIZONTAL ); @@ -194,15 +194,6 @@ DIALOG_DESIGN_RULES_BASE::DIALOG_DESIGN_RULES_BASE( wxWindow* parent, wxWindowID bmainSizerNclasses->Add( bSizerNetSelect, 1, wxEXPAND, 5 ); - m_staticTextMsg = new wxStaticText( m_panelNetClasses, wxID_ANY, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextMsg->Wrap( -1 ); - bmainSizerNclasses->Add( m_staticTextMsg, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_MessagesList = new wxHtmlWindow( m_panelNetClasses, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO|wxSUNKEN_BORDER ); - m_MessagesList->SetMinSize( wxSize( -1,100 ) ); - - bmainSizerNclasses->Add( m_MessagesList, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); - m_panelNetClasses->SetSizer( bmainSizerNclasses ); m_panelNetClasses->Layout(); bmainSizerNclasses->Fit( m_panelNetClasses ); @@ -210,6 +201,15 @@ DIALOG_DESIGN_RULES_BASE::DIALOG_DESIGN_RULES_BASE( wxWindow* parent, wxWindowID bMainSizer->Add( m_notebook, 1, wxALL|wxEXPAND, 5 ); + m_staticTextMsg = new wxStaticText( this, wxID_ANY, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextMsg->Wrap( -1 ); + bMainSizer->Add( m_staticTextMsg, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_MessagesList = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO|wxSUNKEN_BORDER ); + m_MessagesList->SetMinSize( wxSize( -1,100 ) ); + + bMainSizer->Add( m_MessagesList, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + m_sdbSizer1 = new wxStdDialogButtonSizer(); m_sdbSizer1OK = new wxButton( this, wxID_OK ); m_sdbSizer1->AddButton( m_sdbSizer1OK ); diff --git a/pcbnew/dialog_design_rules_base.fbp b/pcbnew/dialog_design_rules_base.fbp index 326284214d..dcde39b3a5 100644 --- a/pcbnew/dialog_design_rules_base.fbp +++ b/pcbnew/dialog_design_rules_base.fbp @@ -29,10 +29,10 @@ 0 wxID_ANY - 600,450 + 600,520 DIALOG_DESIGN_RULES_BASE - 684,486 + 684,568 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER Design Rules Editor @@ -398,7 +398,7 @@ 5 wxEXPAND - 1 + 0 wxID_ANY Net classes: @@ -445,7 +445,7 @@ 0 0 - -1,100 + -1,150 m_gridNetClassesProperties protected @@ -1104,114 +1104,114 @@ - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - - - 1 - - - 0 - wxID_ANY - Messages: - - - m_staticTextMsg - protected - - - - - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND - 0 - - - - 1 - - - 0 - wxID_ANY - - -1,100 - m_MessagesList - protected - - - wxHW_SCROLLBAR_AUTO - - - - - wxSUNKEN_BORDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + + + 0 + wxID_ANY + Messages: + + + m_staticTextMsg + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + + + 0 + wxID_ANY + + -1,100 + m_MessagesList + protected + + + wxHW_SCROLLBAR_AUTO + + + + + wxSUNKEN_BORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxALIGN_RIGHT diff --git a/pcbnew/dialog_design_rules_base.h b/pcbnew/dialog_design_rules_base.h index 79cff66f79..244934295c 100644 --- a/pcbnew/dialog_design_rules_base.h +++ b/pcbnew/dialog_design_rules_base.h @@ -26,9 +26,9 @@ #include #include #include +#include #include #include -#include #include /////////////////////////////////////////////////////////////////////////// @@ -91,7 +91,7 @@ class DIALOG_DESIGN_RULES_BASE : public wxDialog public: - DIALOG_DESIGN_RULES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Design Rules Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 684,486 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_DESIGN_RULES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Design Rules Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 684,568 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_DESIGN_RULES_BASE(); }; diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 2ca0f954e3..7785d7381c 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -651,8 +651,8 @@ void WinEDA_PcbFrame::Show3D_Frame( wxCommandEvent& event ) void WinEDA_PcbFrame::ShowDesignRulesEditor( wxCommandEvent& event ) { DIALOG_DESIGN_RULES dR_editor( this ); - int change = dR_editor.ShowModal( ); - if ( change ) + int returncode = dR_editor.ShowModal( ); + if ( returncode == wxID_OK ) // New rules, or others changes. { ReCreateLayerBox( NULL ); GetScreen()->SetModify();