Design rules dialog: use wxLC_VIRTUAL options in wxListBoxes to speed up nets lists display (which was *very long* for boards with a lot of nets)
This commit is contained in:
commit
76adcc602f
|
@ -113,8 +113,10 @@ static void InitKiCadAboutNew( AboutAppInfo& info )
|
|||
description << wxT( "<p>" );
|
||||
description << wxT( "<b><u>" ) << _( "Description" ) << wxT( "</u></b>" ); // bold & underlined font for caption
|
||||
|
||||
description << wxT(
|
||||
"<p>The KiCad EDA Suite is a set of open source applications for the creation of electronic schematics and to design printed circuit boards.</p>" );
|
||||
description << wxT( "<p>" ) <<
|
||||
_(
|
||||
"The KiCad EDA Suite is a set of open source applications for the creation of electronic schematics and to design printed circuit boards." )
|
||||
<< wxT( "</p>" );
|
||||
|
||||
description << wxT( "</p>" );
|
||||
|
||||
|
@ -170,7 +172,7 @@ static void InitKiCadAboutNew( AboutAppInfo& info )
|
|||
<< HtmlNewline( 4 )
|
||||
<< _( "The complete KiCad EDA Suite is released under the" ) << HtmlNewline( 2 )
|
||||
<< HtmlHyperlink( wxT( "http://www.gnu.org/licenses" ),
|
||||
_( "GNU General Public License version 2" ) )
|
||||
_( "GNU General Public License (GPL) version 2" ) )
|
||||
<< wxT( "</div>" );
|
||||
|
||||
info.SetLicense( license );
|
||||
|
@ -201,7 +203,8 @@ static void InitKiCadAboutNew( AboutAppInfo& info )
|
|||
info.AddDeveloper( new Contributor( wxT( "Lorenzo Marcantonio" ), wxT( "lomarcan@tin.it" ) ) );
|
||||
info.AddDeveloper( new Contributor( wxT( "Marco Serantoni" ), wxT( "marco.serantoni@gmail.com" ) ) );
|
||||
info.AddDeveloper( new Contributor( wxT( "Marco Mattila" ), wxT( "marcom99@gmail.com" ) ) );
|
||||
info.AddDeveloper( new Contributor( wxT( "Rafael Sokolowski" ), wxT( "rafael.sokolowski@web.de" ) ) );
|
||||
info.AddDeveloper( new Contributor( wxT( "Rafael Sokolowski" ),
|
||||
wxT( "rafael.sokolowski@web.de" ) ) );
|
||||
info.AddDeveloper( new Contributor( wxT( "Rok Markovic" ), wxT( "rok@kanardia.eu" ) ) );
|
||||
info.AddDeveloper( new Contributor( wxT( "Tim Hanson" ), wxT( "sideskate@gmail.com" ) ) );
|
||||
info.AddDeveloper( new Contributor( wxT( "Vesa Solonen" ), wxT( "vesa.solonen@hut.fi" ) ) );
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Name: dialog_design_rules.cpp
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -42,7 +43,7 @@
|
|||
#include "pcbnew_id.h"
|
||||
#include "dialog_design_rules.h"
|
||||
#include "wx/generic/gridctrl.h"
|
||||
|
||||
#include "dialog_design_rules_aux_helper_class.h"
|
||||
|
||||
// Field Positions on rules grid
|
||||
enum {
|
||||
|
@ -54,15 +55,62 @@ enum {
|
|||
GRID_uVIADRILL,
|
||||
};
|
||||
|
||||
const wxString DIALOG_DESIGN_RULES::wildCard = _("* (Any)");
|
||||
const wxString DIALOG_DESIGN_RULES::wildCard = _( "* (Any)" );
|
||||
|
||||
// dialog should remember its previously selected tab
|
||||
int DIALOG_DESIGN_RULES::s_LastTabSelection = -1;
|
||||
int DIALOG_DESIGN_RULES:: s_LastTabSelection = -1;
|
||||
|
||||
// dialog should remember its previous screen position and size
|
||||
wxPoint DIALOG_DESIGN_RULES::s_LastPos( -1, -1 );
|
||||
wxSize DIALOG_DESIGN_RULES::s_LastSize;
|
||||
wxPoint DIALOG_DESIGN_RULES:: s_LastPos( -1, -1 );
|
||||
wxSize DIALOG_DESIGN_RULES:: s_LastSize;
|
||||
|
||||
// methods for the helper class NETS_LIST_CTRL
|
||||
|
||||
/** OnGetItemText (overlaid method)
|
||||
* needed by wxListCtrl with wxLC_VIRTUAL options
|
||||
*/
|
||||
wxString NETS_LIST_CTRL::OnGetItemText( long item, long column ) const
|
||||
{
|
||||
if( column == 0 )
|
||||
{
|
||||
if( item < (long) m_Netnames.GetCount() )
|
||||
return m_Netnames[item];
|
||||
else
|
||||
return wxEmptyString;
|
||||
}
|
||||
else if( item < (long) m_Classnames.GetCount() )
|
||||
return m_Classnames[item];
|
||||
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
|
||||
/** Function setRowItems
|
||||
* Initialize the net name and the net class name at row aRow
|
||||
* @param aRow = row index (if aRow > number of stored row, empty rows will be created)
|
||||
* @param aNetname = the string to display in row aRow, column 0
|
||||
* @param aNetclassName = the string to display in row aRow, column 1
|
||||
*/
|
||||
void NETS_LIST_CTRL::setRowItems( unsigned aRow,
|
||||
const wxString& aNetname,
|
||||
const wxString& aNetclassName )
|
||||
{
|
||||
// insert blanks if aRow is larger than existing row count
|
||||
unsigned cnt = m_Netnames.GetCount();
|
||||
|
||||
if( cnt <= aRow )
|
||||
m_Netnames.Add( wxEmptyString, aRow - cnt + 1 );
|
||||
|
||||
cnt = m_Classnames.GetCount();
|
||||
if( cnt <= aRow )
|
||||
m_Classnames.Add( wxEmptyString, aRow - cnt + 1 );
|
||||
|
||||
if( (int)aRow <= GetItemCount() )
|
||||
SetItemCount( aRow + 1 );
|
||||
|
||||
m_Netnames[aRow] = aNetname;
|
||||
m_Classnames[aRow] = aNetclassName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -71,6 +119,7 @@ wxSize DIALOG_DESIGN_RULES::s_LastSize;
|
|||
* column titles and not on the grid cell requirements, assuming that the grid
|
||||
* cell width requirements are narrower than the column title requirements.
|
||||
*/
|
||||
|
||||
// @todo: maybe move this to common.cpp if it works.
|
||||
void EnsureGridColumnWidths( wxGrid* aGrid )
|
||||
{
|
||||
|
@ -79,7 +128,7 @@ void EnsureGridColumnWidths( wxGrid* aGrid )
|
|||
sDC.SetFont( aGrid->GetLabelFont() );
|
||||
|
||||
int colCount = aGrid->GetNumberCols();
|
||||
for( int col=0; col<colCount; ++col )
|
||||
for( int col = 0; col<colCount; ++col )
|
||||
{
|
||||
// add two spaces to the text and size it.
|
||||
wxString colText = aGrid->GetColLabelValue( col ) + wxT( " " );
|
||||
|
@ -108,8 +157,8 @@ DIALOG_DESIGN_RULES::DIALOG_DESIGN_RULES( WinEDA_PcbFrame* parent ) :
|
|||
column0.Clear();
|
||||
column1.Clear();
|
||||
|
||||
column0.SetMask(wxLIST_MASK_TEXT);
|
||||
column1.SetMask(wxLIST_MASK_TEXT);
|
||||
column0.SetMask( wxLIST_MASK_TEXT );
|
||||
column1.SetMask( wxLIST_MASK_TEXT );
|
||||
|
||||
column0.SetText( _( "Net" ) );
|
||||
column1.SetText( _( "Class" ) );
|
||||
|
@ -148,26 +197,31 @@ DIALOG_DESIGN_RULES::DIALOG_DESIGN_RULES( WinEDA_PcbFrame* parent ) :
|
|||
/* Display on m_MessagesList the current global settings:
|
||||
* minimal values for tracks, vias, clearance ...
|
||||
*/
|
||||
void DIALOG_DESIGN_RULES::PrintCurrentSettings( )
|
||||
void DIALOG_DESIGN_RULES::PrintCurrentSettings()
|
||||
{
|
||||
wxString msg, value;
|
||||
int internal_units = m_Parent->m_InternalUnits;
|
||||
|
||||
m_MessagesList->AppendToPage(_("<b>Current general settings:</b><br>") );
|
||||
m_MessagesList->AppendToPage( _( "<b>Current general settings:</b><br>" ) );
|
||||
|
||||
// Display min values:
|
||||
value = ReturnStringFromValue( g_UserUnit, m_BrdSettings->m_TrackMinWidth, internal_units, true );
|
||||
msg.Printf(_("Minimum value for tracks width: <b>%s</b><br>\n"), GetChars( value ) );
|
||||
m_MessagesList->AppendToPage(msg);
|
||||
value = ReturnStringFromValue( g_UserUnit,
|
||||
m_BrdSettings->m_TrackMinWidth,
|
||||
internal_units,
|
||||
true );
|
||||
msg.Printf( _( "Minimum value for tracks width: <b>%s</b><br>\n" ), GetChars( value ) );
|
||||
m_MessagesList->AppendToPage( msg );
|
||||
|
||||
value = ReturnStringFromValue( g_UserUnit, m_BrdSettings->m_ViasMinSize, internal_units, true );
|
||||
msg.Printf(_("Minimum value for vias diameter: <b>%s</b><br>\n"), GetChars( value ) );
|
||||
m_MessagesList->AppendToPage(msg);
|
||||
|
||||
value = ReturnStringFromValue( g_UserUnit, m_BrdSettings->m_MicroViasMinSize, internal_units, true );
|
||||
msg.Printf(_("Minimum value for microvias diameter: <b>%s</b><br>\n"), GetChars( value ) );
|
||||
m_MessagesList->AppendToPage(msg);
|
||||
msg.Printf( _( "Minimum value for vias diameter: <b>%s</b><br>\n" ), GetChars( value ) );
|
||||
m_MessagesList->AppendToPage( msg );
|
||||
|
||||
value = ReturnStringFromValue( g_UserUnit,
|
||||
m_BrdSettings->m_MicroViasMinSize,
|
||||
internal_units,
|
||||
true );
|
||||
msg.Printf( _( "Minimum value for microvias diameter: <b>%s</b><br>\n" ), GetChars( value ) );
|
||||
m_MessagesList->AppendToPage( msg );
|
||||
}
|
||||
|
||||
|
||||
|
@ -215,9 +269,10 @@ void DIALOG_DESIGN_RULES::InitDialogRules()
|
|||
InitializeRulesSelectionBoxes();
|
||||
InitGlobalRules();
|
||||
|
||||
PrintCurrentSettings( );
|
||||
PrintCurrentSettings();
|
||||
}
|
||||
|
||||
|
||||
/*******************************************/
|
||||
void DIALOG_DESIGN_RULES::InitGlobalRules()
|
||||
/*******************************************/
|
||||
|
@ -235,9 +290,13 @@ void DIALOG_DESIGN_RULES::InitGlobalRules()
|
|||
if( m_BrdSettings->m_CurrentViaType != VIA_THROUGH )
|
||||
m_OptViaType->SetSelection( 1 );
|
||||
|
||||
m_AllowMicroViaCtrl->SetSelection( m_BrdSettings->m_MicroViasAllowed ? 1 : 0);
|
||||
PutValueInLocalUnits( *m_SetMicroViasMinSizeCtrl, m_BrdSettings->m_MicroViasMinSize, Internal_Unit );
|
||||
PutValueInLocalUnits( *m_SetMicroViasMinDrillCtrl, m_BrdSettings->m_MicroViasMinDrill, Internal_Unit );
|
||||
m_AllowMicroViaCtrl->SetSelection( m_BrdSettings->m_MicroViasAllowed ? 1 : 0 );
|
||||
PutValueInLocalUnits( *m_SetMicroViasMinSizeCtrl,
|
||||
m_BrdSettings->m_MicroViasMinSize,
|
||||
Internal_Unit );
|
||||
PutValueInLocalUnits( *m_SetMicroViasMinDrillCtrl,
|
||||
m_BrdSettings->m_MicroViasMinDrill,
|
||||
Internal_Unit );
|
||||
|
||||
PutValueInLocalUnits( *m_SetTrackMinWidthCtrl, m_BrdSettings->m_TrackMinWidth, Internal_Unit );
|
||||
|
||||
|
@ -249,9 +308,9 @@ void DIALOG_DESIGN_RULES::InitGlobalRules()
|
|||
m_ViasDimensionsList = m_Parent->GetBoard()->m_ViasDimensionsList;
|
||||
m_ViasDimensionsList.erase( m_ViasDimensionsList.begin() ); // remove the netclass value
|
||||
InitDimensionsLists();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***************************************************/
|
||||
void DIALOG_DESIGN_RULES::InitDimensionsLists()
|
||||
/***************************************************/
|
||||
|
@ -286,6 +345,7 @@ void DIALOG_DESIGN_RULES::InitDimensionsLists()
|
|||
m_gridTrackWidthList->SetColumnWidth( 0, wxLIST_AUTOSIZE );
|
||||
}
|
||||
|
||||
|
||||
// Sort comparison function (helper for makePointers() )
|
||||
static bool sortByClassThenName( NETCUP* a, NETCUP* b )
|
||||
{
|
||||
|
@ -303,6 +363,7 @@ static bool sortByClassThenName( NETCUP* a, NETCUP* b )
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_DESIGN_RULES::makePointers( PNETCUPS* aList, const wxString& aNetClassName )
|
||||
{
|
||||
aList->clear();
|
||||
|
@ -331,36 +392,14 @@ void DIALOG_DESIGN_RULES::makePointers( PNETCUPS* aList, const wxString& aNetCla
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_DESIGN_RULES::setRowItem( wxListCtrl* aListCtrl, int aRow, NETCUP* aNetAndClass )
|
||||
{
|
||||
wxASSERT( aRow >= 0 );
|
||||
|
||||
// insert blanks if aRow is larger than existing count
|
||||
while( aRow >= aListCtrl->GetItemCount() )
|
||||
{
|
||||
long ndx = aListCtrl->InsertItem( aListCtrl->GetItemCount(), wxEmptyString );
|
||||
|
||||
wxASSERT( ndx >= 0 );
|
||||
|
||||
aListCtrl->SetItem( ndx, 1, wxEmptyString );
|
||||
}
|
||||
|
||||
aListCtrl->SetItem( aRow, 0, aNetAndClass->net );
|
||||
aListCtrl->SetItem( aRow, 1, aNetAndClass->clazz );
|
||||
|
||||
// recompute the column widths here, after setting texts
|
||||
aListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
|
||||
aListCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function FillListBoxWithNetNames
|
||||
* populates aListCtrl with net names and class names from m_AllNets in a two column display.
|
||||
*/
|
||||
void DIALOG_DESIGN_RULES::FillListBoxWithNetNames( wxListCtrl* aListCtrl, const wxString& aNetClass )
|
||||
void DIALOG_DESIGN_RULES::FillListBoxWithNetNames( NETS_LIST_CTRL* aListCtrl,
|
||||
const wxString& aNetClass )
|
||||
{
|
||||
aListCtrl->DeleteAllItems();
|
||||
aListCtrl->ClearList();
|
||||
|
||||
PNETCUPS ptrList;
|
||||
|
||||
|
@ -371,8 +410,9 @@ void DIALOG_DESIGN_RULES::FillListBoxWithNetNames( wxListCtrl* aListCtrl, const
|
|||
int r = 0;
|
||||
for( PNETCUPS::iterator i = ptrList.begin(); i!=ptrList.end(); ++i, ++r )
|
||||
{
|
||||
printf("[%d]: %s %s\n", r, CONV_TO_UTF8( (*i)->net ), CONV_TO_UTF8( (*i)->clazz ) );
|
||||
printf( "[%d]: %s %s\n", r, CONV_TO_UTF8( (*i)->net ), CONV_TO_UTF8( (*i)->clazz ) );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// to speed up inserting we hide the control temporarily
|
||||
|
@ -381,9 +421,13 @@ void DIALOG_DESIGN_RULES::FillListBoxWithNetNames( wxListCtrl* aListCtrl, const
|
|||
int row = 0;
|
||||
for( PNETCUPS::iterator i = ptrList.begin(); i!=ptrList.end(); ++i, ++row )
|
||||
{
|
||||
setRowItem( aListCtrl, row, *i );
|
||||
aListCtrl->setRowItems( row, (*i)->net, (*i)->clazz );
|
||||
}
|
||||
|
||||
// recompute the column widths here, after setting texts
|
||||
aListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
|
||||
aListCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE );
|
||||
|
||||
aListCtrl->Show();
|
||||
}
|
||||
|
||||
|
@ -444,6 +488,7 @@ static void class2gridRow( wxGrid* grid, int row, NETCLASS* nc, int units )
|
|||
grid->SetCellValue( row, GRID_uVIADRILL, msg );
|
||||
}
|
||||
|
||||
|
||||
/** Function InitRulesList()
|
||||
* Fill the grid showing current rules with values
|
||||
*/
|
||||
|
@ -452,9 +497,9 @@ void DIALOG_DESIGN_RULES::InitRulesList()
|
|||
NETCLASSES& netclasses = m_Pcb->m_NetClasses;
|
||||
|
||||
// the +1 is for the Default NETCLASS.
|
||||
if( netclasses.GetCount()+1 > (unsigned) m_grid->GetNumberRows() )
|
||||
if( netclasses.GetCount() + 1 > (unsigned) m_grid->GetNumberRows() )
|
||||
{
|
||||
m_grid->AppendRows( netclasses.GetCount()+1 - m_grid->GetNumberRows() );
|
||||
m_grid->AppendRows( netclasses.GetCount() + 1 - m_grid->GetNumberRows() );
|
||||
}
|
||||
|
||||
// enter the Default NETCLASS.
|
||||
|
@ -462,7 +507,7 @@ void DIALOG_DESIGN_RULES::InitRulesList()
|
|||
|
||||
// enter others netclasses
|
||||
int row = 1;
|
||||
for( NETCLASSES::iterator i=netclasses.begin(); i!=netclasses.end(); ++i, ++row )
|
||||
for( NETCLASSES::iterator i = netclasses.begin(); i!=netclasses.end(); ++i, ++row )
|
||||
{
|
||||
NETCLASS* netclass = i->second;
|
||||
|
||||
|
@ -473,7 +518,7 @@ void DIALOG_DESIGN_RULES::InitRulesList()
|
|||
|
||||
static void gridRow2class( wxGrid* grid, int row, NETCLASS* nc, int units )
|
||||
{
|
||||
#define MYCELL(col) \
|
||||
#define MYCELL( col ) \
|
||||
ReturnValueFromString( g_UserUnit, grid->GetCellValue( row, col ), units )
|
||||
|
||||
nc->SetClearance( MYCELL( GRID_CLEARANCE ) );
|
||||
|
@ -507,7 +552,7 @@ void DIALOG_DESIGN_RULES::CopyRulesListToBoard()
|
|||
// this netclass cannot be added because an other netclass with the same name exists
|
||||
// Should not occur because OnAddNetclassClick() tests for existing NetClass names
|
||||
wxString msg;
|
||||
msg.Printf( wxT("CopyRulesListToBoard(): The NetClass \"%s\" already exists. Skip"),
|
||||
msg.Printf( wxT( "CopyRulesListToBoard(): The NetClass \"%s\" already exists. Skip" ),
|
||||
GetChars( m_grid->GetRowLabelValue( row ) ) );
|
||||
wxMessageBox( msg );
|
||||
delete nc;
|
||||
|
@ -528,6 +573,7 @@ void DIALOG_DESIGN_RULES::CopyRulesListToBoard()
|
|||
m_Pcb->SynchronizeNetsAndNetClasses();
|
||||
}
|
||||
|
||||
|
||||
/*************************************************/
|
||||
void DIALOG_DESIGN_RULES::CopyGlobalRulesToBoard()
|
||||
/*************************************************/
|
||||
|
@ -555,8 +601,9 @@ void DIALOG_DESIGN_RULES::CopyGlobalRulesToBoard()
|
|||
ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl, m_Parent->m_InternalUnits );
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
void DIALOG_DESIGN_RULES::CopyDimensionsListsToBoard( )
|
||||
void DIALOG_DESIGN_RULES::CopyDimensionsListsToBoard()
|
||||
/*******************************************************************/
|
||||
{
|
||||
wxString msg;
|
||||
|
@ -569,8 +616,9 @@ void DIALOG_DESIGN_RULES::CopyDimensionsListsToBoard( )
|
|||
if( msg.IsEmpty() )
|
||||
continue;
|
||||
int value = ReturnValueFromString( g_UserUnit, msg, m_Parent->m_InternalUnits );
|
||||
m_TracksWidthList.push_back( value);
|
||||
m_TracksWidthList.push_back( value );
|
||||
}
|
||||
|
||||
// Sort new list by by increasing value
|
||||
sort( m_TracksWidthList.begin(), m_TracksWidthList.end() );
|
||||
|
||||
|
@ -585,13 +633,14 @@ void DIALOG_DESIGN_RULES::CopyDimensionsListsToBoard( )
|
|||
VIA_DIMENSION via_dim;
|
||||
via_dim.m_Diameter = value;
|
||||
msg = m_gridViaSizeList->GetCellValue( row, 1 );
|
||||
if( ! msg.IsEmpty() )
|
||||
if( !msg.IsEmpty() )
|
||||
{
|
||||
value = ReturnValueFromString( g_UserUnit, msg, m_Parent->m_InternalUnits );
|
||||
via_dim.m_Drill = value;
|
||||
}
|
||||
m_ViasDimensionsList.push_back( via_dim);
|
||||
m_ViasDimensionsList.push_back( via_dim );
|
||||
}
|
||||
|
||||
// Sort new list by by increasing value
|
||||
sort( m_ViasDimensionsList.begin(), m_ViasDimensionsList.end() );
|
||||
|
||||
|
@ -636,7 +685,7 @@ void DIALOG_DESIGN_RULES::OnOkButtonClick( wxCommandEvent& event )
|
|||
|
||||
CopyRulesListToBoard();
|
||||
CopyGlobalRulesToBoard();
|
||||
CopyDimensionsListsToBoard( );
|
||||
CopyDimensionsListsToBoard();
|
||||
|
||||
// Save the dialog's position before finishing
|
||||
s_LastPos = GetPosition();
|
||||
|
@ -657,10 +706,11 @@ void DIALOG_DESIGN_RULES::OnAddNetclassClick( wxCommandEvent& event )
|
|||
wxString class_name;
|
||||
|
||||
wxTextEntryDialog dlg( this, _( "New Net Class Name:" ), wxEmptyString, class_name );
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
return; // cancelled by user
|
||||
|
||||
class_name = dlg.GetValue( );
|
||||
class_name = dlg.GetValue();
|
||||
class_name.Trim( true );
|
||||
class_name.Trim( false );
|
||||
if( class_name.IsEmpty() )
|
||||
|
@ -695,25 +745,31 @@ void DIALOG_DESIGN_RULES::OnAddNetclassClick( wxCommandEvent& event )
|
|||
InitializeRulesSelectionBoxes();
|
||||
}
|
||||
|
||||
|
||||
// Sort function for wxArrayInt. Items (ints) are sorted by decreasing value
|
||||
// used in DIALOG_DESIGN_RULES::OnRemoveNetclassClick
|
||||
int sort_int(int *first, int *second)
|
||||
int sort_int( int* first, int* second )
|
||||
{
|
||||
return * second - *first;
|
||||
return *second - *first;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
void DIALOG_DESIGN_RULES::OnRemoveNetclassClick( wxCommandEvent& event )
|
||||
/**************************************************************************/
|
||||
{
|
||||
wxArrayInt select = m_grid->GetSelectedRows();
|
||||
|
||||
// Sort selection by decreasing index order:
|
||||
select.Sort(sort_int);
|
||||
select.Sort( sort_int );
|
||||
bool reinit = false;
|
||||
|
||||
// rows labels are not removed when deleting rows: they are not deleted.
|
||||
// So we must store them, remove correponding labels and reinit them
|
||||
wxArrayString labels;
|
||||
for( int ii = 0; ii < m_grid->GetNumberRows(); ii++ )
|
||||
labels.Add(m_grid->GetRowLabelValue(ii));
|
||||
labels.Add( m_grid->GetRowLabelValue( ii ) );
|
||||
|
||||
// Delete rows from last to first (this is the order wxArrayInt select after sorting) )
|
||||
// This order is Ok when removing rows
|
||||
for( unsigned ii = 0; ii < select.GetCount(); ii++ )
|
||||
|
@ -723,25 +779,27 @@ void DIALOG_DESIGN_RULES::OnRemoveNetclassClick( wxCommandEvent& event )
|
|||
{
|
||||
wxString classname = m_grid->GetRowLabelValue( grid_row );
|
||||
m_grid->DeleteRows( grid_row );
|
||||
labels.RemoveAt(grid_row); // Remove corresponding row label
|
||||
labels.RemoveAt( grid_row ); // Remove corresponding row label
|
||||
reinit = true;
|
||||
|
||||
// reset the net class to default for members of the removed class
|
||||
swapNetClass( classname, NETCLASS::Default );
|
||||
}
|
||||
else
|
||||
wxMessageBox(_("The defaut Netclass cannot be removed") );
|
||||
wxMessageBox( _( "The defaut Netclass cannot be removed" ) );
|
||||
}
|
||||
|
||||
if( reinit )
|
||||
{
|
||||
// Reinit labels :
|
||||
for( unsigned ii = 1; ii < labels.GetCount(); ii++ )
|
||||
m_grid->SetRowLabelValue(ii, labels[ii]);
|
||||
m_grid->SetRowLabelValue( ii, labels[ii] );
|
||||
|
||||
InitializeRulesSelectionBoxes();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called on "Move Up" button click
|
||||
* the selected(s) rules are moved up
|
||||
|
@ -766,14 +824,15 @@ void DIALOG_DESIGN_RULES::OnMoveUpSelectedNetClass( wxCommandEvent& event )
|
|||
{
|
||||
reinit = true;
|
||||
curr_value = m_grid->GetCellValue( ii, icol );
|
||||
previous_value = m_grid->GetCellValue( ii-1, icol );
|
||||
previous_value = m_grid->GetCellValue( ii - 1, icol );
|
||||
m_grid->SetCellValue( ii, icol, previous_value );
|
||||
m_grid->SetCellValue( ii-1, icol, curr_value );
|
||||
m_grid->SetCellValue( ii - 1, icol, curr_value );
|
||||
}
|
||||
|
||||
curr_value = m_grid->GetRowLabelValue( ii );
|
||||
previous_value = m_grid->GetRowLabelValue( ii-1 );
|
||||
m_grid->SetRowLabelValue(ii, previous_value );
|
||||
m_grid->SetRowLabelValue(ii-1, curr_value );
|
||||
previous_value = m_grid->GetRowLabelValue( ii - 1 );
|
||||
m_grid->SetRowLabelValue( ii, previous_value );
|
||||
m_grid->SetRowLabelValue( ii - 1, curr_value );
|
||||
}
|
||||
|
||||
if( reinit )
|
||||
|
@ -819,11 +878,12 @@ void DIALOG_DESIGN_RULES::OnRightCBSelection( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_DESIGN_RULES::moveSelectedItems( wxListCtrl* src, const wxString& newClassName )
|
||||
void DIALOG_DESIGN_RULES::moveSelectedItems( NETS_LIST_CTRL* src, const wxString& newClassName )
|
||||
{
|
||||
wxListItem item;
|
||||
wxString netName;
|
||||
item.m_mask |= wxLIST_MASK_TEXT ; // Validate the member m_text of the wxListItem item
|
||||
|
||||
item.m_mask |= wxLIST_MASK_TEXT; // Validate the member m_text of the wxListItem item
|
||||
|
||||
for( int row = 0; row < src->GetItemCount(); ++row )
|
||||
{
|
||||
|
@ -851,6 +911,7 @@ void DIALOG_DESIGN_RULES::OnRightToLeftCopyButton( wxCommandEvent& event )
|
|||
FillListBoxWithNetNames( m_rightListCtrl, m_rightClassChoice->GetStringSelection() );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_DESIGN_RULES::OnLeftToRightCopyButton( wxCommandEvent& event )
|
||||
{
|
||||
wxString newClassName = m_rightClassChoice->GetStringSelection();
|
||||
|
@ -904,15 +965,20 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
|
|||
{
|
||||
bool result = true;
|
||||
|
||||
m_MessagesList->SetPage(wxEmptyString); // Clear message list
|
||||
m_MessagesList->SetPage( wxEmptyString ); // Clear message list
|
||||
|
||||
wxString msg;
|
||||
|
||||
int minViaDia = ReturnValueFromTextCtrl( *m_SetViasMinSizeCtrl, m_Parent->m_InternalUnits );
|
||||
int minViaDrill = ReturnValueFromTextCtrl( *m_SetViasMinDrillCtrl, m_Parent->m_InternalUnits );
|
||||
int minUViaDia = ReturnValueFromTextCtrl( *m_SetMicroViasMinSizeCtrl, m_Parent->m_InternalUnits );
|
||||
int minUViaDrill = ReturnValueFromTextCtrl( *m_SetMicroViasMinDrillCtrl, m_Parent->m_InternalUnits );
|
||||
int minTrackWidth = ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl, m_Parent->m_InternalUnits );
|
||||
int minViaDia = ReturnValueFromTextCtrl( *m_SetViasMinSizeCtrl,
|
||||
m_Parent->m_InternalUnits );
|
||||
int minViaDrill = ReturnValueFromTextCtrl( *m_SetViasMinDrillCtrl,
|
||||
m_Parent->m_InternalUnits );
|
||||
int minUViaDia = ReturnValueFromTextCtrl( *m_SetMicroViasMinSizeCtrl,
|
||||
m_Parent->m_InternalUnits );
|
||||
int minUViaDrill = ReturnValueFromTextCtrl( *m_SetMicroViasMinDrillCtrl,
|
||||
m_Parent->m_InternalUnits );
|
||||
int minTrackWidth = ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl,
|
||||
m_Parent->m_InternalUnits );
|
||||
|
||||
|
||||
for( int row = 0; row < m_grid->GetNumberRows(); row++ )
|
||||
|
@ -924,7 +990,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
|
|||
{
|
||||
result = false;
|
||||
msg.Printf( _( "%s: <b>Track Size</b> < <b>Min Track Size</b><br>" ),
|
||||
GetChars( m_grid->GetRowLabelValue(row)) );
|
||||
GetChars( m_grid->GetRowLabelValue( row ) ) );
|
||||
|
||||
m_MessagesList->AppendToPage( msg );
|
||||
}
|
||||
|
@ -938,7 +1004,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
|
|||
{
|
||||
result = false;
|
||||
msg.Printf( _( "%s: <b>Via Diameter</b> < <b>Minimun Via Diameter</b><br>" ),
|
||||
GetChars( m_grid->GetRowLabelValue(row)) );
|
||||
GetChars( m_grid->GetRowLabelValue( row ) ) );
|
||||
|
||||
m_MessagesList->AppendToPage( msg );
|
||||
}
|
||||
|
@ -950,7 +1016,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
|
|||
{
|
||||
result = false;
|
||||
msg.Printf( _( "%s: <b>Via Drill</b> ≥ <b>Via Dia</b><br>" ),
|
||||
GetChars( m_grid->GetRowLabelValue(row)) );
|
||||
GetChars( m_grid->GetRowLabelValue( row ) ) );
|
||||
|
||||
m_MessagesList->AppendToPage( msg );
|
||||
}
|
||||
|
@ -959,7 +1025,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
|
|||
{
|
||||
result = false;
|
||||
msg.Printf( _( "%s: <b>Via Drill</b> < <b>Min Via Drill</b><br>" ),
|
||||
GetChars( m_grid->GetRowLabelValue(row)) );
|
||||
GetChars( m_grid->GetRowLabelValue( row ) ) );
|
||||
|
||||
m_MessagesList->AppendToPage( msg );
|
||||
}
|
||||
|
@ -973,7 +1039,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
|
|||
{
|
||||
result = false;
|
||||
msg.Printf( _( "%s: <b>MicroVia Diameter</b> < <b>MicroVia Min Diameter</b><br>" ),
|
||||
GetChars( m_grid->GetRowLabelValue(row)) );
|
||||
GetChars( m_grid->GetRowLabelValue( row ) ) );
|
||||
|
||||
m_MessagesList->AppendToPage( msg );
|
||||
}
|
||||
|
@ -985,7 +1051,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
|
|||
{
|
||||
result = false;
|
||||
msg.Printf( _( "%s: <b>MicroVia Drill</b> ≥ <b>MicroVia Dia</b><br>" ),
|
||||
GetChars( m_grid->GetRowLabelValue(row)) );
|
||||
GetChars( m_grid->GetRowLabelValue( row ) ) );
|
||||
|
||||
m_MessagesList->AppendToPage( msg );
|
||||
}
|
||||
|
@ -994,7 +1060,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
|
|||
{
|
||||
result = false;
|
||||
msg.Printf( _( "%s: <b>MicroVia Drill</b> < <b>MicroVia Min Drill</b><br>" ),
|
||||
GetChars( m_grid->GetRowLabelValue(row)) );
|
||||
GetChars( m_grid->GetRowLabelValue( row ) ) );
|
||||
|
||||
m_MessagesList->AppendToPage( msg );
|
||||
}
|
||||
|
@ -1003,7 +1069,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
|
|||
// Test list of values for specific vias and tracks
|
||||
for( int row = 1; row < m_gridTrackWidthList->GetNumberRows(); ++row )
|
||||
{
|
||||
wxString tvalue = m_gridTrackWidthList->GetCellValue(row, 0);
|
||||
wxString tvalue = m_gridTrackWidthList->GetCellValue( row, 0 );
|
||||
if( tvalue.IsEmpty() )
|
||||
continue;
|
||||
|
||||
|
@ -1014,7 +1080,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
|
|||
{
|
||||
result = false;
|
||||
msg.Printf( _( "<b>Extra Track %d Size</b> %s < <b>Min Track Size</b><br>" ),
|
||||
row+1, GetChars( tvalue ) );
|
||||
row + 1, GetChars( tvalue ) );
|
||||
|
||||
m_MessagesList->AppendToPage( msg );
|
||||
}
|
||||
|
@ -1022,7 +1088,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
|
|||
{
|
||||
result = false;
|
||||
msg.Printf( _( "<b>Extra Track %d Size</b> %s > <b>1 inch!</b><br>" ),
|
||||
row+1, GetChars( tvalue ) );
|
||||
row + 1, GetChars( tvalue ) );
|
||||
|
||||
m_MessagesList->AppendToPage( msg );
|
||||
}
|
||||
|
@ -1030,7 +1096,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
|
|||
|
||||
for( int row = 1; row < m_gridViaSizeList->GetNumberRows(); ++row )
|
||||
{
|
||||
wxString tvalue = m_gridViaSizeList->GetCellValue(row, 0);
|
||||
wxString tvalue = m_gridViaSizeList->GetCellValue( row, 0 );
|
||||
if( tvalue.IsEmpty() )
|
||||
continue;
|
||||
|
||||
|
@ -1041,7 +1107,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
|
|||
{
|
||||
result = false;
|
||||
msg.Printf( _( "<b>Extra Via %d Size</b> %s < <b>Min Via Size</b><br>" ),
|
||||
row+1, GetChars( tvalue ) );
|
||||
row + 1, GetChars( tvalue ) );
|
||||
|
||||
m_MessagesList->AppendToPage( msg );
|
||||
}
|
||||
|
@ -1049,7 +1115,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
|
|||
{
|
||||
result = false;
|
||||
msg.Printf( _( "<b>Extra Via %d Size</b>%s > <b>1 inch!</b><br>" ),
|
||||
row+1, GetChars( tvalue ) );
|
||||
row + 1, GetChars( tvalue ) );
|
||||
|
||||
m_MessagesList->AppendToPage( msg );
|
||||
}
|
||||
|
@ -1057,4 +1123,3 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ private:
|
|||
void CopyGlobalRulesToBoard();
|
||||
void CopyDimensionsListsToBoard( );
|
||||
void SetRoutableLayerStatus();
|
||||
void FillListBoxWithNetNames( wxListCtrl* aListCtrl, const wxString& aNetClass );
|
||||
void FillListBoxWithNetNames( NETS_LIST_CTRL* aListCtrl, const wxString& aNetClass );
|
||||
void PrintCurrentSettings( );
|
||||
|
||||
/**
|
||||
|
@ -96,9 +96,7 @@ private:
|
|||
|
||||
void setNetClass( const wxString& aNetName, const wxString& aClassName );
|
||||
|
||||
static void setRowItem( wxListCtrl* aListCtrl, int aRow, NETCUP* aNetAndClass );
|
||||
|
||||
void moveSelectedItems( wxListCtrl* src, const wxString& newClassName );
|
||||
void moveSelectedItems( NETS_LIST_CTRL* src, const wxString& newClassName );
|
||||
|
||||
|
||||
public:
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class DIALOG_DESIGN_RULES
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __dialog_design_rules_aux_helper_class_h_
|
||||
#define __dialog_design_rules_aux_helper_class_h_
|
||||
|
||||
#include <wx/listctrl.h>
|
||||
|
||||
/* helper class to display lists of nets and associated netclasses
|
||||
* used in dialog design rules.
|
||||
* It s needed because the 2 wxListCtlr used to display lists of nets
|
||||
* use the wxLC_VIRTUAL option.
|
||||
* The virtual wxString OnGetItemText(long item, long column) const method
|
||||
* must be overlaid.
|
||||
*/
|
||||
class NETS_LIST_CTRL: public wxListCtrl
|
||||
{
|
||||
private:
|
||||
wxArrayString m_Netnames; ///< an array to store the list of nets (column 0)
|
||||
wxArrayString m_Classnames; ///< an array to store the list of netclasse (column 1)
|
||||
public:
|
||||
NETS_LIST_CTRL(wxWindow* parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxLC_ICON):
|
||||
wxListCtrl( parent, id, pos, size, style )
|
||||
{
|
||||
};
|
||||
|
||||
NETS_LIST_CTRL()
|
||||
{
|
||||
};
|
||||
void setRowItems(unsigned aRow, const wxString & aNetname, const wxString & aNetclassName );
|
||||
void ClearList()
|
||||
{
|
||||
SetItemCount(0);
|
||||
m_Netnames.Clear();
|
||||
m_Classnames.Clear();
|
||||
}
|
||||
|
||||
virtual wxString OnGetItemText(long item, long column) const;
|
||||
};
|
||||
|
||||
|
||||
#endif //__dialog_design_rules_aux_helper_class_h_
|
|
@ -5,6 +5,8 @@
|
|||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dialog_design_rules_aux_helper_class.h"
|
||||
|
||||
#include "dialog_design_rules_base.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -99,7 +101,7 @@ DIALOG_DESIGN_RULES_BASE::DIALOG_DESIGN_RULES_BASE( wxWindow* parent, wxWindowID
|
|||
m_leftClassChoice->SetSelection( 0 );
|
||||
leftNetSelectBoxSizer->Add( m_leftClassChoice, 0, wxEXPAND, 5 );
|
||||
|
||||
m_leftListCtrl = new wxListCtrl( m_panelNetClassesEditor, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_VRULES|wxSUNKEN_BORDER );
|
||||
m_leftListCtrl = new NETS_LIST_CTRL( m_panelNetClassesEditor, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_VIRTUAL|wxLC_VRULES|wxSUNKEN_BORDER );
|
||||
m_leftListCtrl->SetMinSize( wxSize( 220,200 ) );
|
||||
|
||||
leftNetSelectBoxSizer->Add( m_leftListCtrl, 1, wxEXPAND|wxTOP, 5 );
|
||||
|
@ -139,7 +141,7 @@ DIALOG_DESIGN_RULES_BASE::DIALOG_DESIGN_RULES_BASE( wxWindow* parent, wxWindowID
|
|||
m_rightClassChoice->SetSelection( 0 );
|
||||
rghtNetSelectBoxSizer->Add( m_rightClassChoice, 0, wxEXPAND, 5 );
|
||||
|
||||
m_rightListCtrl = new wxListCtrl( m_panelNetClassesEditor, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_VRULES|wxSUNKEN_BORDER );
|
||||
m_rightListCtrl = new NETS_LIST_CTRL( m_panelNetClassesEditor, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_VIRTUAL|wxLC_VRULES|wxSUNKEN_BORDER );
|
||||
m_rightListCtrl->SetMinSize( wxSize( 220,-1 ) );
|
||||
|
||||
rghtNetSelectBoxSizer->Add( m_rightListCtrl, 1, wxEXPAND|wxTOP, 5 );
|
||||
|
|
|
@ -558,8 +558,8 @@
|
|||
<property name="permission">protected</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size"></property>
|
||||
<property name="style">wxLC_HRULES|wxLC_REPORT|wxLC_VRULES</property>
|
||||
<property name="subclass"></property>
|
||||
<property name="style">wxLC_HRULES|wxLC_REPORT|wxLC_VIRTUAL|wxLC_VRULES</property>
|
||||
<property name="subclass">NETS_LIST_CTRL; dialog_design_rules_aux_helper_class.h</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
|
@ -908,8 +908,8 @@
|
|||
<property name="permission">protected</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size"></property>
|
||||
<property name="style">wxLC_HRULES|wxLC_REPORT|wxLC_VRULES</property>
|
||||
<property name="subclass"></property>
|
||||
<property name="style">wxLC_HRULES|wxLC_REPORT|wxLC_VIRTUAL|wxLC_VRULES</property>
|
||||
<property name="subclass">NETS_LIST_CTRL; dialog_design_rules_aux_helper_class.h</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include <wx/intl.h>
|
||||
|
||||
class NETS_LIST_CTRL;
|
||||
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/string.h>
|
||||
|
@ -60,13 +62,13 @@ class DIALOG_DESIGN_RULES_BASE : public wxDialog
|
|||
wxButton* m_removeButton;
|
||||
wxButton* m_moveUpButton;
|
||||
wxChoice* m_leftClassChoice;
|
||||
wxListCtrl* m_leftListCtrl;
|
||||
NETS_LIST_CTRL* m_leftListCtrl;
|
||||
wxButton* m_buttonRightToLeft;
|
||||
wxButton* m_buttonLeftToRight;
|
||||
wxButton* m_buttonLeftSelAll;
|
||||
wxButton* m_buttonRightSelAll;
|
||||
wxChoice* m_rightClassChoice;
|
||||
wxListCtrl* m_rightListCtrl;
|
||||
NETS_LIST_CTRL* m_rightListCtrl;
|
||||
wxPanel* m_panelGolbalDesignRules;
|
||||
wxRadioBox* m_OptViaType;
|
||||
wxStaticText* m_ViaMinTitle;
|
||||
|
|
Loading…
Reference in New Issue